libnx v4.12.0
Loading...
Searching...
No Matches
svc.h
Go to the documentation of this file.
1/**
2 * @file svc.h
3 * @brief Wrappers for kernel syscalls.
4 * @copyright libnx Authors
5 */
6#pragma once
7#include "../types.h"
8#include "../arm/thread_context.h"
9
10/// Pseudo handle for the current process.
11#define CUR_PROCESS_HANDLE 0xFFFF8001
12
13/// Pseudo handle for the current thread.
14#define CUR_THREAD_HANDLE 0xFFFF8000
15
16/// Maximum number of objects that can be waited on by \ref svcWaitSynchronization (Horizon kernel limitation).
17#define MAX_WAIT_OBJECTS 0x40
18
19/// Memory type enumeration (lower 8 bits of \ref MemoryState)
20typedef enum {
21 MemType_Unmapped=0x00, ///< Unmapped memory.
22 MemType_Io=0x01, ///< Mapped by kernel capability parsing in \ref svcCreateProcess.
23 MemType_Normal=0x02, ///< Mapped by kernel capability parsing in \ref svcCreateProcess.
24 MemType_CodeStatic=0x03, ///< Mapped during \ref svcCreateProcess.
25 MemType_CodeMutable=0x04, ///< Transition from MemType_CodeStatic performed by \ref svcSetProcessMemoryPermission.
26 MemType_Heap=0x05, ///< Mapped using \ref svcSetHeapSize.
27 MemType_SharedMem=0x06, ///< Mapped using \ref svcMapSharedMemory.
28 MemType_WeirdMappedMem=0x07, ///< Mapped using \ref svcMapMemory.
29 MemType_ModuleCodeStatic=0x08, ///< Mapped using \ref svcMapProcessCodeMemory.
30 MemType_ModuleCodeMutable=0x09, ///< Transition from \ref MemType_ModuleCodeStatic performed by \ref svcSetProcessMemoryPermission.
31 MemType_IpcBuffer0=0x0A, ///< IPC buffers with descriptor flags=0.
32 MemType_MappedMemory=0x0B, ///< Mapped using \ref svcMapMemory.
33 MemType_ThreadLocal=0x0C, ///< Mapped during \ref svcCreateThread.
34 MemType_TransferMemIsolated=0x0D, ///< Mapped using \ref svcMapTransferMemory when the owning process has perm=0.
35 MemType_TransferMem=0x0E, ///< Mapped using \ref svcMapTransferMemory when the owning process has perm!=0.
36 MemType_ProcessMem=0x0F, ///< Mapped using \ref svcMapProcessMemory.
37 MemType_Reserved=0x10, ///< Reserved.
38 MemType_IpcBuffer1=0x11, ///< IPC buffers with descriptor flags=1.
39 MemType_IpcBuffer3=0x12, ///< IPC buffers with descriptor flags=3.
40 MemType_KernelStack=0x13, ///< Mapped in kernel during \ref svcCreateThread.
41 MemType_CodeReadOnly=0x14, ///< Mapped in kernel during \ref svcControlCodeMemory.
42 MemType_CodeWritable=0x15, ///< Mapped in kernel during \ref svcControlCodeMemory.
43 MemType_Coverage=0x16, ///< Not available.
44 MemType_Insecure=0x17, ///< Mapped in kernel during \ref svcMapInsecurePhysicalMemory.
46
47/// Memory state bitmasks.
48typedef enum {
49 MemState_Type=0xFF, ///< Type field (see \ref MemoryType).
50 MemState_PermChangeAllowed=BIT(8), ///< Permission change allowed.
51 MemState_ForceRwByDebugSyscalls=BIT(9), ///< Force read/writable by debug syscalls.
52 MemState_IpcSendAllowed_Type0=BIT(10), ///< IPC type 0 send allowed.
53 MemState_IpcSendAllowed_Type3=BIT(11), ///< IPC type 3 send allowed.
54 MemState_IpcSendAllowed_Type1=BIT(12), ///< IPC type 1 send allowed.
55 MemState_ProcessPermChangeAllowed=BIT(14), ///< Process permission change allowed.
56 MemState_MapAllowed=BIT(15), ///< Map allowed.
57 MemState_UnmapProcessCodeMemAllowed=BIT(16), ///< Unmap process code memory allowed.
58 MemState_TransferMemAllowed=BIT(17), ///< Transfer memory allowed.
59 MemState_QueryPAddrAllowed=BIT(18), ///< Query physical address allowed.
60 MemState_MapDeviceAllowed=BIT(19), ///< Map device allowed (\ref svcMapDeviceAddressSpace and \ref svcMapDeviceAddressSpaceByForce).
61 MemState_MapDeviceAlignedAllowed=BIT(20), ///< Map device aligned allowed.
62 MemState_IpcBufferAllowed=BIT(21), ///< IPC buffer allowed.
63 MemState_IsPoolAllocated=BIT(22), ///< Is pool allocated.
64 MemState_IsRefCounted=MemState_IsPoolAllocated, ///< Alias for \ref MemState_IsPoolAllocated.
65 MemState_MapProcessAllowed=BIT(23), ///< Map process allowed.
66 MemState_AttrChangeAllowed=BIT(24), ///< Attribute change allowed.
67 MemState_CodeMemAllowed=BIT(25), ///< Code memory allowed.
69
70/// Memory attribute bitmasks.
71typedef enum {
72 MemAttr_IsBorrowed=BIT(0), ///< Is borrowed memory.
73 MemAttr_IsIpcMapped=BIT(1), ///< Is IPC mapped (when IpcRefCount > 0).
74 MemAttr_IsDeviceMapped=BIT(2), ///< Is device mapped (when DeviceRefCount > 0).
75 MemAttr_IsUncached=BIT(3), ///< Is uncached.
76 MemAttr_IsPermissionLocked=BIT(4), ///< Is permission locked.
78
79/// Memory permission bitmasks.
80typedef enum {
81 Perm_None = 0, ///< No permissions.
82 Perm_R = BIT(0), ///< Read permission.
83 Perm_W = BIT(1), ///< Write permission.
84 Perm_X = BIT(2), ///< Execute permission.
85 Perm_Rw = Perm_R | Perm_W, ///< Read/write permissions.
86 Perm_Rx = Perm_R | Perm_X, ///< Read/execute permissions.
87 Perm_DontCare = BIT(28), ///< Don't care
89
90/// Memory information structure.
91typedef struct {
92 u64 addr; ///< Base address.
93 u64 size; ///< Size.
94 u32 type; ///< Memory type (see lower 8 bits of \ref MemoryState).
95 u32 attr; ///< Memory attributes (see \ref MemoryAttribute).
96 u32 perm; ///< Memory permissions (see \ref Permission).
97 u32 ipc_refcount; ///< IPC reference count.
98 u32 device_refcount; ///< Device reference count.
99 u32 padding; ///< Padding.
100} MemoryInfo;
101
102/// Physical memory information structure.
103typedef struct {
104 u64 physical_address; ///< Physical address.
105 u64 virtual_address; ///< Virtual address.
106 u64 size; ///< Size.
108
109/// Secure monitor arguments.
110typedef struct {
111 u64 X[8]; ///< Values of X0 through X7.
113
114/// Break reasons
115typedef enum {
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,
124
125 BreakReason_NotificationOnlyFlag = 0x80000000,
127
128/// Code memory mapping operations
129typedef enum {
130 CodeMapOperation_MapOwner=0, ///< Map owner.
131 CodeMapOperation_MapSlave=1, ///< Map slave.
132 CodeMapOperation_UnmapOwner=2, ///< Unmap owner.
133 CodeMapOperation_UnmapSlave=3, ///< Unmap slave.
135
136/// Limitable Resources.
137typedef enum {
138 LimitableResource_Memory=0, ///<How much memory can a process map.
139 LimitableResource_Threads=1, ///<How many threads can a process spawn.
140 LimitableResource_Events=2, ///<How many events can a process have.
141 LimitableResource_TransferMemories=3, ///<How many transfer memories can a process make.
142 LimitableResource_Sessions=4, ///<How many sessions can a process own.
144
145/// Thread Activity.
146typedef enum {
147 ThreadActivity_Runnable = 0, ///< Thread can run.
148 ThreadActivity_Paused = 1, ///< Thread is paused.
150
151/// Process Information.
152typedef enum {
153 ProcessInfoType_ProcessState=0, ///<What state is a process in.
155
156/// Process States.
157typedef enum {
158 ProcessState_Created=0, ///<Newly-created process, not yet started.
159 ProcessState_CreatedAttached=1, ///<Newly-created process, not yet started but attached to debugger.
160 ProcessState_Running=2, ///<Process that is running normally (and detached from any debugger).
161 ProcessState_Crashed=3, ///<Process that has just crashed.
162 ProcessState_RunningAttached=4, ///<Process that is running normally, attached to a debugger.
163 ProcessState_Exiting=5, ///<Process has begun exiting.
164 ProcessState_Exited=6, ///<Process has finished exiting.
165 ProcessState_DebugSuspended=7, ///<Process execution suspended by debugger.
167
168/// Process Activity.
169typedef enum {
170 ProcessActivity_Runnable = 0, ///< Process can run.
171 ProcessActivity_Paused = 1, ///< Process is paused.
173
174/// Debug Thread Parameters.
175typedef enum {
176 DebugThreadParam_ActualPriority=0,
177 DebugThreadParam_State=1,
178 DebugThreadParam_IdealCore=2,
179 DebugThreadParam_CurrentCore=3,
180 DebugThreadParam_CoreMask=4,
182
183/// GetInfo IDs.
184typedef enum {
185 InfoType_CoreMask = 0, ///< Bitmask of allowed Core IDs.
186 InfoType_PriorityMask = 1, ///< Bitmask of allowed Thread Priorities.
187 InfoType_AliasRegionAddress = 2, ///< Base of the Alias memory region.
188 InfoType_AliasRegionSize = 3, ///< Size of the Alias memory region.
189 InfoType_HeapRegionAddress = 4, ///< Base of the Heap memory region.
190 InfoType_HeapRegionSize = 5, ///< Size of the Heap memory region.
191 InfoType_TotalMemorySize = 6, ///< Total amount of memory available for process.
192 InfoType_UsedMemorySize = 7, ///< Amount of memory currently used by process.
193 InfoType_DebuggerAttached = 8, ///< Whether current process is being debugged.
194 InfoType_ResourceLimit = 9, ///< Current process's resource limit handle.
195 InfoType_IdleTickCount = 10, ///< Number of idle ticks on CPU (only usable with current thread's core).
196 InfoType_RandomEntropy = 11, ///< [2.0.0+] Random entropy for current process.
197 InfoType_AslrRegionAddress = 12, ///< [2.0.0+] Base of the process's address space.
198 InfoType_AslrRegionSize = 13, ///< [2.0.0+] Size of the process's address space.
199 InfoType_StackRegionAddress = 14, ///< [2.0.0+] Base of the Stack memory region.
200 InfoType_StackRegionSize = 15, ///< [2.0.0+] Size of the Stack memory region.
201 InfoType_SystemResourceSizeTotal = 16, ///< [3.0.0+] Total memory allocated for process memory management.
202 InfoType_SystemResourceSizeUsed = 17, ///< [3.0.0+] Amount of memory currently used by process memory management.
203 InfoType_ProgramId = 18, ///< [3.0.0+] Program ID for the process.
204 InfoType_InitialProcessIdRange = 19, ///< [4.0.0-4.1.0] Min/max initial process IDs.
205 InfoType_UserExceptionContextAddress = 20, ///< [5.0.0+] Address of the process's exception context (for break).
206 InfoType_TotalNonSystemMemorySize = 21, ///< [6.0.0+] Total amount of memory available for process, excluding that for process memory management.
207 InfoType_UsedNonSystemMemorySize = 22, ///< [6.0.0+] Amount of memory used by process, excluding that for process memory management.
208 InfoType_IsApplication = 23, ///< [9.0.0+] Whether the specified process is an Application.
209 InfoType_FreeThreadCount = 24, ///< [11.0.0+] The number of free threads available to the process's resource limit.
210 InfoType_ThreadTickCount = 25, ///< [13.0.0+] Number of ticks spent on thread.
211 InfoType_IsSvcPermitted = 26, ///< [14.0.0+] Does process have access to SVC (only usable with \ref svcSynchronizePreemptionState at present).
212 InfoType_IoRegionHint = 27, ///< [16.0.0+] Low bits of the physical address for a KIoRegion.
213 InfoType_AliasRegionExtraSize = 28, ///< [18.0.0+] Extra size added to the reserved region.
214
215 InfoType_TransferMemoryHint = 34, ///< [19.0.0+] Low bits of the process address for a KTransferMemory.
216
217 InfoType_ThreadTickCountDeprecated = 0xF0000002, ///< [1.0.0-12.1.0] Number of ticks spent on thread.
218} InfoType;
219
220/// GetSystemInfo IDs.
221typedef enum {
222 SystemInfoType_TotalPhysicalMemorySize = 0, ///< Total amount of DRAM available to system.
223 SystemInfoType_UsedPhysicalMemorySize = 1, ///< Current amount of DRAM used by system.
224 SystemInfoType_InitialProcessIdRange = 2, ///< Min/max initial process IDs.
226
227/// GetInfo Idle/Thread Tick Count Sub IDs.
228typedef enum {
229 TickCountInfo_Core0 = 0, ///< Tick count on core 0.
230 TickCountInfo_Core1 = 1, ///< Tick count on core 1.
231 TickCountInfo_Core2 = 2, ///< Tick count on core 2.
232 TickCountInfo_Core3 = 3, ///< Tick count on core 3.
233
234 TickCountInfo_Total = UINT64_MAX, ///< ThreadTickCount: Tick count on all cores, IdleTickCount: Thread's current core.
236
237/// GetInfo InitialProcessIdRange Sub IDs.
238typedef enum {
239 InitialProcessIdRangeInfo_Minimum = 0, ///< Lowest initial process ID.
240 InitialProcessIdRangeInfo_Maximum = 1, ///< Highest initial process ID.
242
243/// GetSystemInfo PhysicalMemory Sub IDs.
244typedef enum {
245 PhysicalMemorySystemInfo_Application = 0, ///< Memory allocated for application usage.
246 PhysicalMemorySystemInfo_Applet = 1, ///< Memory allocated for applet usage.
247 PhysicalMemorySystemInfo_System = 2, ///< Memory allocated for system usage.
248 PhysicalMemorySystemInfo_SystemUnsafe = 3, ///< Memory allocated for unsafe system usage (accessible to devices).
250
251/// SleepThread yield types.
252typedef enum {
253 YieldType_WithoutCoreMigration = 0l, ///< Yields to another thread on the same core.
254 YieldType_WithCoreMigration = -1l, ///< Yields to another thread (possibly on a different core).
255 YieldType_ToAnyThread = -2l, ///< Yields and performs forced load-balancing.
256} YieldType;
257
258/// SignalToAddress behaviors.
259typedef enum {
260 SignalType_Signal = 0, ///< Signals the address.
261 SignalType_SignalAndIncrementIfEqual = 1, ///< Signals the address and increments its value if equal to argument.
262 SignalType_SignalAndModifyBasedOnWaitingThreadCountIfEqual = 2, ///< Signals the address and updates its value if equal to argument.
263} SignalType;
264
265/// WaitForAddress behaviors.
266typedef enum {
267 ArbitrationType_WaitIfLessThan = 0, ///< Wait if the 32-bit value is less than argument.
268 ArbitrationType_DecrementAndWaitIfLessThan = 1, ///< Decrement the 32-bit value and wait if it is less than argument.
269 ArbitrationType_WaitIfEqual = 2, ///< Wait if the 32-bit value is equal to argument.
270 ArbitrationType_WaitIfEqual64 = 3, ///< [19.0.0+] Wait if the 64-bit value is equal to argument.
272
273/// Context of a scheduled thread.
274typedef struct {
275 u64 fp; ///< Frame Pointer for the thread.
276 u64 sp; ///< Stack Pointer for the thread.
277 u64 lr; ///< Link Register for the thread.
278 u64 pc; ///< Program Counter for the thread.
280
281/// Memory mapping type.
282typedef enum {
283 MemoryMapping_IoRegister = 0, ///< Mapping IO registers.
284 MemoryMapping_Uncached = 1, ///< Mapping normal memory without cache.
285 MemoryMapping_Memory = 2, ///< Mapping normal memory.
287
288/// Io Pools.
289typedef enum {
290 IoPoolType_PcieA2 = 0, ///< Physical address range 0x12000000-0x1FFFFFFF
291} IoPoolType;
292
293/// DebugEvent types
294typedef enum {
295 DebugEventType_CreateProcess = 0,
296 DebugEventType_CreateThread = 1,
297 DebugEventType_ExitProcess = 2,
298 DebugEventType_ExitThread = 3,
299 DebugEventType_Exception = 4,
301
302/// Process exit reasons
303typedef enum {
304 ProcessExitReason_ExitProcess = 0,
305 ProcessExitReason_TerminateProcess = 1,
306 ProcessExitReason_Exception = 2,
308
309/// Thread exit reasons
310typedef enum {
311 ThreadExitReason_ExitThread = 0,
312 ThreadExitReason_TerminateThread = 1,
313 ThreadExitReason_ExitProcess = 2,
314 ThreadExitReason_TerminateProcess = 3,
316
317/// Debug exception types
318typedef enum {
319 DebugException_UndefinedInstruction = 0,
320 DebugException_InstructionAbort = 1,
321 DebugException_DataAbort = 2,
322 DebugException_AlignmentFault = 3,
323 DebugException_DebuggerAttached = 4,
324 DebugException_BreakPoint = 5,
325 DebugException_UserBreak = 6,
326 DebugException_DebuggerBreak = 7,
327 DebugException_UndefinedSystemCall = 8,
330
331/// Break point types
332typedef enum {
333 BreakPointType_HardwareInstruction = 0,
334 BreakPointType_HardwareData = 1,
336
337/// DebugEvent flags
338typedef enum {
339 DebugEventFlag_Stopped = BIT(0),
341
342/// Address space types for CreateProcessFlags
343typedef enum {
344 CreateProcessFlagAddressSpace_32bit = 0,
346 CreateProcessFlagAddressSpace_32bitWithoutAlias = 2,
347 CreateProcessFlagAddressSpace_64bit = 3, ///< [2.0.0+] 39-bit width
349
350/// Memory regions
351typedef enum {
352 MemoryRegion_Default = 0, ///< [1.0.0-4.1.0]
353 MemoryRegion_Secure = 1, ///< [2.0.0-4.1.0]
355
356/// Flags for svcCreateProcess and CreateProcess event
357typedef struct {
358 u32 is_64bit: 1;
359 u32 address_space: 3; ///< \ref CreateProcessFlagAddressSpace
360 u32 enable_debug: 1; ///< [2.0.0+]
361 u32 enable_aslr: 1;
362 u32 is_application: 1;
363 u32 pool_partition: 4; ///< [4.0.0-4.1.0] \ref MemoryRegion, [5.0.0+] \ref PhysicalMemorySystemInfo
364 u32 optimize_memory_allocation: 1; ///< [7.0.0+] Only allowed in combination with is_application
367 u32 reserved: 18;
369
370/// DebugEvent structure
371typedef struct {
372 u32 type; ///< \ref DebugEventType
373 u32 flags; ///< \ref DebugEventFlag
374 u64 thread_id;
375
376 union {
377 /// DebugEventType_CreateProcess
378 struct {
379 u64 program_id;
380 u64 process_id;
381 char name[0xC];
382 u32 flags; ///< \ref CreateProcessFlags
384 } create_process;
385
386 /// DebugEventType_CreateThread
387 struct {
388 u64 thread_id;
389 void* tls_address;
390 void* entrypoint; ///< [1.0.0-10.2.0]
391 } create_thread;
392
393 /// DebugEventType_ExitProcess
394 struct {
395 u32 reason; ///< \ref ProcessExitReason
396 } exit_process;
397
398 /// DebugEventType_ExitThread
399 struct {
400 u32 reason; ///< \ref ThreadExitReason
401 } exit_thread;
402
403 /// DebugEventType_Exception
404 struct {
405 u32 type; ///< \ref DebugException
406 void* address;
407 union {
408 /// DebugException_UndefinedInstruction
409 struct {
410 u32 insn;
411 } undefined_instruction;
412
413 /// DebugException_DataAbort
414 struct {
415 void* address;
416 } data_abort;
417
418 /// DebugException_AlignmentFault
419 struct {
420 void* address;
421 } alignment_fault;
422
423 /// DebugException_BreakPoint
424 struct {
425 u32 type; ///< \ref BreakPointType
426 void* address;
427 } break_point;
428
429 /// DebugException_UserBreak
430 struct {
431 u32 break_reason; ///< \ref BreakReason
432 void* address;
433 size_t size;
434 } user_break;
435
436 /// DebugException_DebuggerBreak
437 struct {
438 u64 active_thread_ids[4];
439 } debugger_break;
440
441 /// DebugException_UndefinedSystemCall
442 struct {
443 u32 id;
444 } undefined_system_call;
445
446 u64 raw;
447 } specific;
448 } exception;
449 } info;
451
452///@name Memory management
453///@{
454
455/**
456 * @brief Set the process heap to a given size. It can both extend and shrink the heap.
457 * @param[out] out_addr Variable to which write the address of the heap (which is randomized and fixed by the kernel)
458 * @param[in] size Size of the heap, must be a multiple of 0x200000.
459 * @return Result code.
460 * @note Syscall number 0x01.
461 */
462Result svcSetHeapSize(void** out_addr, u64 size);
463
464/**
465 * @brief Set the memory permissions of a (page-aligned) range of memory.
466 * @param[in] addr Start address of the range.
467 * @param[in] size Size of the range, in bytes.
468 * @param[in] perm Permissions (see \ref Permission).
469 * @return Result code.
470 * @remark Perm_X is not allowed. Setting write-only is not allowed either (Perm_W).
471 * This can be used to move back and forth between Perm_None, Perm_R and Perm_Rw.
472 * @note Syscall number 0x02.
473 */
474Result svcSetMemoryPermission(void* addr, u64 size, u32 perm);
475
476/**
477 * @brief Set the memory attributes of a (page-aligned) range of memory.
478 * @param[in] addr Start address of the range.
479 * @param[in] size Size of the range, in bytes.
480 * @param[in] val0 State0
481 * @param[in] val1 State1
482 * @return Result code.
483 * @remark See <a href="https://switchbrew.org/wiki/SVC#svcSetMemoryAttribute">switchbrew.org Wiki</a> for more details.
484 * @note Syscall number 0x03.
485 */
486Result svcSetMemoryAttribute(void* addr, u64 size, u32 val0, u32 val1);
487
488/**
489 * @brief Maps a memory range into a different range. Mainly used for adding guard pages around stack.
490 * Source range gets reprotected to Perm_None (it can no longer be accessed), and \ref MemAttr_IsBorrowed is set in the source \ref MemoryAttribute.
491 * @param[in] dst_addr Destination address.
492 * @param[in] src_addr Source address.
493 * @param[in] size Size of the range.
494 * @return Result code.
495 * @note Syscall number 0x04.
496 */
497Result svcMapMemory(void* dst_addr, void* src_addr, u64 size);
498
499/**
500 * @brief Unmaps a region that was previously mapped with \ref svcMapMemory.
501 * @param[in] dst_addr Destination address.
502 * @param[in] src_addr Source address.
503 * @param[in] size Size of the range.
504 * @return Result code.
505 * @note Syscall number 0x05.
506 */
507Result svcUnmapMemory(void* dst_addr, void* src_addr, u64 size);
508
509/**
510 * @brief Query information about an address. Will always fetch the lowest page-aligned mapping that contains the provided address.
511 * @param[out] meminfo_ptr \ref MemoryInfo structure which will be filled in.
512 * @param[out] pageinfo Page information which will be filled in.
513 * @param[in] addr Address to query.
514 * @return Result code.
515 * @note Syscall number 0x06.
516 */
517Result svcQueryMemory(MemoryInfo* meminfo_ptr, u32 *pageinfo, u64 addr);
518
519///@}
520
521///@name Process and thread management
522///@{
523
524/**
525 * @brief Exits the current process.
526 * @note Syscall number 0x07.
527 */
528
530
531/**
532 * @brief Creates a thread.
533 * @return Result code.
534 * @note Syscall number 0x08.
535 */
536Result svcCreateThread(Handle* out, void* entry, void* arg, void* stack_top, int prio, int cpuid);
537
538/**
539 * @brief Starts a freshly created thread.
540 * @return Result code.
541 * @note Syscall number 0x09.
542 */
544
545/**
546 * @brief Exits the current thread.
547 * @note Syscall number 0x0A.
548 */
550
551/**
552 * @brief Sleeps the current thread for the specified amount of time.
553 * @param[in] nano Number of nanoseconds to sleep, or \ref YieldType for yield.
554 * @note Syscall number 0x0B.
555 */
557
558/**
559 * @brief Gets a thread's priority.
560 * @return Result code.
561 * @note Syscall number 0x0C.
562 */
564
565/**
566 * @brief Sets a thread's priority.
567 * @return Result code.
568 * @note Syscall number 0x0D.
569 */
571
572/**
573 * @brief Gets a thread's core mask.
574 * @return Result code.
575 * @note Syscall number 0x0E.
576 */
577Result svcGetThreadCoreMask(s32* preferred_core, u64* affinity_mask, Handle handle);
578
579/**
580 * @brief Sets a thread's core mask.
581 * @return Result code.
582 * @note Syscall number 0x0F.
583 */
584Result svcSetThreadCoreMask(Handle handle, s32 preferred_core, u32 affinity_mask);
585
586/**
587 * @brief Gets the current processor's number.
588 * @return The current processor's number.
589 * @note Syscall number 0x10.
590 */
592
593///@}
594
595///@name Synchronization
596///@{
597
598/**
599 * @brief Sets an event's signalled status.
600 * @return Result code.
601 * @note Syscall number 0x11.
602 */
604
605/**
606 * @brief Clears an event's signalled status.
607 * @return Result code.
608 * @note Syscall number 0x12.
609 */
611
612///@}
613
614///@name Inter-process memory sharing
615///@{
616
617/**
618 * @brief Maps a block of shared memory.
619 * @return Result code.
620 * @note Syscall number 0x13.
621 */
622Result svcMapSharedMemory(Handle handle, void* addr, size_t size, u32 perm);
623
624/**
625 * @brief Unmaps a block of shared memory.
626 * @return Result code.
627 * @note Syscall number 0x14.
628 */
629Result svcUnmapSharedMemory(Handle handle, void* addr, size_t size);
630
631/**
632 * @brief Creates a block of transfer memory.
633 * @return Result code.
634 * @note Syscall number 0x15.
635 */
636Result svcCreateTransferMemory(Handle* out, void* addr, size_t size, u32 perm);
637
638///@}
639
640///@name Miscellaneous
641///@{
642
643/**
644 * @brief Closes a handle, decrementing the reference count of the corresponding kernel object.
645 * This might result in the kernel freeing the object.
646 * @param handle Handle to close.
647 * @return Result code.
648 * @note Syscall number 0x16.
649 */
651
652///@}
653
654///@name Synchronization
655///@{
656
657/**
658 * @brief Resets a signal.
659 * @return Result code.
660 * @note Syscall number 0x17.
661 */
663
664///@}
665
666///@name Synchronization
667///@{
668
669/**
670 * @brief Waits on one or more synchronization objects, optionally with a timeout.
671 * @return Result code.
672 * @note Syscall number 0x18.
673 * @note \p handleCount must not be greater than \ref MAX_WAIT_OBJECTS. This is a Horizon kernel limitation.
674 * @note This is the raw syscall, which can be cancelled by \ref svcCancelSynchronization or other means. \ref waitHandles or \ref waitMultiHandle should normally be used instead.
675 */
676Result svcWaitSynchronization(s32* index, const Handle* handles, s32 handleCount, u64 timeout);
677
678/**
679 * @brief Waits on a single synchronization object, optionally with a timeout.
680 * @return Result code.
681 * @note Wrapper for \ref svcWaitSynchronization.
682 * @note This is the raw syscall, which can be cancelled by \ref svcCancelSynchronization or other means. \ref waitSingleHandle should normally be used instead.
683 */
684static inline Result svcWaitSynchronizationSingle(Handle handle, u64 timeout) {
685 s32 tmp;
686 return svcWaitSynchronization(&tmp, &handle, 1, timeout);
687}
688
689/**
690 * @brief Waits a \ref svcWaitSynchronization operation being done on a synchronization object in another thread.
691 * @return Result code.
692 * @note Syscall number 0x19.
693 */
695
696/**
697 * @brief Arbitrates a mutex lock operation in userspace.
698 * @return Result code.
699 * @note Syscall number 0x1A.
700 */
701Result svcArbitrateLock(u32 wait_tag, u32* tag_location, u32 self_tag);
702
703/**
704 * @brief Arbitrates a mutex unlock operation in userspace.
705 * @return Result code.
706 * @note Syscall number 0x1B.
707 */
709
710/**
711 * @brief Performs a condition variable wait operation in userspace.
712 * @return Result code.
713 * @note Syscall number 0x1C.
714 */
715Result svcWaitProcessWideKeyAtomic(u32* key, u32* tag_location, u32 self_tag, u64 timeout);
716
717/**
718 * @brief Performs a condition variable wake-up operation in userspace.
719 * @note Syscall number 0x1D.
720 */
722
723///@}
724
725///@name Miscellaneous
726///@{
727
728/**
729 * @brief Gets the current system tick.
730 * @return The current system tick.
731 * @note Syscall number 0x1E.
732 */
734
735///@}
736
737///@name Inter-process communication (IPC)
738///@{
739
740/**
741 * @brief Connects to a registered named port.
742 * @return Result code.
743 * @note Syscall number 0x1F.
744 */
745Result svcConnectToNamedPort(Handle* session, const char* name);
746
747/**
748 * @brief Sends a light IPC synchronization request to a session.
749 * @return Result code.
750 * @note Syscall number 0x20.
751 */
753
754/**
755 * @brief Sends an IPC synchronization request to a session.
756 * @return Result code.
757 * @note Syscall number 0x21.
758 */
760
761/**
762 * @brief Sends an IPC synchronization request to a session from an user allocated buffer.
763 * @return Result code.
764 * @remark size must be allocated to 0x1000 bytes.
765 * @note Syscall number 0x22.
766 */
767Result svcSendSyncRequestWithUserBuffer(void* usrBuffer, u64 size, Handle session);
768
769/**
770 * @brief Sends an IPC synchronization request to a session from an user allocated buffer (asynchronous version).
771 * @return Result code.
772 * @remark size must be allocated to 0x1000 bytes.
773 * @note Syscall number 0x23.
774 */
775Result svcSendAsyncRequestWithUserBuffer(Handle* handle, void* usrBuffer, u64 size, Handle session);
776
777///@}
778
779///@name Process and thread management
780///@{
781
782/**
783 * @brief Gets the PID associated with a process.
784 * @return Result code.
785 * @note Syscall number 0x24.
786 */
787Result svcGetProcessId(u64 *processID, Handle handle);
788
789/**
790 * @brief Gets the TID associated with a process.
791 * @return Result code.
792 * @note Syscall number 0x25.
793 */
794Result svcGetThreadId(u64 *threadID, Handle handle);
795
796///@}
797
798///@name Miscellaneous
799///@{
800
801/**
802 * @brief Breaks execution.
803 * @param[in] breakReason Break reason (see \ref BreakReason).
804 * @param[in] address Address of the buffer to pass to the debugger.
805 * @param[in] size Size of the buffer to pass to the debugger.
806 * @return Result code.
807 * @note Syscall number 0x26.
808 */
809Result svcBreak(u32 breakReason, uintptr_t address, uintptr_t size);
810
811///@}
812
813///@name Debugging
814///@{
815
816/**
817 * @brief Outputs debug text, if used during debugging.
818 * @param[in] str Text to output.
819 * @param[in] size Size of the text in bytes.
820 * @return Result code.
821 * @note Syscall number 0x27.
822 */
823Result svcOutputDebugString(const char *str, u64 size);
824
825///@}
826
827///@name Miscellaneous
828///@{
829
830/**
831 * @brief Returns from an exception.
832 * @param[in] res Result code.
833 * @note Syscall number 0x28.
834 */
836
837/**
838 * @brief Retrieves information about the system, or a certain kernel object.
839 * @param[out] out Variable to which store the information.
840 * @param[in] id0 First ID of the property to retrieve.
841 * @param[in] handle Handle of the object to retrieve information from, or \ref INVALID_HANDLE to retrieve information about the system.
842 * @param[in] id1 Second ID of the property to retrieve.
843 * @return Result code.
844 * @remark The full list of property IDs can be found on the <a href="https://switchbrew.org/wiki/SVC#svcGetInfo">switchbrew.org wiki</a>.
845 * @note Syscall number 0x29.
846 */
847Result svcGetInfo(u64* out, u32 id0, Handle handle, u64 id1);
848
849///@}
850
851///@name Cache Management
852///@{
853
854/**
855 * @brief Flushes the entire data cache (by set/way).
856 * @note Syscall number 0x2A.
857 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
858 * @warning This syscall is dangerous, and should not be used.
859 */
861
862/**
863 * @brief Flushes data cache for a virtual address range.
864 * @param[in] address Address of region to flush.
865 * @param[in] size Size of region to flush.
866 * @remark armDCacheFlush should be used instead of this syscall whenever possible.
867 * @note Syscall number 0x2B.
868 */
869Result svcFlushDataCache(void *address, size_t size);
870
871///@}
872
873///@name Memory management
874///@{
875
876/**
877 * @brief Maps new heap memory at the desired address. [3.0.0+]
878 * @return Result code.
879 * @note Syscall number 0x2C.
880 */
881Result svcMapPhysicalMemory(void *address, u64 size);
882
883/**
884 * @brief Undoes the effects of \ref svcMapPhysicalMemory. [3.0.0+]
885 * @return Result code.
886 * @note Syscall number 0x2D.
887 */
888Result svcUnmapPhysicalMemory(void *address, u64 size);
889
890///@}
891
892///@name Process and thread management
893///@{
894
895/**
896 * @brief Gets information about a thread that will be scheduled in the future. [5.0.0+]
897 * @param[out] out_context Output \ref LastThreadContext for the thread that will be scheduled.
898 * @param[out] out_thread_id Output thread id for the thread that will be scheduled.
899 * @param[in] debug Debug handle.
900 * @param[in] ns Nanoseconds in the future to get scheduled thread at.
901 * @return Result code.
902 * @note Syscall number 0x2E.
903 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
904 */
905Result svcGetDebugFutureThreadInfo(LastThreadContext *out_context, u64 *out_thread_id, Handle debug, s64 ns);
906
907/**
908 * @brief Gets information about the previously-scheduled thread.
909 * @param[out] out_context Output \ref LastThreadContext for the previously scheduled thread.
910 * @param[out] out_tls_address Output tls address for the previously scheduled thread.
911 * @param[out] out_flags Output flags for the previously scheduled thread.
912 * @return Result code.
913 * @note Syscall number 0x2F.
914 */
915Result svcGetLastThreadInfo(LastThreadContext *out_context, u64 *out_tls_address, u32 *out_flags);
916
917///@}
918
919///@name Resource Limit Management
920///@{
921
922/**
923 * @brief Gets the maximum value a LimitableResource can have, for a Resource Limit handle.
924 * @return Result code.
925 * @note Syscall number 0x30.
926 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
927 */
929
930/**
931 * @brief Gets the maximum value a LimitableResource can have, for a Resource Limit handle.
932 * @return Result code.
933 * @note Syscall number 0x31.
934 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
935 */
937
938///@}
939
940///@name Process and thread management
941///@{
942
943/**
944 * @brief Configures the pause/unpause status of a thread.
945 * @return Result code.
946 * @note Syscall number 0x32.
947 */
949
950/**
951 * @brief Dumps the registers of a thread paused by @ref svcSetThreadActivity (register groups: all).
952 * @param[out] ctx Output thread context (register dump).
953 * @param[in] thread Thread handle.
954 * @return Result code.
955 * @note Syscall number 0x33.
956 * @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.
957 */
959
960///@}
961
962///@name Synchronization
963///@{
964
965/**
966 * @brief Arbitrates an address depending on type and value. [4.0.0+]
967 * @param[in] address Address to arbitrate.
968 * @param[in] arb_type \ref ArbitrationType to use.
969 * @param[in] value Value to arbitrate on.
970 * @param[in] timeout Maximum time in nanoseconds to wait.
971 * @return Result code.
972 * @note Syscall number 0x34.
973 */
974Result svcWaitForAddress(void *address, u32 arb_type, s64 value, s64 timeout);
975
976/**
977 * @brief Signals (and updates) an address depending on type and value. [4.0.0+]
978 * @param[in] address Address to arbitrate.
979 * @param[in] signal_type \ref SignalType to use.
980 * @param[in] value Value to arbitrate on.
981 * @param[in] count Number of waiting threads to signal.
982 * @return Result code.
983 * @note Syscall number 0x35.
984 */
985Result svcSignalToAddress(void *address, u32 signal_type, s32 value, s32 count);
986
987///@}
988
989///@name Miscellaneous
990///@{
991
992/**
993 * @brief Sets thread preemption state (used during abort/panic). [8.0.0+]
994 * @note Syscall number 0x36.
995 */
997
998///@}
999
1000///@name Resource Limit Management
1001///@{
1002
1003/**
1004 * @brief Gets the peak value a LimitableResource has had, for a Resource Limit handle. [11.0.0+]
1005 * @return Result code.
1006 * @note Syscall number 0x37.
1007 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1008 */
1010
1011///@}
1012
1013///@name Memory Management
1014///@{
1015
1016/**
1017 * @brief Creates an IO Pool. [13.0.0+]
1018 * @return Result code.
1019 * @note Syscall number 0x39.
1020 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1021 */
1022Result svcCreateIoPool(Handle *out_handle, u32 pool_type);
1023
1024/**
1025 * @brief Creates an IO Region. [13.0.0+]
1026 * @return Result code.
1027 * @note Syscall number 0x3A.
1028 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1029 */
1030Result svcCreateIoRegion(Handle *out_handle, Handle io_pool_h, u64 physical_address, u64 size, u32 memory_mapping, u32 perm);
1031
1032///@}
1033
1034///@name Debugging
1035///@{
1036/**
1037 * @brief Causes the kernel to dump debug information. [1.0.0-3.0.2]
1038 * @param[in] dump_info_type Type of information to dump.
1039 * @param[in] arg0 Argument to the debugging operation.
1040 * @note Syscall number 0x3C.
1041 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1042 */
1043void svcDumpInfo(u32 dump_info_type, u64 arg0);
1044
1045/**
1046 * @brief Performs a debugging operation on the kernel. [4.0.0+]
1047 * @param[in] kern_debug_type Type of debugging operation to perform.
1048 * @param[in] arg0 First argument to the debugging operation.
1049 * @param[in] arg1 Second argument to the debugging operation.
1050 * @param[in] arg2 Third argument to the debugging operation.
1051 * @note Syscall number 0x3C.
1052 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1053 */
1054void svcKernelDebug(u32 kern_debug_type, u64 arg0, u64 arg1, u64 arg2);
1055
1056/**
1057 * @brief Performs a debugging operation on the kernel. [4.0.0+]
1058 * @param[in] kern_trace_state Type of tracing the kernel should perform.
1059 * @note Syscall number 0x3D.
1060 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1061 */
1062void svcChangeKernelTraceState(u32 kern_trace_state);
1063
1064///@}
1065 \
1066///@name Inter-process communication (IPC)
1067///@{
1068
1069/**
1070 * @brief Creates an IPC session.
1071 * @return Result code.
1072 * @note Syscall number 0x40.
1073 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1074 */
1075Result svcCreateSession(Handle *server_handle, Handle *client_handle, u32 unk0, u64 unk1);//unk* are normally 0?
1076
1077/**
1078 * @brief Accepts an IPC session.
1079 * @return Result code.
1080 * @note Syscall number 0x41.
1081 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1082 */
1083Result svcAcceptSession(Handle *session_handle, Handle port_handle);
1084
1085/**
1086 * @brief Performs light IPC input/output.
1087 * @return Result code.
1088 * @param[in] handle Server or port handle to act on.
1089 * @note Syscall number 0x42.
1090 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1091 */
1093
1094/**
1095 * @brief Performs IPC input/output.
1096 * @return Result code.
1097 * @note Syscall number 0x43.
1098 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1099 */
1100Result svcReplyAndReceive(s32* index, const Handle* handles, s32 handleCount, Handle replyTarget, u64 timeout);
1101
1102/**
1103 * @brief Performs IPC input/output from an user allocated buffer.
1104 * @return Result code.
1105 * @note Syscall number 0x44.
1106 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1107 */
1108Result svcReplyAndReceiveWithUserBuffer(s32* index, void* usrBuffer, u64 size, const Handle* handles, s32 handleCount, Handle replyTarget, u64 timeout);
1109
1110///@}
1111
1112///@name Synchronization
1113///@{
1114
1115/**
1116 * @brief Creates a system event.
1117 * @return Result code.
1118 * @note Syscall number 0x45.
1119 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1120 */
1121Result svcCreateEvent(Handle* server_handle, Handle* client_handle);
1122
1123///@}
1124
1125///@name Memory management
1126///@{
1127
1128/**
1129 * @brief Maps an IO Region. [13.0.0+]
1130 * @return Result code.
1131 * @note Syscall number 0x46.
1132 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1133 */
1134Result svcMapIoRegion(Handle io_region_h, void *address, u64 size, u32 perm);
1135
1136/**
1137 * @brief Undoes the effects of \ref svcMapIoRegion. [13.0.0+]
1138 * @return Result code.
1139 * @note Syscall number 0x47.
1140 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1141 */
1142Result svcUnmapIoRegion(Handle io_region_h, void *address, u64 size);
1143
1144/**
1145 * @brief Maps unsafe memory (usable for GPU DMA) for a system module at the desired address. [5.0.0+]
1146 * @return Result code.
1147 * @note Syscall number 0x48.
1148 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1149 */
1151
1152/**
1153 * @brief Undoes the effects of \ref svcMapPhysicalMemoryUnsafe. [5.0.0+]
1154 * @return Result code.
1155 * @note Syscall number 0x49.
1156 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1157 */
1159
1160/**
1161 * @brief Sets the system-wide limit for unsafe memory mappable using \ref svcMapPhysicalMemoryUnsafe. [5.0.0+]
1162 * @return Result code.
1163 * @note Syscall number 0x4A.
1164 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1165 */
1167
1168///@}
1169
1170
1171///@name Code memory / Just-in-time (JIT) compilation support
1172///@{
1173
1174/**
1175 * @brief Creates code memory in the caller's address space [4.0.0+].
1176 * @return Result code.
1177 * @note Syscall number 0x4B.
1178 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1179 */
1180Result svcCreateCodeMemory(Handle* code_handle, void* src_addr, u64 size);
1181
1182/**
1183 * @brief Maps code memory in the caller's address space [4.0.0+].
1184 * @return Result code.
1185 * @note Syscall number 0x4C.
1186 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1187 */
1188Result svcControlCodeMemory(Handle code_handle, CodeMapOperation op, void* dst_addr, u64 size, u64 perm);
1189
1190///@}
1191
1192///@name Power Management
1193///@{
1194
1195/**
1196 * @brief Causes the system to enter deep sleep.
1197 * @note Syscall number 0x4D.
1198 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1199 */
1201
1202///@}
1203
1204///@name Device memory-mapped I/O (MMIO)
1205///@{
1206
1207/**
1208 * @brief Reads/writes a protected MMIO register.
1209 * @return Result code.
1210 * @note Syscall number 0x4E.
1211 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1212 */
1213Result svcReadWriteRegister(u32* outVal, u64 regAddr, u32 rwMask, u32 inVal);
1214
1215///@}
1216
1217///@name Process and thread management
1218///@{
1219
1220/**
1221 * @brief Configures the pause/unpause status of a process.
1222 * @return Result code.
1223 * @note Syscall number 0x4F.
1224 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1225 */
1227
1228///@}
1229
1230///@name Inter-process memory sharing
1231///@{
1232
1233/**
1234 * @brief Creates a block of shared memory.
1235 * @return Result code.
1236 * @note Syscall number 0x50.
1237 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1238 */
1239Result svcCreateSharedMemory(Handle* out, size_t size, u32 local_perm, u32 other_perm);
1240
1241/**
1242 * @brief Maps a block of transfer memory.
1243 * @return Result code.
1244 * @note Syscall number 0x51.
1245 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1246 */
1247Result svcMapTransferMemory(Handle tmem_handle, void* addr, size_t size, u32 perm);
1248
1249/**
1250 * @brief Unmaps a block of transfer memory.
1251 * @return Result code.
1252 * @note Syscall number 0x52.
1253 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1254 */
1255Result svcUnmapTransferMemory(Handle tmem_handle, void* addr, size_t size);
1256
1257///@}
1258
1259///@name Device memory-mapped I/O (MMIO)
1260///@{
1261
1262/**
1263 * @brief Creates an event and binds it to a specific hardware interrupt.
1264 * @return Result code.
1265 * @note Syscall number 0x53.
1266 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1267 */
1269
1270/**
1271 * @brief Queries information about a certain virtual address, including its physical address.
1272 * @return Result code.
1273 * @note Syscall number 0x54.
1274 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1275 */
1277
1278/**
1279 * @brief Returns a virtual address mapped to a given IO range.
1280 * @return Result code.
1281 * @note Syscall number 0x55.
1282 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1283 * @warning Only exists on [10.0.0+]. For older versions use \ref svcLegacyQueryIoMapping.
1284 */
1285Result svcQueryMemoryMapping(u64* virtaddr, u64* out_size, u64 physaddr, u64 size);
1286
1287/**
1288 * @brief Returns a virtual address mapped to a given IO range.
1289 * @return Result code.
1290 * @note Syscall number 0x55.
1291 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1292 * @warning Only exists on [1.0.0-9.2.0]. For newer versions use \ref svcQueryMemoryMapping.
1293 */
1294Result svcLegacyQueryIoMapping(u64* virtaddr, u64 physaddr, u64 size);
1295
1296///@}
1297
1298///@name I/O memory management unit (IOMMU)
1299///@{
1300
1301/**
1302 * @brief Creates a virtual address space for binding device address spaces.
1303 * @return Result code.
1304 * @note Syscall number 0x56.
1305 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1306 */
1307Result svcCreateDeviceAddressSpace(Handle *handle, u64 dev_addr, u64 dev_size);
1308
1309/**
1310 * @brief Attaches a device address space to a device.
1311 * @return Result code.
1312 * @note Syscall number 0x57.
1313 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1314 */
1316
1317/**
1318 * @brief Detaches a device address space from a device.
1319 * @return Result code.
1320 * @note Syscall number 0x58.
1321 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1322 */
1324
1325/**
1326 * @brief Maps an attached device address space to an userspace address.
1327 * @return Result code.
1328 * @remark The userspace destination address must have the \ref MemState_MapDeviceAllowed bit set.
1329 * @note Syscall number 0x59.
1330 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1331 */
1332Result svcMapDeviceAddressSpaceByForce(Handle handle, Handle proc_handle, u64 map_addr, u64 dev_size, u64 dev_addr, u32 option);
1333
1334/**
1335 * @brief Maps an attached device address space to an userspace address.
1336 * @return Result code.
1337 * @remark The userspace destination address must have the \ref MemState_MapDeviceAlignedAllowed bit set.
1338 * @note Syscall number 0x5A.
1339 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1340 */
1341Result svcMapDeviceAddressSpaceAligned(Handle handle, Handle proc_handle, u64 map_addr, u64 dev_size, u64 dev_addr, u32 option);
1342
1343/**
1344 * @brief Maps an attached device address space to an userspace address. [1.0.0-12.1.0]
1345 * @return Result code.
1346 * @remark The userspace destination address must have the \ref MemState_MapDeviceAlignedAllowed bit set.
1347 * @note Syscall number 0x5B.
1348 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1349 */
1350Result svcMapDeviceAddressSpace(u64 *out_mapped_size, Handle handle, Handle proc_handle, u64 map_addr, u64 dev_size, u64 dev_addr, u32 perm);
1351
1352/**
1353 * @brief Unmaps an attached device address space from an userspace address.
1354 * @return Result code.
1355 * @note Syscall number 0x5C.
1356 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1357 */
1358Result svcUnmapDeviceAddressSpace(Handle handle, Handle proc_handle, u64 map_addr, u64 map_size, u64 dev_addr);
1359
1360///@}
1361
1362///@name Cache Management
1363///@{
1364
1365/**
1366 * @brief Invalidates data cache for a virtual address range within a process.
1367 * @param[in] address Address of region to invalidate.
1368 * @param[in] size Size of region to invalidate.
1369 * @note Syscall number 0x5D.
1370 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1371 */
1372Result svcInvalidateProcessDataCache(Handle process, uintptr_t address, size_t size);
1373
1374/**
1375 * @brief Stores data cache for a virtual address range within a process.
1376 * @param[in] address Address of region to store.
1377 * @param[in] size Size of region to store.
1378 * @note Syscall number 0x5E.
1379 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1380 */
1381Result svcStoreProcessDataCache(Handle process, uintptr_t address, size_t size);
1382
1383/**
1384 * @brief Flushes data cache for a virtual address range within a process.
1385 * @param[in] address Address of region to flush.
1386 * @param[in] size Size of region to flush.
1387 * @note Syscall number 0x5F.
1388 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1389 */
1390Result svcFlushProcessDataCache(Handle process, uintptr_t address, size_t size);
1391
1392///@}
1393
1394///@name Debugging
1395///@{
1396
1397/**
1398 * @brief Debugs an active process.
1399 * @return Result code.
1400 * @note Syscall number 0x60.
1401 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1402 */
1404
1405/**
1406 * @brief Breaks an active debugging session.
1407 * @return Result code.
1408 * @note Syscall number 0x61.
1409 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1410 */
1412
1413/**
1414 * @brief Terminates the process of an active debugging session.
1415 * @return Result code.
1416 * @note Syscall number 0x62.
1417 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1418 */
1420
1421/**
1422 * @brief Gets an incoming debug event from a debugging session.
1423 * @return Result code.
1424 * @note Syscall number 0x63.
1425 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1426 */
1428
1429/**
1430 * @brief Continues a debugging session.
1431 * @return Result code.
1432 * @note Syscall number 0x64.
1433 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1434 * @warning Only exists on [3.0.0+]. For older versions use \ref svcLegacyContinueDebugEvent.
1435 */
1436Result svcContinueDebugEvent(Handle debug, u32 flags, u64* tid_list, u32 num_tids);
1437
1438/**
1439 * @brief Continues a debugging session.
1440 * @return Result code.
1441 * @note Syscall number 0x64.
1442 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1443 * @warning Only exists on [1.0.0-2.3.0]. For newer versions use \ref svcContinueDebugEvent.
1444 */
1446
1447/**
1448 * @brief Gets the context (dump the registers) of a thread in a debugging session.
1449 * @return Result code.
1450 * @param[out] ctx Output thread context (register dump).
1451 * @param[in] debug Debug handle.
1452 * @param[in] threadID ID of the thread to dump the context of.
1453 * @param[in] flags Register groups to select, combination of @ref RegisterGroup flags.
1454 * @note Syscall number 0x67.
1455 * @warning Official kernel will not dump any CPU GPR if the thread is currently executing a system call (except @ref svcBreak and @ref svcReturnFromException).
1456 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1457 */
1459
1460/**
1461 * @brief Gets the context (dump the registers) of a thread in a debugging session.
1462 * @return Result code.
1463 * @param[in] debug Debug handle.
1464 * @param[in] threadID ID of the thread to set the context of.
1465 * @param[in] ctx Input thread context (register dump).
1466 * @param[in] flags Register groups to select, combination of @ref RegisterGroup flags.
1467 * @note Syscall number 0x68.
1468 * @warning Official kernel will return an error if the thread is currently executing a system call (except @ref svcBreak and @ref svcReturnFromException).
1469 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1470 */
1471Result svcSetDebugThreadContext(Handle debug, u64 threadID, const ThreadContext* ctx, u32 flags);
1472
1473///@}
1474
1475///@name Process and thread management
1476///@{
1477
1478/**
1479 * @brief Retrieves a list of all running processes.
1480 * @return Result code.
1481 * @note Syscall number 0x65.
1482 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1483 */
1484Result svcGetProcessList(s32 *num_out, u64 *pids_out, u32 max_pids);
1485
1486/**
1487 * @brief Retrieves a list of all threads for a debug handle (or zero).
1488 * @return Result code.
1489 * @note Syscall number 0x66.
1490 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1491 */
1492Result svcGetThreadList(s32 *num_out, u64 *tids_out, u32 max_tids, Handle debug);
1493
1494///@}
1495
1496///@name Debugging
1497///@{
1498
1499/**
1500 * @brief Queries memory information from a process that is being debugged.
1501 * @return Result code.
1502 * @note Syscall number 0x69.
1503 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1504 */
1505Result svcQueryDebugProcessMemory(MemoryInfo* meminfo_ptr, u32* pageinfo, Handle debug, u64 addr);
1506
1507/**
1508 * @brief Reads memory from a process that is being debugged.
1509 * @return Result code.
1510 * @note Syscall number 0x6A.
1511 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1512 */
1513Result svcReadDebugProcessMemory(void* buffer, Handle debug, u64 addr, u64 size);
1514
1515/**
1516 * @brief Writes to memory in a process that is being debugged.
1517 * @return Result code.
1518 * @note Syscall number 0x6B.
1519 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1520 */
1521Result svcWriteDebugProcessMemory(Handle debug, const void* buffer, u64 addr, u64 size);
1522
1523/**
1524 * @brief Sets one of the hardware breakpoints.
1525 * @return Result code.
1526 * @note Syscall number 0x6C.
1527 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1528 */
1530
1531/**
1532 * @brief Gets parameters from a thread in a debugging session.
1533 * @return Result code.
1534 * @note Syscall number 0x6D.
1535 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1536 */
1537Result svcGetDebugThreadParam(u64* out_64, u32* out_32, Handle debug, u64 threadID, DebugThreadParam param);
1538
1539///@}
1540
1541///@name Miscellaneous
1542///@{
1543
1544/**
1545 * @brief Retrieves privileged information about the system, or a certain kernel object.
1546 * @param[out] out Variable to which store the information.
1547 * @param[in] id0 First ID of the property to retrieve.
1548 * @param[in] handle Handle of the object to retrieve information from, or \ref INVALID_HANDLE to retrieve information about the system.
1549 * @param[in] id1 Second ID of the property to retrieve.
1550 * @return Result code.
1551 * @remark The full list of property IDs can be found on the <a href="https://switchbrew.org/wiki/SVC#svcGetSystemInfo">switchbrew.org wiki</a>.
1552 * @note Syscall number 0x6F.
1553 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1554 */
1555Result svcGetSystemInfo(u64* out, u64 id0, Handle handle, u64 id1);
1556
1557///@}
1558
1559///@name Inter-process communication (IPC)
1560///@{
1561
1562/**
1563 * @brief Creates a port.
1564 * @return Result code.
1565 * @note Syscall number 0x70.
1566 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1567 */
1568Result svcCreatePort(Handle* portServer, Handle *portClient, s32 max_sessions, bool is_light, const char* name);
1569
1570/**
1571 * @brief Manages a named port.
1572 * @return Result code.
1573 * @note Syscall number 0x71.
1574 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1575 */
1576Result svcManageNamedPort(Handle* portServer, const char* name, s32 maxSessions);
1577
1578/**
1579 * @brief Manages a named port.
1580 * @return Result code.
1581 * @note Syscall number 0x72.
1582 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1583 */
1585
1586///@}
1587
1588///@name Memory management
1589///@{
1590
1591/**
1592 * @brief Sets the memory permissions for the specified memory with the supplied process handle.
1593 * @param[in] proc Process handle.
1594 * @param[in] addr Address of the memory.
1595 * @param[in] size Size of the memory.
1596 * @param[in] perm Permissions (see \ref Permission).
1597 * @return Result code.
1598 * @remark This returns an error (0xD801) when \p perm is >0x5, hence -WX and RWX are not allowed.
1599 * @note Syscall number 0x73.
1600 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1601 */
1603
1604/**
1605 * @brief Maps the src address from the supplied process handle into the current process.
1606 * @param[in] dst Address to which map the memory in the current process.
1607 * @param[in] proc Process handle.
1608 * @param[in] src Source mapping address.
1609 * @param[in] size Size of the memory.
1610 * @return Result code.
1611 * @remark This allows mapping code and rodata with RW- permission.
1612 * @note Syscall number 0x74.
1613 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1614 */
1615Result svcMapProcessMemory(void* dst, Handle proc, u64 src, u64 size);
1616
1617/**
1618 * @brief Undoes the effects of \ref svcMapProcessMemory.
1619 * @param[in] dst Destination mapping address
1620 * @param[in] proc Process handle.
1621 * @param[in] src Address of the memory in the process.
1622 * @param[in] size Size of the memory.
1623 * @return Result code.
1624 * @remark This allows mapping code and rodata with RW- permission.
1625 * @note Syscall number 0x75.
1626 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1627 */
1628Result svcUnmapProcessMemory(void* dst, Handle proc, u64 src, u64 size);
1629
1630/**
1631 * @brief Equivalent to \ref svcQueryMemory, for another process.
1632 * @param[out] meminfo_ptr \ref MemoryInfo structure which will be filled in.
1633 * @param[out] pageinfo Page information which will be filled in.
1634 * @param[in] proc Process handle.
1635 * @param[in] addr Address to query.
1636 * @return Result code.
1637 * @note Syscall number 0x76.
1638 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1639 */
1640Result svcQueryProcessMemory(MemoryInfo* meminfo_ptr, u32 *pageinfo, Handle proc, u64 addr);
1641
1642/**
1643 * @brief Maps normal heap in a certain process as executable code (used when loading NROs).
1644 * @param[in] proc Process handle (cannot be \ref CUR_PROCESS_HANDLE).
1645 * @param[in] dst Destination mapping address.
1646 * @param[in] src Source mapping address.
1647 * @param[in] size Size of the mapping.
1648 * @return Result code.
1649 * @note Syscall number 0x77.
1650 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1651 */
1653
1654/**
1655 * @brief Undoes the effects of \ref svcMapProcessCodeMemory.
1656 * @param[in] proc Process handle (cannot be \ref CUR_PROCESS_HANDLE).
1657 * @param[in] dst Destination mapping address.
1658 * @param[in] src Source mapping address.
1659 * @param[in] size Size of the mapping.
1660 * @return Result code.
1661 * @note Syscall number 0x78.
1662 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1663 */
1665
1666///@}
1667
1668///@name Process and thread management
1669///@{
1670
1671/**
1672 * @brief Creates a new process.
1673 * @return Result code.
1674 * @note Syscall number 0x79.
1675 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1676 */
1677Result svcCreateProcess(Handle* out, const void* proc_info, const u32* caps, u64 cap_num);
1678
1679/**
1680 * @brief Starts executing a freshly created process.
1681 * @return Result code.
1682 * @note Syscall number 0x7A.
1683 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1684 */
1685Result svcStartProcess(Handle proc, s32 main_prio, s32 default_cpu, u32 stack_size);
1686
1687/**
1688 * @brief Terminates a running process.
1689 * @return Result code.
1690 * @note Syscall number 0x7B.
1691 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1692 */
1694
1695/**
1696 * @brief Gets a \ref ProcessInfoType for a process.
1697 * @return Result code.
1698 * @note Syscall number 0x7C.
1699 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1700 */
1702
1703///@}
1704
1705///@name Resource Limit Management
1706///@{
1707
1708/**
1709 * @brief Creates a new Resource Limit handle.
1710 * @return Result code.
1711 * @note Syscall number 0x7D.
1712 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1713 */
1715
1716/**
1717 * @brief Sets the value for a \ref LimitableResource for a Resource Limit handle.
1718 * @return Result code.
1719 * @note Syscall number 0x7E.
1720 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1721 */
1723
1724///@}
1725
1726///@name ( ͡° ͜ʖ ͡°)
1727///@{
1728
1729/**
1730 * @brief Calls a secure monitor function (TrustZone, EL3).
1731 * @param regs Arguments to pass to the secure monitor.
1732 * @note Syscall number 0x7F.
1733 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
1734 */
1736
1737///@}
1738
1739///@name Memory management
1740///@{
1741
1742/**
1743 * @brief Maps new insecure memory at the desired address. [15.0.0+]
1744 * @return Result code.
1745 * @note Syscall number 0x90.
1746 */
1748
1749/**
1750 * @brief Undoes the effects of \ref svcMapInsecureMemory. [15.0.0+]
1751 * @return Result code.
1752 * @note Syscall number 0x91.
1753 */
1755
1756///@}
Flags for svcCreateProcess and CreateProcess event.
Definition svc.h:357
u32 enable_debug
[2.0.0+]
Definition svc.h:360
u32 disable_device_address_space_merge
[11.0.0+]
Definition svc.h:365
u32 enable_alias_region_extra_size
[18.0.0+]
Definition svc.h:366
u32 pool_partition
[4.0.0-4.1.0] MemoryRegion, [5.0.0+] PhysicalMemorySystemInfo
Definition svc.h:363
u32 address_space
CreateProcessFlagAddressSpace
Definition svc.h:359
u32 optimize_memory_allocation
[7.0.0+] Only allowed in combination with is_application
Definition svc.h:364
DebugEvent structure.
Definition svc.h:371
u32 flags
DebugEventFlag
Definition svc.h:373
void * user_exception_context_address
[5.0.0+]
Definition svc.h:383
u32 reason
ProcessExitReason
Definition svc.h:395
void * entrypoint
[1.0.0-10.2.0]
Definition svc.h:390
u32 break_reason
BreakReason
Definition svc.h:431
u32 type
DebugEventType
Definition svc.h:372
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
DebugException
Debug exception types.
Definition svc.h:318
@ DebugException_MemorySystemError
[2.0.0+]
Definition svc.h:328
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.
BreakPointType
Break point types.
Definition svc.h:332
void svcReturnFromException(Result res)
Returns from an exception.
void svcDumpInfo(u32 dump_info_type, u64 arg0)
Causes the kernel to dump debug information.
CreateProcessFlagAddressSpace
Address space types for CreateProcessFlags.
Definition svc.h:343
@ CreateProcessFlagAddressSpace_64bitDeprecated
36-bit width
Definition svc.h:345
@ CreateProcessFlagAddressSpace_64bit
[2.0.0+] 39-bit width
Definition svc.h:347
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
DebugEventFlag
DebugEvent flags.
Definition svc.h:338
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 (only usable with current thread's core).
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 svcGetDebugEvent(DebugEventInfo *event_out, Handle debug)
Gets an incoming debug event from a debugging session.
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:684
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 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.
ThreadExitReason
Thread exit reasons.
Definition svc.h:310
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.
DebugEventType
DebugEvent types.
Definition svc.h:294
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.
ProcessExitReason
Process exit reasons.
Definition svc.h:303
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
ThreadTickCount: Tick count on all cores, IdleTickCount: Thread's current core.
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.
MemoryRegion
Memory regions.
Definition svc.h:351
@ MemoryRegion_Default
[1.0.0-4.1.0]
Definition svc.h:352
@ MemoryRegion_Secure
[2.0.0-4.1.0]
Definition svc.h:353
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