libctru  v1.6.0
svc.h
Go to the documentation of this file.
1 /**
2  * @file svc.h
3  * @brief Syscall wrappers.
4  */
5 #pragma once
6 
7 #include "types.h"
8 
9 /// Pseudo handle for the current process
10 #define CUR_PROCESS_HANDLE 0xFFFF8001
11 
12 ///@name Memory management
13 ///@{
14 
15 /**
16  * @brief @ref svcControlMemory operation flags
17  *
18  * The lowest 8 bits are the operation
19  */
20 typedef enum {
21  MEMOP_FREE = 1, ///< Memory un-mapping
22  MEMOP_RESERVE = 2, ///< Reserve memory
23  MEMOP_ALLOC = 3, ///< Memory mapping
24  MEMOP_MAP = 4, ///< Mirror mapping
25  MEMOP_UNMAP = 5, ///< Mirror unmapping
26  MEMOP_PROT = 6, ///< Change protection
27 
28  MEMOP_REGION_APP = 0x100, ///< APPLICATION memory region.
29  MEMOP_REGION_SYSTEM = 0x200, ///< SYSTEM memory region.
30  MEMOP_REGION_BASE = 0x300, ///< BASE memory region.
31 
32  MEMOP_OP_MASK = 0xFF, ///< Operation bitmask.
33  MEMOP_REGION_MASK = 0xF00, ///< Region bitmask.
34  MEMOP_LINEAR_FLAG = 0x10000, ///< Flag for linear memory operations
35 
36  MEMOP_ALLOC_LINEAR = MEMOP_LINEAR_FLAG | MEMOP_ALLOC, ///< Allocates linear memory.
37 } MemOp;
38 
39 /// The state of a memory block.
40 typedef enum {
41  MEMSTATE_FREE = 0, ///< Free memory
42  MEMSTATE_RESERVED = 1, ///< Reserved memory
43  MEMSTATE_IO = 2, ///< I/O memory
44  MEMSTATE_STATIC = 3, ///< Static memory
45  MEMSTATE_CODE = 4, ///< Code memory
46  MEMSTATE_PRIVATE = 5, ///< Private memory
47  MEMSTATE_SHARED = 6, ///< Shared memory
48  MEMSTATE_CONTINUOUS = 7, ///< Continuous memory
49  MEMSTATE_ALIASED = 8, ///< Aliased memory
50  MEMSTATE_ALIAS = 9, ///< Alias memory
51  MEMSTATE_ALIASCODE = 10, ///< Aliased code memory
52  MEMSTATE_LOCKED = 11, ///< Locked memory
53 } MemState;
54 
55 /// Memory permission flags
56 typedef enum {
57  MEMPERM_READ = 1, ///< Readable
58  MEMPERM_WRITE = 2, ///< Writable
59  MEMPERM_EXECUTE = 4, ///< Executable
60  MEMPERM_DONTCARE = 0x10000000, ///< Don't care
61 } MemPerm;
62 
63 /// Memory information.
64 typedef struct {
65  u32 base_addr; ///< Base address.
66  u32 size; ///< Size.
67  u32 perm; ///< Memory permissions. See @ref MemPerm
68  u32 state; ///< Memory state. See @ref MemState
69 } MemInfo;
70 
71 /// Memory page information.
72 typedef struct {
73  u32 flags; ///< Page flags.
74 } PageInfo;
75 
76 /// Arbitration modes.
77 typedef enum {
78  ARBITRATION_SIGNAL = 0, ///< Signal #value threads for wake-up.
79  ARBITRATION_WAIT_IF_LESS_THAN = 1, ///< If the memory at the address is strictly lower than #value, then wait for signal.
80  ARBITRATION_DECREMENT_AND_WAIT_IF_LESS_THAN = 2, ///< If the memory at the address is strictly lower than #value, then decrement it and wait for signal.
81  ARBITRATION_WAIT_IF_LESS_THAN_TIMEOUT = 3, ///< If the memory at the address is strictly lower than #value, then wait for signal or timeout.
82  ARBITRATION_DECREMENT_AND_WAIT_IF_LESS_THAN_TIMEOUT = 4, ///< If the memory at the address is strictly lower than #value, then decrement it and wait for signal or timeout.
84 
85 /// Special value to signal all the threads
86 #define ARBITRATION_SIGNAL_ALL (-1)
87 
88 ///@}
89 
90 ///@name Multithreading
91 ///@{
92 
93 /// Reset types (for use with events and timers)
94 typedef enum {
95  RESET_ONESHOT = 0, ///< When the primitive is signaled, it will wake up exactly one thread and will clear itself automatically.
96  RESET_STICKY = 1, ///< When the primitive is signaled, it will wake up all threads and it won't clear itself automatically.
97  RESET_PULSE = 2, ///< Only meaningful for timers: same as ONESHOT but it will periodically signal the timer instead of just once.
98 } ResetType;
99 
100 /// Types of thread info.
101 typedef enum {
104 
105 /// Types of resource limit
106 typedef enum {
107  RESLIMIT_PRIORITY = 0, ///< Thread priority
108  RESLIMIT_COMMIT = 1, ///< Quantity of allocatable memory
109  RESLIMIT_THREAD = 2, ///< Number of threads
110  RESLIMIT_EVENT = 3, ///< Number of events
111  RESLIMIT_MUTEX = 4, ///< Number of mutexes
112  RESLIMIT_SEMAPHORE = 5, ///< Number of semaphores
113  RESLIMIT_TIMER = 6, ///< Number of timers
114  RESLIMIT_SHAREDMEMORY = 7, ///< Number of shared memory objects, see @ref svcCreateMemoryBlock
115  RESLIMIT_ADDRESSARBITER = 8, ///< Number of address arbiters
116  RESLIMIT_CPUTIME = 9, ///< CPU time. Value expressed in percentage regular until it reaches 90.
117 
118  RESLIMIT_BIT = BIT(31), ///< Forces enum size to be 32 bits
120 
121 /// Pseudo handle for the current thread
122 #define CUR_THREAD_HANDLE 0xFFFF8000
123 
124 ///@}
125 
126 
127 ///@name Debugging
128 ///@{
129 
130 /// Event relating to the attachment of a process.
131 typedef struct {
132  u64 program_id; ///< ID of the program.
133  char process_name[8]; ///< Name of the process.
134  u32 process_id; ///< ID of the process.
135  u32 other_flags; ///< Always 0
137 
138 /// Reasons for an exit process event.
139 typedef enum {
140  EXITPROCESS_EVENT_EXIT = 0, ///< Process exited either normally or due to an uncaught exception.
141  EXITPROCESS_EVENT_TERMINATE = 1, ///< Process has been terminated by @ref svcTerminateProcess.
142  EXITPROCESS_EVENT_DEBUG_TERMINATE = 2, ///< Process has been terminated by @ref svcTerminateDebugProcess.
144 
145 /// Event relating to the exiting of a process.
146 typedef struct {
147  ExitProcessEventReason reason; ///< Reason for exiting. See @ref ExitProcessEventReason
149 
150 /// Event relating to the attachment of a thread.
151 typedef struct {
152  u32 creator_thread_id; ///< ID of the creating thread.
153  u32 thread_local_storage; ///< Thread local storage.
154  u32 entry_point; ///< Entry point of the thread.
156 
157 /// Reasons for an exit thread event.
158 typedef enum {
159  EXITTHREAD_EVENT_EXIT = 0, ///< Thread exited.
160  EXITTHREAD_EVENT_TERMINATE = 1, ///< Thread terminated.
161  EXITTHREAD_EVENT_EXIT_PROCESS = 2, ///< Process exited either normally or due to an uncaught exception.
162  EXITTHREAD_EVENT_TERMINATE_PROCESS = 3, ///< Process has been terminated by @ref svcTerminateProcess.
164 
165 /// Event relating to the exiting of a thread.
166 typedef struct {
167  ExitThreadEventReason reason; ///< Reason for exiting. See @ref ExitThreadEventReason
169 
170 /// Reasons for a user break.
171 typedef enum {
172  USERBREAK_PANIC = 0, ///< Panic.
173  USERBREAK_ASSERT = 1, ///< Assertion failed.
174  USERBREAK_USER = 2, ///< User related.
175  USERBREAK_LOAD_RO = 3, ///< Load RO.
176  USERBREAK_UNLOAD_RO = 4, ///< Unload RO.
177 } UserBreakType;
178 
179 /// Reasons for an exception event.
180 typedef enum {
181  EXCEVENT_UNDEFINED_INSTRUCTION = 0, ///< Undefined instruction.
182  EXCEVENT_PREFETCH_ABORT = 1, ///< Prefetch abort.
183  EXCEVENT_DATA_ABORT = 2, ///< Data abort (other than the below kind).
184  EXCEVENT_UNALIGNED_DATA_ACCESS = 3, ///< Unaligned data access.
185  EXCEVENT_ATTACH_BREAK = 4, ///< Attached break.
186  EXCEVENT_STOP_POINT = 5, ///< Stop point reached.
187  EXCEVENT_USER_BREAK = 6, ///< User break occurred.
188  EXCEVENT_DEBUGGER_BREAK = 7, ///< Debugger break occurred.
189  EXCEVENT_UNDEFINED_SYSCALL = 8, ///< Undefined syscall.
191 
192 /// Event relating to fault exceptions (CPU exceptions other than stop points and undefined syscalls).
193 typedef struct {
194  u32 fault_information; ///< FAR (for DATA ABORT / UNALIGNED DATA ACCESS), attempted syscall or 0
196 
197 /// Stop point types
198 typedef enum {
199  STOPPOINT_SVC_FF = 0, ///< See @ref SVC_STOP_POINT.
200  STOPPOINT_BREAKPOINT = 1, ///< Breakpoint.
201  STOPPOINT_WATCHPOINT = 2, ///< Watchpoint.
202 } StopPointType;
203 
204 /// Event relating to stop points
205 typedef struct {
206  StopPointType type; ///< Stop point type, see @ref StopPointType.
207  u32 fault_information; ///< FAR for Watchpoints, otherwise 0.
209 
210 /// Event relating to @ref svcBreak
211 typedef struct {
212  UserBreakType type; ///< User break type, see @ref UserBreakType.
213  u32 croInfo; ///< For LOAD_RO and UNLOAD_RO.
214  u32 croInfoSize; ///< For LOAD_RO and UNLOAD_RO.
216 
217 /// Event relating to @ref svcBreakDebugProcess
218 typedef struct {
219  s32 thread_ids[4]; ///< IDs of the attached process's threads that were running on each core at the time of the @ref svcBreakDebugProcess call, or -1 (only the first 2 values are meaningful on O3DS).
221 
222 /// Event relating to exceptions.
223 typedef struct {
224  ExceptionEventType type; ///< Type of event. See @ref ExceptionEventType.
225  u32 address; ///< Address of the exception.
226  union {
227  FaultExceptionEvent fault; ///< Fault exception event data.
228  StopPointExceptionEvent stop_point; ///< Stop point exception event data.
229  UserBreakExceptionEvent user_break; ///< User break exception event data.
230  DebuggerBreakExceptionEvent debugger_break; ///< Debugger break exception event data
231  };
233 
234 /// Event relating to the scheduler.
235 typedef struct {
236  u64 clock_tick; ///< Clock tick that the event occurred.
238 
239 /// Event relating to syscalls.
240 typedef struct {
241  u64 clock_tick; ///< Clock tick that the event occurred.
242  u32 syscall; ///< Syscall sent/received.
244 
245 /// Event relating to debug output.
246 typedef struct {
247  u32 string_addr; ///< Address of the outputted string.
248  u32 string_size; ///< Size of the outputted string.
250 
251 /// Event relating to the mapping of memory.
252 typedef struct {
253  u32 mapped_addr; ///< Mapped address.
254  u32 mapped_size; ///< Mapped size.
255  MemPerm memperm; ///< Memory permissions. See @ref MemPerm.
256  MemState memstate; ///< Memory state. See @ref MemState.
257 } MapEvent;
258 
259 /// Debug event type.
260 typedef enum {
261  DBGEVENT_ATTACH_PROCESS = 0, ///< Process attached event.
262  DBGEVENT_ATTACH_THREAD = 1, ///< Thread attached event.
263  DBGEVENT_EXIT_THREAD = 2, ///< Thread exit event.
264  DBGEVENT_EXIT_PROCESS = 3, ///< Process exit event.
265  DBGEVENT_EXCEPTION = 4, ///< Exception event.
266  DBGEVENT_DLL_LOAD = 5, ///< DLL load event.
267  DBGEVENT_DLL_UNLOAD = 6, ///< DLL unload event.
268  DBGEVENT_SCHEDULE_IN = 7, ///< Schedule in event.
269  DBGEVENT_SCHEDULE_OUT = 8, ///< Schedule out event.
270  DBGEVENT_SYSCALL_IN = 9, ///< Syscall in event.
271  DBGEVENT_SYSCALL_OUT = 10, ///< Syscall out event.
272  DBGEVENT_OUTPUT_STRING = 11, ///< Output string event.
273  DBGEVENT_MAP = 12, ///< Map event.
275 
276 /// Information about a debug event.
277 typedef struct {
278  DebugEventType type; ///< Type of event. See @ref DebugEventType
279  u32 thread_id; ///< ID of the thread.
280  u32 flags; ///< Flags. Bit0 means that @ref svcContinueDebugEvent needs to be called for this event (except for EXIT PROCESS events, where this flag is disregarded).
281  u8 remnants[4]; ///< Always 0.
282  union {
283  AttachProcessEvent attach_process; ///< Process attachment event data.
284  AttachThreadEvent attach_thread; ///< Thread attachment event data.
285  ExitThreadEvent exit_thread; ///< Thread exit event data.
286  ExitProcessEvent exit_process; ///< Process exit event data.
287  ExceptionEvent exception; ///< Exception event data.
288  /* DLL_LOAD and DLL_UNLOAD do not seem to possess any event data */
289  ScheduleInOutEvent scheduler; ///< Schedule in/out event data.
290  SyscallInOutEvent syscall; ///< Syscall in/out event data.
291  OutputStringEvent output_string; ///< Output string event data.
292  MapEvent map; ///< Map event data.
293  };
295 
296 /// Debug flags for an attached process, set by @ref svcContinueDebugEvent
297 typedef enum {
298  DBG_INHIBIT_USER_CPU_EXCEPTION_HANDLERS = BIT(0), ///< Inhibit user-defined CPU exception handlers (including watchpoints and breakpoints, regardless of any @ref svcKernelSetState call).
299  DBG_SIGNAL_FAULT_EXCEPTION_EVENTS = BIT(1), ///< Signal fault exception events. See @ref FaultExceptionEvent.
300  DBG_SIGNAL_SCHEDULE_EVENTS = BIT(2), ///< Signal schedule in/out events. See @ref ScheduleInOutEvent.
301  DBG_SIGNAL_SYSCALL_EVENTS = BIT(3), ///< Signal syscall in/out events. See @ref SyscallInOutEvent.
302  DBG_SIGNAL_MAP_EVENTS = BIT(4), ///< Signal map events. See @ref MapEvent.
303 } DebugFlags;
304 
305 typedef struct {
306  CpuRegisters cpu_registers; ///< CPU registers.
307  FpuRegisters fpu_registers; ///< FPU registers.
308 } ThreadContext;
309 
310 /// Control flags for @ref svcGetDebugThreadContext and @ref svcSetDebugThreadContext
311 typedef enum {
312  THREADCONTEXT_CONTROL_CPU_GPRS = BIT(0), ///< Control r0-r12.
313  THREADCONTEXT_CONTROL_CPU_SPRS = BIT(1), ///< Control sp, lr, pc, cpsr.
314  THREADCONTEXT_CONTROL_FPU_GPRS = BIT(2), ///< Control d0-d15 (or s0-s31).
315  THREADCONTEXT_CONTROL_FPU_SPRS = BIT(3), ///< Control fpscr, fpexc.
316 
317  THREADCONTEXT_CONTROL_CPU_REGS = BIT(0) | BIT(1), ///< Control r0-r12, sp, lr, pc, cpsr.
318  THREADCONTEXT_CONTROL_FPU_REGS = BIT(2) | BIT(3), ///< Control d0-d15, fpscr, fpexc.
319 
320  THREADCONTEXT_CONTROL_ALL = BIT(0) | BIT(1) | BIT(2) | BIT(3), ///< Control all of the above.
322 
323 /// Thread parameter field for @ref svcGetDebugThreadParameter
324 typedef enum {
325  DBGTHREAD_PARAMETER_PRIORITY = 0, ///< Thread priority.
326  DBGTHREAD_PARAMETER_SCHEDULING_MASK_LOW = 1, ///< Low scheduling mask.
327  DBGTHREAD_PARAMETER_CPU_IDEAL = 2, ///< Ideal processor.
328  DBGTHREAD_PARAMETER_CPU_CREATOR = 3, ///< Processor that created the threod.
330 
331 ///@}
332 
333 ///@name Processes
334 ///@{
335 
336 /// Information on address space for process. All sizes are in pages (0x1000 bytes)
337 typedef struct {
338  u8 name[8]; ///< ASCII name of codeset
339  u16 unk1;
340  u16 unk2;
341  u32 unk3;
342  u32 text_addr; ///< .text start address
343  u32 text_size; ///< .text number of pages
344  u32 ro_addr; ///< .rodata start address
345  u32 ro_size; ///< .rodata number of pages
346  u32 rw_addr; ///< .data, .bss start address
347  u32 rw_size; ///< .data number of pages
348  u32 text_size_total; ///< total pages for .text (aligned)
349  u32 ro_size_total; ///< total pages for .rodata (aligned)
350  u32 rw_size_total; ///< total pages for .data, .bss (aligned)
351  u32 unk4;
352  u64 program_id; ///< Program ID
353 } CodeSetInfo;
354 
355 /// Information for the main thread of a process.
356 typedef struct
357 {
358  int priority; ///< Priority of the main thread.
359  u32 stack_size; ///< Size of the stack of the main thread.
360  int argc; ///< Unused on retail kernel.
361  u16* argv; ///< Unused on retail kernel.
362  u16* envp; ///< Unused on retail kernel.
363 } StartupInfo;
364 
365 ///@}
366 
367 /**
368  * @brief Gets the thread local storage buffer.
369  * @return The thread local storage bufger.
370  */
371 static inline void* getThreadLocalStorage(void)
372 {
373  void* ret;
374  __asm__ ("mrc p15, 0, %[data], c13, c0, 3" : [data] "=r" (ret));
375  return ret;
376 }
377 
378 /**
379  * @brief Gets the thread command buffer.
380  * @return The thread command bufger.
381  */
382 static inline u32* getThreadCommandBuffer(void)
383 {
384  return (u32*)((u8*)getThreadLocalStorage() + 0x80);
385 }
386 
387 /**
388  * @brief Gets the thread static buffer.
389  * @return The thread static bufger.
390  */
391 static inline u32* getThreadStaticBuffers(void)
392 {
393  return (u32*)((u8*)getThreadLocalStorage() + 0x180);
394 }
395 
396 ///@name Memory management
397 ///@{
398 /**
399  * @brief Controls memory mapping
400  * @param[out] addr_out The virtual address resulting from the operation. Usually the same as addr0.
401  * @param addr0 The virtual address to be used for the operation.
402  * @param addr1 The virtual address to be (un)mirrored by @p addr0 when using @ref MEMOP_MAP or @ref MEMOP_UNMAP.
403  * It has to be pointing to a RW memory.
404  * Use NULL if the operation is @ref MEMOP_FREE or @ref MEMOP_ALLOC.
405  * @param size The requested size for @ref MEMOP_ALLOC and @ref MEMOP_ALLOC_LINEAR.
406  * @param op Operation flags. See @ref MemOp.
407  * @param perm A combination of @ref MEMPERM_READ and @ref MEMPERM_WRITE. Using MEMPERM_EXECUTE will return an error.
408  * Value 0 is used when unmapping memory.
409  *
410  * If a memory is mapped for two or more addresses, you have to use MEMOP_UNMAP before being able to MEMOP_FREE it.
411  * MEMOP_MAP will fail if @p addr1 was already mapped to another address.
412  *
413  * More information is available at http://3dbrew.org/wiki/SVC#Memory_Mapping.
414  *
415  * @sa svcControlProcessMemory
416  */
417 Result svcControlMemory(u32* addr_out, u32 addr0, u32 addr1, u32 size, MemOp op, MemPerm perm);
418 
419 /**
420  * @brief Controls the memory mapping of a process
421  * @param addr0 The virtual address to map
422  * @param addr1 The virtual address to be mapped by @p addr0
423  * @param type Only operations @ref MEMOP_MAP, @ref MEMOP_UNMAP and @ref MEMOP_PROT are allowed.
424  *
425  * This is the only SVC which allows mapping executable memory.
426  * Using @ref MEMOP_PROT will change the memory permissions of an already mapped memory.
427  *
428  * @note The pseudo handle for the current process is not supported by this service call.
429  * @sa svcControlProcess
430  */
431 Result svcControlProcessMemory(Handle process, u32 addr0, u32 addr1, u32 size, u32 type, u32 perm);
432 
433 /**
434  * @brief Creates a block of shared memory
435  * @param[out] memblock Pointer to store the handle of the block
436  * @param addr Address of the memory to map, page-aligned. So its alignment must be 0x1000.
437  * @param size Size of the memory to map, a multiple of 0x1000.
438  * @param my_perm Memory permissions for the current process
439  * @param other_perm Memory permissions for the other processes
440  *
441  * @note The shared memory block, and its rights, are destroyed when the handle is closed.
442  */
443 Result svcCreateMemoryBlock(Handle* memblock, u32 addr, u32 size, MemPerm my_perm, MemPerm other_perm);
444 
445 /**
446  * @brief Maps a block of shared memory
447  * @param memblock Handle of the block
448  * @param addr Address of the memory to map, page-aligned. So its alignment must be 0x1000.
449  * @param my_perm Memory permissions for the current process
450  * @param other_perm Memory permissions for the other processes
451  *
452  * @note The shared memory block, and its rights, are destroyed when the handle is closed.
453  */
454 Result svcMapMemoryBlock(Handle memblock, u32 addr, MemPerm my_perm, MemPerm other_perm);
455 
456 /**
457  * @brief Maps a block of process memory, starting from address 0x00100000.
458  * @param process Handle of the process.
459  * @param destAddress Address of the block of memory to map, in the current (destination) process.
460  * @param size Size of the block of memory to map (truncated to a multiple of 0x1000 bytes).
461  */
462 Result svcMapProcessMemory(Handle process, u32 destAddress, u32 size);
463 
464 /**
465  * @brief Unmaps a block of process memory, starting from address 0x00100000.
466  * @param process Handle of the process.
467  * @param destAddress Address of the block of memory to unmap, in the current (destination) process.
468  * @param size Size of the block of memory to unmap (truncated to a multiple of 0x1000 bytes).
469  */
470 Result svcUnmapProcessMemory(Handle process, u32 destAddress, u32 size);
471 
472 /**
473  * @brief Unmaps a block of shared memory
474  * @param memblock Handle of the block
475  * @param addr Address of the memory to unmap, page-aligned. So its alignment must be 0x1000.
476  */
477 Result svcUnmapMemoryBlock(Handle memblock, u32 addr);
478 
479 /**
480  * @brief Begins an inter-process DMA.
481  * @param[out] dma Pointer to output the handle of the DMA to.
482  * @param dstProcess Destination process.
483  * @param dst Buffer to write data to.
484  * @param srcprocess Source process.
485  * @param src Buffer to read data from.
486  * @param size Size of the data to DMA.
487  * @param dmaConfig DMA configuration data.
488  */
489 Result svcStartInterProcessDma(Handle* dma, Handle dstProcess, void* dst, Handle srcProcess, const void* src, u32 size, void* dmaConfig);
490 
491 /**
492  * @brief Terminates an inter-process DMA.
493  * @param dma Handle of the DMA.
494  */
496 
497 /**
498  * @brief Gets the state of an inter-process DMA.
499  * @param[out] dmaState Pointer to output the state of the DMA to.
500  * @param dma Handle of the DMA.
501  */
502 Result svcGetDmaState(void* dmaState, Handle dma);
503 
504 /**
505  * @brief Queries memory information.
506  * @param[out] info Pointer to output memory info to.
507  * @param out Pointer to output page info to.
508  * @param addr Virtual memory address to query.
509  */
510 Result svcQueryMemory(MemInfo* info, PageInfo* out, u32 addr);
511 
512 /**
513  * @brief Queries process memory information.
514  * @param[out] info Pointer to output memory info to.
515  * @param[out] out Pointer to output page info to.
516  * @param process Process to query memory from.
517  * @param addr Virtual memory address to query.
518  */
519 Result svcQueryProcessMemory(MemInfo* info, PageInfo* out, Handle process, u32 addr);
520 
521 /**
522  * @brief Invalidates a process's data cache.
523  * @param process Handle of the process.
524  * @param addr Address to invalidate.
525  * @param size Size of the memory to invalidate.
526  */
527 Result svcInvalidateProcessDataCache(Handle process, void* addr, u32 size);
528 
529 /**
530  * @brief Cleans a process's data cache.
531  * @param process Handle of the process.
532  * @param addr Address to clean.
533  * @param size Size of the memory to clean.
534  */
535 Result svcStoreProcessDataCache(Handle process, void* addr, u32 size);
536 
537 /**
538  * @brief Flushes (cleans and invalidates) a process's data cache.
539  * @param process Handle of the process.
540  * @param addr Address to flush.
541  * @param size Size of the memory to flush.
542  */
543 Result svcFlushProcessDataCache(Handle process, void const* addr, u32 size);
544 ///@}
545 
546 
547 ///@name Process management
548 ///@{
549 /**
550  * @brief Gets the handle of a process.
551  * @param[out] process The handle of the process
552  * @param processId The ID of the process to open
553  */
554 Result svcOpenProcess(Handle* process, u32 processId);
555 
556 /// Exits the current process.
557 void svcExitProcess() __attribute__((noreturn));
558 
559 /**
560  * @brief Terminates a process.
561  * @param process Handle of the process to terminate.
562  */
564 
565 /**
566  * @brief Gets information about a process.
567  * @param[out] out Pointer to output process info to.
568  * @param process Handle of the process to get information about.
569  * @param type Type of information to retreieve.
570  */
571 Result svcGetProcessInfo(s64* out, Handle process, u32 type);
572 
573 /**
574  * @brief Gets the ID of a process.
575  * @param[out] out Pointer to output the process ID to.
576  * @param handle Handle of the process to get the ID of.
577  */
578 Result svcGetProcessId(u32 *out, Handle handle);
579 
580 /**
581  * @brief Gets a list of running processes.
582  * @param[out] processCount Pointer to output the process count to.
583  * @param[out] processIds Pointer to output the process IDs to.
584  * @param processIdMaxCount Maximum number of process IDs.
585  */
586 Result svcGetProcessList(s32* processCount, u32* processIds, s32 processIdMaxCount);
587 
588 /**
589  * @brief Gets a list of the threads of a process.
590  * @param[out] threadCount Pointer to output the thread count to.
591  * @param[out] threadIds Pointer to output the thread IDs to.
592  * @param threadIdMaxCount Maximum number of thread IDs.
593  * @param process Process handle to list the threads of.
594  */
595 Result svcGetThreadList(s32* threadCount, u32* threadIds, s32 threadIdMaxCount, Handle process);
596 
597 /**
598  * @brief Creates a port.
599  * @param[out] portServer Pointer to output the port server handle to.
600  * @param[out] portClient Pointer to output the port client handle to.
601  * @param name Name of the port.
602  * @param maxSessions Maximum number of sessions that can connect to the port.
603  */
604 Result svcCreatePort(Handle* portServer, Handle* portClient, const char* name, s32 maxSessions);
605 
606 /**
607  * @brief Connects to a port.
608  * @param[out] out Pointer to output the port handle to.
609  * @param portName Name of the port.
610  */
611 Result svcConnectToPort(volatile Handle* out, const char* portName);
612 
613 /**
614  * @brief Sets up virtual address space for a new process
615  * @param[out] out Pointer to output the code set handle to.
616  * @param info Description for setting up the addresses
617  * @param code_ptr Pointer to .text in shared memory
618  * @param ro_ptr Pointer to .rodata in shared memory
619  * @param data_ptr Pointer to .data in shared memory
620  */
621 Result svcCreateCodeSet(Handle* out, const CodeSetInfo *info, void* code_ptr, void* ro_ptr, void* data_ptr);
622 
623 /**
624  * @brief Sets up virtual address space for a new process
625  * @param[out] out Pointer to output the process handle to.
626  * @param codeset Codeset created for this process
627  * @param arm11kernelcaps ARM11 Kernel Capabilities from exheader
628  * @param arm11kernelcaps_num Number of kernel capabilities
629  */
630 Result svcCreateProcess(Handle* out, Handle codeset, const u32 *arm11kernelcaps, u32 arm11kernelcaps_num);
631 
632 /**
633  * @brief Gets a process's affinity mask.
634  * @param[out] affinitymask Pointer to store the affinity masks.
635  * @param process Handle of the process.
636  * @param processorcount Number of processors.
637  */
638 Result svcGetProcessAffinityMask(u8* affinitymask, Handle process, s32 processorcount);
639 
640 /**
641  * @brief Sets a process's affinity mask.
642  * @param process Handle of the process.
643  * @param affinitymask Pointer to retrieve the affinity masks from.
644  * @param processorcount Number of processors.
645  */
646 Result svcSetProcessAffinityMask(Handle process, const u8* affinitymask, s32 processorcount);
647 
648 /**
649  * Gets a process's ideal processor.
650  * @param[out] processorid Pointer to store the ID of the process's ideal processor.
651  * @param process Handle of the process.
652  */
653 Result svcGetProcessIdealProcessor(s32 *processorid, Handle process);
654 
655 /**
656  * Sets a process's ideal processor.
657  * @param process Handle of the process.
658  * @param processorid ID of the process's ideal processor.
659  */
660 Result svcSetProcessIdealProcessor(Handle process, s32 processorid);
661 
662 /**
663  * Launches the main thread of the process.
664  * @param process Handle of the process.
665  * @param info Pointer to a StartupInfo structure describing information for the main thread.
666  */
667 Result svcRun(Handle process, const StartupInfo* info);
668 
669 ///@}
670 
671 ///@name Multithreading
672 ///@{
673 /**
674  * @brief Creates a new thread.
675  * @param[out] thread The thread handle
676  * @param entrypoint The function that will be called first upon thread creation
677  * @param arg The argument passed to @p entrypoint
678  * @param stack_top The top of the thread's stack. Must be 0x8 bytes mem-aligned.
679  * @param thread_priority Low values gives the thread higher priority.
680  * For userland apps, this has to be within the range [0x18;0x3F]
681  * @param processor_id The id of the processor the thread should be ran on. Those are labelled starting from 0.
682  * For old 3ds it has to be <2, and for new 3DS <4.
683  * Value -1 means all CPUs and -2 read from the Exheader.
684  *
685  * The processor with ID 1 is the system processor.
686  * To enable multi-threading on this core you need to call APT_SetAppCpuTimeLimit at least once with a non-zero value.
687  *
688  * Since a thread is considered as a waitable object, you can use @ref svcWaitSynchronization
689  * and @ref svcWaitSynchronizationN to join with it.
690  *
691  * @note The kernel will clear the @p stack_top's address low 3 bits to make sure it is 0x8-bytes aligned.
692  */
693 Result svcCreateThread(Handle* thread, ThreadFunc entrypoint, u32 arg, u32* stack_top, s32 thread_priority, s32 processor_id);
694 
695 /**
696  * @brief Gets the handle of a thread.
697  * @param[out] thread The handle of the thread
698  * @param process The ID of the process linked to the thread
699  */
700 Result svcOpenThread(Handle* thread,Handle process, u32 threadId);
701 
702 /**
703  * @brief Exits the current thread.
704  *
705  * This will trigger a state change and hence release all @ref svcWaitSynchronization operations.
706  * It means that you can join a thread by calling @code svcWaitSynchronization(threadHandle,yourtimeout); @endcode
707  */
708 void svcExitThread(void) __attribute__((noreturn));
709 
710 /**
711  * @brief Puts the current thread to sleep.
712  * @param ns The minimum number of nanoseconds to sleep for.
713  */
714 void svcSleepThread(s64 ns);
715 
716 /// Retrieves the priority of a thread.
717 Result svcGetThreadPriority(s32 *out, Handle handle);
718 
719 /**
720  * @brief Changes the priority of a thread
721  * @param prio For userland apps, this has to be within the range [0x18;0x3F]
722  *
723  * Low values gives the thread higher priority.
724  */
725 Result svcSetThreadPriority(Handle thread, s32 prio);
726 
727 /**
728  * @brief Gets a thread's affinity mask.
729  * @param[out] affinitymask Pointer to output the affinity masks to.
730  * @param thread Handle of the thread.
731  * @param processorcount Number of processors.
732  */
733 Result svcGetThreadAffinityMask(u8* affinitymask, Handle thread, s32 processorcount);
734 
735 /**
736  * @brief Sets a thread's affinity mask.
737  * @param thread Handle of the thread.
738  * @param affinitymask Pointer to retrieve the affinity masks from.
739  * @param processorcount Number of processors.
740  */
741 Result svcSetThreadAffinityMask(Handle thread, const u8* affinitymask, s32 processorcount);
742 
743 /**
744  * @brief Gets a thread's ideal processor.
745  * @param[out] processorid Pointer to output the ID of the thread's ideal processor to.
746  * @param thread Handle of the thread.
747  */
748 Result svcGetThreadIdealProcessor(s32* processorid, Handle thread);
749 
750 /**
751  * Sets a thread's ideal processor.
752  * @param thread Handle of the thread.
753  * @param processorid ID of the thread's ideal processor.
754  */
755 Result svcSetThreadIdealProcessor(Handle thread, s32 processorid);
756 
757 /**
758  * @brief Returns the ID of the processor the current thread is running on.
759  * @sa svcCreateThread
760  */
761 s32 svcGetProcessorID(void);
762 
763 /**
764  * @brief Gets the ID of a thread.
765  * @param[out] out Pointer to output the thread ID of the thread @p handle to.
766  * @param handle Handle of the thread.
767  */
768 Result svcGetThreadId(u32 *out, Handle handle);
769 
770 /**
771  * @brief Gets the resource limit set of a process.
772  * @param[out] resourceLimit Pointer to output the resource limit set handle to.
773  * @param process Process to get the resource limits of.
774  */
775 Result svcGetResourceLimit(Handle* resourceLimit, Handle process);
776 
777 /**
778  * @brief Gets the value limits of a resource limit set.
779  * @param[out] values Pointer to output the value limits to.
780  * @param resourceLimit Resource limit set to use.
781  * @param names Resource limit names to get the limits of.
782  * @param nameCount Number of resource limit names.
783  */
784 Result svcGetResourceLimitLimitValues(s64* values, Handle resourceLimit, ResourceLimitType* names, s32 nameCount);
785 
786 /**
787  * @brief Gets the values of a resource limit set.
788  * @param[out] values Pointer to output the values to.
789  * @param resourceLimit Resource limit set to use.
790  * @param names Resource limit names to get the values of.
791  * @param nameCount Number of resource limit names.
792  */
793 Result svcGetResourceLimitCurrentValues(s64* values, Handle resourceLimit, ResourceLimitType* names, s32 nameCount);
794 
795 /**
796  * @brief Sets the resource limit set of a process.
797  * @param process Process to set the resource limit set to.
798  * @param resourceLimit Resource limit set handle.
799  */
800 Result svcSetProcessResourceLimits(Handle process, Handle resourceLimit);
801 
802 /**
803  * @brief Creates a resource limit set.
804  * @param[out] resourceLimit Pointer to output the resource limit set handle to.
805  */
806 Result svcCreateResourceLimit(Handle* resourceLimit);
807 
808 /**
809  * @brief Sets the value limits of a resource limit set.
810  * @param resourceLimit Resource limit set to use.
811  * @param names Resource limit names to set the limits of.
812  * @param values Value limits to set. The high 32 bits of RESLIMIT_COMMIT are used to
813  set APPMEMALLOC in configuration memory, otherwise those bits are unused.
814  * @param nameCount Number of resource limit names.
815  */
816 Result svcSetResourceLimitValues(Handle resourceLimit, const ResourceLimitType* names, const s64* values, s32 nameCount);
817 
818 /**
819  * @brief Gets the process ID of a thread.
820  * @param[out] out Pointer to output the process ID of the thread @p handle to.
821  * @param handle Handle of the thread.
822  * @sa svcOpenProcess
823  */
825 
826 /**
827  * @brief Checks if a thread handle is valid.
828  * This requests always return an error when called, it only checks if the handle is a thread or not.
829  * @return 0xD8E007ED (BAD_ENUM) if the Handle is a Thread Handle
830  * @return 0xD8E007F7 (BAD_HANDLE) if it isn't.
831  */
832 Result svcGetThreadInfo(s64* out, Handle thread, ThreadInfoType type);
833 ///@}
834 
835 
836 ///@name Synchronization
837 ///@{
838 /**
839  * @brief Creates a mutex.
840  * @param[out] mutex Pointer to output the handle of the created mutex to.
841  * @param initially_locked Whether the mutex should be initially locked.
842  */
843 Result svcCreateMutex(Handle* mutex, bool initially_locked);
844 
845 /**
846  * @brief Releases a mutex.
847  * @param handle Handle of the mutex.
848  */
850 
851 /**
852  * @brief Creates a semaphore.
853  * @param[out] semaphore Pointer to output the handle of the created semaphore to.
854  * @param initial_count Initial count of the semaphore.
855  * @param max_count Maximum count of the semaphore.
856  */
857 Result svcCreateSemaphore(Handle* semaphore, s32 initial_count, s32 max_count);
858 
859 /**
860  * @brief Releases a semaphore.
861  * @param[out] count Pointer to output the current count of the semaphore to.
862  * @param semaphore Handle of the semaphore.
863  * @param release_count Number to increase the semaphore count by.
864  */
865 Result svcReleaseSemaphore(s32* count, Handle semaphore, s32 release_count);
866 
867 /**
868  * @brief Creates an event handle.
869  * @param[out] event Pointer to output the created event handle to.
870  * @param reset_type Type of reset the event uses (RESET_ONESHOT/RESET_STICKY).
871  */
872 Result svcCreateEvent(Handle* event, ResetType reset_type);
873 
874 /**
875  * @brief Signals an event.
876  * @param handle Handle of the event to signal.
877  */
879 
880 /**
881  * @brief Clears an event.
882  * @param handle Handle of the event to clear.
883  */
884 Result svcClearEvent(Handle handle);
885 
886 /**
887  * @brief Waits for synchronization on a handle.
888  * @param handle Handle to wait on.
889  * @param nanoseconds Maximum nanoseconds to wait for.
890  */
891 Result svcWaitSynchronization(Handle handle, s64 nanoseconds);
892 
893 /**
894  * @brief Waits for synchronization on multiple handles.
895  * @param[out] out Pointer to output the index of the synchronized handle to.
896  * @param handles Handles to wait on.
897  * @param handles_num Number of handles.
898  * @param wait_all Whether to wait for synchronization on all handles.
899  * @param nanoseconds Maximum nanoseconds to wait for.
900  */
901 Result svcWaitSynchronizationN(s32* out, const Handle* handles, s32 handles_num, bool wait_all, s64 nanoseconds);
902 
903 /**
904  * @brief Creates an address arbiter
905  * @param[out] mutex Pointer to output the handle of the created address arbiter to.
906  * @sa svcArbitrateAddress
907  */
909 
910 /**
911  * @brief Arbitrate an address, can be used for synchronization
912  * @param arbiter Handle of the arbiter
913  * @param addr A pointer to a s32 value.
914  * @param type Type of action to be performed by the arbiter
915  * @param value Number of threads to signal if using @ref ARBITRATION_SIGNAL, or the value used for comparison.
916  *
917  * This will perform an arbitration based on #type. The comparisons are done between #value and the value at the address #addr.
918  *
919  * @code
920  * s32 val=0;
921  * // Does *nothing* since val >= 0
922  * svcCreateAddressArbiter(arbiter,&val,ARBITRATION_WAIT_IF_LESS_THAN,0,0);
923  * // Thread will wait for a signal or wake up after 10000000 nanoseconds because val < 1.
924  * svcCreateAddressArbiter(arbiter,&val,ARBITRATION_WAIT_IF_LESS_THAN_TIMEOUT,1,10000000ULL);
925  * @endcode
926  */
927 Result svcArbitrateAddress(Handle arbiter, u32 addr, ArbitrationType type, s32 value, s64 nanoseconds);
928 
929 /**
930  * @brief Sends a synchronized request to a session handle.
931  * @param session Handle of the session.
932  */
934 
935 /**
936  * @brief Connects to a port via a handle.
937  * @param[out] clientSession Pointer to output the client session handle to.
938  * @param clientPort Port client endpoint to connect to.
939  */
940 Result svcCreateSessionToPort(Handle* clientSession, Handle clientPort);
941 
942 /**
943  * @brief Creates a linked pair of session endpoints.
944  * @param[out] serverSession Pointer to output the created server endpoint handle to.
945  * @param[out] clientSession Pointer to output the created client endpoint handle to.
946  */
947 Result svcCreateSession(Handle* serverSession, Handle* clientSession);
948 
949 /**
950  * @brief Accepts a session.
951  * @param[out] session Pointer to output the created session handle to.
952  * @param port Handle of the port to accept a session from.
953  */
954 Result svcAcceptSession(Handle* session, Handle port);
955 
956 /**
957  * @brief Replies to and receives a new request.
958  * @param index Pointer to the index of the request.
959  * @param handles Session handles to receive requests from.
960  * @param handleCount Number of handles.
961  * @param replyTarget Handle of the session to reply to.
962  */
963 Result svcReplyAndReceive(s32* index, const Handle* handles, s32 handleCount, Handle replyTarget);
964 
965 /**
966  * @brief Binds an event or semaphore handle to an ARM11 interrupt.
967  * @param interruptId Interrupt identfier (see https://www.3dbrew.org/wiki/ARM11_Interrupts).
968  * @param eventOrSemaphore Event or semaphore handle to bind to the given interrupt.
969  * @param priority Priority of the interrupt for the current process.
970  * @param isManualClear Indicates whether the interrupt has to be manually cleared or not (= level-high active).
971  */
972 Result svcBindInterrupt(u32 interruptId, Handle eventOrSemaphore, s32 priority, bool isManualClear);
973 
974 /**
975  * @brief Unbinds an event or semaphore handle from an ARM11 interrupt.
976  * @param interruptId Interrupt identfier, see (see https://www.3dbrew.org/wiki/ARM11_Interrupts).
977  * @param eventOrSemaphore Event or semaphore handle to unbind from the given interrupt.
978  */
979 Result svcUnbindInterrupt(u32 interruptId, Handle eventOrSemaphore);
980 ///@}
981 
982 ///@name Time
983 ///@{
984 /**
985  * @brief Creates a timer.
986  * @param[out] timer Pointer to output the handle of the created timer to.
987  * @param reset_type Type of reset to perform on the timer.
988  */
989 Result svcCreateTimer(Handle* timer, ResetType reset_type);
990 
991 /**
992  * @brief Sets a timer.
993  * @param timer Handle of the timer to set.
994  * @param initial Initial value of the timer.
995  * @param interval Interval of the timer.
996  */
997 Result svcSetTimer(Handle timer, s64 initial, s64 interval);
998 
999 /**
1000  * @brief Cancels a timer.
1001  * @param timer Handle of the timer to cancel.
1002  */
1004 
1005 /**
1006  * @brief Clears a timer.
1007  * @param timer Handle of the timer to clear.
1008  */
1009 Result svcClearTimer(Handle timer);
1010 
1011 /**
1012  * @brief Gets the current system tick.
1013  * @return The current system tick.
1014  */
1015 u64 svcGetSystemTick(void);
1016 ///@}
1017 
1018 ///@name System
1019 ///@{
1020 /**
1021  * @brief Closes a handle.
1022  * @param handle Handle to close.
1023  */
1024 Result svcCloseHandle(Handle handle);
1025 
1026 /**
1027  * @brief Duplicates a handle.
1028  * @param[out] out Pointer to output the duplicated handle to.
1029  * @param original Handle to duplicate.
1030  */
1031 Result svcDuplicateHandle(Handle* out, Handle original);
1032 
1033 /**
1034  * @brief Gets a handle info.
1035  * @param[out] out Pointer to output the handle info to.
1036  * @param handle Handle to get the info for.
1037  * @param param Parameter clarifying the handle info type.
1038  */
1039 Result svcGetHandleInfo(s64* out, Handle handle, u32 param);
1040 
1041 /**
1042  * @brief Gets the system info.
1043  * @param[out] out Pointer to output the system info to.
1044  * @param type Type of system info to retrieve.
1045  * @param param Parameter clarifying the system info type.
1046  */
1047 Result svcGetSystemInfo(s64* out, u32 type, s32 param);
1048 
1049 /**
1050  * @brief Sets the GPU protection register to restrict the range of the GPU DMA. 11.3+ only.
1051  * @param useApplicationRestriction Whether to use the register value used for APPLICATION titles.
1052  */
1053 Result svcSetGpuProt(bool useApplicationRestriction);
1054 
1055 /**
1056  * @brief Enables or disables Wi-Fi. 11.4+ only.
1057  * @param enabled Whether to enable or disable Wi-Fi.
1058  */
1059 Result svcSetWifiEnabled(bool enabled);
1060 
1061 /**
1062  * @brief Sets the current kernel state.
1063  * @param type Type of state to set (the other parameters depend on it).
1064  */
1065 Result svcKernelSetState(u32 type, ...);
1066 ///@}
1067 
1068 
1069 ///@name Debugging
1070 ///@{
1071 /**
1072  * @brief Breaks execution.
1073  * @param breakReason Reason for breaking.
1074  */
1075 void svcBreak(UserBreakType breakReason);
1076 
1077 /**
1078  * @brief Breaks execution (LOAD_RO and UNLOAD_RO).
1079  * @param breakReason Debug reason for breaking.
1080  * @param croInfo Library information.
1081  * @param croInfoSize Size of the above structure.
1082  */
1083 void svcBreakRO(UserBreakType breakReason, const void* croInfo, u32 croInfoSize) __asm__("svcBreak");
1084 
1085 /**
1086  * @brief Outputs a debug string.
1087  * @param str String to output.
1088  * @param length Length of the string to output, needs to be positive.
1089  */
1090 Result svcOutputDebugString(const char* str, s32 length);
1091 /**
1092  * @brief Creates a debug handle for an active process.
1093  * @param[out] debug Pointer to output the created debug handle to.
1094  * @param processId ID of the process to debug.
1095  */
1096 Result svcDebugActiveProcess(Handle* debug, u32 processId);
1097 
1098 /**
1099  * @brief Breaks a debugged process.
1100  * @param debug Debug handle of the process.
1101  */
1103 
1104 /**
1105  * @brief Terminates a debugged process.
1106  * @param debug Debug handle of the process.
1107  */
1109 
1110 /**
1111  * @brief Gets the current debug event of a debugged process.
1112  * @param[out] info Pointer to output the debug event information to.
1113  * @param debug Debug handle of the process.
1114  */
1116 
1117 /**
1118  * @brief Continues the current debug event of a debugged process (not necessarily the same as @ref svcGetProcessDebugEvent).
1119  * @param debug Debug handle of the process.
1120  * @param flags Flags to continue with, see @ref DebugFlags.
1121  */
1123 
1124 /**
1125  * @brief Fetches the saved registers of a thread, either inactive or awaiting @ref svcContinueDebugEvent, belonging to a debugged process.
1126  * @param[out] context Values of the registers to fetch, see @ref ThreadContext.
1127  * @param debug Debug handle of the parent process.
1128  * @param threadId ID of the thread to fetch the saved registers of.
1129  * @param controlFlags Which registers to fetch, see @ref ThreadContextControlFlags.
1130  */
1131 Result svcGetDebugThreadContext(ThreadContext* context, Handle debug, u32 threadId, ThreadContextControlFlags controlFlags);
1132 
1133 /**
1134  * @brief Updates the saved registers of a thread, either inactive or awaiting @ref svcContinueDebugEvent, belonging to a debugged process.
1135  * @param debug Debug handle of the parent process.
1136  * @param threadId ID of the thread to update the saved registers of.
1137  * @param context Values of the registers to update, see @ref ThreadContext.
1138  * @param controlFlags Which registers to update, see @ref ThreadContextControlFlags.
1139  */
1140 Result svcSetDebugThreadContext(Handle debug, u32 threadId, ThreadContext* context, ThreadContextControlFlags controlFlags);
1141 
1142 /**
1143  * @brief Queries memory information of a debugged process.
1144  * @param[out] info Pointer to output memory info to.
1145  * @param[out] out Pointer to output page info to.
1146  * @param debug Debug handle of the process to query memory from.
1147  * @param addr Virtual memory address to query.
1148  */
1149 Result svcQueryDebugProcessMemory(MemInfo* info, PageInfo* out, Handle debug, u32 addr);
1150 
1151 /**
1152  * @brief Reads from a debugged process's memory.
1153  * @param buffer Buffer to read data to.
1154  * @param debug Debug handle of the process.
1155  * @param addr Address to read from.
1156  * @param size Size of the memory to read.
1157  */
1158 Result svcReadProcessMemory(void* buffer, Handle debug, u32 addr, u32 size);
1159 
1160 /**
1161  * @brief Writes to a debugged process's memory.
1162  * @param debug Debug handle of the process.
1163  * @param buffer Buffer to write data from.
1164  * @param addr Address to write to.
1165  * @param size Size of the memory to write.
1166  */
1167 Result svcWriteProcessMemory(Handle debug, const void* buffer, u32 addr, u32 size);
1168 
1169 /**
1170  * @brief Sets an hardware breakpoint or watchpoint. This is an interface to the BRP/WRP registers, see http://infocenter.arm.com/help/topic/com.arm.doc.ddi0360f/CEGEBGFC.html .
1171  * @param registerId range 0..5 = breakpoints (BRP0-5), 0x100..0x101 = watchpoints (WRP0-1). The previous stop point for the register is disabled.
1172  * @param control Value of the control regiser.
1173  * @param value Value of the value register: either and address (if bit21 of control is clear) or the debug handle of a process to fetch the context ID of.
1174  */
1175 Result svcSetHardwareBreakPoint(s32 registerId, u32 control, u32 value);
1176 
1177 /**
1178  * @brief Gets a debugged thread's parameter.
1179  * @param[out] unused Unused.
1180  * @param[out] out Output value.
1181  * @param debug Debug handle of the process.
1182  * @param threadId ID of the thread
1183  * @param parameter Parameter to fetch, see @ref DebugThreadParameter.
1184  */
1185 Result svcGetDebugThreadParam(s64* unused, u32* out, Handle debug, u32 threadId, DebugThreadParameter parameter);
1186 
1187 ///@}
1188 
1189 /**
1190  * @brief Executes a function in supervisor mode.
1191  * @param callback Function to execute.
1192  */
1193 Result svcBackdoor(s32 (*callback)(void));
1194 
1195 /// Stop point, does nothing if the process is not attached (as opposed to 'bkpt' instructions)
1196 #define SVC_STOP_POINT __asm__ volatile("svc 0xFF");
Result svcOpenProcess(Handle *process, u32 processId)
Gets the handle of a process.
u64 svcGetSystemTick(void)
Gets the current system tick.
Signal map events. See MapEvent.
Definition: svc.h:302
Memory mapping.
Definition: svc.h:23
Process has been terminated by svcTerminateDebugProcess.
Definition: svc.h:142
Thread terminated.
Definition: svc.h:160
User break occurred.
Definition: svc.h:187
Event relating to the attachment of a process.
Definition: svc.h:131
SYSTEM memory region.
Definition: svc.h:29
Panic.
Definition: svc.h:172
Unload RO.
Definition: svc.h:176
void svcSleepThread(s64 ns)
Puts the current thread to sleep.
Number of address arbiters.
Definition: svc.h:115
Watchpoint.
Definition: svc.h:201
Number of events.
Definition: svc.h:110
u32 state
Memory state. See MemState.
Definition: svc.h:68
Various system types.
Low scheduling mask.
Definition: svc.h:326
u32 syscall
Syscall sent/received.
Definition: svc.h:242
Breakpoint.
Definition: svc.h:200
Result svcGetHandleInfo(s64 *out, Handle handle, u32 param)
Gets a handle info.
Result svcReleaseSemaphore(s32 *count, Handle semaphore, s32 release_count)
Releases a semaphore.
Event relating to the attachment of a thread.
Definition: svc.h:151
CPU time. Value expressed in percentage regular until it reaches 90.
Definition: svc.h:116
See SVC_STOP_POINT.
Definition: svc.h:199
Result svcCreateThread(Handle *thread, ThreadFunc entrypoint, u32 arg, u32 *stack_top, s32 thread_priority, s32 processor_id)
Creates a new thread.
s32 Result
Function result.
Definition: types.h:42
Result svcGetSystemInfo(s64 *out, u32 type, s32 param)
Gets the system info.
ExitThreadEvent exit_thread
Thread exit event data.
Definition: svc.h:285
Event relating to exceptions.
Definition: svc.h:223
Memory un-mapping.
Definition: svc.h:21
ScheduleInOutEvent scheduler
Schedule in/out event data.
Definition: svc.h:289
When the primitive is signaled, it will wake up all threads and it won't clear itself automatically.
Definition: svc.h:96
Private memory.
Definition: svc.h:46
void(* ThreadFunc)(void *)
Thread entrypoint function.
Definition: types.h:43
Schedule out event.
Definition: svc.h:269
void svcBreakRO(UserBreakType breakReason, const void *croInfo, u32 croInfoSize) __asm__("svcBreak")
Breaks execution (LOAD_RO and UNLOAD_RO).
u32 mapped_addr
Mapped address.
Definition: svc.h:253
ResetType
Reset types (for use with events and timers)
Definition: svc.h:94
int priority
Priority of the main thread.
Definition: svc.h:358
Result svcCreateMemoryBlock(Handle *memblock, u32 addr, u32 size, MemPerm my_perm, MemPerm other_perm)
Creates a block of shared memory.
uint16_t u16
16-bit unsigned integer
Definition: types.h:22
Process exited either normally or due to an uncaught exception.
Definition: svc.h:161
Signal schedule in/out events. See ScheduleInOutEvent.
Definition: svc.h:300
StopPointType type
Stop point type, see StopPointType.
Definition: svc.h:206
Exception event.
Definition: svc.h:265
Schedule in event.
Definition: svc.h:268
int argc
Unused on retail kernel.
Definition: svc.h:360
void svcBreak(UserBreakType breakReason)
Breaks execution.
Result svcCreateResourceLimit(Handle *resourceLimit)
Creates a resource limit set.
Result svcControlMemory(u32 *addr_out, u32 addr0, u32 addr1, u32 size, MemOp op, MemPerm perm)
Controls memory mapping.
Aliased code memory.
Definition: svc.h:51
MemState memstate
Memory state. See MemState.
Definition: svc.h:256
u32 ro_addr
.rodata start address
Definition: svc.h:344
u16 * argv
Unused on retail kernel.
Definition: svc.h:361
u32 text_addr
.text start address
Definition: svc.h:342
Result svcMapMemoryBlock(Handle memblock, u32 addr, MemPerm my_perm, MemPerm other_perm)
Maps a block of shared memory.
u32 string_size
Size of the outputted string.
Definition: svc.h:248
ArbitrationType
Arbitration modes.
Definition: svc.h:77
Result svcWaitSynchronization(Handle handle, s64 nanoseconds)
Waits for synchronization on a handle.
Event relating to stop points.
Definition: svc.h:205
Number of mutexes.
Definition: svc.h:111
Result svcConnectToPort(volatile Handle *out, const char *portName)
Connects to a port.
u32 size
Size.
Definition: svc.h:66
Continuous memory.
Definition: svc.h:48
ExitThreadEventReason reason
Reason for exiting. See ExitThreadEventReason.
Definition: svc.h:167
Control r0-r12.
Definition: svc.h:312
Result svcGetResourceLimit(Handle *resourceLimit, Handle process)
Gets the resource limit set of a process.
Number of threads.
Definition: svc.h:109
u16 * envp
Unused on retail kernel.
Definition: svc.h:362
Result svcGetProcessId(u32 *out, Handle handle)
Gets the ID of a process.
Control r0-r12, sp, lr, pc, cpsr.
Definition: svc.h:317
Number of timers.
Definition: svc.h:113
Event relating to the mapping of memory.
Definition: svc.h:252
u32 Handle
Resource handle.
Definition: types.h:41
UserBreakType
Reasons for a user break.
Definition: svc.h:171
u32 text_size_total
total pages for .text (aligned)
Definition: svc.h:348
Don't care.
Definition: svc.h:60
Result svcCreateSemaphore(Handle *semaphore, s32 initial_count, s32 max_count)
Creates a semaphore.
Control d0-d15 (or s0-s31).
Definition: svc.h:314
Signal #value threads for wake-up.
Definition: svc.h:78
MemPerm
Memory permission flags.
Definition: svc.h:56
Result svcSetThreadAffinityMask(Handle thread, const u8 *affinitymask, s32 processorcount)
Sets a thread's affinity mask.
Inhibit user-defined CPU exception handlers (including watchpoints and breakpoints,...
Definition: svc.h:298
I/O memory.
Definition: svc.h:43
APPLICATION memory region.
Definition: svc.h:28
u32 rw_addr
.data, .bss start address
Definition: svc.h:346
Result svcSignalEvent(Handle handle)
Signals an event.
Event relating to the exiting of a thread.
Definition: svc.h:166
ExceptionEvent exception
Exception event data.
Definition: svc.h:287
Result svcFlushProcessDataCache(Handle process, void const *addr, u32 size)
Flushes (cleans and invalidates) a process's data cache.
u32 address
Address of the exception.
Definition: svc.h:225
Result svcOpenThread(Handle *thread, Handle process, u32 threadId)
Gets the handle of a thread.
Reserve memory.
Definition: svc.h:22
Result svcGetThreadInfo(s64 *out, Handle thread, ThreadInfoType type)
Checks if a thread handle is valid.
Alias memory.
Definition: svc.h:50
uint8_t u8
would be nice if newlib had this already
Definition: types.h:21
Result svcRun(Handle process, const StartupInfo *info)
Launches the main thread of the process.
DebugThreadParameter
Thread parameter field for svcGetDebugThreadParameter.
Definition: svc.h:324
Process has been terminated by svcTerminateProcess.
Definition: svc.h:162
FaultExceptionEvent fault
Fault exception event data.
Definition: svc.h:227
Only meaningful for timers: same as ONESHOT but it will periodically signal the timer instead of just...
Definition: svc.h:97
u32 ro_size_total
total pages for .rodata (aligned)
Definition: svc.h:349
Result svcSetProcessResourceLimits(Handle process, Handle resourceLimit)
Sets the resource limit set of a process.
Result svcWriteProcessMemory(Handle debug, const void *buffer, u32 addr, u32 size)
Writes to a debugged process's memory.
Structure representing CPU registers.
Definition: types.h:63
Event relating to debug output.
Definition: svc.h:246
uint64_t u64
64-bit unsigned integer
Definition: types.h:24
Result svcUnmapMemoryBlock(Handle memblock, u32 addr)
Unmaps a block of shared memory.
Result svcKernelSetState(u32 type,...)
Sets the current kernel state.
Result svcGetProcessList(s32 *processCount, u32 *processIds, s32 processIdMaxCount)
Gets a list of running processes.
Result svcStoreProcessDataCache(Handle process, void *addr, u32 size)
Cleans a process's data cache.
Result svcGetProcessInfo(s64 *out, Handle process, u32 type)
Gets information about a process.
Result svcCreateProcess(Handle *out, Handle codeset, const u32 *arm11kernelcaps, u32 arm11kernelcaps_num)
Sets up virtual address space for a new process.
Thread attached event.
Definition: svc.h:262
MemState
The state of a memory block.
Definition: svc.h:40
Result svcGetProcessIdOfThread(u32 *out, Handle handle)
Gets the process ID of a thread.
Result svcGetThreadId(u32 *out, Handle handle)
Gets the ID of a thread.
Result svcCreateEvent(Handle *event, ResetType reset_type)
Creates an event handle.
Load RO.
Definition: svc.h:175
u32 perm
Memory permissions. See MemPerm.
Definition: svc.h:67
Result svcQueryMemory(MemInfo *info, PageInfo *out, u32 addr)
Queries memory information.
Result svcReadProcessMemory(void *buffer, Handle debug, u32 addr, u32 size)
Reads from a debugged process's memory.
void svcExitProcess() __attribute__((noreturn))
Exits the current process.
Quantity of allocatable memory.
Definition: svc.h:108
Result svcSetTimer(Handle timer, s64 initial, s64 interval)
Sets a timer.
Signal syscall in/out events. See SyscallInOutEvent.
Definition: svc.h:301
Signal fault exception events. See FaultExceptionEvent.
Definition: svc.h:299
FpuRegisters fpu_registers
FPU registers.
Definition: svc.h:307
Process exited either normally or due to an uncaught exception.
Definition: svc.h:140
Result svcMapProcessMemory(Handle process, u32 destAddress, u32 size)
Maps a block of process memory, starting from address 0x00100000.
uint32_t u32
32-bit unsigned integer
Definition: types.h:23
Result svcCreateCodeSet(Handle *out, const CodeSetInfo *info, void *code_ptr, void *ro_ptr, void *data_ptr)
Sets up virtual address space for a new process.
u32 rw_size
.data number of pages
Definition: svc.h:347
Result svcWaitSynchronizationN(s32 *out, const Handle *handles, s32 handles_num, bool wait_all, s64 nanoseconds)
Waits for synchronization on multiple handles.
Result svcCreateMutex(Handle *mutex, bool initially_locked)
Creates a mutex.
MapEvent map
Map event data.
Definition: svc.h:292
Information for the main thread of a process.
Definition: svc.h:356
Executable.
Definition: svc.h:59
Result svcGetThreadAffinityMask(u8 *affinitymask, Handle thread, s32 processorcount)
Gets a thread's affinity mask.
Thread priority.
Definition: svc.h:107
Definition: svc.h:305
Result svcSetGpuProt(bool useApplicationRestriction)
Sets the GPU protection register to restrict the range of the GPU DMA.
Result svcDuplicateHandle(Handle *out, Handle original)
Duplicates a handle.
Unknown.
Definition: svc.h:102
Unaligned data access.
Definition: svc.h:184
DebugEventType type
Type of event. See DebugEventType.
Definition: svc.h:278
u32 base_addr
Base address.
Definition: svc.h:65
Event relating to the exiting of a process.
Definition: svc.h:146
Processor that created the threod.
Definition: svc.h:328
ExitThreadEventReason
Reasons for an exit thread event.
Definition: svc.h:158
Result svcOutputDebugString(const char *str, s32 length)
Outputs a debug string.
Syscall in event.
Definition: svc.h:270
Operation bitmask.
Definition: svc.h:32
Flag for linear memory operations.
Definition: svc.h:34
u64 clock_tick
Clock tick that the event occurred.
Definition: svc.h:236
Result svcGetResourceLimitLimitValues(s64 *values, Handle resourceLimit, ResourceLimitType *names, s32 nameCount)
Gets the value limits of a resource limit set.
Ideal processor.
Definition: svc.h:327
Result svcGetDebugThreadParam(s64 *unused, u32 *out, Handle debug, u32 threadId, DebugThreadParameter parameter)
Gets a debugged thread's parameter.
static u32 * getThreadCommandBuffer(void)
Gets the thread command buffer.
Definition: svc.h:382
Result svcBackdoor(s32(*callback)(void))
Executes a function in supervisor mode.
Result svcCreateTimer(Handle *timer, ResetType reset_type)
Creates a timer.
OutputStringEvent output_string
Output string event data.
Definition: svc.h:291
int32_t s32
32-bit signed integer
Definition: types.h:28
u32 croInfoSize
For LOAD_RO and UNLOAD_RO.
Definition: svc.h:214
Result svcAcceptSession(Handle *session, Handle port)
Accepts a session.
Readable.
Definition: svc.h:57
u32 fault_information
FAR (for DATA ABORT / UNALIGNED DATA ACCESS), attempted syscall or 0.
Definition: svc.h:194
Event relating to the scheduler.
Definition: svc.h:235
Result svcGetThreadIdealProcessor(s32 *processorid, Handle thread)
Gets a thread's ideal processor.
Change protection.
Definition: svc.h:26
Attached break.
Definition: svc.h:185
DLL load event.
Definition: svc.h:266
ExitProcessEventReason reason
Reason for exiting. See ExitProcessEventReason.
Definition: svc.h:147
Reserved memory.
Definition: svc.h:42
Result svcSetHardwareBreakPoint(s32 registerId, u32 control, u32 value)
Sets an hardware breakpoint or watchpoint.
Result svcClearEvent(Handle handle)
Clears an event.
s32 svcGetProcessorID(void)
Returns the ID of the processor the current thread is running on.
UserBreakExceptionEvent user_break
User break exception event data.
Definition: svc.h:229
void svcExitThread(void) __attribute__((noreturn))
Exits the current thread.
u64 program_id
Program ID.
Definition: svc.h:352
Control fpscr, fpexc.
Definition: svc.h:315
u32 process_id
ID of the process.
Definition: svc.h:134
Result svcInvalidateProcessDataCache(Handle process, void *addr, u32 size)
Invalidates a process's data cache.
Mirror unmapping.
Definition: svc.h:25
AttachThreadEvent attach_thread
Thread attachment event data.
Definition: svc.h:284
UserBreakType type
User break type, see UserBreakType.
Definition: svc.h:212
Result svcGetThreadPriority(s32 *out, Handle handle)
Retrieves the priority of a thread.
Memory information.
Definition: svc.h:64
BASE memory region.
Definition: svc.h:30
Output string event.
Definition: svc.h:272
ExitProcessEvent exit_process
Process exit event data.
Definition: svc.h:286
If the memory at the address is strictly lower than #value, then decrement it and wait for signal.
Definition: svc.h:80
Result svcSetWifiEnabled(bool enabled)
Enables or disables Wi-Fi.
Result svcGetThreadList(s32 *threadCount, u32 *threadIds, s32 threadIdMaxCount, Handle process)
Gets a list of the threads of a process.
u32 thread_id
ID of the thread.
Definition: svc.h:279
ExitProcessEventReason
Reasons for an exit process event.
Definition: svc.h:139
Event relating to svcBreak.
Definition: svc.h:211
Result svcCreateSessionToPort(Handle *clientSession, Handle clientPort)
Connects to a port via a handle.
Information about a debug event.
Definition: svc.h:277
Writable.
Definition: svc.h:58
static u32 * getThreadStaticBuffers(void)
Gets the thread static buffer.
Definition: svc.h:391
Prefetch abort.
Definition: svc.h:182
Static memory.
Definition: svc.h:44
Region bitmask.
Definition: svc.h:33
Result svcGetProcessDebugEvent(DebugEventInfo *info, Handle debug)
Gets the current debug event of a debugged process.
Process exit event.
Definition: svc.h:264
u64 program_id
ID of the program.
Definition: svc.h:132
u32 entry_point
Entry point of the thread.
Definition: svc.h:154
DebugEventType
Debug event type.
Definition: svc.h:260
ThreadInfoType
Types of thread info.
Definition: svc.h:101
u32 fault_information
FAR for Watchpoints, otherwise 0.
Definition: svc.h:207
Code memory.
Definition: svc.h:45
MemOp
svcControlMemory operation flags
Definition: svc.h:20
Debugger break occurred.
Definition: svc.h:188
Result svcSetResourceLimitValues(Handle resourceLimit, const ResourceLimitType *names, const s64 *values, s32 nameCount)
Sets the value limits of a resource limit set.
Allocates linear memory.
Definition: svc.h:36
Result svcSetThreadIdealProcessor(Handle thread, s32 processorid)
Sets a thread's ideal processor.
Result svcCancelTimer(Handle timer)
Cancels a timer.
Stop point reached.
Definition: svc.h:186
Thread exited.
Definition: svc.h:159
Result svcBindInterrupt(u32 interruptId, Handle eventOrSemaphore, s32 priority, bool isManualClear)
Binds an event or semaphore handle to an ARM11 interrupt.
u32 thread_local_storage
Thread local storage.
Definition: svc.h:153
Syscall out event.
Definition: svc.h:271
Result svcControlProcessMemory(Handle process, u32 addr0, u32 addr1, u32 size, u32 type, u32 perm)
Controls the memory mapping of a process.
Structure representing FPU registers.
Definition: types.h:72
If the memory at the address is strictly lower than #value, then wait for signal or timeout.
Definition: svc.h:81
u32 ro_size
.rodata number of pages
Definition: svc.h:345
Information on address space for process. All sizes are in pages (0x1000 bytes)
Definition: svc.h:337
Result svcArbitrateAddress(Handle arbiter, u32 addr, ArbitrationType type, s32 value, s64 nanoseconds)
Arbitrate an address, can be used for synchronization.
u32 flags
Flags. Bit0 means that svcContinueDebugEvent needs to be called for this event (except for EXIT PROCE...
Definition: svc.h:280
#define BIT(n)
Creates a bitmask from a bit number.
Definition: types.h:47
Result svcQueryProcessMemory(MemInfo *info, PageInfo *out, Handle process, u32 addr)
Queries process memory information.
u64 clock_tick
Clock tick that the event occurred.
Definition: svc.h:241
Undefined instruction.
Definition: svc.h:181
DLL unload event.
Definition: svc.h:267
Assertion failed.
Definition: svc.h:173
Result svcTerminateDebugProcess(Handle debug)
Terminates a debugged process.
u32 stack_size
Size of the stack of the main thread.
Definition: svc.h:359
Locked memory.
Definition: svc.h:52
int64_t s64
64-bit signed integer
Definition: types.h:29
Result svcStopDma(Handle dma)
Terminates an inter-process DMA.
DebugFlags
Debug flags for an attached process, set by svcContinueDebugEvent.
Definition: svc.h:297
Result svcCreateSession(Handle *serverSession, Handle *clientSession)
Creates a linked pair of session endpoints.
Result svcContinueDebugEvent(Handle debug, DebugFlags flags)
Continues the current debug event of a debugged process (not necessarily the same as svcGetProcessDeb...
Thread exit event.
Definition: svc.h:263
Result svcReplyAndReceive(s32 *index, const Handle *handles, s32 handleCount, Handle replyTarget)
Replies to and receives a new request.
Map event.
Definition: svc.h:273
Result svcSetProcessIdealProcessor(Handle process, s32 processorid)
Sets a process's ideal processor.
Number of semaphores.
Definition: svc.h:112
DebuggerBreakExceptionEvent debugger_break
Debugger break exception event data.
Definition: svc.h:230
ResourceLimitType
Types of resource limit.
Definition: svc.h:106
When the primitive is signaled, it will wake up exactly one thread and will clear itself automaticall...
Definition: svc.h:95
Control d0-d15, fpscr, fpexc.
Definition: svc.h:318
User related.
Definition: svc.h:174
Control sp, lr, pc, cpsr.
Definition: svc.h:313
Undefined syscall.
Definition: svc.h:189
Result svcSetThreadPriority(Handle thread, s32 prio)
Changes the priority of a thread.
u32 croInfo
For LOAD_RO and UNLOAD_RO.
Definition: svc.h:213
Result svcSetDebugThreadContext(Handle debug, u32 threadId, ThreadContext *context, ThreadContextControlFlags controlFlags)
Updates the saved registers of a thread, either inactive or awaiting svcContinueDebugEvent,...
Result svcGetProcessAffinityMask(u8 *affinitymask, Handle process, s32 processorcount)
Gets a process's affinity mask.
Result svcGetDmaState(void *dmaState, Handle dma)
Gets the state of an inter-process DMA.
Result svcGetDebugThreadContext(ThreadContext *context, Handle debug, u32 threadId, ThreadContextControlFlags controlFlags)
Fetches the saved registers of a thread, either inactive or awaiting svcContinueDebugEvent,...
static void * getThreadLocalStorage(void)
Gets the thread local storage buffer.
Definition: svc.h:371
ExceptionEventType type
Type of event. See ExceptionEventType.
Definition: svc.h:224
Result svcBreakDebugProcess(Handle debug)
Breaks a debugged process.
Aliased memory.
Definition: svc.h:49
StopPointType
Stop point types.
Definition: svc.h:198
Memory page information.
Definition: svc.h:72
Result svcStartInterProcessDma(Handle *dma, Handle dstProcess, void *dst, Handle srcProcess, const void *src, u32 size, void *dmaConfig)
Begins an inter-process DMA.
ThreadContextControlFlags
Control flags for svcGetDebugThreadContext and svcSetDebugThreadContext.
Definition: svc.h:311
Result svcCreatePort(Handle *portServer, Handle *portClient, const char *name, s32 maxSessions)
Creates a port.
If the memory at the address is strictly lower than #value, then wait for signal.
Definition: svc.h:79
Mirror mapping.
Definition: svc.h:24
Process attached event.
Definition: svc.h:261
SyscallInOutEvent syscall
Syscall in/out event data.
Definition: svc.h:290
u32 rw_size_total
total pages for .data, .bss (aligned)
Definition: svc.h:350
u32 other_flags
Always 0.
Definition: svc.h:135
u32 flags
Page flags.
Definition: svc.h:73
Result svcDebugActiveProcess(Handle *debug, u32 processId)
Creates a debug handle for an active process.
Process has been terminated by svcTerminateProcess.
Definition: svc.h:141
u32 mapped_size
Mapped size.
Definition: svc.h:254
Result svcSetProcessAffinityMask(Handle process, const u8 *affinitymask, s32 processorcount)
Sets a process's affinity mask.
Result svcQueryDebugProcessMemory(MemInfo *info, PageInfo *out, Handle debug, u32 addr)
Queries memory information of a debugged process.
MemPerm memperm
Memory permissions. See MemPerm.
Definition: svc.h:255
Result svcReleaseMutex(Handle handle)
Releases a mutex.
Event relating to syscalls.
Definition: svc.h:240
Shared memory.
Definition: svc.h:47
Control all of the above.
Definition: svc.h:320
Result svcCloseHandle(Handle handle)
Closes a handle.
u32 creator_thread_id
ID of the creating thread.
Definition: svc.h:152
Result svcGetResourceLimitCurrentValues(s64 *values, Handle resourceLimit, ResourceLimitType *names, s32 nameCount)
Gets the values of a resource limit set.
__attribute__((warn_unused_result)) rbtree_node_t *rbtree_insert(rbtree_t *tree
Inserts a node into an rbtree.
If the memory at the address is strictly lower than #value, then decrement it and wait for signal or ...
Definition: svc.h:82
Result svcUnmapProcessMemory(Handle process, u32 destAddress, u32 size)
Unmaps a block of process memory, starting from address 0x00100000.
Event relating to svcBreakDebugProcess.
Definition: svc.h:218
ExceptionEventType
Reasons for an exception event.
Definition: svc.h:180
u32 string_addr
Address of the outputted string.
Definition: svc.h:247
Result svcGetProcessIdealProcessor(s32 *processorid, Handle process)
Gets a process's ideal processor.
CpuRegisters cpu_registers
CPU registers.
Definition: svc.h:306
Result svcSendSyncRequest(Handle session)
Sends a synchronized request to a session handle.
Free memory.
Definition: svc.h:41
Result svcClearTimer(Handle timer)
Clears a timer.
Forces enum size to be 32 bits.
Definition: svc.h:118
AttachProcessEvent attach_process
Process attachment event data.
Definition: svc.h:283
Result svcCreateAddressArbiter(Handle *arbiter)
Creates an address arbiter.
Number of shared memory objects, see svcCreateMemoryBlock.
Definition: svc.h:114
Event relating to fault exceptions (CPU exceptions other than stop points and undefined syscalls).
Definition: svc.h:193
Result svcUnbindInterrupt(u32 interruptId, Handle eventOrSemaphore)
Unbinds an event or semaphore handle from an ARM11 interrupt.
Data abort (other than the below kind).
Definition: svc.h:183
Result svcTerminateProcess(Handle process)
Terminates a process.
Thread priority.
Definition: svc.h:325
u32 text_size
.text number of pages
Definition: svc.h:343
StopPointExceptionEvent stop_point
Stop point exception event data.
Definition: svc.h:228