libnx
v4.8.0
|
Wrappers for kernel syscalls. More...
Go to the source code of this file.
Data Structures | |
struct | MemoryInfo |
Memory information structure. More... | |
struct | PhysicalMemoryInfo |
Physical memory information structure. More... | |
struct | SecmonArgs |
Secure monitor arguments. More... | |
struct | LastThreadContext |
Context of a scheduled thread. More... | |
Macros | |
#define | CUR_PROCESS_HANDLE 0xFFFF8001 |
Pseudo handle for the current process. | |
#define | CUR_THREAD_HANDLE 0xFFFF8000 |
Pseudo handle for the current thread. | |
#define | MAX_WAIT_OBJECTS 0x40 |
Maximum number of objects that can be waited on by svcWaitSynchronization (Horizon kernel limitation). | |
Functions | |
Memory management | |
Result | svcSetHeapSize (void **out_addr, u64 size) |
Set the process heap to a given size. More... | |
Result | svcSetMemoryPermission (void *addr, u64 size, u32 perm) |
Set the memory permissions of a (page-aligned) range of memory. More... | |
Result | svcSetMemoryAttribute (void *addr, u64 size, u32 val0, u32 val1) |
Set the memory attributes of a (page-aligned) range of memory. More... | |
Result | svcMapMemory (void *dst_addr, void *src_addr, u64 size) |
Maps a memory range into a different range. More... | |
Result | svcUnmapMemory (void *dst_addr, void *src_addr, u64 size) |
Unmaps a region that was previously mapped with svcMapMemory. More... | |
Result | svcQueryMemory (MemoryInfo *meminfo_ptr, u32 *pageinfo, u64 addr) |
Query information about an address. More... | |
Result | svcMapPhysicalMemory (void *address, u64 size) |
Maps new heap memory at the desired address. More... | |
Result | svcUnmapPhysicalMemory (void *address, u64 size) |
Undoes the effects of svcMapPhysicalMemory. More... | |
Result | svcCreateIoPool (Handle *out_handle, u32 pool_type) |
Creates an IO Pool. More... | |
Result | svcCreateIoRegion (Handle *out_handle, Handle io_pool_h, u64 physical_address, u64 size, u32 memory_mapping, u32 perm) |
Creates an IO Region. More... | |
Result | svcMapIoRegion (Handle io_region_h, void *address, u64 size, u32 perm) |
Maps an IO Region. More... | |
Result | svcUnmapIoRegion (Handle io_region_h, void *address, u64 size) |
Undoes the effects of svcMapIoRegion. More... | |
Result | svcMapPhysicalMemoryUnsafe (void *address, u64 size) |
Maps unsafe memory (usable for GPU DMA) for a system module at the desired address. More... | |
Result | svcUnmapPhysicalMemoryUnsafe (void *address, u64 size) |
Undoes the effects of svcMapPhysicalMemoryUnsafe. More... | |
Result | svcSetUnsafeLimit (u64 size) |
Sets the system-wide limit for unsafe memory mappable using svcMapPhysicalMemoryUnsafe. More... | |
Result | svcSetProcessMemoryPermission (Handle proc, u64 addr, u64 size, u32 perm) |
Sets the memory permissions for the specified memory with the supplied process handle. More... | |
Result | svcMapProcessMemory (void *dst, Handle proc, u64 src, u64 size) |
Maps the src address from the supplied process handle into the current process. More... | |
Result | svcUnmapProcessMemory (void *dst, Handle proc, u64 src, u64 size) |
Undoes the effects of svcMapProcessMemory. More... | |
Result | svcQueryProcessMemory (MemoryInfo *meminfo_ptr, u32 *pageinfo, Handle proc, u64 addr) |
Equivalent to svcQueryMemory, for another process. More... | |
Result | svcMapProcessCodeMemory (Handle proc, u64 dst, u64 src, u64 size) |
Maps normal heap in a certain process as executable code (used when loading NROs). More... | |
Result | svcUnmapProcessCodeMemory (Handle proc, u64 dst, u64 src, u64 size) |
Undoes the effects of svcMapProcessCodeMemory. More... | |
Result | svcMapInsecurePhysicalMemory (void *address, u64 size) |
Maps new insecure memory at the desired address. More... | |
Result | svcUnmapInsecurePhysicalMemory (void *address, u64 size) |
Undoes the effects of svcMapInsecureMemory. More... | |
Process and thread management | |
void | svcExitProcess (void) |
Exits the current process. More... | |
Result | svcCreateThread (Handle *out, void *entry, void *arg, void *stack_top, int prio, int cpuid) |
Creates a thread. More... | |
Result | svcStartThread (Handle handle) |
Starts a freshly created thread. More... | |
void | svcExitThread (void) |
Exits the current thread. More... | |
void | svcSleepThread (s64 nano) |
Sleeps the current thread for the specified amount of time. More... | |
Result | svcGetThreadPriority (s32 *priority, Handle handle) |
Gets a thread's priority. More... | |
Result | svcSetThreadPriority (Handle handle, u32 priority) |
Sets a thread's priority. More... | |
Result | svcGetThreadCoreMask (s32 *preferred_core, u64 *affinity_mask, Handle handle) |
Gets a thread's core mask. More... | |
Result | svcSetThreadCoreMask (Handle handle, s32 preferred_core, u32 affinity_mask) |
Sets a thread's core mask. More... | |
u32 | svcGetCurrentProcessorNumber (void) |
Gets the current processor's number. More... | |
Result | svcGetProcessId (u64 *processID, Handle handle) |
Gets the PID associated with a process. More... | |
Result | svcGetThreadId (u64 *threadID, Handle handle) |
Gets the TID associated with a process. More... | |
Result | svcGetDebugFutureThreadInfo (LastThreadContext *out_context, u64 *out_thread_id, Handle debug, s64 ns) |
Gets information about a thread that will be scheduled in the future. More... | |
Result | svcGetLastThreadInfo (LastThreadContext *out_context, u64 *out_tls_address, u32 *out_flags) |
Gets information about the previously-scheduled thread. More... | |
Result | svcSetThreadActivity (Handle thread, ThreadActivity paused) |
Configures the pause/unpause status of a thread. More... | |
Result | svcGetThreadContext3 (ThreadContext *ctx, Handle thread) |
Dumps the registers of a thread paused by svcSetThreadActivity (register groups: all). More... | |
Result | svcSetProcessActivity (Handle process, ProcessActivity paused) |
Configures the pause/unpause status of a process. More... | |
Result | svcGetProcessList (s32 *num_out, u64 *pids_out, u32 max_pids) |
Retrieves a list of all running processes. More... | |
Result | svcGetThreadList (s32 *num_out, u64 *tids_out, u32 max_tids, Handle debug) |
Retrieves a list of all threads for a debug handle (or zero). More... | |
Result | svcCreateProcess (Handle *out, const void *proc_info, const u32 *caps, u64 cap_num) |
Creates a new process. More... | |
Result | svcStartProcess (Handle proc, s32 main_prio, s32 default_cpu, u32 stack_size) |
Starts executing a freshly created process. More... | |
Result | svcTerminateProcess (Handle proc) |
Terminates a running process. More... | |
Result | svcGetProcessInfo (s64 *out, Handle proc, ProcessInfoType which) |
Gets a ProcessInfoType for a process. More... | |
Synchronization | |
Result | svcSignalEvent (Handle handle) |
Sets an event's signalled status. More... | |
Result | svcClearEvent (Handle handle) |
Clears an event's signalled status. More... | |
Result | svcResetSignal (Handle handle) |
Resets a signal. More... | |
Result | svcWaitSynchronization (s32 *index, const Handle *handles, s32 handleCount, u64 timeout) |
Waits on one or more synchronization objects, optionally with a timeout. More... | |
static Result | svcWaitSynchronizationSingle (Handle handle, u64 timeout) |
Waits on a single synchronization object, optionally with a timeout. More... | |
Result | svcCancelSynchronization (Handle thread) |
Waits a svcWaitSynchronization operation being done on a synchronization object in another thread. More... | |
Result | svcArbitrateLock (u32 wait_tag, u32 *tag_location, u32 self_tag) |
Arbitrates a mutex lock operation in userspace. More... | |
Result | svcArbitrateUnlock (u32 *tag_location) |
Arbitrates a mutex unlock operation in userspace. More... | |
Result | svcWaitProcessWideKeyAtomic (u32 *key, u32 *tag_location, u32 self_tag, u64 timeout) |
Performs a condition variable wait operation in userspace. More... | |
void | svcSignalProcessWideKey (u32 *key, s32 num) |
Performs a condition variable wake-up operation in userspace. More... | |
Result | svcWaitForAddress (void *address, u32 arb_type, s64 value, s64 timeout) |
Arbitrates an address depending on type and value. More... | |
Result | svcSignalToAddress (void *address, u32 signal_type, s32 value, s32 count) |
Signals (and updates) an address depending on type and value. More... | |
Result | svcCreateEvent (Handle *server_handle, Handle *client_handle) |
Creates a system event. More... | |
Inter-process memory sharing | |
Result | svcMapSharedMemory (Handle handle, void *addr, size_t size, u32 perm) |
Maps a block of shared memory. More... | |
Result | svcUnmapSharedMemory (Handle handle, void *addr, size_t size) |
Unmaps a block of shared memory. More... | |
Result | svcCreateTransferMemory (Handle *out, void *addr, size_t size, u32 perm) |
Creates a block of transfer memory. More... | |
Result | svcCreateSharedMemory (Handle *out, size_t size, u32 local_perm, u32 other_perm) |
Creates a block of shared memory. More... | |
Result | svcMapTransferMemory (Handle tmem_handle, void *addr, size_t size, u32 perm) |
Maps a block of transfer memory. More... | |
Result | svcUnmapTransferMemory (Handle tmem_handle, void *addr, size_t size) |
Unmaps a block of transfer memory. More... | |
Miscellaneous | |
Result | svcCloseHandle (Handle handle) |
Closes a handle, decrementing the reference count of the corresponding kernel object. More... | |
u64 | svcGetSystemTick (void) |
Gets the current system tick. More... | |
Result | svcBreak (u32 breakReason, uintptr_t address, uintptr_t size) |
Breaks execution. More... | |
void | svcReturnFromException (Result res) |
Returns from an exception. More... | |
Result | svcGetInfo (u64 *out, u32 id0, Handle handle, u64 id1) |
Retrieves information about the system, or a certain kernel object. More... | |
void | svcSynchronizePreemptionState (void) |
Sets thread preemption state (used during abort/panic). More... | |
Result | svcGetSystemInfo (u64 *out, u64 id0, Handle handle, u64 id1) |
Retrieves privileged information about the system, or a certain kernel object. More... | |
Inter-process communication (IPC) | |
Result | svcConnectToNamedPort (Handle *session, const char *name) |
Connects to a registered named port. More... | |
Result | svcSendSyncRequestLight (Handle session) |
Sends a light IPC synchronization request to a session. More... | |
Result | svcSendSyncRequest (Handle session) |
Sends an IPC synchronization request to a session. More... | |
Result | svcSendSyncRequestWithUserBuffer (void *usrBuffer, u64 size, Handle session) |
Sends an IPC synchronization request to a session from an user allocated buffer. More... | |
Result | svcSendAsyncRequestWithUserBuffer (Handle *handle, void *usrBuffer, u64 size, Handle session) |
Sends an IPC synchronization request to a session from an user allocated buffer (asynchronous version). More... | |
Result | svcCreateSession (Handle *server_handle, Handle *client_handle, u32 unk0, u64 unk1) |
Creates an IPC session. More... | |
Result | svcAcceptSession (Handle *session_handle, Handle port_handle) |
Accepts an IPC session. More... | |
Result | svcReplyAndReceiveLight (Handle handle) |
Performs light IPC input/output. More... | |
Result | svcReplyAndReceive (s32 *index, const Handle *handles, s32 handleCount, Handle replyTarget, u64 timeout) |
Performs IPC input/output. More... | |
Result | svcReplyAndReceiveWithUserBuffer (s32 *index, void *usrBuffer, u64 size, const Handle *handles, s32 handleCount, Handle replyTarget, u64 timeout) |
Performs IPC input/output from an user allocated buffer. More... | |
Result | svcCreatePort (Handle *portServer, Handle *portClient, s32 max_sessions, bool is_light, const char *name) |
Creates a port. More... | |
Result | svcManageNamedPort (Handle *portServer, const char *name, s32 maxSessions) |
Manages a named port. More... | |
Result | svcConnectToPort (Handle *session, Handle port) |
Manages a named port. More... | |
Debugging | |
Result | svcOutputDebugString (const char *str, u64 size) |
Outputs debug text, if used during debugging. More... | |
void | svcDumpInfo (u32 dump_info_type, u64 arg0) |
Causes the kernel to dump debug information. More... | |
void | svcKernelDebug (u32 kern_debug_type, u64 arg0, u64 arg1, u64 arg2) |
Performs a debugging operation on the kernel. More... | |
void | svcChangeKernelTraceState (u32 kern_trace_state) |
Performs a debugging operation on the kernel. More... | |
Result | svcDebugActiveProcess (Handle *debug, u64 processID) |
Debugs an active process. More... | |
Result | svcBreakDebugProcess (Handle debug) |
Breaks an active debugging session. More... | |
Result | svcTerminateDebugProcess (Handle debug) |
Terminates the process of an active debugging session. More... | |
Result | svcGetDebugEvent (void *event_out, Handle debug) |
Gets an incoming debug event from a debugging session. More... | |
Result | svcContinueDebugEvent (Handle debug, u32 flags, u64 *tid_list, u32 num_tids) |
Continues a debugging session. More... | |
Result | svcLegacyContinueDebugEvent (Handle debug, u32 flags, u64 threadID) |
Continues a debugging session. More... | |
Result | svcGetDebugThreadContext (ThreadContext *ctx, Handle debug, u64 threadID, u32 flags) |
Gets the context (dump the registers) of a thread in a debugging session. More... | |
Result | svcSetDebugThreadContext (Handle debug, u64 threadID, const ThreadContext *ctx, u32 flags) |
Gets the context (dump the registers) of a thread in a debugging session. More... | |
Result | svcQueryDebugProcessMemory (MemoryInfo *meminfo_ptr, u32 *pageinfo, Handle debug, u64 addr) |
Queries memory information from a process that is being debugged. More... | |
Result | svcReadDebugProcessMemory (void *buffer, Handle debug, u64 addr, u64 size) |
Reads memory from a process that is being debugged. More... | |
Result | svcWriteDebugProcessMemory (Handle debug, const void *buffer, u64 addr, u64 size) |
Writes to memory in a process that is being debugged. More... | |
Result | svcSetHardwareBreakPoint (u32 which, u64 flags, u64 value) |
Sets one of the hardware breakpoints. More... | |
Result | svcGetDebugThreadParam (u64 *out_64, u32 *out_32, Handle debug, u64 threadID, DebugThreadParam param) |
Gets parameters from a thread in a debugging session. More... | |
Cache Management | |
void | svcFlushEntireDataCache (void) |
Flushes the entire data cache (by set/way). More... | |
Result | svcFlushDataCache (void *address, size_t size) |
Flushes data cache for a virtual address range. More... | |
Result | svcInvalidateProcessDataCache (Handle process, uintptr_t address, size_t size) |
Invalidates data cache for a virtual address range within a process. More... | |
Result | svcStoreProcessDataCache (Handle process, uintptr_t address, size_t size) |
Stores data cache for a virtual address range within a process. More... | |
Result | svcFlushProcessDataCache (Handle process, uintptr_t address, size_t size) |
Flushes data cache for a virtual address range within a process. More... | |
Resource Limit Management | |
Result | svcGetResourceLimitLimitValue (s64 *out, Handle reslimit_h, LimitableResource which) |
Gets the maximum value a LimitableResource can have, for a Resource Limit handle. More... | |
Result | svcGetResourceLimitCurrentValue (s64 *out, Handle reslimit_h, LimitableResource which) |
Gets the maximum value a LimitableResource can have, for a Resource Limit handle. More... | |
Result | svcGetResourceLimitPeakValue (s64 *out, Handle reslimit_h, LimitableResource which) |
Gets the peak value a LimitableResource has had, for a Resource Limit handle. More... | |
Result | svcCreateResourceLimit (Handle *out) |
Creates a new Resource Limit handle. More... | |
Result | svcSetResourceLimitLimitValue (Handle reslimit, LimitableResource which, u64 value) |
Sets the value for a LimitableResource for a Resource Limit handle. More... | |
Code memory / Just-in-time (JIT) compilation support | |
Result | svcCreateCodeMemory (Handle *code_handle, void *src_addr, u64 size) |
Creates code memory in the caller's address space [4.0.0+]. More... | |
Result | svcControlCodeMemory (Handle code_handle, CodeMapOperation op, void *dst_addr, u64 size, u64 perm) |
Maps code memory in the caller's address space [4.0.0+]. More... | |
Power Management | |
void | svcSleepSystem (void) |
Causes the system to enter deep sleep. More... | |
Device memory-mapped I/O (MMIO) | |
Result | svcReadWriteRegister (u32 *outVal, u64 regAddr, u32 rwMask, u32 inVal) |
Reads/writes a protected MMIO register. More... | |
Result | svcCreateInterruptEvent (Handle *handle, u64 irqNum, u32 flag) |
Creates an event and binds it to a specific hardware interrupt. More... | |
Result | svcQueryPhysicalAddress (PhysicalMemoryInfo *out, u64 virtaddr) |
Queries information about a certain virtual address, including its physical address. More... | |
Result | svcQueryMemoryMapping (u64 *virtaddr, u64 *out_size, u64 physaddr, u64 size) |
Returns a virtual address mapped to a given IO range. More... | |
Result | svcLegacyQueryIoMapping (u64 *virtaddr, u64 physaddr, u64 size) |
Returns a virtual address mapped to a given IO range. More... | |
I/O memory management unit (IOMMU) | |
Result | svcCreateDeviceAddressSpace (Handle *handle, u64 dev_addr, u64 dev_size) |
Creates a virtual address space for binding device address spaces. More... | |
Result | svcAttachDeviceAddressSpace (u64 device, Handle handle) |
Attaches a device address space to a device. More... | |
Result | svcDetachDeviceAddressSpace (u64 device, Handle handle) |
Detaches a device address space from a device. More... | |
Result | svcMapDeviceAddressSpaceByForce (Handle handle, Handle proc_handle, u64 map_addr, u64 dev_size, u64 dev_addr, u32 option) |
Maps an attached device address space to an userspace address. More... | |
Result | svcMapDeviceAddressSpaceAligned (Handle handle, Handle proc_handle, u64 map_addr, u64 dev_size, u64 dev_addr, u32 option) |
Maps an attached device address space to an userspace address. More... | |
Result | svcMapDeviceAddressSpace (u64 *out_mapped_size, Handle handle, Handle proc_handle, u64 map_addr, u64 dev_size, u64 dev_addr, u32 perm) |
Maps an attached device address space to an userspace address. More... | |
Result | svcUnmapDeviceAddressSpace (Handle handle, Handle proc_handle, u64 map_addr, u64 map_size, u64 dev_addr) |
Unmaps an attached device address space from an userspace address. More... | |
( ͡° ͜ʖ ͡°) | |
void | svcCallSecureMonitor (SecmonArgs *regs) |
Calls a secure monitor function (TrustZone, EL3). More... | |
Wrappers for kernel syscalls.
enum ArbitrationType |
WaitForAddress behaviors.
enum CodeMapOperation |
enum InfoType |
GetInfo IDs.
Enumerator | |
---|---|
InfoType_CoreMask | Bitmask of allowed Core IDs. |
InfoType_PriorityMask | Bitmask of allowed Thread Priorities. |
InfoType_AliasRegionAddress | Base of the Alias memory region. |
InfoType_AliasRegionSize | Size of the Alias memory region. |
InfoType_HeapRegionAddress | Base of the Heap memory region. |
InfoType_HeapRegionSize | Size of the Heap memory region. |
InfoType_TotalMemorySize | Total amount of memory available for process. |
InfoType_UsedMemorySize | Amount of memory currently used by process. |
InfoType_DebuggerAttached | Whether current process is being debugged. |
InfoType_ResourceLimit | Current process's resource limit handle. |
InfoType_IdleTickCount | Number of idle ticks on CPU. |
InfoType_RandomEntropy | [2.0.0+] Random entropy for current process. |
InfoType_AslrRegionAddress | [2.0.0+] Base of the process's address space. |
InfoType_AslrRegionSize | [2.0.0+] Size of the process's address space. |
InfoType_StackRegionAddress | [2.0.0+] Base of the Stack memory region. |
InfoType_StackRegionSize | [2.0.0+] Size of the Stack memory region. |
InfoType_SystemResourceSizeTotal | [3.0.0+] Total memory allocated for process memory management. |
InfoType_SystemResourceSizeUsed | [3.0.0+] Amount of memory currently used by process memory management. |
InfoType_ProgramId | [3.0.0+] Program ID for the process. |
InfoType_InitialProcessIdRange | [4.0.0-4.1.0] Min/max initial process IDs. |
InfoType_UserExceptionContextAddress | [5.0.0+] Address of the process's exception context (for break). |
InfoType_TotalNonSystemMemorySize | [6.0.0+] Total amount of memory available for process, excluding that for process memory management. |
InfoType_UsedNonSystemMemorySize | [6.0.0+] Amount of memory used by process, excluding that for process memory management. |
InfoType_IsApplication | [9.0.0+] Whether the specified process is an Application. |
InfoType_FreeThreadCount | [11.0.0+] The number of free threads available to the process's resource limit. |
InfoType_ThreadTickCount | [13.0.0+] Number of ticks spent on thread. |
InfoType_IsSvcPermitted | [14.0.0+] Does process have access to SVC (only usable with svcSynchronizePreemptionState at present). |
InfoType_IoRegionHint | [16.0.0+] Low bits of the physical address for a KIoRegion. |
InfoType_AliasRegionExtraSize | [18.0.0+] Extra size added to the reserved region. |
InfoType_TransferMemoryHint | [19.0.0+] Low bits of the process address for a KTransferMemory. |
InfoType_ThreadTickCountDeprecated | [1.0.0-12.1.0] Number of ticks spent on thread. |
enum IoPoolType |
enum LimitableResource |
Limitable Resources.
enum MemoryAttribute |
enum MemoryMapping |
enum MemoryState |
Memory state bitmasks.
Enumerator | |
---|---|
MemState_Type | Type field (see MemoryType). |
MemState_PermChangeAllowed | Permission change allowed. |
MemState_ForceRwByDebugSyscalls | Force read/writable by debug syscalls. |
MemState_IpcSendAllowed_Type0 | IPC type 0 send allowed. |
MemState_IpcSendAllowed_Type3 | IPC type 3 send allowed. |
MemState_IpcSendAllowed_Type1 | IPC type 1 send allowed. |
MemState_ProcessPermChangeAllowed | Process permission change allowed. |
MemState_MapAllowed | Map allowed. |
MemState_UnmapProcessCodeMemAllowed | Unmap process code memory allowed. |
MemState_TransferMemAllowed | Transfer memory allowed. |
MemState_QueryPAddrAllowed | Query physical address allowed. |
MemState_MapDeviceAllowed | Map device allowed (svcMapDeviceAddressSpace and svcMapDeviceAddressSpaceByForce). |
MemState_MapDeviceAlignedAllowed | Map device aligned allowed. |
MemState_IpcBufferAllowed | IPC buffer allowed. |
MemState_IsPoolAllocated | Is pool allocated. |
MemState_IsRefCounted | Alias for MemState_IsPoolAllocated. |
MemState_MapProcessAllowed | Map process allowed. |
MemState_AttrChangeAllowed | Attribute change allowed. |
MemState_CodeMemAllowed | Code memory allowed. |
enum MemoryType |
Memory type enumeration (lower 8 bits of MemoryState)
Enumerator | |
---|---|
MemType_Unmapped | Unmapped memory. |
MemType_Io | Mapped by kernel capability parsing in svcCreateProcess. |
MemType_Normal | Mapped by kernel capability parsing in svcCreateProcess. |
MemType_CodeStatic | Mapped during svcCreateProcess. |
MemType_CodeMutable | Transition from MemType_CodeStatic performed by svcSetProcessMemoryPermission. |
MemType_Heap | Mapped using svcSetHeapSize. |
MemType_SharedMem | Mapped using svcMapSharedMemory. |
MemType_WeirdMappedMem | Mapped using svcMapMemory. |
MemType_ModuleCodeStatic | Mapped using svcMapProcessCodeMemory. |
MemType_ModuleCodeMutable | Transition from MemType_ModuleCodeStatic performed by svcSetProcessMemoryPermission. |
MemType_IpcBuffer0 | IPC buffers with descriptor flags=0. |
MemType_MappedMemory | Mapped using svcMapMemory. |
MemType_ThreadLocal | Mapped during svcCreateThread. |
MemType_TransferMemIsolated | Mapped using svcMapTransferMemory when the owning process has perm=0. |
MemType_TransferMem | Mapped using svcMapTransferMemory when the owning process has perm!=0. |
MemType_ProcessMem | Mapped using svcMapProcessMemory. |
MemType_Reserved | Reserved. |
MemType_IpcBuffer1 | IPC buffers with descriptor flags=1. |
MemType_IpcBuffer3 | IPC buffers with descriptor flags=3. |
MemType_KernelStack | Mapped in kernel during svcCreateThread. |
MemType_CodeReadOnly | Mapped in kernel during svcControlCodeMemory. |
MemType_CodeWritable | Mapped in kernel during svcControlCodeMemory. |
MemType_Coverage | Not available. |
MemType_Insecure | Mapped in kernel during svcMapInsecurePhysicalMemory. |
enum Permission |
GetSystemInfo PhysicalMemory Sub IDs.
enum ProcessActivity |
enum ProcessInfoType |
enum ProcessState |
Process States.
enum SignalType |
SignalToAddress behaviors.
enum SystemInfoType |
enum ThreadActivity |
enum TickCountInfo |
enum YieldType |
Accepts an IPC session.
Arbitrates a mutex lock operation in userspace.
Arbitrates a mutex unlock operation in userspace.
Attaches a device address space to a device.
Breaks execution.
[in] | breakReason | Break reason (see BreakReason). |
[in] | address | Address of the buffer to pass to the debugger. |
[in] | size | Size of the buffer to pass to the debugger. |
Breaks an active debugging session.
void svcCallSecureMonitor | ( | SecmonArgs * | regs | ) |
Calls a secure monitor function (TrustZone, EL3).
regs | Arguments to pass to the secure monitor. |
Waits a svcWaitSynchronization operation being done on a synchronization object in another thread.
void svcChangeKernelTraceState | ( | u32 | kern_trace_state | ) |
Performs a debugging operation on the kernel.
[4.0.0+]
[in] | kern_trace_state | Type of tracing the kernel should perform. |
Clears an event's signalled status.
Closes a handle, decrementing the reference count of the corresponding kernel object.
This might result in the kernel freeing the object.
handle | Handle to close. |
Connects to a registered named port.
Manages a named port.
Continues a debugging session.
Result svcControlCodeMemory | ( | Handle | code_handle, |
CodeMapOperation | op, | ||
void * | dst_addr, | ||
u64 | size, | ||
u64 | perm | ||
) |
Maps code memory in the caller's address space [4.0.0+].
Creates code memory in the caller's address space [4.0.0+].
Creates a virtual address space for binding device address spaces.
Creates a system event.
Creates an event and binds it to a specific hardware interrupt.
Creates an IO Pool.
[13.0.0+]
Result svcCreateIoRegion | ( | Handle * | out_handle, |
Handle | io_pool_h, | ||
u64 | physical_address, | ||
u64 | size, | ||
u32 | memory_mapping, | ||
u32 | perm | ||
) |
Creates an IO Region.
[13.0.0+]
Result svcCreatePort | ( | Handle * | portServer, |
Handle * | portClient, | ||
s32 | max_sessions, | ||
bool | is_light, | ||
const char * | name | ||
) |
Creates a port.
Creates a new process.
Creates a new Resource Limit handle.
Creates an IPC session.
Creates a block of shared memory.
Result svcCreateThread | ( | Handle * | out, |
void * | entry, | ||
void * | arg, | ||
void * | stack_top, | ||
int | prio, | ||
int | cpuid | ||
) |
Creates a thread.
Creates a block of transfer memory.
Debugs an active process.
Detaches a device address space from a device.
Causes the kernel to dump debug information.
[1.0.0-3.0.2]
[in] | dump_info_type | Type of information to dump. |
[in] | arg0 | Argument to the debugging operation. |
void svcExitProcess | ( | void | ) |
Exits the current process.
void svcExitThread | ( | void | ) |
Exits the current thread.
Result svcFlushDataCache | ( | void * | address, |
size_t | size | ||
) |
Flushes data cache for a virtual address range.
[in] | address | Address of region to flush. |
[in] | size | Size of region to flush. |
void svcFlushEntireDataCache | ( | void | ) |
Flushes the entire data cache (by set/way).
Flushes data cache for a virtual address range within a process.
[in] | address | Address of region to flush. |
[in] | size | Size of region to flush. |
u32 svcGetCurrentProcessorNumber | ( | void | ) |
Gets the current processor's number.
Gets an incoming debug event from a debugging session.
Result svcGetDebugFutureThreadInfo | ( | LastThreadContext * | out_context, |
u64 * | out_thread_id, | ||
Handle | debug, | ||
s64 | ns | ||
) |
Gets information about a thread that will be scheduled in the future.
[5.0.0+]
[out] | out_context | Output LastThreadContext for the thread that will be scheduled. |
[out] | out_thread_id | Output thread id for the thread that will be scheduled. |
[in] | debug | Debug handle. |
[in] | ns | Nanoseconds in the future to get scheduled thread at. |
Result svcGetDebugThreadContext | ( | ThreadContext * | ctx, |
Handle | debug, | ||
u64 | threadID, | ||
u32 | flags | ||
) |
Gets the context (dump the registers) of a thread in a debugging session.
[out] | ctx | Output thread context (register dump). |
[in] | debug | Debug handle. |
[in] | threadID | ID of the thread to dump the context of. |
[in] | flags | Register groups to select, combination of RegisterGroup flags. |
Result svcGetDebugThreadParam | ( | u64 * | out_64, |
u32 * | out_32, | ||
Handle | debug, | ||
u64 | threadID, | ||
DebugThreadParam | param | ||
) |
Gets parameters from a thread in a debugging session.
Retrieves information about the system, or a certain kernel object.
[out] | out | Variable to which store the information. |
[in] | id0 | First ID of the property to retrieve. |
[in] | handle | Handle of the object to retrieve information from, or INVALID_HANDLE to retrieve information about the system. |
[in] | id1 | Second ID of the property to retrieve. |
Result svcGetLastThreadInfo | ( | LastThreadContext * | out_context, |
u64 * | out_tls_address, | ||
u32 * | out_flags | ||
) |
Gets information about the previously-scheduled thread.
[out] | out_context | Output LastThreadContext for the previously scheduled thread. |
[out] | out_tls_address | Output tls address for the previously scheduled thread. |
[out] | out_flags | Output flags for the previously scheduled thread. |
Gets the PID associated with a process.
Result svcGetProcessInfo | ( | s64 * | out, |
Handle | proc, | ||
ProcessInfoType | which | ||
) |
Gets a ProcessInfoType for a process.
Retrieves a list of all running processes.
Result svcGetResourceLimitCurrentValue | ( | s64 * | out, |
Handle | reslimit_h, | ||
LimitableResource | which | ||
) |
Gets the maximum value a LimitableResource can have, for a Resource Limit handle.
Result svcGetResourceLimitLimitValue | ( | s64 * | out, |
Handle | reslimit_h, | ||
LimitableResource | which | ||
) |
Gets the maximum value a LimitableResource can have, for a Resource Limit handle.
Result svcGetResourceLimitPeakValue | ( | s64 * | out, |
Handle | reslimit_h, | ||
LimitableResource | which | ||
) |
Gets the peak value a LimitableResource has had, for a Resource Limit handle.
[11.0.0+]
Retrieves privileged information about the system, or a certain kernel object.
[out] | out | Variable to which store the information. |
[in] | id0 | First ID of the property to retrieve. |
[in] | handle | Handle of the object to retrieve information from, or INVALID_HANDLE to retrieve information about the system. |
[in] | id1 | Second ID of the property to retrieve. |
u64 svcGetSystemTick | ( | void | ) |
Gets the current system tick.
Result svcGetThreadContext3 | ( | ThreadContext * | ctx, |
Handle | thread | ||
) |
Dumps the registers of a thread paused by svcSetThreadActivity (register groups: all).
[out] | ctx | Output thread context (register dump). |
[in] | thread | Thread handle. |
Gets a thread's core mask.
Gets the TID associated with a process.
Retrieves a list of all threads for a debug handle (or zero).
Gets a thread's priority.
Invalidates data cache for a virtual address range within a process.
[in] | address | Address of region to invalidate. |
[in] | size | Size of region to invalidate. |
Performs a debugging operation on the kernel.
[4.0.0+]
[in] | kern_debug_type | Type of debugging operation to perform. |
[in] | arg0 | First argument to the debugging operation. |
[in] | arg1 | Second argument to the debugging operation. |
[in] | arg2 | Third argument to the debugging operation. |
Continues a debugging session.
Returns a virtual address mapped to a given IO range.
Manages a named port.
Result svcMapDeviceAddressSpace | ( | u64 * | out_mapped_size, |
Handle | handle, | ||
Handle | proc_handle, | ||
u64 | map_addr, | ||
u64 | dev_size, | ||
u64 | dev_addr, | ||
u32 | perm | ||
) |
Maps an attached device address space to an userspace address.
[1.0.0-12.1.0]
Result svcMapDeviceAddressSpaceAligned | ( | Handle | handle, |
Handle | proc_handle, | ||
u64 | map_addr, | ||
u64 | dev_size, | ||
u64 | dev_addr, | ||
u32 | option | ||
) |
Maps an attached device address space to an userspace address.
Result svcMapDeviceAddressSpaceByForce | ( | Handle | handle, |
Handle | proc_handle, | ||
u64 | map_addr, | ||
u64 | dev_size, | ||
u64 | dev_addr, | ||
u32 | option | ||
) |
Maps an attached device address space to an userspace address.
Maps new insecure memory at the desired address.
[15.0.0+]
Maps an IO Region.
[13.0.0+]
Maps a memory range into a different range.
Mainly used for adding guard pages around stack. Source range gets reprotected to Perm_None (it can no longer be accessed), and MemAttr_IsBorrowed is set in the source MemoryAttribute.
[in] | dst_addr | Destination address. |
[in] | src_addr | Source address. |
[in] | size | Size of the range. |
Maps new heap memory at the desired address.
[3.0.0+]
Maps unsafe memory (usable for GPU DMA) for a system module at the desired address.
[5.0.0+]
Maps normal heap in a certain process as executable code (used when loading NROs).
[in] | proc | Process handle (cannot be CUR_PROCESS_HANDLE). |
[in] | dst | Destination mapping address. |
[in] | src | Source mapping address. |
[in] | size | Size of the mapping. |
Maps the src address from the supplied process handle into the current process.
[in] | dst | Address to which map the memory in the current process. |
[in] | proc | Process handle. |
[in] | src | Source mapping address. |
[in] | size | Size of the memory. |
Maps a block of shared memory.
Maps a block of transfer memory.
Outputs debug text, if used during debugging.
[in] | str | Text to output. |
[in] | size | Size of the text in bytes. |
Result svcQueryDebugProcessMemory | ( | MemoryInfo * | meminfo_ptr, |
u32 * | pageinfo, | ||
Handle | debug, | ||
u64 | addr | ||
) |
Queries memory information from a process that is being debugged.
Result svcQueryMemory | ( | MemoryInfo * | meminfo_ptr, |
u32 * | pageinfo, | ||
u64 | addr | ||
) |
Query information about an address.
Will always fetch the lowest page-aligned mapping that contains the provided address.
[out] | meminfo_ptr | MemoryInfo structure which will be filled in. |
[out] | pageinfo | Page information which will be filled in. |
[in] | addr | Address to query. |
Returns a virtual address mapped to a given IO range.
Result svcQueryPhysicalAddress | ( | PhysicalMemoryInfo * | out, |
u64 | virtaddr | ||
) |
Queries information about a certain virtual address, including its physical address.
Result svcQueryProcessMemory | ( | MemoryInfo * | meminfo_ptr, |
u32 * | pageinfo, | ||
Handle | proc, | ||
u64 | addr | ||
) |
Equivalent to svcQueryMemory, for another process.
[out] | meminfo_ptr | MemoryInfo structure which will be filled in. |
[out] | pageinfo | Page information which will be filled in. |
[in] | proc | Process handle. |
[in] | addr | Address to query. |
Reads memory from a process that is being debugged.
Reads/writes a protected MMIO register.
Result svcReplyAndReceive | ( | s32 * | index, |
const Handle * | handles, | ||
s32 | handleCount, | ||
Handle | replyTarget, | ||
u64 | timeout | ||
) |
Performs IPC input/output.
Performs light IPC input/output.
[in] | handle | Server or port handle to act on. |
Result svcReplyAndReceiveWithUserBuffer | ( | s32 * | index, |
void * | usrBuffer, | ||
u64 | size, | ||
const Handle * | handles, | ||
s32 | handleCount, | ||
Handle | replyTarget, | ||
u64 | timeout | ||
) |
Performs IPC input/output from an user allocated buffer.
Resets a signal.
void svcReturnFromException | ( | Result | res | ) |
Returns from an exception.
[in] | res | Result code. |
Result svcSendAsyncRequestWithUserBuffer | ( | Handle * | handle, |
void * | usrBuffer, | ||
u64 | size, | ||
Handle | session | ||
) |
Sends an IPC synchronization request to a session from an user allocated buffer (asynchronous version).
Sends an IPC synchronization request to a session.
Sends a light IPC synchronization request to a session.
Sends an IPC synchronization request to a session from an user allocated buffer.
Result svcSetDebugThreadContext | ( | Handle | debug, |
u64 | threadID, | ||
const ThreadContext * | ctx, | ||
u32 | flags | ||
) |
Gets the context (dump the registers) of a thread in a debugging session.
[in] | debug | Debug handle. |
[in] | threadID | ID of the thread to set the context of. |
[in] | ctx | Input thread context (register dump). |
[in] | flags | Register groups to select, combination of RegisterGroup flags. |
Sets one of the hardware breakpoints.
Set the process heap to a given size.
It can both extend and shrink the heap.
[out] | out_addr | Variable to which write the address of the heap (which is randomized and fixed by the kernel) |
[in] | size | Size of the heap, must be a multiple of 0x200000 and [2.0.0+] less than 0x18000000. |
Set the memory attributes of a (page-aligned) range of memory.
[in] | addr | Start address of the range. |
[in] | size | Size of the range, in bytes. |
[in] | val0 | State0 |
[in] | val1 | State1 |
Set the memory permissions of a (page-aligned) range of memory.
[in] | addr | Start address of the range. |
[in] | size | Size of the range, in bytes. |
[in] | perm | Permissions (see Permission). |
Result svcSetProcessActivity | ( | Handle | process, |
ProcessActivity | paused | ||
) |
Configures the pause/unpause status of a process.
Sets the memory permissions for the specified memory with the supplied process handle.
[in] | proc | Process handle. |
[in] | addr | Address of the memory. |
[in] | size | Size of the memory. |
[in] | perm | Permissions (see Permission). |
perm
is >0x5, hence -WX and RWX are not allowed. Result svcSetResourceLimitLimitValue | ( | Handle | reslimit, |
LimitableResource | which, | ||
u64 | value | ||
) |
Sets the value for a LimitableResource for a Resource Limit handle.
Result svcSetThreadActivity | ( | Handle | thread, |
ThreadActivity | paused | ||
) |
Configures the pause/unpause status of a thread.
Sets a thread's core mask.
Sets a thread's priority.
Sets the system-wide limit for unsafe memory mappable using svcMapPhysicalMemoryUnsafe.
[5.0.0+]
Sets an event's signalled status.
Performs a condition variable wake-up operation in userspace.
Signals (and updates) an address depending on type and value.
[4.0.0+]
[in] | address | Address to arbitrate. |
[in] | signal_type | SignalType to use. |
[in] | value | Value to arbitrate on. |
[in] | count | Number of waiting threads to signal. |
void svcSleepSystem | ( | void | ) |
Causes the system to enter deep sleep.
void svcSleepThread | ( | s64 | nano | ) |
Sleeps the current thread for the specified amount of time.
[in] | nano | Number of nanoseconds to sleep, or YieldType for yield. |
Starts executing a freshly created process.
Starts a freshly created thread.
Stores data cache for a virtual address range within a process.
[in] | address | Address of region to store. |
[in] | size | Size of region to store. |
void svcSynchronizePreemptionState | ( | void | ) |
Sets thread preemption state (used during abort/panic).
[8.0.0+]
Terminates the process of an active debugging session.
Terminates a running process.
Result svcUnmapDeviceAddressSpace | ( | Handle | handle, |
Handle | proc_handle, | ||
u64 | map_addr, | ||
u64 | map_size, | ||
u64 | dev_addr | ||
) |
Unmaps an attached device address space from an userspace address.
Undoes the effects of svcMapInsecureMemory.
[15.0.0+]
Undoes the effects of svcMapIoRegion.
[13.0.0+]
Unmaps a region that was previously mapped with svcMapMemory.
[in] | dst_addr | Destination address. |
[in] | src_addr | Source address. |
[in] | size | Size of the range. |
Undoes the effects of svcMapPhysicalMemoryUnsafe.
[5.0.0+]
Undoes the effects of svcMapProcessCodeMemory.
[in] | proc | Process handle (cannot be CUR_PROCESS_HANDLE). |
[in] | dst | Destination mapping address. |
[in] | src | Source mapping address. |
[in] | size | Size of the mapping. |
Undoes the effects of svcMapProcessMemory.
[in] | dst | Destination mapping address |
[in] | proc | Process handle. |
[in] | src | Address of the memory in the process. |
[in] | size | Size of the memory. |
Unmaps a block of shared memory.
Unmaps a block of transfer memory.
Arbitrates an address depending on type and value.
[4.0.0+]
[in] | address | Address to arbitrate. |
[in] | arb_type | ArbitrationType to use. |
[in] | value | Value to arbitrate on. |
[in] | timeout | Maximum time in nanoseconds to wait. |
Performs a condition variable wait operation in userspace.
Waits on one or more synchronization objects, optionally with a timeout.
handleCount
must not be greater than MAX_WAIT_OBJECTS. This is a Horizon kernel limitation. Waits on a single synchronization object, optionally with a timeout.
Writes to memory in a process that is being debugged.