8#include "../arm/thread_context.h"
11#define CUR_PROCESS_HANDLE 0xFFFF8001
14#define CUR_THREAD_HANDLE 0xFFFF8000
17#define MAX_WAIT_OBJECTS 0x40
116 BreakReason_Panic = 0,
117 BreakReason_Assert = 1,
118 BreakReason_User = 2,
119 BreakReason_PreLoadDll = 3,
120 BreakReason_PostLoadDll = 4,
121 BreakReason_PreUnloadDll = 5,
122 BreakReason_PostUnloadDll = 6,
123 BreakReason_CppException = 7,
125 BreakReason_NotificationOnlyFlag = 0x80000000,
176 DebugThreadParam_ActualPriority=0,
177 DebugThreadParam_State=1,
178 DebugThreadParam_IdealCore=2,
179 DebugThreadParam_CurrentCore=3,
180 DebugThreadParam_CoreMask=4,
Context of a scheduled thread.
Definition svc.h:274
u64 fp
Frame Pointer for the thread.
Definition svc.h:275
u64 lr
Link Register for the thread.
Definition svc.h:277
u64 sp
Stack Pointer for the thread.
Definition svc.h:276
u64 pc
Program Counter for the thread.
Definition svc.h:278
Memory information structure.
Definition svc.h:91
u32 attr
Memory attributes (see MemoryAttribute).
Definition svc.h:95
u32 type
Memory type (see lower 8 bits of MemoryState).
Definition svc.h:94
u32 ipc_refcount
IPC reference count.
Definition svc.h:97
u32 perm
Memory permissions (see Permission).
Definition svc.h:96
u64 addr
Base address.
Definition svc.h:92
u64 size
Size.
Definition svc.h:93
u32 padding
Padding.
Definition svc.h:99
u32 device_refcount
Device reference count.
Definition svc.h:98
Physical memory information structure.
Definition svc.h:103
u64 virtual_address
Virtual address.
Definition svc.h:105
u64 physical_address
Physical address.
Definition svc.h:104
u64 size
Size.
Definition svc.h:106
Secure monitor arguments.
Definition svc.h:110
Thread context structure (register dump)
Definition thread_context.h:49
void svcChangeKernelTraceState(u32 kern_trace_state)
Performs a debugging operation on the kernel.
ArbitrationType
WaitForAddress behaviors.
Definition svc.h:266
@ ArbitrationType_WaitIfEqual64
[19.0.0+] Wait if the 64-bit value is equal to argument.
Definition svc.h:270
@ ArbitrationType_WaitIfEqual
Wait if the 32-bit value is equal to argument.
Definition svc.h:269
@ ArbitrationType_DecrementAndWaitIfLessThan
Decrement the 32-bit value and wait if it is less than argument.
Definition svc.h:268
@ ArbitrationType_WaitIfLessThan
Wait if the 32-bit value is less than argument.
Definition svc.h:267
Result svcSetMemoryPermission(void *addr, u64 size, u32 perm)
Set the memory permissions of a (page-aligned) range of memory.
void svcSleepThread(s64 nano)
Sleeps the current thread for the specified amount of time.
Result svcSetProcessActivity(Handle process, ProcessActivity paused)
Configures the pause/unpause status of a process.
Result svcCloseHandle(Handle handle)
Closes a handle, decrementing the reference count of the corresponding kernel object.
Result svcSetHeapSize(void **out_addr, u64 size)
Set the process heap to a given size.
Result svcGetThreadCoreMask(s32 *preferred_core, u64 *affinity_mask, Handle handle)
Gets a thread's core mask.
Result svcMapInsecurePhysicalMemory(void *address, u64 size)
Maps new insecure memory at the desired address.
Result svcSetUnsafeLimit(u64 size)
Sets the system-wide limit for unsafe memory mappable using svcMapPhysicalMemoryUnsafe.
void svcExitProcess(void)
Exits the current process.
Permission
Memory permission bitmasks.
Definition svc.h:80
@ Perm_W
Write permission.
Definition svc.h:83
@ Perm_Rx
Read/execute permissions.
Definition svc.h:86
@ Perm_None
No permissions.
Definition svc.h:81
@ Perm_X
Execute permission.
Definition svc.h:84
@ Perm_Rw
Read/write permissions.
Definition svc.h:85
@ Perm_R
Read permission.
Definition svc.h:82
@ Perm_DontCare
Don't care.
Definition svc.h:87
Result svcUnmapInsecurePhysicalMemory(void *address, u64 size)
Undoes the effects of svcMapInsecureMemory.
Result svcSetThreadPriority(Handle handle, u32 priority)
Sets a thread's priority.
Result svcStoreProcessDataCache(Handle process, uintptr_t address, size_t size)
Stores data cache for a virtual address range within a process.
Result svcWaitSynchronization(s32 *index, const Handle *handles, s32 handleCount, u64 timeout)
Waits on one or more synchronization objects, optionally with a timeout.
LimitableResource
Limitable Resources.
Definition svc.h:137
@ LimitableResource_Memory
How much memory can a process map.
Definition svc.h:138
@ LimitableResource_Sessions
How many sessions can a process own.
Definition svc.h:142
@ LimitableResource_Events
How many events can a process have.
Definition svc.h:140
@ LimitableResource_Threads
How many threads can a process spawn.
Definition svc.h:139
@ LimitableResource_TransferMemories
How many transfer memories can a process make.
Definition svc.h:141
Result svcSetDebugThreadContext(Handle debug, u64 threadID, const ThreadContext *ctx, u32 flags)
Gets the context (dump the registers) of a thread in a debugging session.
void svcReturnFromException(Result res)
Returns from an exception.
void svcDumpInfo(u32 dump_info_type, u64 arg0)
Causes the kernel to dump debug information.
Result svcReadWriteRegister(u32 *outVal, u64 regAddr, u32 rwMask, u32 inVal)
Reads/writes a protected MMIO register.
void svcSignalProcessWideKey(u32 *key, s32 num)
Performs a condition variable wake-up operation in userspace.
Result svcUnmapSharedMemory(Handle handle, void *addr, size_t size)
Unmaps a block of shared memory.
Result svcSetThreadCoreMask(Handle handle, s32 preferred_core, u32 affinity_mask)
Sets a thread's core mask.
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.
Result svcCancelSynchronization(Handle thread)
Waits a svcWaitSynchronization operation being done on a synchronization object in another thread.
Result svcCreateCodeMemory(Handle *code_handle, void *src_addr, u64 size)
Creates code memory in the caller's address space [4.0.0+].
PhysicalMemorySystemInfo
GetSystemInfo PhysicalMemory Sub IDs.
Definition svc.h:244
@ PhysicalMemorySystemInfo_SystemUnsafe
Memory allocated for unsafe system usage (accessible to devices).
Definition svc.h:248
@ PhysicalMemorySystemInfo_Applet
Memory allocated for applet usage.
Definition svc.h:246
@ PhysicalMemorySystemInfo_System
Memory allocated for system usage.
Definition svc.h:247
@ PhysicalMemorySystemInfo_Application
Memory allocated for application usage.
Definition svc.h:245
ProcessState
Process States.
Definition svc.h:157
@ ProcessState_RunningAttached
Process that is running normally, attached to a debugger.
Definition svc.h:162
@ ProcessState_DebugSuspended
Process execution suspended by debugger.
Definition svc.h:165
@ ProcessState_Crashed
Process that has just crashed.
Definition svc.h:161
@ ProcessState_Created
Newly-created process, not yet started.
Definition svc.h:158
@ ProcessState_Exited
Process has finished exiting.
Definition svc.h:164
@ ProcessState_Running
Process that is running normally (and detached from any debugger).
Definition svc.h:160
@ ProcessState_CreatedAttached
Newly-created process, not yet started but attached to debugger.
Definition svc.h:159
@ ProcessState_Exiting
Process has begun exiting.
Definition svc.h:163
YieldType
SleepThread yield types.
Definition svc.h:252
@ YieldType_WithCoreMigration
Yields to another thread (possibly on a different core).
Definition svc.h:254
@ YieldType_ToAnyThread
Yields and performs forced load-balancing.
Definition svc.h:255
@ YieldType_WithoutCoreMigration
Yields to another thread on the same core.
Definition svc.h:253
MemoryMapping
Memory mapping type.
Definition svc.h:282
@ MemoryMapping_Memory
Mapping normal memory.
Definition svc.h:285
@ MemoryMapping_Uncached
Mapping normal memory without cache.
Definition svc.h:284
@ MemoryMapping_IoRegister
Mapping IO registers.
Definition svc.h:283
u64 svcGetSystemTick(void)
Gets the current system tick.
Result svcArbitrateUnlock(u32 *tag_location)
Arbitrates a mutex unlock operation in userspace.
Result svcWriteDebugProcessMemory(Handle debug, const void *buffer, u64 addr, u64 size)
Writes to memory in a process that is being debugged.
Result svcGetProcessId(u64 *processID, Handle handle)
Gets the PID associated with a process.
Result svcSendSyncRequest(Handle session)
Sends an IPC synchronization request to a session.
Result svcReadDebugProcessMemory(void *buffer, Handle debug, u64 addr, u64 size)
Reads memory from a process that is being debugged.
BreakReason
Break reasons.
Definition svc.h:115
MemoryType
Memory type enumeration (lower 8 bits of MemoryState)
Definition svc.h:20
@ MemType_Normal
Mapped by kernel capability parsing in svcCreateProcess.
Definition svc.h:23
@ MemType_Heap
Mapped using svcSetHeapSize.
Definition svc.h:26
@ MemType_CodeReadOnly
Mapped in kernel during svcControlCodeMemory.
Definition svc.h:41
@ MemType_Unmapped
Unmapped memory.
Definition svc.h:21
@ MemType_IpcBuffer0
IPC buffers with descriptor flags=0.
Definition svc.h:31
@ MemType_CodeWritable
Mapped in kernel during svcControlCodeMemory.
Definition svc.h:42
@ MemType_WeirdMappedMem
Mapped using svcMapMemory.
Definition svc.h:28
@ MemType_Insecure
Mapped in kernel during svcMapInsecurePhysicalMemory.
Definition svc.h:44
@ MemType_MappedMemory
Mapped using svcMapMemory.
Definition svc.h:32
@ MemType_IpcBuffer1
IPC buffers with descriptor flags=1.
Definition svc.h:38
@ MemType_ModuleCodeMutable
Transition from MemType_ModuleCodeStatic performed by svcSetProcessMemoryPermission.
Definition svc.h:30
@ MemType_CodeStatic
Mapped during svcCreateProcess.
Definition svc.h:24
@ MemType_Coverage
Not available.
Definition svc.h:43
@ MemType_Reserved
Reserved.
Definition svc.h:37
@ MemType_TransferMem
Mapped using svcMapTransferMemory when the owning process has perm!=0.
Definition svc.h:35
@ MemType_ModuleCodeStatic
Mapped using svcMapProcessCodeMemory.
Definition svc.h:29
@ MemType_ThreadLocal
Mapped during svcCreateThread.
Definition svc.h:33
@ MemType_IpcBuffer3
IPC buffers with descriptor flags=3.
Definition svc.h:39
@ MemType_ProcessMem
Mapped using svcMapProcessMemory.
Definition svc.h:36
@ MemType_TransferMemIsolated
Mapped using svcMapTransferMemory when the owning process has perm=0.
Definition svc.h:34
@ MemType_CodeMutable
Transition from MemType_CodeStatic performed by svcSetProcessMemoryPermission.
Definition svc.h:25
@ MemType_KernelStack
Mapped in kernel during svcCreateThread.
Definition svc.h:40
@ MemType_SharedMem
Mapped using svcMapSharedMemory.
Definition svc.h:27
@ MemType_Io
Mapped by kernel capability parsing in svcCreateProcess.
Definition svc.h:22
Result svcGetResourceLimitCurrentValue(s64 *out, Handle reslimit_h, LimitableResource which)
Gets the maximum value a LimitableResource can have, for a Resource Limit handle.
Result svcLegacyQueryIoMapping(u64 *virtaddr, u64 physaddr, u64 size)
Returns a virtual address mapped to a given IO range.
Result svcAcceptSession(Handle *session_handle, Handle port_handle)
Accepts an IPC session.
Result svcSendSyncRequestWithUserBuffer(void *usrBuffer, u64 size, Handle session)
Sends an IPC synchronization request to a session from an user allocated buffer.
Result svcUnmapProcessMemory(void *dst, Handle proc, u64 src, u64 size)
Undoes the effects of svcMapProcessMemory.
InfoType
GetInfo IDs.
Definition svc.h:184
@ InfoType_HeapRegionSize
Size of the Heap memory region.
Definition svc.h:190
@ InfoType_TransferMemoryHint
[19.0.0+] Low bits of the process address for a KTransferMemory.
Definition svc.h:215
@ InfoType_SystemResourceSizeUsed
[3.0.0+] Amount of memory currently used by process memory management.
Definition svc.h:202
@ InfoType_StackRegionAddress
[2.0.0+] Base of the Stack memory region.
Definition svc.h:199
@ InfoType_SystemResourceSizeTotal
[3.0.0+] Total memory allocated for process memory management.
Definition svc.h:201
@ InfoType_PriorityMask
Bitmask of allowed Thread Priorities.
Definition svc.h:186
@ InfoType_IoRegionHint
[16.0.0+] Low bits of the physical address for a KIoRegion.
Definition svc.h:212
@ InfoType_IsSvcPermitted
[14.0.0+] Does process have access to SVC (only usable with svcSynchronizePreemptionState at present)...
Definition svc.h:211
@ InfoType_TotalMemorySize
Total amount of memory available for process.
Definition svc.h:191
@ InfoType_AslrRegionSize
[2.0.0+] Size of the process's address space.
Definition svc.h:198
@ InfoType_ThreadTickCountDeprecated
[1.0.0-12.1.0] Number of ticks spent on thread.
Definition svc.h:217
@ InfoType_AslrRegionAddress
[2.0.0+] Base of the process's address space.
Definition svc.h:197
@ InfoType_ResourceLimit
Current process's resource limit handle.
Definition svc.h:194
@ InfoType_UsedNonSystemMemorySize
[6.0.0+] Amount of memory used by process, excluding that for process memory management.
Definition svc.h:207
@ InfoType_DebuggerAttached
Whether current process is being debugged.
Definition svc.h:193
@ InfoType_RandomEntropy
[2.0.0+] Random entropy for current process.
Definition svc.h:196
@ InfoType_IdleTickCount
Number of idle ticks on CPU.
Definition svc.h:195
@ InfoType_IsApplication
[9.0.0+] Whether the specified process is an Application.
Definition svc.h:208
@ InfoType_FreeThreadCount
[11.0.0+] The number of free threads available to the process's resource limit.
Definition svc.h:209
@ InfoType_ThreadTickCount
[13.0.0+] Number of ticks spent on thread.
Definition svc.h:210
@ InfoType_ProgramId
[3.0.0+] Program ID for the process.
Definition svc.h:203
@ InfoType_AliasRegionSize
Size of the Alias memory region.
Definition svc.h:188
@ InfoType_StackRegionSize
[2.0.0+] Size of the Stack memory region.
Definition svc.h:200
@ InfoType_UsedMemorySize
Amount of memory currently used by process.
Definition svc.h:192
@ InfoType_HeapRegionAddress
Base of the Heap memory region.
Definition svc.h:189
@ InfoType_InitialProcessIdRange
[4.0.0-4.1.0] Min/max initial process IDs.
Definition svc.h:204
@ InfoType_AliasRegionExtraSize
[18.0.0+] Extra size added to the reserved region.
Definition svc.h:213
@ InfoType_TotalNonSystemMemorySize
[6.0.0+] Total amount of memory available for process, excluding that for process memory management.
Definition svc.h:206
@ InfoType_CoreMask
Bitmask of allowed Core IDs.
Definition svc.h:185
@ InfoType_AliasRegionAddress
Base of the Alias memory region.
Definition svc.h:187
@ InfoType_UserExceptionContextAddress
[5.0.0+] Address of the process's exception context (for break).
Definition svc.h:205
void svcSynchronizePreemptionState(void)
Sets thread preemption state (used during abort/panic).
InitialProcessIdRangeInfo
GetInfo InitialProcessIdRange Sub IDs.
Definition svc.h:238
@ InitialProcessIdRangeInfo_Maximum
Highest initial process ID.
Definition svc.h:240
@ InitialProcessIdRangeInfo_Minimum
Lowest initial process ID.
Definition svc.h:239
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.
Result svcGetProcessInfo(s64 *out, Handle proc, ProcessInfoType which)
Gets a ProcessInfoType for a process.
ProcessActivity
Process Activity.
Definition svc.h:169
@ ProcessActivity_Runnable
Process can run.
Definition svc.h:170
@ ProcessActivity_Paused
Process is paused.
Definition svc.h:171
CodeMapOperation
Code memory mapping operations.
Definition svc.h:129
@ CodeMapOperation_UnmapSlave
Unmap slave.
Definition svc.h:133
@ CodeMapOperation_UnmapOwner
Unmap owner.
Definition svc.h:132
@ CodeMapOperation_MapSlave
Map slave.
Definition svc.h:131
@ CodeMapOperation_MapOwner
Map owner.
Definition svc.h:130
Result svcCreateInterruptEvent(Handle *handle, u64 irqNum, u32 flag)
Creates an event and binds it to a specific hardware interrupt.
Result svcMapSharedMemory(Handle handle, void *addr, size_t size, u32 perm)
Maps a block of shared memory.
Result svcMapMemory(void *dst_addr, void *src_addr, u64 size)
Maps a memory range into a different range.
Result svcStartProcess(Handle proc, s32 main_prio, s32 default_cpu, u32 stack_size)
Starts executing a freshly created process.
Result svcCreateIoPool(Handle *out_handle, u32 pool_type)
Creates an IO Pool.
Result svcTerminateProcess(Handle proc)
Terminates a running process.
Result svcSetMemoryAttribute(void *addr, u64 size, u32 val0, u32 val1)
Set the memory attributes of a (page-aligned) range of memory.
Result svcSetResourceLimitLimitValue(Handle reslimit, LimitableResource which, u64 value)
Sets the value for a LimitableResource for a Resource Limit handle.
Result svcSignalToAddress(void *address, u32 signal_type, s32 value, s32 count)
Signals (and updates) an address depending on type and value.
void svcExitThread(void)
Exits the current thread.
DebugThreadParam
Debug Thread Parameters.
Definition svc.h:175
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).
u32 svcGetCurrentProcessorNumber(void)
Gets the current processor's number.
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 svcCreateSharedMemory(Handle *out, size_t size, u32 local_perm, u32 other_perm)
Creates a block of shared memory.
Result svcArbitrateLock(u32 wait_tag, u32 *tag_location, u32 self_tag)
Arbitrates a mutex lock operation in userspace.
Result svcFlushProcessDataCache(Handle process, uintptr_t address, size_t size)
Flushes data cache for a virtual address range within a process.
Result svcGetLastThreadInfo(LastThreadContext *out_context, u64 *out_tls_address, u32 *out_flags)
Gets information about the previously-scheduled thread.
Result svcDebugActiveProcess(Handle *debug, u64 processID)
Debugs an active process.
static Result svcWaitSynchronizationSingle(Handle handle, u64 timeout)
Waits on a single synchronization object, optionally with a timeout.
Definition svc.h:525
Result svcGetDebugThreadContext(ThreadContext *ctx, Handle debug, u64 threadID, u32 flags)
Gets the context (dump the registers) of a thread in a debugging session.
Result svcMapPhysicalMemoryUnsafe(void *address, u64 size)
Maps unsafe memory (usable for GPU DMA) for a system module at the desired address.
Result svcAttachDeviceAddressSpace(u64 device, Handle handle)
Attaches a device address space to a device.
ThreadActivity
Thread Activity.
Definition svc.h:146
@ ThreadActivity_Paused
Thread is paused.
Definition svc.h:148
@ ThreadActivity_Runnable
Thread can run.
Definition svc.h:147
Result svcGetThreadContext3(ThreadContext *ctx, Handle thread)
Dumps the registers of a thread paused by svcSetThreadActivity (register groups: all).
Result svcSetHardwareBreakPoint(u32 which, u64 flags, u64 value)
Sets one of the hardware breakpoints.
MemoryAttribute
Memory attribute bitmasks.
Definition svc.h:71
@ MemAttr_IsUncached
Is uncached.
Definition svc.h:75
@ MemAttr_IsPermissionLocked
Is permission locked.
Definition svc.h:76
@ MemAttr_IsBorrowed
Is borrowed memory.
Definition svc.h:72
@ MemAttr_IsDeviceMapped
Is device mapped (when DeviceRefCount > 0).
Definition svc.h:74
@ MemAttr_IsIpcMapped
Is IPC mapped (when IpcRefCount > 0).
Definition svc.h:73
Result svcGetSystemInfo(u64 *out, u64 id0, Handle handle, u64 id1)
Retrieves privileged information about the system, or a certain kernel object.
Result svcMapProcessMemory(void *dst, Handle proc, u64 src, u64 size)
Maps the src address from the supplied process handle into the current process.
void svcSleepSystem(void)
Causes the system to enter deep sleep.
Result svcStartThread(Handle handle)
Starts a freshly created thread.
Result svcUnmapIoRegion(Handle io_region_h, void *address, u64 size)
Undoes the effects of svcMapIoRegion.
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.
Result svcGetThreadId(u64 *threadID, Handle handle)
Gets the TID associated with a process.
Result svcWaitProcessWideKeyAtomic(u32 *key, u32 *tag_location, u32 self_tag, u64 timeout)
Performs a condition variable wait operation in userspace.
Result svcBreakDebugProcess(Handle debug)
Breaks an active debugging session.
Result svcUnmapMemory(void *dst_addr, void *src_addr, u64 size)
Unmaps a region that was previously mapped with svcMapMemory.
Result svcFlushDataCache(void *address, size_t size)
Flushes data cache for a virtual address range.
Result svcGetDebugEvent(void *event_out, Handle debug)
Gets an incoming debug event from a debugging session.
Result svcCreateEvent(Handle *server_handle, Handle *client_handle)
Creates a system event.
Result svcQueryMemory(MemoryInfo *meminfo_ptr, u32 *pageinfo, u64 addr)
Query information about an address.
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.
Result svcInvalidateProcessDataCache(Handle process, uintptr_t address, size_t size)
Invalidates data cache for a virtual address range within a process.
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.
Result svcUnmapProcessCodeMemory(Handle proc, u64 dst, u64 src, u64 size)
Undoes the effects of svcMapProcessCodeMemory.
Result svcMapIoRegion(Handle io_region_h, void *address, u64 size, u32 perm)
Maps an IO Region.
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+].
Result svcConnectToNamedPort(Handle *session, const char *name)
Connects to a registered named port.
Result svcUnmapPhysicalMemory(void *address, u64 size)
Undoes the effects of svcMapPhysicalMemory.
SignalType
SignalToAddress behaviors.
Definition svc.h:259
@ SignalType_Signal
Signals the address.
Definition svc.h:260
@ SignalType_SignalAndModifyBasedOnWaitingThreadCountIfEqual
Signals the address and updates its value if equal to argument.
Definition svc.h:262
@ SignalType_SignalAndIncrementIfEqual
Signals the address and increments its value if equal to argument.
Definition svc.h:261
void svcCallSecureMonitor(SecmonArgs *regs)
Calls a secure monitor function (TrustZone, EL3).
Result svcWaitForAddress(void *address, u32 arb_type, s64 value, s64 timeout)
Arbitrates an address depending on type and value.
Result svcCreateIoRegion(Handle *out_handle, Handle io_pool_h, u64 physical_address, u64 size, u32 memory_mapping, u32 perm)
Creates an IO Region.
ProcessInfoType
Process Information.
Definition svc.h:152
@ ProcessInfoType_ProcessState
What state is a process in.
Definition svc.h:153
Result svcResetSignal(Handle handle)
Resets a signal.
Result svcUnmapTransferMemory(Handle tmem_handle, void *addr, size_t size)
Unmaps a block of transfer memory.
Result svcLegacyContinueDebugEvent(Handle debug, u32 flags, u64 threadID)
Continues a debugging session.
Result svcOutputDebugString(const char *str, u64 size)
Outputs debug text, if used during debugging.
Result svcQueryPhysicalAddress(PhysicalMemoryInfo *out, u64 virtaddr)
Queries information about a certain virtual address, including its physical address.
Result svcCreateSession(Handle *server_handle, Handle *client_handle, u32 unk0, u64 unk1)
Creates an IPC session.
Result svcCreateTransferMemory(Handle *out, void *addr, size_t size, u32 perm)
Creates a block of transfer memory.
IoPoolType
Io Pools.
Definition svc.h:289
@ IoPoolType_PcieA2
Physical address range 0x12000000-0x1FFFFFFF.
Definition svc.h:290
Result svcReplyAndReceive(s32 *index, const Handle *handles, s32 handleCount, Handle replyTarget, u64 timeout)
Performs IPC input/output.
SystemInfoType
GetSystemInfo IDs.
Definition svc.h:221
@ SystemInfoType_TotalPhysicalMemorySize
Total amount of DRAM available to system.
Definition svc.h:222
@ SystemInfoType_UsedPhysicalMemorySize
Current amount of DRAM used by system.
Definition svc.h:223
@ SystemInfoType_InitialProcessIdRange
Min/max initial process IDs.
Definition svc.h:224
Result svcMapTransferMemory(Handle tmem_handle, void *addr, size_t size, u32 perm)
Maps a block of transfer memory.
Result svcConnectToPort(Handle *session, Handle port)
Manages a named port.
Result svcClearEvent(Handle handle)
Clears an event's signalled status.
Result svcUnmapPhysicalMemoryUnsafe(void *address, u64 size)
Undoes the effects of svcMapPhysicalMemoryUnsafe.
MemoryState
Memory state bitmasks.
Definition svc.h:48
@ MemState_MapAllowed
Map allowed.
Definition svc.h:56
@ MemState_IpcSendAllowed_Type0
IPC type 0 send allowed.
Definition svc.h:52
@ MemState_MapDeviceAlignedAllowed
Map device aligned allowed.
Definition svc.h:61
@ MemState_IsRefCounted
Alias for MemState_IsPoolAllocated.
Definition svc.h:64
@ MemState_AttrChangeAllowed
Attribute change allowed.
Definition svc.h:66
@ MemState_CodeMemAllowed
Code memory allowed.
Definition svc.h:67
@ MemState_IpcSendAllowed_Type1
IPC type 1 send allowed.
Definition svc.h:54
@ MemState_IpcBufferAllowed
IPC buffer allowed.
Definition svc.h:62
@ MemState_IpcSendAllowed_Type3
IPC type 3 send allowed.
Definition svc.h:53
@ MemState_TransferMemAllowed
Transfer memory allowed.
Definition svc.h:58
@ MemState_Type
Type field (see MemoryType).
Definition svc.h:49
@ MemState_ProcessPermChangeAllowed
Process permission change allowed.
Definition svc.h:55
@ MemState_UnmapProcessCodeMemAllowed
Unmap process code memory allowed.
Definition svc.h:57
@ MemState_IsPoolAllocated
Is pool allocated.
Definition svc.h:63
@ MemState_QueryPAddrAllowed
Query physical address allowed.
Definition svc.h:59
@ MemState_PermChangeAllowed
Permission change allowed.
Definition svc.h:50
@ MemState_ForceRwByDebugSyscalls
Force read/writable by debug syscalls.
Definition svc.h:51
@ MemState_MapDeviceAllowed
Map device allowed (svcMapDeviceAddressSpace and svcMapDeviceAddressSpaceByForce).
Definition svc.h:60
@ MemState_MapProcessAllowed
Map process allowed.
Definition svc.h:65
Result svcReplyAndReceiveLight(Handle handle)
Performs light IPC input/output.
Result svcContinueDebugEvent(Handle debug, u32 flags, u64 *tid_list, u32 num_tids)
Continues a debugging session.
void svcFlushEntireDataCache(void)
Flushes the entire data cache (by set/way).
Result svcCreatePort(Handle *portServer, Handle *portClient, s32 max_sessions, bool is_light, const char *name)
Creates a port.
Result svcQueryMemoryMapping(u64 *virtaddr, u64 *out_size, u64 physaddr, u64 size)
Returns a virtual address mapped to a given IO range.
Result svcGetInfo(u64 *out, u32 id0, Handle handle, u64 id1)
Retrieves information about the system, or a certain kernel object.
Result svcSetThreadActivity(Handle thread, ThreadActivity paused)
Configures the pause/unpause status of a thread.
Result svcSendSyncRequestLight(Handle session)
Sends a light IPC synchronization request to a session.
TickCountInfo
GetInfo Idle/Thread Tick Count Sub IDs.
Definition svc.h:228
@ TickCountInfo_Core3
Tick count on core 3.
Definition svc.h:232
@ TickCountInfo_Core2
Tick count on core 2.
Definition svc.h:231
@ TickCountInfo_Core0
Tick count on core 0.
Definition svc.h:229
@ TickCountInfo_Core1
Tick count on core 1.
Definition svc.h:230
@ TickCountInfo_Total
Tick count on all cores.
Definition svc.h:234
Result svcGetResourceLimitLimitValue(s64 *out, Handle reslimit_h, LimitableResource which)
Gets the maximum value a LimitableResource can have, for a Resource Limit handle.
Result svcCreateResourceLimit(Handle *out)
Creates a new Resource Limit handle.
Result svcMapProcessCodeMemory(Handle proc, u64 dst, u64 src, u64 size)
Maps normal heap in a certain process as executable code (used when loading NROs).
Result svcGetDebugThreadParam(u64 *out_64, u32 *out_32, Handle debug, u64 threadID, DebugThreadParam param)
Gets parameters from a thread in a debugging session.
Result svcCreateProcess(Handle *out, const void *proc_info, const u32 *caps, u64 cap_num)
Creates a new process.
void svcKernelDebug(u32 kern_debug_type, u64 arg0, u64 arg1, u64 arg2)
Performs a debugging operation on the kernel.
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...
Result svcTerminateDebugProcess(Handle debug)
Terminates the process of an active debugging session.
Result svcGetThreadPriority(s32 *priority, Handle handle)
Gets a thread's priority.
Result svcManageNamedPort(Handle *portServer, const char *name, s32 maxSessions)
Manages a named port.
Result svcSetProcessMemoryPermission(Handle proc, u64 addr, u64 size, u32 perm)
Sets the memory permissions for the specified memory with the supplied process handle.
Result svcCreateDeviceAddressSpace(Handle *handle, u64 dev_addr, u64 dev_size)
Creates a virtual address space for binding device address spaces.
Result svcMapPhysicalMemory(void *address, u64 size)
Maps new heap memory at the desired address.
Result svcBreak(u32 breakReason, uintptr_t address, uintptr_t size)
Breaks execution.
Result svcSignalEvent(Handle handle)
Sets an event's signalled status.
Result svcGetProcessList(s32 *num_out, u64 *pids_out, u32 max_pids)
Retrieves a list of all running processes.
Result svcGetResourceLimitPeakValue(s64 *out, Handle reslimit_h, LimitableResource which)
Gets the peak value a LimitableResource has had, for a Resource Limit handle.
Result svcQueryDebugProcessMemory(MemoryInfo *meminfo_ptr, u32 *pageinfo, Handle debug, u64 addr)
Queries memory information from a process that is being debugged.
Result svcQueryProcessMemory(MemoryInfo *meminfo_ptr, u32 *pageinfo, Handle proc, u64 addr)
Equivalent to svcQueryMemory, for another process.
Result svcCreateThread(Handle *out, void *entry, void *arg, void *stack_top, int prio, int cpuid)
Creates a thread.
Result svcDetachDeviceAddressSpace(u64 device, Handle handle)
Detaches a device address space from a device.
int64_t s64
64-bit signed integer.
Definition types.h:28
#define BIT(n)
Creates a bitmask from a bit number.
Definition types.h:54
uint64_t u64
64-bit unsigned integer.
Definition types.h:22
#define NX_PACKED
Packs a struct so that it won't include padding bytes.
Definition types.h:63
u32 Handle
Kernel object handle.
Definition types.h:43
u32 Result
Function error code result type.
Definition types.h:44
#define NX_NORETURN
Marks a function as not returning, for the purposes of compiler optimization.
Definition types.h:68
int32_t s32
32-bit signed integer.
Definition types.h:27
uint32_t u32
32-bit unsigned integer.
Definition types.h:21