mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 12:32:40 +02:00
Add ResourceLimit SVCs, svcGetProcessInfo (#76)
This commit is contained in:
parent
e001318c42
commit
0ac5743c1f
@ -105,6 +105,32 @@ typedef enum {
|
||||
JitMapOperation_UnmapSlave=3, ///< Unmap slave.
|
||||
} JitMapOperation;
|
||||
|
||||
/// Limitable Resources.
|
||||
typedef enum {
|
||||
LimitableResource_Memory=0, ///<How much memory can a process map.
|
||||
LimitableResource_Threads=1, ///<How many threads can a process spawn.
|
||||
LimitableResource_Events=2, ///<How many events can a process have.
|
||||
LimitableResource_TransferMemories=3, ///<How many transfer memories can a process make.
|
||||
LimitableResource_Sessions=4, ///<How many sessions can a process own.
|
||||
} LimitableResource;
|
||||
|
||||
/// Process Information.
|
||||
typedef enum {
|
||||
ProcessInfoType_ProcessState=0, ///<What state is a process in.
|
||||
} ProcessInfoType;
|
||||
|
||||
/// Process States.
|
||||
typedef enum {
|
||||
ProcessState_Created=0, ///<Newly-created process.
|
||||
ProcessState_DebugAttached=1, ///<Process attached to debugger.
|
||||
ProcessState_DebugDetached=2, ///<Process detached from debugger.
|
||||
ProcessState_Crashed=3, ///<Process that has just creashed.
|
||||
ProcessState_Running=4, ///<Process executing normally.
|
||||
ProcessState_Exiting=5, ///<Process has begun exiting.
|
||||
ProcessState_Exited=6, ///<Process has finished exiting.
|
||||
ProcessState_DebugSuspended=7, ///<Process execution suspended by debugger.
|
||||
} ProcessState;
|
||||
|
||||
///@name Memory management
|
||||
///@{
|
||||
|
||||
@ -487,6 +513,25 @@ Result svcSetThreadActivity(Handle thread, bool paused);
|
||||
|
||||
///@}
|
||||
|
||||
///@name Resource Limit Management
|
||||
///@{
|
||||
|
||||
/**
|
||||
* @brief Gets the maximum value a LimitableResource can have, for a Resource Limit handle.
|
||||
* @return Result code.
|
||||
* @note Syscall number 0x30.
|
||||
*/
|
||||
Result svcGetResourceLimitLimitValue(u64 *out, Handle reslimit_h, LimitableResource which);
|
||||
|
||||
/**
|
||||
* @brief Gets the maximum value a LimitableResource can have, for a Resource Limit handle.
|
||||
* @return Result code.
|
||||
* @note Syscall number 0x31.
|
||||
*/
|
||||
Result svcGetResourceLimitCurrentValue(u64 *out, Handle reslimit_h, LimitableResource which);
|
||||
|
||||
///@}
|
||||
|
||||
///@name Inter-process communication (IPC)
|
||||
///@{
|
||||
|
||||
@ -912,6 +957,35 @@ Result svcStartProcess(Handle proc, s32 main_prio, s32 default_cpu, u32 stack_si
|
||||
*/
|
||||
Result svcTerminateProcess(Handle proc);
|
||||
|
||||
/**
|
||||
* @brief Gets a \ref ProcessInfoType for a process.
|
||||
* @return Result code.
|
||||
* @note Syscall number 0x7C.
|
||||
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
|
||||
*/
|
||||
Result svcGetProcessInfo(u64 *out, Handle proc, ProcessInfoType which);
|
||||
|
||||
///@}
|
||||
|
||||
///@name Resource Limit Management
|
||||
///@{
|
||||
|
||||
/**
|
||||
* @brief Creates a new Resource Limit handle.
|
||||
* @return Result code.
|
||||
* @note Syscall number 0x7D.
|
||||
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
|
||||
*/
|
||||
Result svcCreateResourceLimit(Handle* out);
|
||||
|
||||
/**
|
||||
* @brief Sets the value for a \ref LimitableResource for a Resource Limit handle.
|
||||
* @return Result code.
|
||||
* @note Syscall number 0x7E.
|
||||
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
|
||||
*/
|
||||
Result svcSetResourceLimitLimitValue(Handle reslimit, LimitableResource which, u64 value);
|
||||
|
||||
///@}
|
||||
|
||||
///@name ( ͡° ͜ʖ ͡°)
|
||||
|
@ -229,6 +229,22 @@ SVC_BEGIN svcGetInfo
|
||||
ret
|
||||
SVC_END
|
||||
|
||||
SVC_BEGIN svcGetResourceLimitLimitValue
|
||||
str x0, [sp, #-16]!
|
||||
svc 0x30
|
||||
ldr x2, [sp], #16
|
||||
str w1, [x2]
|
||||
ret
|
||||
SVC_END
|
||||
|
||||
SVC_BEGIN svcGetResourceLimitCurrentValue
|
||||
str x0, [sp, #-16]!
|
||||
svc 0x31
|
||||
ldr x2, [sp], #16
|
||||
str w1, [x2]
|
||||
ret
|
||||
SVC_END
|
||||
|
||||
SVC_BEGIN svcSetThreadActivity
|
||||
svc 0x32
|
||||
ret
|
||||
@ -503,6 +519,27 @@ SVC_BEGIN svcTerminateProcess
|
||||
ret
|
||||
SVC_END
|
||||
|
||||
SVC_BEGIN svcGetProcessInfo
|
||||
str x0, [sp, #-16]!
|
||||
svc 0x7C
|
||||
ldr x2, [sp], #16
|
||||
str w1, [x2]
|
||||
ret
|
||||
SVC_END
|
||||
|
||||
SVC_BEGIN svcCreateResourceLimit
|
||||
str x0, [sp, #-16]!
|
||||
svc 0x7D
|
||||
ldr x2, [sp], #16
|
||||
str w1, [x2]
|
||||
ret
|
||||
SVC_END
|
||||
|
||||
SVC_BEGIN svcSetResourceLimitLimitValue
|
||||
svc 0x7E
|
||||
ret
|
||||
SVC_END
|
||||
|
||||
SVC_BEGIN svcCallSecureMonitor
|
||||
str x0, [sp, #-16]!
|
||||
mov x8, x0
|
||||
|
Loading…
Reference in New Issue
Block a user