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