libnx  v4.6.0
Data Structures | Macros | Enumerations
svc.h File Reference

Wrappers for kernel syscalls. More...

#include "../types.h"
#include "../arm/thread_context.h"

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).
 

Enumerations

enum  MemoryType {
  MemType_Unmapped =0x00 ,
  MemType_Io =0x01 ,
  MemType_Normal =0x02 ,
  MemType_CodeStatic =0x03 ,
  MemType_CodeMutable =0x04 ,
  MemType_Heap =0x05 ,
  MemType_SharedMem =0x06 ,
  MemType_WeirdMappedMem =0x07 ,
  MemType_ModuleCodeStatic =0x08 ,
  MemType_ModuleCodeMutable =0x09 ,
  MemType_IpcBuffer0 =0x0A ,
  MemType_MappedMemory =0x0B ,
  MemType_ThreadLocal =0x0C ,
  MemType_TransferMemIsolated =0x0D ,
  MemType_TransferMem =0x0E ,
  MemType_ProcessMem =0x0F ,
  MemType_Reserved =0x10 ,
  MemType_IpcBuffer1 =0x11 ,
  MemType_IpcBuffer3 =0x12 ,
  MemType_KernelStack =0x13 ,
  MemType_CodeReadOnly =0x14 ,
  MemType_CodeWritable =0x15 ,
  MemType_Coverage =0x16 ,
  MemType_Insecure =0x17
}
 Memory type enumeration (lower 8 bits of MemoryState) More...
 
enum  MemoryState {
  MemState_Type =0xFF ,
  MemState_PermChangeAllowed =(1U<<( 8 )) ,
  MemState_ForceRwByDebugSyscalls =(1U<<( 9 )) ,
  MemState_IpcSendAllowed_Type0 =(1U<<( 10 )) ,
  MemState_IpcSendAllowed_Type3 =(1U<<( 11 )) ,
  MemState_IpcSendAllowed_Type1 =(1U<<( 12 )) ,
  MemState_ProcessPermChangeAllowed =(1U<<( 14 )) ,
  MemState_MapAllowed =(1U<<( 15 )) ,
  MemState_UnmapProcessCodeMemAllowed =(1U<<( 16 )) ,
  MemState_TransferMemAllowed =(1U<<( 17 )) ,
  MemState_QueryPAddrAllowed =(1U<<( 18 )) ,
  MemState_MapDeviceAllowed =(1U<<( 19 )) ,
  MemState_MapDeviceAlignedAllowed =(1U<<( 20 )) ,
  MemState_IpcBufferAllowed =(1U<<( 21 )) ,
  MemState_IsPoolAllocated =(1U<<( 22 )) ,
  MemState_IsRefCounted =MemState_IsPoolAllocated ,
  MemState_MapProcessAllowed =(1U<<( 23 )) ,
  MemState_AttrChangeAllowed =(1U<<( 24 )) ,
  MemState_CodeMemAllowed =(1U<<( 25 ))
}
 Memory state bitmasks. More...
 
enum  MemoryAttribute {
  MemAttr_IsBorrowed =(1U<<( 0 )) ,
  MemAttr_IsIpcMapped =(1U<<( 1 )) ,
  MemAttr_IsDeviceMapped =(1U<<( 2 )) ,
  MemAttr_IsUncached =(1U<<( 3 )) ,
  MemAttr_IsPermissionLocked =(1U<<( 4 ))
}
 Memory attribute bitmasks. More...
 
enum  Permission {
  Perm_None = 0 ,
  Perm_R = (1U<<( 0 )) ,
  Perm_W = (1U<<( 1 )) ,
  Perm_X = (1U<<( 2 )) ,
  Perm_Rw = Perm_R | Perm_W ,
  Perm_Rx = Perm_R | Perm_X ,
  Perm_DontCare = (1U<<( 28 ))
}
 Memory permission bitmasks. More...
 
enum  BreakReason {
  BreakReason_Panic = 0 ,
  BreakReason_Assert = 1 ,
  BreakReason_User = 2 ,
  BreakReason_PreLoadDll = 3 ,
  BreakReason_PostLoadDll = 4 ,
  BreakReason_PreUnloadDll = 5 ,
  BreakReason_PostUnloadDll = 6 ,
  BreakReason_CppException = 7 ,
  BreakReason_NotificationOnlyFlag = 0x80000000
}
 Break reasons.
 
enum  CodeMapOperation {
  CodeMapOperation_MapOwner =0 ,
  CodeMapOperation_MapSlave =1 ,
  CodeMapOperation_UnmapOwner =2 ,
  CodeMapOperation_UnmapSlave =3
}
 Code memory mapping operations. More...
 
enum  LimitableResource {
  LimitableResource_Memory =0 ,
  LimitableResource_Threads =1 ,
  LimitableResource_Events =2 ,
  LimitableResource_TransferMemories =3 ,
  LimitableResource_Sessions =4
}
 Limitable Resources. More...
 
enum  ThreadActivity {
  ThreadActivity_Runnable = 0 ,
  ThreadActivity_Paused = 1
}
 Thread Activity. More...
 
enum  ProcessInfoType { ProcessInfoType_ProcessState =0 }
 Process Information. More...
 
enum  ProcessState {
  ProcessState_Created =0 ,
  ProcessState_CreatedAttached =1 ,
  ProcessState_Running =2 ,
  ProcessState_Crashed =3 ,
  ProcessState_RunningAttached =4 ,
  ProcessState_Exiting =5 ,
  ProcessState_Exited =6 ,
  ProcessState_DebugSuspended =7
}
 Process States. More...
 
enum  ProcessActivity {
  ProcessActivity_Runnable = 0 ,
  ProcessActivity_Paused = 1
}
 Process Activity. More...
 
enum  DebugThreadParam {
  DebugThreadParam_ActualPriority =0 ,
  DebugThreadParam_State =1 ,
  DebugThreadParam_IdealCore =2 ,
  DebugThreadParam_CurrentCore =3 ,
  DebugThreadParam_CoreMask =4
}
 Debug Thread Parameters.
 
enum  InfoType {
  InfoType_CoreMask = 0 ,
  InfoType_PriorityMask = 1 ,
  InfoType_AliasRegionAddress = 2 ,
  InfoType_AliasRegionSize = 3 ,
  InfoType_HeapRegionAddress = 4 ,
  InfoType_HeapRegionSize = 5 ,
  InfoType_TotalMemorySize = 6 ,
  InfoType_UsedMemorySize = 7 ,
  InfoType_DebuggerAttached = 8 ,
  InfoType_ResourceLimit = 9 ,
  InfoType_IdleTickCount = 10 ,
  InfoType_RandomEntropy = 11 ,
  InfoType_AslrRegionAddress = 12 ,
  InfoType_AslrRegionSize = 13 ,
  InfoType_StackRegionAddress = 14 ,
  InfoType_StackRegionSize = 15 ,
  InfoType_SystemResourceSizeTotal = 16 ,
  InfoType_SystemResourceSizeUsed = 17 ,
  InfoType_ProgramId = 18 ,
  InfoType_InitialProcessIdRange = 19 ,
  InfoType_UserExceptionContextAddress = 20 ,
  InfoType_TotalNonSystemMemorySize = 21 ,
  InfoType_UsedNonSystemMemorySize = 22 ,
  InfoType_IsApplication = 23 ,
  InfoType_FreeThreadCount = 24 ,
  InfoType_ThreadTickCount = 25 ,
  InfoType_IsSvcPermitted = 26 ,
  InfoType_ThreadTickCountDeprecated = 0xF0000002
}
 GetInfo IDs. More...
 
enum  SystemInfoType {
  SystemInfoType_TotalPhysicalMemorySize = 0 ,
  SystemInfoType_UsedPhysicalMemorySize = 1 ,
  SystemInfoType_InitialProcessIdRange = 2
}
 GetSystemInfo IDs. More...
 
enum  TickCountInfo {
  TickCountInfo_Core0 = 0 ,
  TickCountInfo_Core1 = 1 ,
  TickCountInfo_Core2 = 2 ,
  TickCountInfo_Core3 = 3 ,
  TickCountInfo_Total = UINT64_MAX
}
 GetInfo Idle/Thread Tick Count Sub IDs. More...
 
enum  InitialProcessIdRangeInfo {
  InitialProcessIdRangeInfo_Minimum = 0 ,
  InitialProcessIdRangeInfo_Maximum = 1
}
 GetInfo InitialProcessIdRange Sub IDs. More...
 
enum  PhysicalMemorySystemInfo {
  PhysicalMemorySystemInfo_Application = 0 ,
  PhysicalMemorySystemInfo_Applet = 1 ,
  PhysicalMemorySystemInfo_System = 2 ,
  PhysicalMemorySystemInfo_SystemUnsafe = 3
}
 GetSystemInfo PhysicalMemory Sub IDs. More...
 
enum  YieldType {
  YieldType_WithoutCoreMigration = 0l ,
  YieldType_WithCoreMigration = -1l ,
  YieldType_ToAnyThread = -2l
}
 SleepThread yield types. More...
 
enum  SignalType {
  SignalType_Signal = 0 ,
  SignalType_SignalAndIncrementIfEqual = 1 ,
  SignalType_SignalAndModifyBasedOnWaitingThreadCountIfEqual = 2
}
 SignalToAddress behaviors. More...
 
enum  ArbitrationType {
  ArbitrationType_WaitIfLessThan = 0 ,
  ArbitrationType_DecrementAndWaitIfLessThan = 1 ,
  ArbitrationType_WaitIfEqual = 2
}
 WaitForAddress behaviors. More...
 
enum  MemoryMapping {
  MemoryMapping_IoRegister = 0 ,
  MemoryMapping_Uncached = 1 ,
  MemoryMapping_Memory = 2
}
 Memory mapping type. More...
 
enum  IoPoolType { IoPoolType_PcieA2 = 0 }
 Io Pools. More...
 

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, s32 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...
 

Detailed Description

Wrappers for kernel syscalls.

Enumeration Type Documentation

◆ ArbitrationType

WaitForAddress behaviors.

Enumerator
ArbitrationType_WaitIfLessThan 

Wait if the value is less than argument.

ArbitrationType_DecrementAndWaitIfLessThan 

Decrement the value and wait if it is less than argument.

ArbitrationType_WaitIfEqual 

Wait if the value is equal to argument.

◆ CodeMapOperation

Code memory mapping operations.

Enumerator
CodeMapOperation_MapOwner 

Map owner.

CodeMapOperation_MapSlave 

Map slave.

CodeMapOperation_UnmapOwner 

Unmap owner.

CodeMapOperation_UnmapSlave 

Unmap slave.

◆ InfoType

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_ThreadTickCountDeprecated 

[1.0.0-12.1.0] Number of ticks spent on thread.

◆ InitialProcessIdRangeInfo

GetInfo InitialProcessIdRange Sub IDs.

Enumerator
InitialProcessIdRangeInfo_Minimum 

Lowest initial process ID.

InitialProcessIdRangeInfo_Maximum 

Highest initial process ID.

◆ IoPoolType

enum IoPoolType

Io Pools.

Enumerator
IoPoolType_PcieA2 

Physical address range 0x12000000-0x1FFFFFFF.

◆ LimitableResource

Limitable Resources.

Enumerator
LimitableResource_Memory 

How much memory can a process map.

LimitableResource_Threads 

How many threads can a process spawn.

LimitableResource_Events 

How many events can a process have.

LimitableResource_TransferMemories 

How many transfer memories can a process make.

LimitableResource_Sessions 

How many sessions can a process own.

◆ MemoryAttribute

Memory attribute bitmasks.

Enumerator
MemAttr_IsBorrowed 

Is borrowed memory.

MemAttr_IsIpcMapped 

Is IPC mapped (when IpcRefCount > 0).

MemAttr_IsDeviceMapped 

Is device mapped (when DeviceRefCount > 0).

MemAttr_IsUncached 

Is uncached.

MemAttr_IsPermissionLocked 

Is permission locked.

◆ MemoryMapping

Memory mapping type.

Enumerator
MemoryMapping_IoRegister 

Mapping IO registers.

MemoryMapping_Uncached 

Mapping normal memory without cache.

MemoryMapping_Memory 

Mapping normal memory.

◆ 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.

◆ MemoryType

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.

◆ Permission

enum Permission

Memory permission bitmasks.

Enumerator
Perm_None 

No permissions.

Perm_R 

Read permission.

Perm_W 

Write permission.

Perm_X 

Execute permission.

Perm_Rw 

Read/write permissions.

Perm_Rx 

Read/execute permissions.

Perm_DontCare 

Don't care.

◆ PhysicalMemorySystemInfo

GetSystemInfo PhysicalMemory Sub IDs.

Enumerator
PhysicalMemorySystemInfo_Application 

Memory allocated for application usage.

PhysicalMemorySystemInfo_Applet 

Memory allocated for applet usage.

PhysicalMemorySystemInfo_System 

Memory allocated for system usage.

PhysicalMemorySystemInfo_SystemUnsafe 

Memory allocated for unsafe system usage (accessible to devices).

◆ ProcessActivity

Process Activity.

Enumerator
ProcessActivity_Runnable 

Process can run.

ProcessActivity_Paused 

Process is paused.

◆ ProcessInfoType

Process Information.

Enumerator
ProcessInfoType_ProcessState 

What state is a process in.

◆ ProcessState

Process States.

Enumerator
ProcessState_Created 

Newly-created process, not yet started.

ProcessState_CreatedAttached 

Newly-created process, not yet started but attached to debugger.

ProcessState_Running 

Process that is running normally (and detached from any debugger).

ProcessState_Crashed 

Process that has just crashed.

ProcessState_RunningAttached 

Process that is running normally, attached to a debugger.

ProcessState_Exiting 

Process has begun exiting.

ProcessState_Exited 

Process has finished exiting.

ProcessState_DebugSuspended 

Process execution suspended by debugger.

◆ SignalType

enum SignalType

SignalToAddress behaviors.

Enumerator
SignalType_Signal 

Signals the address.

SignalType_SignalAndIncrementIfEqual 

Signals the address and increments its value if equal to argument.

SignalType_SignalAndModifyBasedOnWaitingThreadCountIfEqual 

Signals the address and updates its value if equal to argument.

◆ SystemInfoType

GetSystemInfo IDs.

Enumerator
SystemInfoType_TotalPhysicalMemorySize 

Total amount of DRAM available to system.

SystemInfoType_UsedPhysicalMemorySize 

Current amount of DRAM used by system.

SystemInfoType_InitialProcessIdRange 

Min/max initial process IDs.

◆ ThreadActivity

Thread Activity.

Enumerator
ThreadActivity_Runnable 

Thread can run.

ThreadActivity_Paused 

Thread is paused.

◆ TickCountInfo

GetInfo Idle/Thread Tick Count Sub IDs.

Enumerator
TickCountInfo_Core0 

Tick count on core 0.

TickCountInfo_Core1 

Tick count on core 1.

TickCountInfo_Core2 

Tick count on core 2.

TickCountInfo_Core3 

Tick count on core 3.

TickCountInfo_Total 

Tick count on all cores.

◆ YieldType

enum YieldType

SleepThread yield types.

Enumerator
YieldType_WithoutCoreMigration 

Yields to another thread on the same core.

YieldType_WithCoreMigration 

Yields to another thread (possibly on a different core).

YieldType_ToAnyThread 

Yields and performs forced load-balancing.

Function Documentation

◆ svcAcceptSession()

Result svcAcceptSession ( Handle session_handle,
Handle  port_handle 
)

Accepts an IPC session.

Returns
Result code.
Note
Syscall number 0x41.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcArbitrateLock()

Result svcArbitrateLock ( u32  wait_tag,
u32 tag_location,
u32  self_tag 
)

Arbitrates a mutex lock operation in userspace.

Returns
Result code.
Note
Syscall number 0x1A.

◆ svcArbitrateUnlock()

Result svcArbitrateUnlock ( u32 tag_location)

Arbitrates a mutex unlock operation in userspace.

Returns
Result code.
Note
Syscall number 0x1B.

◆ svcAttachDeviceAddressSpace()

Result svcAttachDeviceAddressSpace ( u64  device,
Handle  handle 
)

Attaches a device address space to a device.

Returns
Result code.
Note
Syscall number 0x57.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcBreak()

Result svcBreak ( u32  breakReason,
uintptr_t  address,
uintptr_t  size 
)

Breaks execution.

Parameters
[in]breakReasonBreak reason (see BreakReason).
[in]addressAddress of the buffer to pass to the debugger.
[in]sizeSize of the buffer to pass to the debugger.
Returns
Result code.
Note
Syscall number 0x26.

◆ svcBreakDebugProcess()

Result svcBreakDebugProcess ( Handle  debug)

Breaks an active debugging session.

Returns
Result code.
Note
Syscall number 0x61.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcCallSecureMonitor()

void svcCallSecureMonitor ( SecmonArgs regs)

Calls a secure monitor function (TrustZone, EL3).

Parameters
regsArguments to pass to the secure monitor.
Note
Syscall number 0x7F.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcCancelSynchronization()

Result svcCancelSynchronization ( Handle  thread)

Waits a svcWaitSynchronization operation being done on a synchronization object in another thread.

Returns
Result code.
Note
Syscall number 0x19.

◆ svcChangeKernelTraceState()

void svcChangeKernelTraceState ( u32  kern_trace_state)

Performs a debugging operation on the kernel.

[4.0.0+]

Parameters
[in]kern_trace_stateType of tracing the kernel should perform.
Note
Syscall number 0x3D.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcClearEvent()

Result svcClearEvent ( Handle  handle)

Clears an event's signalled status.

Returns
Result code.
Note
Syscall number 0x12.

◆ svcCloseHandle()

Result svcCloseHandle ( Handle  handle)

Closes a handle, decrementing the reference count of the corresponding kernel object.

This might result in the kernel freeing the object.

Parameters
handleHandle to close.
Returns
Result code.
Note
Syscall number 0x16.

◆ svcConnectToNamedPort()

Result svcConnectToNamedPort ( Handle session,
const char *  name 
)

Connects to a registered named port.

Returns
Result code.
Note
Syscall number 0x1F.

◆ svcConnectToPort()

Result svcConnectToPort ( Handle session,
Handle  port 
)

Manages a named port.

Returns
Result code.
Note
Syscall number 0x72.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcContinueDebugEvent()

Result svcContinueDebugEvent ( Handle  debug,
u32  flags,
u64 tid_list,
u32  num_tids 
)

Continues a debugging session.

Returns
Result code.
Note
Syscall number 0x64.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.
Only exists on [3.0.0+]. For older versions use svcLegacyContinueDebugEvent.

◆ svcControlCodeMemory()

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+].

Returns
Result code.
Note
Syscall number 0x4C.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcCreateCodeMemory()

Result svcCreateCodeMemory ( Handle code_handle,
void *  src_addr,
u64  size 
)

Creates code memory in the caller's address space [4.0.0+].

Returns
Result code.
Note
Syscall number 0x4B.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcCreateDeviceAddressSpace()

Result svcCreateDeviceAddressSpace ( Handle handle,
u64  dev_addr,
u64  dev_size 
)

Creates a virtual address space for binding device address spaces.

Returns
Result code.
Note
Syscall number 0x56.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcCreateEvent()

Result svcCreateEvent ( Handle server_handle,
Handle client_handle 
)

Creates a system event.

Returns
Result code.
Note
Syscall number 0x45.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcCreateInterruptEvent()

Result svcCreateInterruptEvent ( Handle handle,
u64  irqNum,
u32  flag 
)

Creates an event and binds it to a specific hardware interrupt.

Returns
Result code.
Note
Syscall number 0x53.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcCreateIoPool()

Result svcCreateIoPool ( Handle out_handle,
u32  pool_type 
)

Creates an IO Pool.

[13.0.0+]

Returns
Result code.
Note
Syscall number 0x39.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcCreateIoRegion()

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+]

Returns
Result code.
Note
Syscall number 0x3A.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcCreatePort()

Result svcCreatePort ( Handle portServer,
Handle portClient,
s32  max_sessions,
bool  is_light,
const char *  name 
)

Creates a port.

Returns
Result code.
Note
Syscall number 0x70.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcCreateProcess()

Result svcCreateProcess ( Handle out,
const void *  proc_info,
const u32 caps,
u64  cap_num 
)

Creates a new process.

Returns
Result code.
Note
Syscall number 0x79.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcCreateResourceLimit()

Result svcCreateResourceLimit ( Handle out)

Creates a new Resource Limit handle.

Returns
Result code.
Note
Syscall number 0x7D.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcCreateSession()

Result svcCreateSession ( Handle server_handle,
Handle client_handle,
u32  unk0,
u64  unk1 
)

Creates an IPC session.

Returns
Result code.
Note
Syscall number 0x40.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcCreateSharedMemory()

Result svcCreateSharedMemory ( Handle out,
size_t  size,
u32  local_perm,
u32  other_perm 
)

Creates a block of shared memory.

Returns
Result code.
Note
Syscall number 0x50.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcCreateThread()

Result svcCreateThread ( Handle out,
void *  entry,
void *  arg,
void *  stack_top,
int  prio,
int  cpuid 
)

Creates a thread.

Returns
Result code.
Note
Syscall number 0x08.

◆ svcCreateTransferMemory()

Result svcCreateTransferMemory ( Handle out,
void *  addr,
size_t  size,
u32  perm 
)

Creates a block of transfer memory.

Returns
Result code.
Note
Syscall number 0x15.

◆ svcDebugActiveProcess()

Result svcDebugActiveProcess ( Handle debug,
u64  processID 
)

Debugs an active process.

Returns
Result code.
Note
Syscall number 0x60.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcDetachDeviceAddressSpace()

Result svcDetachDeviceAddressSpace ( u64  device,
Handle  handle 
)

Detaches a device address space from a device.

Returns
Result code.
Note
Syscall number 0x58.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcDumpInfo()

void svcDumpInfo ( u32  dump_info_type,
u64  arg0 
)

Causes the kernel to dump debug information.

[1.0.0-3.0.2]

Parameters
[in]dump_info_typeType of information to dump.
[in]arg0Argument to the debugging operation.
Note
Syscall number 0x3C.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcExitProcess()

void svcExitProcess ( void  )

Exits the current process.

Note
Syscall number 0x07.

◆ svcExitThread()

void svcExitThread ( void  )

Exits the current thread.

Note
Syscall number 0x0A.

◆ svcFlushDataCache()

Result svcFlushDataCache ( void *  address,
size_t  size 
)

Flushes data cache for a virtual address range.

Parameters
[in]addressAddress of region to flush.
[in]sizeSize of region to flush.
Remarks
armDCacheFlush should be used instead of this syscall whenever possible.
Note
Syscall number 0x2B.

◆ svcFlushEntireDataCache()

void svcFlushEntireDataCache ( void  )

Flushes the entire data cache (by set/way).

Note
Syscall number 0x2A.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.
This syscall is dangerous, and should not be used.

◆ svcFlushProcessDataCache()

Result svcFlushProcessDataCache ( Handle  process,
uintptr_t  address,
size_t  size 
)

Flushes data cache for a virtual address range within a process.

Parameters
[in]addressAddress of region to flush.
[in]sizeSize of region to flush.
Note
Syscall number 0x5F.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcGetCurrentProcessorNumber()

u32 svcGetCurrentProcessorNumber ( void  )

Gets the current processor's number.

Returns
The current processor's number.
Note
Syscall number 0x10.

◆ svcGetDebugEvent()

Result svcGetDebugEvent ( void *  event_out,
Handle  debug 
)

Gets an incoming debug event from a debugging session.

Returns
Result code.
Note
Syscall number 0x63.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcGetDebugFutureThreadInfo()

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+]

Parameters
[out]out_contextOutput LastThreadContext for the thread that will be scheduled.
[out]out_thread_idOutput thread id for the thread that will be scheduled.
[in]debugDebug handle.
[in]nsNanoseconds in the future to get scheduled thread at.
Returns
Result code.
Note
Syscall number 0x2E.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcGetDebugThreadContext()

Result svcGetDebugThreadContext ( ThreadContext ctx,
Handle  debug,
u64  threadID,
u32  flags 
)

Gets the context (dump the registers) of a thread in a debugging session.

Returns
Result code.
Parameters
[out]ctxOutput thread context (register dump).
[in]debugDebug handle.
[in]threadIDID of the thread to dump the context of.
[in]flagsRegister groups to select, combination of RegisterGroup flags.
Note
Syscall number 0x67.
Warning
Official kernel will not dump any CPU GPR if the thread is currently executing a system call (except svcBreak and svcReturnFromException).
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcGetDebugThreadParam()

Result svcGetDebugThreadParam ( u64 out_64,
u32 out_32,
Handle  debug,
u64  threadID,
DebugThreadParam  param 
)

Gets parameters from a thread in a debugging session.

Returns
Result code.
Note
Syscall number 0x6D.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcGetInfo()

Result svcGetInfo ( u64 out,
u32  id0,
Handle  handle,
u64  id1 
)

Retrieves information about the system, or a certain kernel object.

Parameters
[out]outVariable to which store the information.
[in]id0First ID of the property to retrieve.
[in]handleHandle of the object to retrieve information from, or INVALID_HANDLE to retrieve information about the system.
[in]id1Second ID of the property to retrieve.
Returns
Result code.
Remarks
The full list of property IDs can be found on the switchbrew.org wiki.
Note
Syscall number 0x29.

◆ svcGetLastThreadInfo()

Result svcGetLastThreadInfo ( LastThreadContext out_context,
u64 out_tls_address,
u32 out_flags 
)

Gets information about the previously-scheduled thread.

Parameters
[out]out_contextOutput LastThreadContext for the previously scheduled thread.
[out]out_tls_addressOutput tls address for the previously scheduled thread.
[out]out_flagsOutput flags for the previously scheduled thread.
Returns
Result code.
Note
Syscall number 0x2F.

◆ svcGetProcessId()

Result svcGetProcessId ( u64 processID,
Handle  handle 
)

Gets the PID associated with a process.

Returns
Result code.
Note
Syscall number 0x24.

◆ svcGetProcessInfo()

Result svcGetProcessInfo ( s64 out,
Handle  proc,
ProcessInfoType  which 
)

Gets a ProcessInfoType for a process.

Returns
Result code.
Note
Syscall number 0x7C.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcGetProcessList()

Result svcGetProcessList ( s32 num_out,
u64 pids_out,
u32  max_pids 
)

Retrieves a list of all running processes.

Returns
Result code.
Note
Syscall number 0x65.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcGetResourceLimitCurrentValue()

Result svcGetResourceLimitCurrentValue ( s64 out,
Handle  reslimit_h,
LimitableResource  which 
)

Gets the maximum value a LimitableResource can have, for a Resource Limit handle.

Returns
Result code.
Note
Syscall number 0x31.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcGetResourceLimitLimitValue()

Result svcGetResourceLimitLimitValue ( s64 out,
Handle  reslimit_h,
LimitableResource  which 
)

Gets the maximum value a LimitableResource can have, for a Resource Limit handle.

Returns
Result code.
Note
Syscall number 0x30.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcGetResourceLimitPeakValue()

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+]

Returns
Result code.
Note
Syscall number 0x37.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcGetSystemInfo()

Result svcGetSystemInfo ( u64 out,
u64  id0,
Handle  handle,
u64  id1 
)

Retrieves privileged information about the system, or a certain kernel object.

Parameters
[out]outVariable to which store the information.
[in]id0First ID of the property to retrieve.
[in]handleHandle of the object to retrieve information from, or INVALID_HANDLE to retrieve information about the system.
[in]id1Second ID of the property to retrieve.
Returns
Result code.
Remarks
The full list of property IDs can be found on the switchbrew.org wiki.
Note
Syscall number 0x6F.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcGetSystemTick()

u64 svcGetSystemTick ( void  )

Gets the current system tick.

Returns
The current system tick.
Note
Syscall number 0x1E.

◆ svcGetThreadContext3()

Result svcGetThreadContext3 ( ThreadContext ctx,
Handle  thread 
)

Dumps the registers of a thread paused by svcSetThreadActivity (register groups: all).

Parameters
[out]ctxOutput thread context (register dump).
[in]threadThread handle.
Returns
Result code.
Note
Syscall number 0x33.
Warning
Official kernel will not dump x0..x18 if the thread is currently executing a system call, and prior to 6.0.0 doesn't dump TPIDR_EL0.

◆ svcGetThreadCoreMask()

Result svcGetThreadCoreMask ( s32 preferred_core,
u64 affinity_mask,
Handle  handle 
)

Gets a thread's core mask.

Returns
Result code.
Note
Syscall number 0x0E.

◆ svcGetThreadId()

Result svcGetThreadId ( u64 threadID,
Handle  handle 
)

Gets the TID associated with a process.

Returns
Result code.
Note
Syscall number 0x25.

◆ svcGetThreadList()

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).

Returns
Result code.
Note
Syscall number 0x66.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcGetThreadPriority()

Result svcGetThreadPriority ( s32 priority,
Handle  handle 
)

Gets a thread's priority.

Returns
Result code.
Note
Syscall number 0x0C.

◆ svcInvalidateProcessDataCache()

Result svcInvalidateProcessDataCache ( Handle  process,
uintptr_t  address,
size_t  size 
)

Invalidates data cache for a virtual address range within a process.

Parameters
[in]addressAddress of region to invalidate.
[in]sizeSize of region to invalidate.
Note
Syscall number 0x5D.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcKernelDebug()

void svcKernelDebug ( u32  kern_debug_type,
u64  arg0,
u64  arg1,
u64  arg2 
)

Performs a debugging operation on the kernel.

[4.0.0+]

Parameters
[in]kern_debug_typeType of debugging operation to perform.
[in]arg0First argument to the debugging operation.
[in]arg1Second argument to the debugging operation.
[in]arg2Third argument to the debugging operation.
Note
Syscall number 0x3C.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcLegacyContinueDebugEvent()

Result svcLegacyContinueDebugEvent ( Handle  debug,
u32  flags,
u64  threadID 
)

Continues a debugging session.

Returns
Result code.
Note
Syscall number 0x64.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.
Only exists on [1.0.0-2.3.0]. For newer versions use svcContinueDebugEvent.

◆ svcLegacyQueryIoMapping()

Result svcLegacyQueryIoMapping ( u64 virtaddr,
u64  physaddr,
u64  size 
)

Returns a virtual address mapped to a given IO range.

Returns
Result code.
Note
Syscall number 0x55.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.
Only exists on [1.0.0-9.2.0]. For newer versions use svcQueryMemoryMapping.

◆ svcManageNamedPort()

Result svcManageNamedPort ( Handle portServer,
const char *  name,
s32  maxSessions 
)

Manages a named port.

Returns
Result code.
Note
Syscall number 0x71.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcMapDeviceAddressSpace()

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]

Returns
Result code.
Remarks
The userspace destination address must have the MemState_MapDeviceAlignedAllowed bit set.
Note
Syscall number 0x5B.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcMapDeviceAddressSpaceAligned()

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.

Returns
Result code.
Remarks
The userspace destination address must have the MemState_MapDeviceAlignedAllowed bit set.
Note
Syscall number 0x5A.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcMapDeviceAddressSpaceByForce()

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.

Returns
Result code.
Remarks
The userspace destination address must have the MemState_MapDeviceAllowed bit set.
Note
Syscall number 0x59.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcMapInsecurePhysicalMemory()

Result svcMapInsecurePhysicalMemory ( void *  address,
u64  size 
)

Maps new insecure memory at the desired address.

[15.0.0+]

Returns
Result code.
Note
Syscall number 0x90.

◆ svcMapIoRegion()

Result svcMapIoRegion ( Handle  io_region_h,
void *  address,
u64  size,
u32  perm 
)

Maps an IO Region.

[13.0.0+]

Returns
Result code.
Note
Syscall number 0x46.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcMapMemory()

Result svcMapMemory ( void *  dst_addr,
void *  src_addr,
u64  size 
)

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.

Parameters
[in]dst_addrDestination address.
[in]src_addrSource address.
[in]sizeSize of the range.
Returns
Result code.
Note
Syscall number 0x04.

◆ svcMapPhysicalMemory()

Result svcMapPhysicalMemory ( void *  address,
u64  size 
)

Maps new heap memory at the desired address.

[3.0.0+]

Returns
Result code.
Note
Syscall number 0x2C.

◆ svcMapPhysicalMemoryUnsafe()

Result svcMapPhysicalMemoryUnsafe ( void *  address,
u64  size 
)

Maps unsafe memory (usable for GPU DMA) for a system module at the desired address.

[5.0.0+]

Returns
Result code.
Note
Syscall number 0x48.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcMapProcessCodeMemory()

Result svcMapProcessCodeMemory ( Handle  proc,
u64  dst,
u64  src,
u64  size 
)

Maps normal heap in a certain process as executable code (used when loading NROs).

Parameters
[in]procProcess handle (cannot be CUR_PROCESS_HANDLE).
[in]dstDestination mapping address.
[in]srcSource mapping address.
[in]sizeSize of the mapping.
Returns
Result code.
Note
Syscall number 0x77.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcMapProcessMemory()

Result svcMapProcessMemory ( void *  dst,
Handle  proc,
u64  src,
u64  size 
)

Maps the src address from the supplied process handle into the current process.

Parameters
[in]dstAddress to which map the memory in the current process.
[in]procProcess handle.
[in]srcSource mapping address.
[in]sizeSize of the memory.
Returns
Result code.
Remarks
This allows mapping code and rodata with RW- permission.
Note
Syscall number 0x74.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcMapSharedMemory()

Result svcMapSharedMemory ( Handle  handle,
void *  addr,
size_t  size,
u32  perm 
)

Maps a block of shared memory.

Returns
Result code.
Note
Syscall number 0x13.

◆ svcMapTransferMemory()

Result svcMapTransferMemory ( Handle  tmem_handle,
void *  addr,
size_t  size,
u32  perm 
)

Maps a block of transfer memory.

Returns
Result code.
Note
Syscall number 0x51.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcOutputDebugString()

Result svcOutputDebugString ( const char *  str,
u64  size 
)

Outputs debug text, if used during debugging.

Parameters
[in]strText to output.
[in]sizeSize of the text in bytes.
Returns
Result code.
Note
Syscall number 0x27.

◆ svcQueryDebugProcessMemory()

Result svcQueryDebugProcessMemory ( MemoryInfo meminfo_ptr,
u32 pageinfo,
Handle  debug,
u64  addr 
)

Queries memory information from a process that is being debugged.

Returns
Result code.
Note
Syscall number 0x69.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcQueryMemory()

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.

Parameters
[out]meminfo_ptrMemoryInfo structure which will be filled in.
[out]pageinfoPage information which will be filled in.
[in]addrAddress to query.
Returns
Result code.
Note
Syscall number 0x06.

◆ svcQueryMemoryMapping()

Result svcQueryMemoryMapping ( u64 virtaddr,
u64 out_size,
u64  physaddr,
u64  size 
)

Returns a virtual address mapped to a given IO range.

Returns
Result code.
Note
Syscall number 0x55.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.
Only exists on [10.0.0+]. For older versions use svcLegacyQueryIoMapping.

◆ svcQueryPhysicalAddress()

Result svcQueryPhysicalAddress ( PhysicalMemoryInfo out,
u64  virtaddr 
)

Queries information about a certain virtual address, including its physical address.

Returns
Result code.
Note
Syscall number 0x54.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcQueryProcessMemory()

Result svcQueryProcessMemory ( MemoryInfo meminfo_ptr,
u32 pageinfo,
Handle  proc,
u64  addr 
)

Equivalent to svcQueryMemory, for another process.

Parameters
[out]meminfo_ptrMemoryInfo structure which will be filled in.
[out]pageinfoPage information which will be filled in.
[in]procProcess handle.
[in]addrAddress to query.
Returns
Result code.
Note
Syscall number 0x76.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcReadDebugProcessMemory()

Result svcReadDebugProcessMemory ( void *  buffer,
Handle  debug,
u64  addr,
u64  size 
)

Reads memory from a process that is being debugged.

Returns
Result code.
Note
Syscall number 0x6A.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcReadWriteRegister()

Result svcReadWriteRegister ( u32 outVal,
u64  regAddr,
u32  rwMask,
u32  inVal 
)

Reads/writes a protected MMIO register.

Returns
Result code.
Note
Syscall number 0x4E.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcReplyAndReceive()

Result svcReplyAndReceive ( s32 index,
const Handle handles,
s32  handleCount,
Handle  replyTarget,
u64  timeout 
)

Performs IPC input/output.

Returns
Result code.
Note
Syscall number 0x43.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcReplyAndReceiveLight()

Result svcReplyAndReceiveLight ( Handle  handle)

Performs light IPC input/output.

Returns
Result code.
Parameters
[in]handleServer or port handle to act on.
Note
Syscall number 0x42.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcReplyAndReceiveWithUserBuffer()

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.

Returns
Result code.
Note
Syscall number 0x44.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcResetSignal()

Result svcResetSignal ( Handle  handle)

Resets a signal.

Returns
Result code.
Note
Syscall number 0x17.

◆ svcReturnFromException()

void svcReturnFromException ( Result  res)

Returns from an exception.

Parameters
[in]resResult code.
Note
Syscall number 0x28.

◆ svcSendAsyncRequestWithUserBuffer()

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).

Returns
Result code.
Remarks
size must be allocated to 0x1000 bytes.
Note
Syscall number 0x23.

◆ svcSendSyncRequest()

Result svcSendSyncRequest ( Handle  session)

Sends an IPC synchronization request to a session.

Returns
Result code.
Note
Syscall number 0x21.

◆ svcSendSyncRequestLight()

Result svcSendSyncRequestLight ( Handle  session)

Sends a light IPC synchronization request to a session.

Returns
Result code.
Note
Syscall number 0x20.

◆ svcSendSyncRequestWithUserBuffer()

Result svcSendSyncRequestWithUserBuffer ( void *  usrBuffer,
u64  size,
Handle  session 
)

Sends an IPC synchronization request to a session from an user allocated buffer.

Returns
Result code.
Remarks
size must be allocated to 0x1000 bytes.
Note
Syscall number 0x22.

◆ svcSetDebugThreadContext()

Result svcSetDebugThreadContext ( Handle  debug,
u64  threadID,
const ThreadContext ctx,
u32  flags 
)

Gets the context (dump the registers) of a thread in a debugging session.

Returns
Result code.
Parameters
[in]debugDebug handle.
[in]threadIDID of the thread to set the context of.
[in]ctxInput thread context (register dump).
[in]flagsRegister groups to select, combination of RegisterGroup flags.
Note
Syscall number 0x68.
Warning
Official kernel will return an error if the thread is currently executing a system call (except svcBreak and svcReturnFromException).
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcSetHardwareBreakPoint()

Result svcSetHardwareBreakPoint ( u32  which,
u64  flags,
u64  value 
)

Sets one of the hardware breakpoints.

Returns
Result code.
Note
Syscall number 0x6C.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcSetHeapSize()

Result svcSetHeapSize ( void **  out_addr,
u64  size 
)

Set the process heap to a given size.

It can both extend and shrink the heap.

Parameters
[out]out_addrVariable to which write the address of the heap (which is randomized and fixed by the kernel)
[in]sizeSize of the heap, must be a multiple of 0x200000 and [2.0.0+] less than 0x18000000.
Returns
Result code.
Note
Syscall number 0x01.

◆ svcSetMemoryAttribute()

Result svcSetMemoryAttribute ( void *  addr,
u64  size,
u32  val0,
u32  val1 
)

Set the memory attributes of a (page-aligned) range of memory.

Parameters
[in]addrStart address of the range.
[in]sizeSize of the range, in bytes.
[in]val0State0
[in]val1State1
Returns
Result code.
Remarks
See switchbrew.org Wiki for more details.
Note
Syscall number 0x03.

◆ svcSetMemoryPermission()

Result svcSetMemoryPermission ( void *  addr,
u64  size,
u32  perm 
)

Set the memory permissions of a (page-aligned) range of memory.

Parameters
[in]addrStart address of the range.
[in]sizeSize of the range, in bytes.
[in]permPermissions (see Permission).
Returns
Result code.
Remarks
Perm_X is not allowed. Setting write-only is not allowed either (Perm_W). This can be used to move back and forth between Perm_None, Perm_R and Perm_Rw.
Note
Syscall number 0x02.

◆ svcSetProcessActivity()

Result svcSetProcessActivity ( Handle  process,
ProcessActivity  paused 
)

Configures the pause/unpause status of a process.

Returns
Result code.
Note
Syscall number 0x4F.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcSetProcessMemoryPermission()

Result svcSetProcessMemoryPermission ( Handle  proc,
u64  addr,
u64  size,
u32  perm 
)

Sets the memory permissions for the specified memory with the supplied process handle.

Parameters
[in]procProcess handle.
[in]addrAddress of the memory.
[in]sizeSize of the memory.
[in]permPermissions (see Permission).
Returns
Result code.
Remarks
This returns an error (0xD801) when perm is >0x5, hence -WX and RWX are not allowed.
Note
Syscall number 0x73.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcSetResourceLimitLimitValue()

Result svcSetResourceLimitLimitValue ( Handle  reslimit,
LimitableResource  which,
u64  value 
)

Sets the value for a LimitableResource for a Resource Limit handle.

Returns
Result code.
Note
Syscall number 0x7E.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcSetThreadActivity()

Result svcSetThreadActivity ( Handle  thread,
ThreadActivity  paused 
)

Configures the pause/unpause status of a thread.

Returns
Result code.
Note
Syscall number 0x32.

◆ svcSetThreadCoreMask()

Result svcSetThreadCoreMask ( Handle  handle,
s32  preferred_core,
u32  affinity_mask 
)

Sets a thread's core mask.

Returns
Result code.
Note
Syscall number 0x0F.

◆ svcSetThreadPriority()

Result svcSetThreadPriority ( Handle  handle,
u32  priority 
)

Sets a thread's priority.

Returns
Result code.
Note
Syscall number 0x0D.

◆ svcSetUnsafeLimit()

Result svcSetUnsafeLimit ( u64  size)

Sets the system-wide limit for unsafe memory mappable using svcMapPhysicalMemoryUnsafe.

[5.0.0+]

Returns
Result code.
Note
Syscall number 0x4A.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcSignalEvent()

Result svcSignalEvent ( Handle  handle)

Sets an event's signalled status.

Returns
Result code.
Note
Syscall number 0x11.

◆ svcSignalProcessWideKey()

void svcSignalProcessWideKey ( u32 key,
s32  num 
)

Performs a condition variable wake-up operation in userspace.

Note
Syscall number 0x1D.

◆ svcSignalToAddress()

Result svcSignalToAddress ( void *  address,
u32  signal_type,
s32  value,
s32  count 
)

Signals (and updates) an address depending on type and value.

[4.0.0+]

Parameters
[in]addressAddress to arbitrate.
[in]signal_typeSignalType to use.
[in]valueValue to arbitrate on.
[in]countNumber of waiting threads to signal.
Returns
Result code.
Note
Syscall number 0x35.

◆ svcSleepSystem()

void svcSleepSystem ( void  )

Causes the system to enter deep sleep.

Note
Syscall number 0x4D.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcSleepThread()

void svcSleepThread ( s64  nano)

Sleeps the current thread for the specified amount of time.

Parameters
[in]nanoNumber of nanoseconds to sleep, or YieldType for yield.
Note
Syscall number 0x0B.

◆ svcStartProcess()

Result svcStartProcess ( Handle  proc,
s32  main_prio,
s32  default_cpu,
u32  stack_size 
)

Starts executing a freshly created process.

Returns
Result code.
Note
Syscall number 0x7A.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcStartThread()

Result svcStartThread ( Handle  handle)

Starts a freshly created thread.

Returns
Result code.
Note
Syscall number 0x09.

◆ svcStoreProcessDataCache()

Result svcStoreProcessDataCache ( Handle  process,
uintptr_t  address,
size_t  size 
)

Stores data cache for a virtual address range within a process.

Parameters
[in]addressAddress of region to store.
[in]sizeSize of region to store.
Note
Syscall number 0x5E.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcSynchronizePreemptionState()

void svcSynchronizePreemptionState ( void  )

Sets thread preemption state (used during abort/panic).

[8.0.0+]

Note
Syscall number 0x36.

◆ svcTerminateDebugProcess()

Result svcTerminateDebugProcess ( Handle  debug)

Terminates the process of an active debugging session.

Returns
Result code.
Note
Syscall number 0x62.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcTerminateProcess()

Result svcTerminateProcess ( Handle  proc)

Terminates a running process.

Returns
Result code.
Note
Syscall number 0x7B.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcUnmapDeviceAddressSpace()

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.

Returns
Result code.
Note
Syscall number 0x5C.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcUnmapInsecurePhysicalMemory()

Result svcUnmapInsecurePhysicalMemory ( void *  address,
u64  size 
)

Undoes the effects of svcMapInsecureMemory.

[15.0.0+]

Returns
Result code.
Note
Syscall number 0x91.

◆ svcUnmapIoRegion()

Result svcUnmapIoRegion ( Handle  io_region_h,
void *  address,
u64  size 
)

Undoes the effects of svcMapIoRegion.

[13.0.0+]

Returns
Result code.
Note
Syscall number 0x47.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcUnmapMemory()

Result svcUnmapMemory ( void *  dst_addr,
void *  src_addr,
u64  size 
)

Unmaps a region that was previously mapped with svcMapMemory.

Parameters
[in]dst_addrDestination address.
[in]src_addrSource address.
[in]sizeSize of the range.
Returns
Result code.
Note
Syscall number 0x05.

◆ svcUnmapPhysicalMemory()

Result svcUnmapPhysicalMemory ( void *  address,
u64  size 
)

Undoes the effects of svcMapPhysicalMemory.

[3.0.0+]

Returns
Result code.
Note
Syscall number 0x2D.

◆ svcUnmapPhysicalMemoryUnsafe()

Result svcUnmapPhysicalMemoryUnsafe ( void *  address,
u64  size 
)

Undoes the effects of svcMapPhysicalMemoryUnsafe.

[5.0.0+]

Returns
Result code.
Note
Syscall number 0x49.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcUnmapProcessCodeMemory()

Result svcUnmapProcessCodeMemory ( Handle  proc,
u64  dst,
u64  src,
u64  size 
)

Undoes the effects of svcMapProcessCodeMemory.

Parameters
[in]procProcess handle (cannot be CUR_PROCESS_HANDLE).
[in]dstDestination mapping address.
[in]srcSource mapping address.
[in]sizeSize of the mapping.
Returns
Result code.
Note
Syscall number 0x78.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcUnmapProcessMemory()

Result svcUnmapProcessMemory ( void *  dst,
Handle  proc,
u64  src,
u64  size 
)

Undoes the effects of svcMapProcessMemory.

Parameters
[in]dstDestination mapping address
[in]procProcess handle.
[in]srcAddress of the memory in the process.
[in]sizeSize of the memory.
Returns
Result code.
Remarks
This allows mapping code and rodata with RW- permission.
Note
Syscall number 0x75.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcUnmapSharedMemory()

Result svcUnmapSharedMemory ( Handle  handle,
void *  addr,
size_t  size 
)

Unmaps a block of shared memory.

Returns
Result code.
Note
Syscall number 0x14.

◆ svcUnmapTransferMemory()

Result svcUnmapTransferMemory ( Handle  tmem_handle,
void *  addr,
size_t  size 
)

Unmaps a block of transfer memory.

Returns
Result code.
Note
Syscall number 0x52.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.

◆ svcWaitForAddress()

Result svcWaitForAddress ( void *  address,
u32  arb_type,
s32  value,
s64  timeout 
)

Arbitrates an address depending on type and value.

[4.0.0+]

Parameters
[in]addressAddress to arbitrate.
[in]arb_typeArbitrationType to use.
[in]valueValue to arbitrate on.
[in]timeoutMaximum time in nanoseconds to wait.
Returns
Result code.
Note
Syscall number 0x34.

◆ svcWaitProcessWideKeyAtomic()

Result svcWaitProcessWideKeyAtomic ( u32 key,
u32 tag_location,
u32  self_tag,
u64  timeout 
)

Performs a condition variable wait operation in userspace.

Returns
Result code.
Note
Syscall number 0x1C.

◆ svcWaitSynchronization()

Result svcWaitSynchronization ( s32 index,
const Handle handles,
s32  handleCount,
u64  timeout 
)

Waits on one or more synchronization objects, optionally with a timeout.

Returns
Result code.
Note
Syscall number 0x18.
handleCount must not be greater than MAX_WAIT_OBJECTS. This is a Horizon kernel limitation.
This is the raw syscall, which can be cancelled by svcCancelSynchronization or other means. waitHandles or waitMultiHandle should normally be used instead.

◆ svcWaitSynchronizationSingle()

static Result svcWaitSynchronizationSingle ( Handle  handle,
u64  timeout 
)
inlinestatic

Waits on a single synchronization object, optionally with a timeout.

Returns
Result code.
Note
Wrapper for svcWaitSynchronization.
This is the raw syscall, which can be cancelled by svcCancelSynchronization or other means. waitSingleHandle should normally be used instead.

◆ svcWriteDebugProcessMemory()

Result svcWriteDebugProcessMemory ( Handle  debug,
const void *  buffer,
u64  addr,
u64  size 
)

Writes to memory in a process that is being debugged.

Returns
Result code.
Note
Syscall number 0x6B.
Warning
This is a privileged syscall. Use envIsSyscallHinted to check if it is available.