libctru  v1.6.0
Data Structures | Macros | Functions
svc.h File Reference

Syscall wrappers. More...

#include "types.h"

Go to the source code of this file.

Data Structures

struct  MemInfo
 Memory information. More...
 
struct  PageInfo
 Memory page information. More...
 
struct  AttachProcessEvent
 Event relating to the attachment of a process. More...
 
struct  ExitProcessEvent
 Event relating to the exiting of a process. More...
 
struct  AttachThreadEvent
 Event relating to the attachment of a thread. More...
 
struct  ExitThreadEvent
 Event relating to the exiting of a thread. More...
 
struct  FaultExceptionEvent
 Event relating to fault exceptions (CPU exceptions other than stop points and undefined syscalls). More...
 
struct  StopPointExceptionEvent
 Event relating to stop points. More...
 
struct  UserBreakExceptionEvent
 Event relating to svcBreak. More...
 
struct  DebuggerBreakExceptionEvent
 Event relating to svcBreakDebugProcess. More...
 
struct  ExceptionEvent
 Event relating to exceptions. More...
 
struct  ScheduleInOutEvent
 Event relating to the scheduler. More...
 
struct  SyscallInOutEvent
 Event relating to syscalls. More...
 
struct  OutputStringEvent
 Event relating to debug output. More...
 
struct  MapEvent
 Event relating to the mapping of memory. More...
 
struct  DebugEventInfo
 Information about a debug event. More...
 
struct  ThreadContext
 
struct  CodeSetInfo
 Information on address space for process. All sizes are in pages (0x1000 bytes) More...
 
struct  StartupInfo
 Information for the main thread of a process. More...
 

Macros

#define CUR_PROCESS_HANDLE   0xFFFF8001
 Pseudo handle for the current process.
 
#define SVC_STOP_POINT   __asm__ volatile("svc 0xFF");
 Stop point, does nothing if the process is not attached (as opposed to 'bkpt' instructions)
 

Functions

static void * getThreadLocalStorage (void)
 Gets the thread local storage buffer. More...
 
static u32getThreadCommandBuffer (void)
 Gets the thread command buffer. More...
 
static u32getThreadStaticBuffers (void)
 Gets the thread static buffer. More...
 
Result svcBackdoor (s32(*callback)(void))
 Executes a function in supervisor mode. More...
 
Process management
Result svcOpenProcess (Handle *process, u32 processId)
 Gets the handle of a process. More...
 
void svcExitProcess () __attribute__((noreturn))
 Exits the current process.
 
Result svcTerminateProcess (Handle process)
 Terminates a process. More...
 
Result svcGetProcessInfo (s64 *out, Handle process, u32 type)
 Gets information about a process. More...
 
Result svcGetProcessId (u32 *out, Handle handle)
 Gets the ID of a process. More...
 
Result svcGetProcessList (s32 *processCount, u32 *processIds, s32 processIdMaxCount)
 Gets a list of running processes. More...
 
Result svcGetThreadList (s32 *threadCount, u32 *threadIds, s32 threadIdMaxCount, Handle process)
 Gets a list of the threads of a process. More...
 
Result svcCreatePort (Handle *portServer, Handle *portClient, const char *name, s32 maxSessions)
 Creates a port. More...
 
Result svcConnectToPort (volatile Handle *out, const char *portName)
 Connects to a port. More...
 
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. More...
 
Result svcCreateProcess (Handle *out, Handle codeset, const u32 *arm11kernelcaps, u32 arm11kernelcaps_num)
 Sets up virtual address space for a new process. More...
 
Result svcGetProcessAffinityMask (u8 *affinitymask, Handle process, s32 processorcount)
 Gets a process's affinity mask. More...
 
Result svcSetProcessAffinityMask (Handle process, const u8 *affinitymask, s32 processorcount)
 Sets a process's affinity mask. More...
 
Result svcGetProcessIdealProcessor (s32 *processorid, Handle process)
 Gets a process's ideal processor. More...
 
Result svcSetProcessIdealProcessor (Handle process, s32 processorid)
 Sets a process's ideal processor. More...
 
Result svcRun (Handle process, const StartupInfo *info)
 Launches the main thread of the process. More...
 
Synchronization
Result svcCreateMutex (Handle *mutex, bool initially_locked)
 Creates a mutex. More...
 
Result svcReleaseMutex (Handle handle)
 Releases a mutex. More...
 
Result svcCreateSemaphore (Handle *semaphore, s32 initial_count, s32 max_count)
 Creates a semaphore. More...
 
Result svcReleaseSemaphore (s32 *count, Handle semaphore, s32 release_count)
 Releases a semaphore. More...
 
Result svcCreateEvent (Handle *event, ResetType reset_type)
 Creates an event handle. More...
 
Result svcSignalEvent (Handle handle)
 Signals an event. More...
 
Result svcClearEvent (Handle handle)
 Clears an event. More...
 
Result svcWaitSynchronization (Handle handle, s64 nanoseconds)
 Waits for synchronization on a handle. More...
 
Result svcWaitSynchronizationN (s32 *out, const Handle *handles, s32 handles_num, bool wait_all, s64 nanoseconds)
 Waits for synchronization on multiple handles. More...
 
Result svcCreateAddressArbiter (Handle *arbiter)
 Creates an address arbiter. More...
 
Result svcArbitrateAddress (Handle arbiter, u32 addr, ArbitrationType type, s32 value, s64 nanoseconds)
 Arbitrate an address, can be used for synchronization. More...
 
Result svcSendSyncRequest (Handle session)
 Sends a synchronized request to a session handle. More...
 
Result svcCreateSessionToPort (Handle *clientSession, Handle clientPort)
 Connects to a port via a handle. More...
 
Result svcCreateSession (Handle *serverSession, Handle *clientSession)
 Creates a linked pair of session endpoints. More...
 
Result svcAcceptSession (Handle *session, Handle port)
 Accepts a session. More...
 
Result svcReplyAndReceive (s32 *index, const Handle *handles, s32 handleCount, Handle replyTarget)
 Replies to and receives a new request. More...
 
Result svcBindInterrupt (u32 interruptId, Handle eventOrSemaphore, s32 priority, bool isManualClear)
 Binds an event or semaphore handle to an ARM11 interrupt. More...
 
Result svcUnbindInterrupt (u32 interruptId, Handle eventOrSemaphore)
 Unbinds an event or semaphore handle from an ARM11 interrupt. More...
 
Time
Result svcCreateTimer (Handle *timer, ResetType reset_type)
 Creates a timer. More...
 
Result svcSetTimer (Handle timer, s64 initial, s64 interval)
 Sets a timer. More...
 
Result svcCancelTimer (Handle timer)
 Cancels a timer. More...
 
Result svcClearTimer (Handle timer)
 Clears a timer. More...
 
u64 svcGetSystemTick (void)
 Gets the current system tick. More...
 
System
Result svcCloseHandle (Handle handle)
 Closes a handle. More...
 
Result svcDuplicateHandle (Handle *out, Handle original)
 Duplicates a handle. More...
 
Result svcGetHandleInfo (s64 *out, Handle handle, u32 param)
 Gets a handle info. More...
 
Result svcGetSystemInfo (s64 *out, u32 type, s32 param)
 Gets the system info. More...
 
Result svcSetGpuProt (bool useApplicationRestriction)
 Sets the GPU protection register to restrict the range of the GPU DMA. More...
 
Result svcSetWifiEnabled (bool enabled)
 Enables or disables Wi-Fi. More...
 
Result svcKernelSetState (u32 type,...)
 Sets the current kernel state. More...
 

Memory management

#define ARBITRATION_SIGNAL_ALL   (-1)
 Special value to signal all the threads.
 
enum  MemOp {
  MEMOP_FREE = 1,
  MEMOP_RESERVE = 2,
  MEMOP_ALLOC = 3,
  MEMOP_MAP = 4,
  MEMOP_UNMAP = 5,
  MEMOP_PROT = 6,
  MEMOP_REGION_APP = 0x100,
  MEMOP_REGION_SYSTEM = 0x200,
  MEMOP_REGION_BASE = 0x300,
  MEMOP_OP_MASK = 0xFF,
  MEMOP_REGION_MASK = 0xF00,
  MEMOP_LINEAR_FLAG = 0x10000,
  MEMOP_ALLOC_LINEAR = MEMOP_LINEAR_FLAG | MEMOP_ALLOC
}
 svcControlMemory operation flags More...
 
enum  MemState {
  MEMSTATE_FREE = 0,
  MEMSTATE_RESERVED = 1,
  MEMSTATE_IO = 2,
  MEMSTATE_STATIC = 3,
  MEMSTATE_CODE = 4,
  MEMSTATE_PRIVATE = 5,
  MEMSTATE_SHARED = 6,
  MEMSTATE_CONTINUOUS = 7,
  MEMSTATE_ALIASED = 8,
  MEMSTATE_ALIAS = 9,
  MEMSTATE_ALIASCODE = 10,
  MEMSTATE_LOCKED = 11
}
 The state of a memory block. More...
 
enum  MemPerm {
  MEMPERM_READ = 1,
  MEMPERM_WRITE = 2,
  MEMPERM_EXECUTE = 4,
  MEMPERM_DONTCARE = 0x10000000
}
 Memory permission flags. More...
 
enum  ArbitrationType {
  ARBITRATION_SIGNAL = 0,
  ARBITRATION_WAIT_IF_LESS_THAN = 1,
  ARBITRATION_DECREMENT_AND_WAIT_IF_LESS_THAN = 2,
  ARBITRATION_WAIT_IF_LESS_THAN_TIMEOUT = 3,
  ARBITRATION_DECREMENT_AND_WAIT_IF_LESS_THAN_TIMEOUT = 4
}
 Arbitration modes. More...
 
Result svcControlMemory (u32 *addr_out, u32 addr0, u32 addr1, u32 size, MemOp op, MemPerm perm)
 Controls memory mapping. More...
 
Result svcControlProcessMemory (Handle process, u32 addr0, u32 addr1, u32 size, u32 type, u32 perm)
 Controls the memory mapping of a process. More...
 
Result svcCreateMemoryBlock (Handle *memblock, u32 addr, u32 size, MemPerm my_perm, MemPerm other_perm)
 Creates a block of shared memory. More...
 
Result svcMapMemoryBlock (Handle memblock, u32 addr, MemPerm my_perm, MemPerm other_perm)
 Maps a block of shared memory. More...
 
Result svcMapProcessMemory (Handle process, u32 destAddress, u32 size)
 Maps a block of process memory, starting from address 0x00100000. More...
 
Result svcUnmapProcessMemory (Handle process, u32 destAddress, u32 size)
 Unmaps a block of process memory, starting from address 0x00100000. More...
 
Result svcUnmapMemoryBlock (Handle memblock, u32 addr)
 Unmaps a block of shared memory. More...
 
Result svcStartInterProcessDma (Handle *dma, Handle dstProcess, void *dst, Handle srcProcess, const void *src, u32 size, void *dmaConfig)
 Begins an inter-process DMA. More...
 
Result svcStopDma (Handle dma)
 Terminates an inter-process DMA. More...
 
Result svcGetDmaState (void *dmaState, Handle dma)
 Gets the state of an inter-process DMA. More...
 
Result svcQueryMemory (MemInfo *info, PageInfo *out, u32 addr)
 Queries memory information. More...
 
Result svcQueryProcessMemory (MemInfo *info, PageInfo *out, Handle process, u32 addr)
 Queries process memory information. More...
 
Result svcInvalidateProcessDataCache (Handle process, void *addr, u32 size)
 Invalidates a process's data cache. More...
 
Result svcStoreProcessDataCache (Handle process, void *addr, u32 size)
 Cleans a process's data cache. More...
 
Result svcFlushProcessDataCache (Handle process, void const *addr, u32 size)
 Flushes (cleans and invalidates) a process's data cache. More...
 

Multithreading

#define CUR_THREAD_HANDLE   0xFFFF8000
 Pseudo handle for the current thread.
 
enum  ResetType {
  RESET_ONESHOT = 0,
  RESET_STICKY = 1,
  RESET_PULSE = 2
}
 Reset types (for use with events and timers) More...
 
enum  ThreadInfoType { THREADINFO_TYPE_UNKNOWN }
 Types of thread info. More...
 
enum  ResourceLimitType {
  RESLIMIT_PRIORITY = 0,
  RESLIMIT_COMMIT = 1,
  RESLIMIT_THREAD = 2,
  RESLIMIT_EVENT = 3,
  RESLIMIT_MUTEX = 4,
  RESLIMIT_SEMAPHORE = 5,
  RESLIMIT_TIMER = 6,
  RESLIMIT_SHAREDMEMORY = 7,
  RESLIMIT_ADDRESSARBITER = 8,
  RESLIMIT_CPUTIME = 9,
  RESLIMIT_BIT = BIT(31)
}
 Types of resource limit. More...
 
Result svcCreateThread (Handle *thread, ThreadFunc entrypoint, u32 arg, u32 *stack_top, s32 thread_priority, s32 processor_id)
 Creates a new thread. More...
 
Result svcOpenThread (Handle *thread, Handle process, u32 threadId)
 Gets the handle of a thread. More...
 
void svcExitThread (void) __attribute__((noreturn))
 Exits the current thread. More...
 
void svcSleepThread (s64 ns)
 Puts the current thread to sleep. More...
 
Result svcGetThreadPriority (s32 *out, Handle handle)
 Retrieves the priority of a thread.
 
Result svcSetThreadPriority (Handle thread, s32 prio)
 Changes the priority of a thread. More...
 
Result svcGetThreadAffinityMask (u8 *affinitymask, Handle thread, s32 processorcount)
 Gets a thread's affinity mask. More...
 
Result svcSetThreadAffinityMask (Handle thread, const u8 *affinitymask, s32 processorcount)
 Sets a thread's affinity mask. More...
 
Result svcGetThreadIdealProcessor (s32 *processorid, Handle thread)
 Gets a thread's ideal processor. More...
 
Result svcSetThreadIdealProcessor (Handle thread, s32 processorid)
 Sets a thread's ideal processor. More...
 
s32 svcGetProcessorID (void)
 Returns the ID of the processor the current thread is running on. More...
 
Result svcGetThreadId (u32 *out, Handle handle)
 Gets the ID of a thread. More...
 
Result svcGetResourceLimit (Handle *resourceLimit, Handle process)
 Gets the resource limit set of a process. More...
 
Result svcGetResourceLimitLimitValues (s64 *values, Handle resourceLimit, ResourceLimitType *names, s32 nameCount)
 Gets the value limits of a resource limit set. More...
 
Result svcGetResourceLimitCurrentValues (s64 *values, Handle resourceLimit, ResourceLimitType *names, s32 nameCount)
 Gets the values of a resource limit set. More...
 
Result svcSetProcessResourceLimits (Handle process, Handle resourceLimit)
 Sets the resource limit set of a process. More...
 
Result svcCreateResourceLimit (Handle *resourceLimit)
 Creates a resource limit set. More...
 
Result svcSetResourceLimitValues (Handle resourceLimit, const ResourceLimitType *names, const s64 *values, s32 nameCount)
 Sets the value limits of a resource limit set. More...
 
Result svcGetProcessIdOfThread (u32 *out, Handle handle)
 Gets the process ID of a thread. More...
 
Result svcGetThreadInfo (s64 *out, Handle thread, ThreadInfoType type)
 Checks if a thread handle is valid. More...
 

Debugging

enum  ExitProcessEventReason {
  EXITPROCESS_EVENT_EXIT = 0,
  EXITPROCESS_EVENT_TERMINATE = 1,
  EXITPROCESS_EVENT_DEBUG_TERMINATE = 2
}
 Reasons for an exit process event. More...
 
enum  ExitThreadEventReason {
  EXITTHREAD_EVENT_EXIT = 0,
  EXITTHREAD_EVENT_TERMINATE = 1,
  EXITTHREAD_EVENT_EXIT_PROCESS = 2,
  EXITTHREAD_EVENT_TERMINATE_PROCESS = 3
}
 Reasons for an exit thread event. More...
 
enum  UserBreakType {
  USERBREAK_PANIC = 0,
  USERBREAK_ASSERT = 1,
  USERBREAK_USER = 2,
  USERBREAK_LOAD_RO = 3,
  USERBREAK_UNLOAD_RO = 4
}
 Reasons for a user break. More...
 
enum  ExceptionEventType {
  EXCEVENT_UNDEFINED_INSTRUCTION = 0,
  EXCEVENT_PREFETCH_ABORT = 1,
  EXCEVENT_DATA_ABORT = 2,
  EXCEVENT_UNALIGNED_DATA_ACCESS = 3,
  EXCEVENT_ATTACH_BREAK = 4,
  EXCEVENT_STOP_POINT = 5,
  EXCEVENT_USER_BREAK = 6,
  EXCEVENT_DEBUGGER_BREAK = 7,
  EXCEVENT_UNDEFINED_SYSCALL = 8
}
 Reasons for an exception event. More...
 
enum  StopPointType {
  STOPPOINT_SVC_FF = 0,
  STOPPOINT_BREAKPOINT = 1,
  STOPPOINT_WATCHPOINT = 2
}
 Stop point types. More...
 
enum  DebugEventType {
  DBGEVENT_ATTACH_PROCESS = 0,
  DBGEVENT_ATTACH_THREAD = 1,
  DBGEVENT_EXIT_THREAD = 2,
  DBGEVENT_EXIT_PROCESS = 3,
  DBGEVENT_EXCEPTION = 4,
  DBGEVENT_DLL_LOAD = 5,
  DBGEVENT_DLL_UNLOAD = 6,
  DBGEVENT_SCHEDULE_IN = 7,
  DBGEVENT_SCHEDULE_OUT = 8,
  DBGEVENT_SYSCALL_IN = 9,
  DBGEVENT_SYSCALL_OUT = 10,
  DBGEVENT_OUTPUT_STRING = 11,
  DBGEVENT_MAP = 12
}
 Debug event type. More...
 
enum  DebugFlags {
  DBG_INHIBIT_USER_CPU_EXCEPTION_HANDLERS = BIT(0),
  DBG_SIGNAL_FAULT_EXCEPTION_EVENTS = BIT(1),
  DBG_SIGNAL_SCHEDULE_EVENTS = BIT(2),
  DBG_SIGNAL_SYSCALL_EVENTS = BIT(3),
  DBG_SIGNAL_MAP_EVENTS = BIT(4)
}
 Debug flags for an attached process, set by svcContinueDebugEvent. More...
 
enum  ThreadContextControlFlags {
  THREADCONTEXT_CONTROL_CPU_GPRS = BIT(0),
  THREADCONTEXT_CONTROL_CPU_SPRS = BIT(1),
  THREADCONTEXT_CONTROL_FPU_GPRS = BIT(2),
  THREADCONTEXT_CONTROL_FPU_SPRS = BIT(3),
  THREADCONTEXT_CONTROL_CPU_REGS = BIT(0) | BIT(1),
  THREADCONTEXT_CONTROL_FPU_REGS = BIT(2) | BIT(3),
  THREADCONTEXT_CONTROL_ALL = BIT(0) | BIT(1) | BIT(2) | BIT(3)
}
 Control flags for svcGetDebugThreadContext and svcSetDebugThreadContext. More...
 
enum  DebugThreadParameter {
  DBGTHREAD_PARAMETER_PRIORITY = 0,
  DBGTHREAD_PARAMETER_SCHEDULING_MASK_LOW = 1,
  DBGTHREAD_PARAMETER_CPU_IDEAL = 2,
  DBGTHREAD_PARAMETER_CPU_CREATOR = 3
}
 Thread parameter field for svcGetDebugThreadParameter. More...
 
void svcBreak (UserBreakType breakReason)
 Breaks execution. More...
 
void svcBreakRO (UserBreakType breakReason, const void *croInfo, u32 croInfoSize) __asm__("svcBreak")
 Breaks execution (LOAD_RO and UNLOAD_RO). More...
 
Result svcOutputDebugString (const char *str, s32 length)
 Outputs a debug string. More...
 
Result svcDebugActiveProcess (Handle *debug, u32 processId)
 Creates a debug handle for an active process. More...
 
Result svcBreakDebugProcess (Handle debug)
 Breaks a debugged process. More...
 
Result svcTerminateDebugProcess (Handle debug)
 Terminates a debugged process. More...
 
Result svcGetProcessDebugEvent (DebugEventInfo *info, Handle debug)
 Gets the current debug event of a debugged process. More...
 
Result svcContinueDebugEvent (Handle debug, DebugFlags flags)
 Continues the current debug event of a debugged process (not necessarily the same as svcGetProcessDebugEvent). More...
 
Result svcGetDebugThreadContext (ThreadContext *context, Handle debug, u32 threadId, ThreadContextControlFlags controlFlags)
 Fetches the saved registers of a thread, either inactive or awaiting svcContinueDebugEvent, belonging to a debugged process. More...
 
Result svcSetDebugThreadContext (Handle debug, u32 threadId, ThreadContext *context, ThreadContextControlFlags controlFlags)
 Updates the saved registers of a thread, either inactive or awaiting svcContinueDebugEvent, belonging to a debugged process. More...
 
Result svcQueryDebugProcessMemory (MemInfo *info, PageInfo *out, Handle debug, u32 addr)
 Queries memory information of a debugged process. More...
 
Result svcReadProcessMemory (void *buffer, Handle debug, u32 addr, u32 size)
 Reads from a debugged process's memory. More...
 
Result svcWriteProcessMemory (Handle debug, const void *buffer, u32 addr, u32 size)
 Writes to a debugged process's memory. More...
 
Result svcSetHardwareBreakPoint (s32 registerId, u32 control, u32 value)
 Sets an hardware breakpoint or watchpoint. More...
 
Result svcGetDebugThreadParam (s64 *unused, u32 *out, Handle debug, u32 threadId, DebugThreadParameter parameter)
 Gets a debugged thread's parameter. More...
 

Detailed Description

Syscall wrappers.

Enumeration Type Documentation

◆ ArbitrationType

Arbitration modes.

Enumerator
ARBITRATION_SIGNAL 

Signal #value threads for wake-up.

ARBITRATION_WAIT_IF_LESS_THAN 

If the memory at the address is strictly lower than #value, then wait for signal.

ARBITRATION_DECREMENT_AND_WAIT_IF_LESS_THAN 

If the memory at the address is strictly lower than #value, then decrement it and wait for signal.

ARBITRATION_WAIT_IF_LESS_THAN_TIMEOUT 

If the memory at the address is strictly lower than #value, then wait for signal or timeout.

ARBITRATION_DECREMENT_AND_WAIT_IF_LESS_THAN_TIMEOUT 

If the memory at the address is strictly lower than #value, then decrement it and wait for signal or timeout.

◆ DebugEventType

Debug event type.

Enumerator
DBGEVENT_ATTACH_PROCESS 

Process attached event.

DBGEVENT_ATTACH_THREAD 

Thread attached event.

DBGEVENT_EXIT_THREAD 

Thread exit event.

DBGEVENT_EXIT_PROCESS 

Process exit event.

DBGEVENT_EXCEPTION 

Exception event.

DBGEVENT_DLL_LOAD 

DLL load event.

DBGEVENT_DLL_UNLOAD 

DLL unload event.

DBGEVENT_SCHEDULE_IN 

Schedule in event.

DBGEVENT_SCHEDULE_OUT 

Schedule out event.

DBGEVENT_SYSCALL_IN 

Syscall in event.

DBGEVENT_SYSCALL_OUT 

Syscall out event.

DBGEVENT_OUTPUT_STRING 

Output string event.

DBGEVENT_MAP 

Map event.

◆ DebugFlags

enum DebugFlags

Debug flags for an attached process, set by svcContinueDebugEvent.

Enumerator
DBG_INHIBIT_USER_CPU_EXCEPTION_HANDLERS 

Inhibit user-defined CPU exception handlers (including watchpoints and breakpoints, regardless of any svcKernelSetState call).

DBG_SIGNAL_FAULT_EXCEPTION_EVENTS 

Signal fault exception events. See FaultExceptionEvent.

DBG_SIGNAL_SCHEDULE_EVENTS 

Signal schedule in/out events. See ScheduleInOutEvent.

DBG_SIGNAL_SYSCALL_EVENTS 

Signal syscall in/out events. See SyscallInOutEvent.

DBG_SIGNAL_MAP_EVENTS 

Signal map events. See MapEvent.

◆ DebugThreadParameter

Thread parameter field for svcGetDebugThreadParameter.

Enumerator
DBGTHREAD_PARAMETER_PRIORITY 

Thread priority.

DBGTHREAD_PARAMETER_SCHEDULING_MASK_LOW 

Low scheduling mask.

DBGTHREAD_PARAMETER_CPU_IDEAL 

Ideal processor.

DBGTHREAD_PARAMETER_CPU_CREATOR 

Processor that created the threod.

◆ ExceptionEventType

Reasons for an exception event.

Enumerator
EXCEVENT_UNDEFINED_INSTRUCTION 

Undefined instruction.

EXCEVENT_PREFETCH_ABORT 

Prefetch abort.

EXCEVENT_DATA_ABORT 

Data abort (other than the below kind).

EXCEVENT_UNALIGNED_DATA_ACCESS 

Unaligned data access.

EXCEVENT_ATTACH_BREAK 

Attached break.

EXCEVENT_STOP_POINT 

Stop point reached.

EXCEVENT_USER_BREAK 

User break occurred.

EXCEVENT_DEBUGGER_BREAK 

Debugger break occurred.

EXCEVENT_UNDEFINED_SYSCALL 

Undefined syscall.

◆ ExitProcessEventReason

Reasons for an exit process event.

Enumerator
EXITPROCESS_EVENT_EXIT 

Process exited either normally or due to an uncaught exception.

EXITPROCESS_EVENT_TERMINATE 

Process has been terminated by svcTerminateProcess.

EXITPROCESS_EVENT_DEBUG_TERMINATE 

Process has been terminated by svcTerminateDebugProcess.

◆ ExitThreadEventReason

Reasons for an exit thread event.

Enumerator
EXITTHREAD_EVENT_EXIT 

Thread exited.

EXITTHREAD_EVENT_TERMINATE 

Thread terminated.

EXITTHREAD_EVENT_EXIT_PROCESS 

Process exited either normally or due to an uncaught exception.

EXITTHREAD_EVENT_TERMINATE_PROCESS 

Process has been terminated by svcTerminateProcess.

◆ MemOp

enum MemOp

svcControlMemory operation flags

The lowest 8 bits are the operation

Enumerator
MEMOP_FREE 

Memory un-mapping.

MEMOP_RESERVE 

Reserve memory.

MEMOP_ALLOC 

Memory mapping.

MEMOP_MAP 

Mirror mapping.

MEMOP_UNMAP 

Mirror unmapping.

MEMOP_PROT 

Change protection.

MEMOP_REGION_APP 

APPLICATION memory region.

MEMOP_REGION_SYSTEM 

SYSTEM memory region.

MEMOP_REGION_BASE 

BASE memory region.

MEMOP_OP_MASK 

Operation bitmask.

MEMOP_REGION_MASK 

Region bitmask.

MEMOP_LINEAR_FLAG 

Flag for linear memory operations.

MEMOP_ALLOC_LINEAR 

Allocates linear memory.

◆ MemPerm

enum MemPerm

Memory permission flags.

Enumerator
MEMPERM_READ 

Readable.

MEMPERM_WRITE 

Writable.

MEMPERM_EXECUTE 

Executable.

MEMPERM_DONTCARE 

Don't care.

◆ MemState

enum MemState

The state of a memory block.

Enumerator
MEMSTATE_FREE 

Free memory.

MEMSTATE_RESERVED 

Reserved memory.

MEMSTATE_IO 

I/O memory.

MEMSTATE_STATIC 

Static memory.

MEMSTATE_CODE 

Code memory.

MEMSTATE_PRIVATE 

Private memory.

MEMSTATE_SHARED 

Shared memory.

MEMSTATE_CONTINUOUS 

Continuous memory.

MEMSTATE_ALIASED 

Aliased memory.

MEMSTATE_ALIAS 

Alias memory.

MEMSTATE_ALIASCODE 

Aliased code memory.

MEMSTATE_LOCKED 

Locked memory.

◆ ResetType

enum ResetType

Reset types (for use with events and timers)

Enumerator
RESET_ONESHOT 

When the primitive is signaled, it will wake up exactly one thread and will clear itself automatically.

RESET_STICKY 

When the primitive is signaled, it will wake up all threads and it won't clear itself automatically.

RESET_PULSE 

Only meaningful for timers: same as ONESHOT but it will periodically signal the timer instead of just once.

◆ ResourceLimitType

Types of resource limit.

Enumerator
RESLIMIT_PRIORITY 

Thread priority.

RESLIMIT_COMMIT 

Quantity of allocatable memory.

RESLIMIT_THREAD 

Number of threads.

RESLIMIT_EVENT 

Number of events.

RESLIMIT_MUTEX 

Number of mutexes.

RESLIMIT_SEMAPHORE 

Number of semaphores.

RESLIMIT_TIMER 

Number of timers.

RESLIMIT_SHAREDMEMORY 

Number of shared memory objects, see svcCreateMemoryBlock.

RESLIMIT_ADDRESSARBITER 

Number of address arbiters.

RESLIMIT_CPUTIME 

CPU time. Value expressed in percentage regular until it reaches 90.

RESLIMIT_BIT 

Forces enum size to be 32 bits.

◆ StopPointType

Stop point types.

Enumerator
STOPPOINT_SVC_FF 

See SVC_STOP_POINT.

STOPPOINT_BREAKPOINT 

Breakpoint.

STOPPOINT_WATCHPOINT 

Watchpoint.

◆ ThreadContextControlFlags

Control flags for svcGetDebugThreadContext and svcSetDebugThreadContext.

Enumerator
THREADCONTEXT_CONTROL_CPU_GPRS 

Control r0-r12.

THREADCONTEXT_CONTROL_CPU_SPRS 

Control sp, lr, pc, cpsr.

THREADCONTEXT_CONTROL_FPU_GPRS 

Control d0-d15 (or s0-s31).

THREADCONTEXT_CONTROL_FPU_SPRS 

Control fpscr, fpexc.

THREADCONTEXT_CONTROL_CPU_REGS 

Control r0-r12, sp, lr, pc, cpsr.

THREADCONTEXT_CONTROL_FPU_REGS 

Control d0-d15, fpscr, fpexc.

THREADCONTEXT_CONTROL_ALL 

Control all of the above.

◆ ThreadInfoType

Types of thread info.

Enumerator
THREADINFO_TYPE_UNKNOWN 

Unknown.

◆ UserBreakType

Reasons for a user break.

Enumerator
USERBREAK_PANIC 

Panic.

USERBREAK_ASSERT 

Assertion failed.

USERBREAK_USER 

User related.

USERBREAK_LOAD_RO 

Load RO.

USERBREAK_UNLOAD_RO 

Unload RO.

Function Documentation

◆ getThreadCommandBuffer()

static u32* getThreadCommandBuffer ( void  )
inlinestatic

Gets the thread command buffer.

Returns
The thread command bufger.

◆ getThreadLocalStorage()

static void* getThreadLocalStorage ( void  )
inlinestatic

Gets the thread local storage buffer.

Returns
The thread local storage bufger.

◆ getThreadStaticBuffers()

static u32* getThreadStaticBuffers ( void  )
inlinestatic

Gets the thread static buffer.

Returns
The thread static bufger.

◆ svcAcceptSession()

Result svcAcceptSession ( Handle session,
Handle  port 
)

Accepts a session.

Parameters
[out]sessionPointer to output the created session handle to.
portHandle of the port to accept a session from.

◆ svcArbitrateAddress()

Result svcArbitrateAddress ( Handle  arbiter,
u32  addr,
ArbitrationType  type,
s32  value,
s64  nanoseconds 
)

Arbitrate an address, can be used for synchronization.

Parameters
arbiterHandle of the arbiter
addrA pointer to a s32 value.
typeType of action to be performed by the arbiter
valueNumber of threads to signal if using ARBITRATION_SIGNAL, or the value used for comparison.

This will perform an arbitration based on #type. The comparisons are done between #value and the value at the address #addr.

s32 val=0;
// Does *nothing* since val >= 0
// Thread will wait for a signal or wake up after 10000000 nanoseconds because val < 1.

◆ svcBackdoor()

Result svcBackdoor ( s32(*)(void)  callback)

Executes a function in supervisor mode.

Parameters
callbackFunction to execute.

◆ svcBindInterrupt()

Result svcBindInterrupt ( u32  interruptId,
Handle  eventOrSemaphore,
s32  priority,
bool  isManualClear 
)

Binds an event or semaphore handle to an ARM11 interrupt.

Parameters
interruptIdInterrupt identfier (see https://www.3dbrew.org/wiki/ARM11_Interrupts).
eventOrSemaphoreEvent or semaphore handle to bind to the given interrupt.
priorityPriority of the interrupt for the current process.
isManualClearIndicates whether the interrupt has to be manually cleared or not (= level-high active).

◆ svcBreak()

void svcBreak ( UserBreakType  breakReason)

Breaks execution.

Parameters
breakReasonReason for breaking.
Examples
graphics/gpu/gpusprites/source/main.c, and graphics/gpu/textured_cube/source/main.c.

◆ svcBreakDebugProcess()

Result svcBreakDebugProcess ( Handle  debug)

Breaks a debugged process.

Parameters
debugDebug handle of the process.

◆ svcBreakRO()

void svcBreakRO ( UserBreakType  breakReason,
const void *  croInfo,
u32  croInfoSize 
)

Breaks execution (LOAD_RO and UNLOAD_RO).

Parameters
breakReasonDebug reason for breaking.
croInfoLibrary information.
croInfoSizeSize of the above structure.

◆ svcCancelTimer()

Result svcCancelTimer ( Handle  timer)

Cancels a timer.

Parameters
timerHandle of the timer to cancel.

◆ svcClearEvent()

Result svcClearEvent ( Handle  handle)

Clears an event.

Parameters
handleHandle of the event to clear.
Examples
threads/event/source/main.c.

◆ svcClearTimer()

Result svcClearTimer ( Handle  timer)

Clears a timer.

Parameters
timerHandle of the timer to clear.

◆ svcCloseHandle()

Result svcCloseHandle ( Handle  handle)

Closes a handle.

Parameters
handleHandle to close.
Examples
camera/image/source/main.c, camera/video/source/main.c, and threads/event/source/main.c.

◆ svcConnectToPort()

Result svcConnectToPort ( volatile Handle out,
const char *  portName 
)

Connects to a port.

Parameters
[out]outPointer to output the port handle to.
portNameName of the port.

◆ svcContinueDebugEvent()

Result svcContinueDebugEvent ( Handle  debug,
DebugFlags  flags 
)

Continues the current debug event of a debugged process (not necessarily the same as svcGetProcessDebugEvent).

Parameters
debugDebug handle of the process.
flagsFlags to continue with, see DebugFlags.

◆ svcControlMemory()

Result svcControlMemory ( u32 addr_out,
u32  addr0,
u32  addr1,
u32  size,
MemOp  op,
MemPerm  perm 
)

Controls memory mapping.

Parameters
[out]addr_outThe virtual address resulting from the operation. Usually the same as addr0.
addr0The virtual address to be used for the operation.
addr1The virtual address to be (un)mirrored by addr0 when using MEMOP_MAP or MEMOP_UNMAP. It has to be pointing to a RW memory. Use NULL if the operation is MEMOP_FREE or MEMOP_ALLOC.
sizeThe requested size for MEMOP_ALLOC and MEMOP_ALLOC_LINEAR.
opOperation flags. See MemOp.
permA combination of MEMPERM_READ and MEMPERM_WRITE. Using MEMPERM_EXECUTE will return an error. Value 0 is used when unmapping memory.

If a memory is mapped for two or more addresses, you have to use MEMOP_UNMAP before being able to MEMOP_FREE it. MEMOP_MAP will fail if addr1 was already mapped to another address.

More information is available at http://3dbrew.org/wiki/SVC#Memory_Mapping.

See also
svcControlProcessMemory

◆ svcControlProcessMemory()

Result svcControlProcessMemory ( Handle  process,
u32  addr0,
u32  addr1,
u32  size,
u32  type,
u32  perm 
)

Controls the memory mapping of a process.

Parameters
addr0The virtual address to map
addr1The virtual address to be mapped by addr0
typeOnly operations MEMOP_MAP, MEMOP_UNMAP and MEMOP_PROT are allowed.

This is the only SVC which allows mapping executable memory. Using MEMOP_PROT will change the memory permissions of an already mapped memory.

Note
The pseudo handle for the current process is not supported by this service call.
See also
svcControlProcess

◆ svcCreateAddressArbiter()

Result svcCreateAddressArbiter ( Handle arbiter)

Creates an address arbiter.

Parameters
[out]mutexPointer to output the handle of the created address arbiter to.
See also
svcArbitrateAddress

◆ svcCreateCodeSet()

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.

Parameters
[out]outPointer to output the code set handle to.
infoDescription for setting up the addresses
code_ptrPointer to .text in shared memory
ro_ptrPointer to .rodata in shared memory
data_ptrPointer to .data in shared memory

◆ svcCreateEvent()

Result svcCreateEvent ( Handle event,
ResetType  reset_type 
)

Creates an event handle.

Parameters
[out]eventPointer to output the created event handle to.
reset_typeType of reset the event uses (RESET_ONESHOT/RESET_STICKY).
Examples
threads/event/source/main.c.

◆ svcCreateMemoryBlock()

Result svcCreateMemoryBlock ( Handle memblock,
u32  addr,
u32  size,
MemPerm  my_perm,
MemPerm  other_perm 
)

Creates a block of shared memory.

Parameters
[out]memblockPointer to store the handle of the block
addrAddress of the memory to map, page-aligned. So its alignment must be 0x1000.
sizeSize of the memory to map, a multiple of 0x1000.
my_permMemory permissions for the current process
other_permMemory permissions for the other processes
Note
The shared memory block, and its rights, are destroyed when the handle is closed.

◆ svcCreateMutex()

Result svcCreateMutex ( Handle mutex,
bool  initially_locked 
)

Creates a mutex.

Parameters
[out]mutexPointer to output the handle of the created mutex to.
initially_lockedWhether the mutex should be initially locked.

◆ svcCreatePort()

Result svcCreatePort ( Handle portServer,
Handle portClient,
const char *  name,
s32  maxSessions 
)

Creates a port.

Parameters
[out]portServerPointer to output the port server handle to.
[out]portClientPointer to output the port client handle to.
nameName of the port.
maxSessionsMaximum number of sessions that can connect to the port.

◆ svcCreateProcess()

Result svcCreateProcess ( Handle out,
Handle  codeset,
const u32 arm11kernelcaps,
u32  arm11kernelcaps_num 
)

Sets up virtual address space for a new process.

Parameters
[out]outPointer to output the process handle to.
codesetCodeset created for this process
arm11kernelcapsARM11 Kernel Capabilities from exheader
arm11kernelcaps_numNumber of kernel capabilities

◆ svcCreateResourceLimit()

Result svcCreateResourceLimit ( Handle resourceLimit)

Creates a resource limit set.

Parameters
[out]resourceLimitPointer to output the resource limit set handle to.

◆ svcCreateSemaphore()

Result svcCreateSemaphore ( Handle semaphore,
s32  initial_count,
s32  max_count 
)

Creates a semaphore.

Parameters
[out]semaphorePointer to output the handle of the created semaphore to.
initial_countInitial count of the semaphore.
max_countMaximum count of the semaphore.

◆ svcCreateSession()

Result svcCreateSession ( Handle serverSession,
Handle clientSession 
)

Creates a linked pair of session endpoints.

Parameters
[out]serverSessionPointer to output the created server endpoint handle to.
[out]clientSessionPointer to output the created client endpoint handle to.

◆ svcCreateSessionToPort()

Result svcCreateSessionToPort ( Handle clientSession,
Handle  clientPort 
)

Connects to a port via a handle.

Parameters
[out]clientSessionPointer to output the client session handle to.
clientPortPort client endpoint to connect to.

◆ svcCreateThread()

Result svcCreateThread ( Handle thread,
ThreadFunc  entrypoint,
u32  arg,
u32 stack_top,
s32  thread_priority,
s32  processor_id 
)

Creates a new thread.

Parameters
[out]threadThe thread handle
entrypointThe function that will be called first upon thread creation
argThe argument passed to entrypoint
stack_topThe top of the thread's stack. Must be 0x8 bytes mem-aligned.
thread_priorityLow values gives the thread higher priority. For userland apps, this has to be within the range [0x18;0x3F]
processor_idThe id of the processor the thread should be ran on. Those are labelled starting from 0. For old 3ds it has to be <2, and for new 3DS <4. Value -1 means all CPUs and -2 read from the Exheader.

The processor with ID 1 is the system processor. To enable multi-threading on this core you need to call APT_SetAppCpuTimeLimit at least once with a non-zero value.

Since a thread is considered as a waitable object, you can use svcWaitSynchronization and svcWaitSynchronizationN to join with it.

Note
The kernel will clear the stack_top's address low 3 bits to make sure it is 0x8-bytes aligned.

◆ svcCreateTimer()

Result svcCreateTimer ( Handle timer,
ResetType  reset_type 
)

Creates a timer.

Parameters
[out]timerPointer to output the handle of the created timer to.
reset_typeType of reset to perform on the timer.

◆ svcDebugActiveProcess()

Result svcDebugActiveProcess ( Handle debug,
u32  processId 
)

Creates a debug handle for an active process.

Parameters
[out]debugPointer to output the created debug handle to.
processIdID of the process to debug.

◆ svcDuplicateHandle()

Result svcDuplicateHandle ( Handle out,
Handle  original 
)

Duplicates a handle.

Parameters
[out]outPointer to output the duplicated handle to.
originalHandle to duplicate.

◆ svcExitThread()

void svcExitThread ( void  )

Exits the current thread.

This will trigger a state change and hence release all svcWaitSynchronization operations. It means that you can join a thread by calling

svcWaitSynchronization(threadHandle,yourtimeout);

◆ svcFlushProcessDataCache()

Result svcFlushProcessDataCache ( Handle  process,
void const *  addr,
u32  size 
)

Flushes (cleans and invalidates) a process's data cache.

Parameters
processHandle of the process.
addrAddress to flush.
sizeSize of the memory to flush.

◆ svcGetDebugThreadContext()

Result svcGetDebugThreadContext ( ThreadContext context,
Handle  debug,
u32  threadId,
ThreadContextControlFlags  controlFlags 
)

Fetches the saved registers of a thread, either inactive or awaiting svcContinueDebugEvent, belonging to a debugged process.

Parameters
[out]contextValues of the registers to fetch, see ThreadContext.
debugDebug handle of the parent process.
threadIdID of the thread to fetch the saved registers of.
controlFlagsWhich registers to fetch, see ThreadContextControlFlags.

◆ svcGetDebugThreadParam()

Result svcGetDebugThreadParam ( s64 unused,
u32 out,
Handle  debug,
u32  threadId,
DebugThreadParameter  parameter 
)

Gets a debugged thread's parameter.

Parameters
[out]unusedUnused.
[out]outOutput value.
debugDebug handle of the process.
threadIdID of the thread
parameterParameter to fetch, see DebugThreadParameter.

◆ svcGetDmaState()

Result svcGetDmaState ( void *  dmaState,
Handle  dma 
)

Gets the state of an inter-process DMA.

Parameters
[out]dmaStatePointer to output the state of the DMA to.
dmaHandle of the DMA.

◆ svcGetHandleInfo()

Result svcGetHandleInfo ( s64 out,
Handle  handle,
u32  param 
)

Gets a handle info.

Parameters
[out]outPointer to output the handle info to.
handleHandle to get the info for.
paramParameter clarifying the handle info type.

◆ svcGetProcessAffinityMask()

Result svcGetProcessAffinityMask ( u8 affinitymask,
Handle  process,
s32  processorcount 
)

Gets a process's affinity mask.

Parameters
[out]affinitymaskPointer to store the affinity masks.
processHandle of the process.
processorcountNumber of processors.

◆ svcGetProcessDebugEvent()

Result svcGetProcessDebugEvent ( DebugEventInfo info,
Handle  debug 
)

Gets the current debug event of a debugged process.

Parameters
[out]infoPointer to output the debug event information to.
debugDebug handle of the process.

◆ svcGetProcessId()

Result svcGetProcessId ( u32 out,
Handle  handle 
)

Gets the ID of a process.

Parameters
[out]outPointer to output the process ID to.
handleHandle of the process to get the ID of.

◆ svcGetProcessIdealProcessor()

Result svcGetProcessIdealProcessor ( s32 processorid,
Handle  process 
)

Gets a process's ideal processor.

Parameters
[out]processoridPointer to store the ID of the process's ideal processor.
processHandle of the process.

◆ svcGetProcessIdOfThread()

Result svcGetProcessIdOfThread ( u32 out,
Handle  handle 
)

Gets the process ID of a thread.

Parameters
[out]outPointer to output the process ID of the thread handle to.
handleHandle of the thread.
See also
svcOpenProcess

◆ svcGetProcessInfo()

Result svcGetProcessInfo ( s64 out,
Handle  process,
u32  type 
)

Gets information about a process.

Parameters
[out]outPointer to output process info to.
processHandle of the process to get information about.
typeType of information to retreieve.

◆ svcGetProcessList()

Result svcGetProcessList ( s32 processCount,
u32 processIds,
s32  processIdMaxCount 
)

Gets a list of running processes.

Parameters
[out]processCountPointer to output the process count to.
[out]processIdsPointer to output the process IDs to.
processIdMaxCountMaximum number of process IDs.

◆ svcGetProcessorID()

s32 svcGetProcessorID ( void  )

Returns the ID of the processor the current thread is running on.

See also
svcCreateThread

◆ svcGetResourceLimit()

Result svcGetResourceLimit ( Handle resourceLimit,
Handle  process 
)

Gets the resource limit set of a process.

Parameters
[out]resourceLimitPointer to output the resource limit set handle to.
processProcess to get the resource limits of.

◆ svcGetResourceLimitCurrentValues()

Result svcGetResourceLimitCurrentValues ( s64 values,
Handle  resourceLimit,
ResourceLimitType names,
s32  nameCount 
)

Gets the values of a resource limit set.

Parameters
[out]valuesPointer to output the values to.
resourceLimitResource limit set to use.
namesResource limit names to get the values of.
nameCountNumber of resource limit names.

◆ svcGetResourceLimitLimitValues()

Result svcGetResourceLimitLimitValues ( s64 values,
Handle  resourceLimit,
ResourceLimitType names,
s32  nameCount 
)

Gets the value limits of a resource limit set.

Parameters
[out]valuesPointer to output the value limits to.
resourceLimitResource limit set to use.
namesResource limit names to get the limits of.
nameCountNumber of resource limit names.

◆ svcGetSystemInfo()

Result svcGetSystemInfo ( s64 out,
u32  type,
s32  param 
)

Gets the system info.

Parameters
[out]outPointer to output the system info to.
typeType of system info to retrieve.
paramParameter clarifying the system info type.

◆ svcGetSystemTick()

u64 svcGetSystemTick ( void  )

Gets the current system tick.

Returns
The current system tick.

◆ svcGetThreadAffinityMask()

Result svcGetThreadAffinityMask ( u8 affinitymask,
Handle  thread,
s32  processorcount 
)

Gets a thread's affinity mask.

Parameters
[out]affinitymaskPointer to output the affinity masks to.
threadHandle of the thread.
processorcountNumber of processors.

◆ svcGetThreadId()

Result svcGetThreadId ( u32 out,
Handle  handle 
)

Gets the ID of a thread.

Parameters
[out]outPointer to output the thread ID of the thread handle to.
handleHandle of the thread.

◆ svcGetThreadIdealProcessor()

Result svcGetThreadIdealProcessor ( s32 processorid,
Handle  thread 
)

Gets a thread's ideal processor.

Parameters
[out]processoridPointer to output the ID of the thread's ideal processor to.
threadHandle of the thread.

◆ svcGetThreadInfo()

Result svcGetThreadInfo ( s64 out,
Handle  thread,
ThreadInfoType  type 
)

Checks if a thread handle is valid.

This requests always return an error when called, it only checks if the handle is a thread or not.

Returns
0xD8E007ED (BAD_ENUM) if the Handle is a Thread Handle
0xD8E007F7 (BAD_HANDLE) if it isn't.

◆ svcGetThreadList()

Result svcGetThreadList ( s32 threadCount,
u32 threadIds,
s32  threadIdMaxCount,
Handle  process 
)

Gets a list of the threads of a process.

Parameters
[out]threadCountPointer to output the thread count to.
[out]threadIdsPointer to output the thread IDs to.
threadIdMaxCountMaximum number of thread IDs.
processProcess handle to list the threads of.

◆ svcInvalidateProcessDataCache()

Result svcInvalidateProcessDataCache ( Handle  process,
void *  addr,
u32  size 
)

Invalidates a process's data cache.

Parameters
processHandle of the process.
addrAddress to invalidate.
sizeSize of the memory to invalidate.

◆ svcKernelSetState()

Result svcKernelSetState ( u32  type,
  ... 
)

Sets the current kernel state.

Parameters
typeType of state to set (the other parameters depend on it).

◆ svcMapMemoryBlock()

Result svcMapMemoryBlock ( Handle  memblock,
u32  addr,
MemPerm  my_perm,
MemPerm  other_perm 
)

Maps a block of shared memory.

Parameters
memblockHandle of the block
addrAddress of the memory to map, page-aligned. So its alignment must be 0x1000.
my_permMemory permissions for the current process
other_permMemory permissions for the other processes
Note
The shared memory block, and its rights, are destroyed when the handle is closed.

◆ svcMapProcessMemory()

Result svcMapProcessMemory ( Handle  process,
u32  destAddress,
u32  size 
)

Maps a block of process memory, starting from address 0x00100000.

Parameters
processHandle of the process.
destAddressAddress of the block of memory to map, in the current (destination) process.
sizeSize of the block of memory to map (truncated to a multiple of 0x1000 bytes).

◆ svcOpenProcess()

Result svcOpenProcess ( Handle process,
u32  processId 
)

Gets the handle of a process.

Parameters
[out]processThe handle of the process
processIdThe ID of the process to open

◆ svcOpenThread()

Result svcOpenThread ( Handle thread,
Handle  process,
u32  threadId 
)

Gets the handle of a thread.

Parameters
[out]threadThe handle of the thread
processThe ID of the process linked to the thread

◆ svcOutputDebugString()

Result svcOutputDebugString ( const char *  str,
s32  length 
)

Outputs a debug string.

Parameters
strString to output.
lengthLength of the string to output, needs to be positive.

◆ svcQueryDebugProcessMemory()

Result svcQueryDebugProcessMemory ( MemInfo info,
PageInfo out,
Handle  debug,
u32  addr 
)

Queries memory information of a debugged process.

Parameters
[out]infoPointer to output memory info to.
[out]outPointer to output page info to.
debugDebug handle of the process to query memory from.
addrVirtual memory address to query.

◆ svcQueryMemory()

Result svcQueryMemory ( MemInfo info,
PageInfo out,
u32  addr 
)

Queries memory information.

Parameters
[out]infoPointer to output memory info to.
outPointer to output page info to.
addrVirtual memory address to query.

◆ svcQueryProcessMemory()

Result svcQueryProcessMemory ( MemInfo info,
PageInfo out,
Handle  process,
u32  addr 
)

Queries process memory information.

Parameters
[out]infoPointer to output memory info to.
[out]outPointer to output page info to.
processProcess to query memory from.
addrVirtual memory address to query.

◆ svcReadProcessMemory()

Result svcReadProcessMemory ( void *  buffer,
Handle  debug,
u32  addr,
u32  size 
)

Reads from a debugged process's memory.

Parameters
bufferBuffer to read data to.
debugDebug handle of the process.
addrAddress to read from.
sizeSize of the memory to read.

◆ svcReleaseMutex()

Result svcReleaseMutex ( Handle  handle)

Releases a mutex.

Parameters
handleHandle of the mutex.

◆ svcReleaseSemaphore()

Result svcReleaseSemaphore ( s32 count,
Handle  semaphore,
s32  release_count 
)

Releases a semaphore.

Parameters
[out]countPointer to output the current count of the semaphore to.
semaphoreHandle of the semaphore.
release_countNumber to increase the semaphore count by.

◆ svcReplyAndReceive()

Result svcReplyAndReceive ( s32 index,
const Handle handles,
s32  handleCount,
Handle  replyTarget 
)

Replies to and receives a new request.

Parameters
indexPointer to the index of the request.
handlesSession handles to receive requests from.
handleCountNumber of handles.
replyTargetHandle of the session to reply to.

◆ svcRun()

Result svcRun ( Handle  process,
const StartupInfo info 
)

Launches the main thread of the process.

Parameters
processHandle of the process.
infoPointer to a StartupInfo structure describing information for the main thread.

◆ svcSendSyncRequest()

Result svcSendSyncRequest ( Handle  session)

Sends a synchronized request to a session handle.

Parameters
sessionHandle of the session.

◆ svcSetDebugThreadContext()

Result svcSetDebugThreadContext ( Handle  debug,
u32  threadId,
ThreadContext context,
ThreadContextControlFlags  controlFlags 
)

Updates the saved registers of a thread, either inactive or awaiting svcContinueDebugEvent, belonging to a debugged process.

Parameters
debugDebug handle of the parent process.
threadIdID of the thread to update the saved registers of.
contextValues of the registers to update, see ThreadContext.
controlFlagsWhich registers to update, see ThreadContextControlFlags.

◆ svcSetGpuProt()

Result svcSetGpuProt ( bool  useApplicationRestriction)

Sets the GPU protection register to restrict the range of the GPU DMA.

11.3+ only.

Parameters
useApplicationRestrictionWhether to use the register value used for APPLICATION titles.

◆ svcSetHardwareBreakPoint()

Result svcSetHardwareBreakPoint ( s32  registerId,
u32  control,
u32  value 
)

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 .

Parameters
registerIdrange 0..5 = breakpoints (BRP0-5), 0x100..0x101 = watchpoints (WRP0-1). The previous stop point for the register is disabled.
controlValue of the control regiser.
valueValue 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.

◆ svcSetProcessAffinityMask()

Result svcSetProcessAffinityMask ( Handle  process,
const u8 affinitymask,
s32  processorcount 
)

Sets a process's affinity mask.

Parameters
processHandle of the process.
affinitymaskPointer to retrieve the affinity masks from.
processorcountNumber of processors.

◆ svcSetProcessIdealProcessor()

Result svcSetProcessIdealProcessor ( Handle  process,
s32  processorid 
)

Sets a process's ideal processor.

Parameters
processHandle of the process.
processoridID of the process's ideal processor.

◆ svcSetProcessResourceLimits()

Result svcSetProcessResourceLimits ( Handle  process,
Handle  resourceLimit 
)

Sets the resource limit set of a process.

Parameters
processProcess to set the resource limit set to.
resourceLimitResource limit set handle.

◆ svcSetResourceLimitValues()

Result svcSetResourceLimitValues ( Handle  resourceLimit,
const ResourceLimitType names,
const s64 values,
s32  nameCount 
)

Sets the value limits of a resource limit set.

Parameters
resourceLimitResource limit set to use.
namesResource limit names to set the limits of.
valuesValue limits to set. The high 32 bits of RESLIMIT_COMMIT are used to set APPMEMALLOC in configuration memory, otherwise those bits are unused.
nameCountNumber of resource limit names.

◆ svcSetThreadAffinityMask()

Result svcSetThreadAffinityMask ( Handle  thread,
const u8 affinitymask,
s32  processorcount 
)

Sets a thread's affinity mask.

Parameters
threadHandle of the thread.
affinitymaskPointer to retrieve the affinity masks from.
processorcountNumber of processors.

◆ svcSetThreadIdealProcessor()

Result svcSetThreadIdealProcessor ( Handle  thread,
s32  processorid 
)

Sets a thread's ideal processor.

Parameters
threadHandle of the thread.
processoridID of the thread's ideal processor.

◆ svcSetThreadPriority()

Result svcSetThreadPriority ( Handle  thread,
s32  prio 
)

Changes the priority of a thread.

Parameters
prioFor userland apps, this has to be within the range [0x18;0x3F]

Low values gives the thread higher priority.

◆ svcSetTimer()

Result svcSetTimer ( Handle  timer,
s64  initial,
s64  interval 
)

Sets a timer.

Parameters
timerHandle of the timer to set.
initialInitial value of the timer.
intervalInterval of the timer.

◆ svcSetWifiEnabled()

Result svcSetWifiEnabled ( bool  enabled)

Enables or disables Wi-Fi.

11.4+ only.

Parameters
enabledWhether to enable or disable Wi-Fi.

◆ svcSignalEvent()

Result svcSignalEvent ( Handle  handle)

Signals an event.

Parameters
handleHandle of the event to signal.
Examples
threads/event/source/main.c.

◆ svcSleepThread()

void svcSleepThread ( s64  ns)

Puts the current thread to sleep.

Parameters
nsThe minimum number of nanoseconds to sleep for.
Examples
network/boss/source/main.c, and threads/thread-basic/source/main.c.

◆ svcStartInterProcessDma()

Result svcStartInterProcessDma ( Handle dma,
Handle  dstProcess,
void *  dst,
Handle  srcProcess,
const void *  src,
u32  size,
void *  dmaConfig 
)

Begins an inter-process DMA.

Parameters
[out]dmaPointer to output the handle of the DMA to.
dstProcessDestination process.
dstBuffer to write data to.
srcprocessSource process.
srcBuffer to read data from.
sizeSize of the data to DMA.
dmaConfigDMA configuration data.

◆ svcStopDma()

Result svcStopDma ( Handle  dma)

Terminates an inter-process DMA.

Parameters
dmaHandle of the DMA.

◆ svcStoreProcessDataCache()

Result svcStoreProcessDataCache ( Handle  process,
void *  addr,
u32  size 
)

Cleans a process's data cache.

Parameters
processHandle of the process.
addrAddress to clean.
sizeSize of the memory to clean.

◆ svcTerminateDebugProcess()

Result svcTerminateDebugProcess ( Handle  debug)

Terminates a debugged process.

Parameters
debugDebug handle of the process.

◆ svcTerminateProcess()

Result svcTerminateProcess ( Handle  process)

Terminates a process.

Parameters
processHandle of the process to terminate.

◆ svcUnbindInterrupt()

Result svcUnbindInterrupt ( u32  interruptId,
Handle  eventOrSemaphore 
)

Unbinds an event or semaphore handle from an ARM11 interrupt.

Parameters
interruptIdInterrupt identfier, see (see https://www.3dbrew.org/wiki/ARM11_Interrupts).
eventOrSemaphoreEvent or semaphore handle to unbind from the given interrupt.

◆ svcUnmapMemoryBlock()

Result svcUnmapMemoryBlock ( Handle  memblock,
u32  addr 
)

Unmaps a block of shared memory.

Parameters
memblockHandle of the block
addrAddress of the memory to unmap, page-aligned. So its alignment must be 0x1000.

◆ svcUnmapProcessMemory()

Result svcUnmapProcessMemory ( Handle  process,
u32  destAddress,
u32  size 
)

Unmaps a block of process memory, starting from address 0x00100000.

Parameters
processHandle of the process.
destAddressAddress of the block of memory to unmap, in the current (destination) process.
sizeSize of the block of memory to unmap (truncated to a multiple of 0x1000 bytes).

◆ svcWaitSynchronization()

Result svcWaitSynchronization ( Handle  handle,
s64  nanoseconds 
)

Waits for synchronization on a handle.

Parameters
handleHandle to wait on.
nanosecondsMaximum nanoseconds to wait for.
Examples
camera/image/source/main.c, camera/video/source/main.c, and threads/event/source/main.c.

◆ svcWaitSynchronizationN()

Result svcWaitSynchronizationN ( s32 out,
const Handle handles,
s32  handles_num,
bool  wait_all,
s64  nanoseconds 
)

Waits for synchronization on multiple handles.

Parameters
[out]outPointer to output the index of the synchronized handle to.
handlesHandles to wait on.
handles_numNumber of handles.
wait_allWhether to wait for synchronization on all handles.
nanosecondsMaximum nanoseconds to wait for.

◆ svcWriteProcessMemory()

Result svcWriteProcessMemory ( Handle  debug,
const void *  buffer,
u32  addr,
u32  size 
)

Writes to a debugged process's memory.

Parameters
debugDebug handle of the process.
bufferBuffer to write data from.
addrAddress to write to.
sizeSize of the memory to write.