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