10 #define CUR_PROCESS_HANDLE 0xFFFF8001
97 #define ARBITRATION_SIGNAL_ALL (-1)
133 #define CUR_THREAD_HANDLE 0xFFFF8000
214 PERFCOUNTERREG_CORE_BASE = 0,
220 PERFCOUNTERREG_SCU_BASE = 0x10,
241 PERFCOUNTEREVT_CORE_BASE = 0x0,
242 PERFCOUNTEREVT_CORE_INST_CACHE_MISS = PERFCOUNTEREVT_CORE_BASE,
243 PERFCOUNTEREVT_CORE_STALL_BY_LACK_OF_INST,
244 PERFCOUNTEREVT_CORE_STALL_BY_DATA_HAZARD,
245 PERFCOUNTEREVT_CORE_INST_MICRO_TLB_MISS,
246 PERFCOUNTEREVT_CORE_DATA_MICRO_TLB_MISS,
247 PERFCOUNTEREVT_CORE_BRANCH_INST,
248 PERFCOUNTEREVT_CORE_BRANCH_NOT_PREDICTED,
249 PERFCOUNTEREVT_CORE_BRANCH_MISS_PREDICTED,
250 PERFCOUNTEREVT_CORE_INST_EXECUTED,
251 PERFCOUNTEREVT_CORE_FOLDED_INST_EXECUTED,
252 PERFCOUNTEREVT_CORE_DATA_CACHE_READ,
253 PERFCOUNTEREVT_CORE_DATA_CACHE_READ_MISS,
254 PERFCOUNTEREVT_CORE_DATA_CACHE_WRITE,
255 PERFCOUNTEREVT_CORE_DATA_CACHE_WRITE_MISS,
256 PERFCOUNTEREVT_CORE_DATA_CACHE_LINE_EVICTION,
257 PERFCOUNTEREVT_CORE_PC_CHANGED,
258 PERFCOUNTEREVT_CORE_MAIN_TLB_MISS,
259 PERFCOUNTEREVT_CORE_EXTERNAL_REQUEST,
260 PERFCOUNTEREVT_CORE_STALL_BY_LSU_FULL,
261 PERFCOUNTEREVT_CORE_STORE_BUFFER_DRAIN,
262 PERFCOUNTEREVT_CORE_MERGE_IN_STORE_BUFFER,
267 PERFCOUNTEREVT_SCU_BASE = 0x1000,
268 PERFCOUNTEREVT_SCU_DISABLED = PERFCOUNTEREVT_SCU_BASE,
269 PERFCOUNTEREVT_SCU_LINEFILL_MISS_FROM_CORE0,
270 PERFCOUNTEREVT_SCU_LINEFILL_MISS_FROM_CORE1,
271 PERFCOUNTEREVT_SCU_LINEFILL_MISS_FROM_CORE2,
272 PERFCOUNTEREVT_SCU_LINEFILL_MISS_FROM_CORE3,
273 PERFCOUNTEREVT_SCU_LINEFILL_HIT_FROM_CORE0,
274 PERFCOUNTEREVT_SCU_LINEFILL_HIT_FROM_CORE1,
275 PERFCOUNTEREVT_SCU_LINEFILL_HIT_FROM_CORE2,
276 PERFCOUNTEREVT_SCU_LINEFILL_HIT_FROM_CORE3,
277 PERFCOUNTEREVT_SCU_LINE_MISSING_FROM_CORE0,
278 PERFCOUNTEREVT_SCU_LINE_MISSING_FROM_CORE1,
279 PERFCOUNTEREVT_SCU_LINE_MISSING_FROM_CORE2,
280 PERFCOUNTEREVT_SCU_LINE_MISSING_FROM_CORE3,
281 PERFCOUNTEREVT_SCU_LINE_MIGRATION,
282 PERFCOUNTEREVT_SCU_READ_BUSY_PORT0,
283 PERFCOUNTEREVT_SCU_READ_BUSY_PORT1,
284 PERFCOUNTEREVT_SCU_WRITE_BUSY_PORT0,
285 PERFCOUNTEREVT_SCU_WRITE_BUSY_PORT1,
286 PERFCOUNTEREVT_SCU_EXTERNAL_READ,
287 PERFCOUNTEREVT_SCU_EXTERNAL_WRITE,
288 PERFCOUNTEREVT_SCU_CYCLE_COUNT = PERFCOUNTEREVT_SCU_BASE + 0x1F,
294 char process_name[8];
534 __asm__ (
"mrc p15, 0, %[data], c13, c0, 3" : [data]
"=r" (ret));
565 .allowedAlignments = 8 | 4 | 2 | 1,
1440 #define SVC_STOP_POINT __asm__ volatile("svc 0xFF");
__attribute__((warn_unused_result)) rbtree_node_t *rbtree_insert(rbtree_t *tree
Inserts a node into an rbtree.
Event relating to the attachment of a process.
Definition: svc.h:292
u32 other_flags
Always 0.
Definition: svc.h:296
u64 program_id
ID of the program.
Definition: svc.h:293
u32 process_id
ID of the process.
Definition: svc.h:295
Event relating to the attachment of a thread.
Definition: svc.h:312
u32 entry_point
Entry point of the thread.
Definition: svc.h:315
u32 creator_thread_id
ID of the creating thread.
Definition: svc.h:313
u32 thread_local_storage
Thread local storage.
Definition: svc.h:314
Structure representing CPU registers.
Definition: types.h:63
Information about a debug event.
Definition: svc.h:438
u32 flags
Flags. Bit0 means that svcContinueDebugEvent needs to be called for this event (except for EXIT PROCE...
Definition: svc.h:441
ExitProcessEvent exit_process
Process exit event data.
Definition: svc.h:447
SyscallInOutEvent syscall
Syscall in/out event data.
Definition: svc.h:451
ScheduleInOutEvent scheduler
Schedule in/out event data.
Definition: svc.h:450
u32 thread_id
ID of the thread.
Definition: svc.h:440
AttachThreadEvent attach_thread
Thread attachment event data.
Definition: svc.h:445
ExitThreadEvent exit_thread
Thread exit event data.
Definition: svc.h:446
AttachProcessEvent attach_process
Process attachment event data.
Definition: svc.h:444
OutputStringEvent output_string
Output string event data.
Definition: svc.h:452
ExceptionEvent exception
Exception event data.
Definition: svc.h:448
DebugEventType type
Type of event. See DebugEventType.
Definition: svc.h:439
MapEvent map
Map event data.
Definition: svc.h:453
Event relating to svcBreakDebugProcess.
Definition: svc.h:379
Configuration stucture for svcStartInterProcessDma.
Definition: svc.h:183
s8 channelId
Channel ID (Arm11: 0-7, Arm9: 0-1). Use -1 to auto-assign to a free channel (Arm11: 3-7,...
Definition: svc.h:184
s8 endianSwapSize
Endian swap size (can be 0).
Definition: svc.h:185
DmaDeviceConfig srcCfg
Source device configuration, read if DMACFG_SRC_IS_DEVICE and/or DMACFG_USE_SRC_CONFIG are set.
Definition: svc.h:188
u8 flags
DMACFG_* flags.
Definition: svc.h:186
DmaDeviceConfig dstCfg
Destination device configuration, read if DMACFG_SRC_IS_DEVICE and/or DMACFG_USE_SRC_CONFIG are set.
Definition: svc.h:189
Device configuration structure, part of DmaConfig.
Definition: svc.h:173
s16 burstStride
Burst loop stride, can be <= 0.
Definition: svc.h:178
s8 deviceId
DMA device ID.
Definition: svc.h:174
s16 transferStride
"Transfer" loop stride, can be <= 0.
Definition: svc.h:179
s16 burstSize
Number of bytes transferred in a burst loop. Can be 0 (in which case the max allowed alignment is use...
Definition: svc.h:176
s16 transferSize
Number of bytes transferred in a "transfer" loop (made of burst loops).
Definition: svc.h:177
s8 allowedAlignments
Mask of allowed access alignments (8, 4, 2, 1).
Definition: svc.h:175
Event relating to exceptions.
Definition: svc.h:384
ExceptionEventType type
Type of event. See ExceptionEventType.
Definition: svc.h:385
UserBreakExceptionEvent user_break
User break exception event data.
Definition: svc.h:390
u32 address
Address of the exception.
Definition: svc.h:386
FaultExceptionEvent fault
Fault exception event data.
Definition: svc.h:388
StopPointExceptionEvent stop_point
Stop point exception event data.
Definition: svc.h:389
DebuggerBreakExceptionEvent debugger_break
Debugger break exception event data.
Definition: svc.h:391
Event relating to the exiting of a process.
Definition: svc.h:307
ExitProcessEventReason reason
Reason for exiting. See ExitProcessEventReason.
Definition: svc.h:308
Event relating to the exiting of a thread.
Definition: svc.h:327
ExitThreadEventReason reason
Reason for exiting. See ExitThreadEventReason.
Definition: svc.h:328
Event relating to fault exceptions (CPU exceptions other than stop points and undefined syscalls).
Definition: svc.h:354
u32 fault_information
FAR (for DATA ABORT / UNALIGNED DATA ACCESS), attempted syscall or 0.
Definition: svc.h:355
Structure representing FPU registers.
Definition: types.h:72
Event relating to the mapping of memory.
Definition: svc.h:413
MemState memstate
Memory state. See MemState.
Definition: svc.h:417
u32 mapped_addr
Mapped address.
Definition: svc.h:414
MemPerm memperm
Memory permissions. See MemPerm.
Definition: svc.h:416
u32 mapped_size
Mapped size.
Definition: svc.h:415
Memory information.
Definition: svc.h:75
u32 base_addr
Base address.
Definition: svc.h:76
u32 state
Memory state. See MemState.
Definition: svc.h:79
u32 perm
Memory permissions. See MemPerm.
Definition: svc.h:78
u32 size
Size.
Definition: svc.h:77
Event relating to debug output.
Definition: svc.h:407
u32 string_size
Size of the outputted string.
Definition: svc.h:409
u32 string_addr
Address of the outputted string.
Definition: svc.h:408
Memory page information.
Definition: svc.h:83
u32 flags
Page flags.
Definition: svc.h:84
Event relating to the scheduler.
Definition: svc.h:396
u64 clock_tick
Clock tick that the event occurred.
Definition: svc.h:397
Information for the main thread of a process.
Definition: svc.h:517
u32 stack_size
Size of the stack of the main thread.
Definition: svc.h:519
u16 * envp
Unused on retail kernel.
Definition: svc.h:522
int priority
Priority of the main thread.
Definition: svc.h:518
int argc
Unused on retail kernel.
Definition: svc.h:520
u16 * argv
Unused on retail kernel.
Definition: svc.h:521
Event relating to stop points.
Definition: svc.h:366
StopPointType type
Stop point type, see StopPointType.
Definition: svc.h:367
u32 fault_information
FAR for Watchpoints, otherwise 0.
Definition: svc.h:368
Event relating to syscalls.
Definition: svc.h:401
u32 syscall
Syscall sent/received.
Definition: svc.h:403
u64 clock_tick
Clock tick that the event occurred.
Definition: svc.h:402
CpuRegisters cpu_registers
CPU registers.
Definition: svc.h:467
FpuRegisters fpu_registers
FPU registers.
Definition: svc.h:468
Event relating to svcBreak.
Definition: svc.h:372
u32 croInfo
For LOAD_RO and UNLOAD_RO.
Definition: svc.h:374
UserBreakType type
User break type, see UserBreakType.
Definition: svc.h:373
u32 croInfoSize
For LOAD_RO and UNLOAD_RO.
Definition: svc.h:375
ArbitrationType
Arbitration modes.
Definition: svc.h:88
@ ARBITRATION_SIGNAL
Signal #value threads for wake-up.
Definition: svc.h:89
@ 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.
Definition: svc.h:91
@ ARBITRATION_WAIT_IF_LESS_THAN
If the memory at the address is strictly lower than #value, then wait for signal.
Definition: svc.h:90
@ 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 ...
Definition: svc.h:93
@ ARBITRATION_WAIT_IF_LESS_THAN_TIMEOUT
If the memory at the address is strictly lower than #value, then wait for signal or timeout.
Definition: svc.h:92
Result svcTerminateProcess(Handle process)
Terminates a process.
Result svcCreateTimer(Handle *timer, ResetType reset_type)
Creates a timer.
Result svcOpenProcess(Handle *process, u32 processId)
Gets the handle of a process.
Result svcMapMemoryBlock(Handle memblock, u32 addr, MemPerm my_perm, MemPerm other_perm)
Maps a block of shared memory.
Result svcGetProcessInfo(s64 *out, Handle process, u32 type)
Gets information about a process.
Result svcCloseHandle(Handle handle)
Closes a handle.
ThreadInfoType
Types of thread info.
Definition: svc.h:112
@ THREADINFO_TYPE_UNKNOWN
Unknown.
Definition: svc.h:113
Result svcWriteProcessMemory(Handle debug, const void *buffer, u32 addr, u32 size)
Writes to a debugged process's memory.
Result svcWaitSynchronizationN(s32 *out, const Handle *handles, s32 handles_num, bool wait_all, s64 nanoseconds)
Waits for synchronization on multiple handles.
Result svcGetResourceLimitLimitValues(s64 *values, Handle resourceLimit, ResourceLimitType *names, s32 nameCount)
Gets the value limits of a resource limit set.
Result svcGetResourceLimitCurrentValues(s64 *values, Handle resourceLimit, ResourceLimitType *names, s32 nameCount)
Gets the values of a resource limit set.
ThreadContextControlFlags
Control flags for svcGetDebugThreadContext and svcSetDebugThreadContext.
Definition: svc.h:472
@ THREADCONTEXT_CONTROL_ALL
Control all of the above.
Definition: svc.h:481
@ THREADCONTEXT_CONTROL_FPU_GPRS
Control d0-d15 (or s0-s31).
Definition: svc.h:475
@ THREADCONTEXT_CONTROL_CPU_REGS
Control r0-r12, sp, lr, pc, cpsr.
Definition: svc.h:478
@ THREADCONTEXT_CONTROL_CPU_SPRS
Control sp, lr, pc, cpsr.
Definition: svc.h:474
@ THREADCONTEXT_CONTROL_CPU_GPRS
Control r0-r12.
Definition: svc.h:473
@ THREADCONTEXT_CONTROL_FPU_SPRS
Control fpscr, fpexc.
Definition: svc.h:476
@ THREADCONTEXT_CONTROL_FPU_REGS
Control d0-d15, fpscr, fpexc.
Definition: svc.h:479
Result svcOutputDebugString(const char *str, s32 length)
Outputs a debug string.
Result svcUnmapMemoryBlock(Handle memblock, u32 addr)
Unmaps a block of shared memory.
Result svcBackdoor(s32(*callback)(void))
Executes a function in supervisor mode.
Result svcDebugActiveProcess(Handle *debug, u32 processId)
Creates a debug handle for an active process.
UserBreakType
Reasons for a user break.
Definition: svc.h:332
@ USERBREAK_LOAD_RO
Load RO.
Definition: svc.h:336
@ USERBREAK_PANIC
Panic.
Definition: svc.h:333
@ USERBREAK_USER
User related.
Definition: svc.h:335
@ USERBREAK_UNLOAD_RO
Unload RO.
Definition: svc.h:337
@ USERBREAK_ASSERT
Assertion failed.
Definition: svc.h:334
Result svcRun(Handle process, const StartupInfo *info)
Launches the main thread of the process.
Result svcReleaseMutex(Handle handle)
Releases a mutex.
void svcExitThread(void) __attribute__((noreturn))
Exits the current thread.
static u32 * getThreadCommandBuffer(void)
Gets the thread command buffer.
Definition: svc.h:542
ExitProcessEventReason
Reasons for an exit process event.
Definition: svc.h:300
@ EXITPROCESS_EVENT_DEBUG_TERMINATE
Process has been terminated by svcTerminateDebugProcess.
Definition: svc.h:303
@ EXITPROCESS_EVENT_EXIT
Process exited either normally or due to an uncaught exception.
Definition: svc.h:301
@ EXITPROCESS_EVENT_TERMINATE
Process has been terminated by svcTerminateProcess.
Definition: svc.h:302
Result svcBindInterrupt(u32 interruptId, Handle eventOrSemaphore, s32 priority, bool isManualClear)
Binds an event or semaphore handle to an ARM11 interrupt.
Result svcDuplicateHandle(Handle *out, Handle original)
Duplicates a handle.
Result svcConnectToPort(volatile Handle *out, const char *portName)
Connects to a port.
PerfCounterOperation
Operations for svcControlPerformanceCounter.
Definition: svc.h:198
@ PERFCOUNTEROP_SET_EVENT
Set the event ID associated to a paritcular counter.
Definition: svc.h:206
@ PERFCOUNTEROP_ENABLE
Enable and lock perfmon. functionality.
Definition: svc.h:199
@ PERFCOUNTEROP_SET_VIRTUAL_COUNTER_ENABLED
(Dis)allow the kernel to track counter overflows and to use 64-bit counter values.
Definition: svc.h:207
@ PERFCOUNTEROP_SET_VALUE
Set the value of a counter register.
Definition: svc.h:202
@ PERFCOUNTEROP_GET_EVENT
Get the event ID associated to a particular counter.
Definition: svc.h:205
@ PERFCOUNTEROP_GET_OVERFLOW_FLAGS
Get the overflow flags for all CP15 and SCU counters.
Definition: svc.h:203
@ PERFCOUNTEROP_DISABLE
Disable and forcibly unlock perfmon. functionality.
Definition: svc.h:200
@ PERFCOUNTEROP_GET_VALUE
Get the value of a counter register.
Definition: svc.h:201
@ PERFCOUNTEROP_RESET
Reset the value and/or overflow flags of selected counters.
Definition: svc.h:204
s32 svcGetProcessorID(void)
Returns the ID of the processor the current thread is running on.
Result svcClearTimer(Handle timer)
Clears a timer.
Result svcCreateSession(Handle *serverSession, Handle *clientSession)
Creates a linked pair of session endpoints.
u64 svcGetSystemTick(void)
Gets the current system tick.
DebugThreadParameter
Thread parameter field for svcGetDebugThreadParameter.
Definition: svc.h:485
@ DBGTHREAD_PARAMETER_SCHEDULING_MASK_LOW
Low scheduling mask.
Definition: svc.h:487
@ DBGTHREAD_PARAMETER_CPU_IDEAL
Ideal processor.
Definition: svc.h:488
@ DBGTHREAD_PARAMETER_CPU_CREATOR
Processor that created the threod.
Definition: svc.h:489
@ DBGTHREAD_PARAMETER_PRIORITY
Thread priority.
Definition: svc.h:486
Result svcSendSyncRequest(Handle session)
Sends a synchronized request to a session handle.
Result svcGetThreadList(s32 *threadCount, u32 *threadIds, s32 threadIdMaxCount, Handle process)
Gets a list of the threads of a process.
static void * getThreadLocalStorage(void)
Gets the thread local storage buffer.
Definition: svc.h:531
Result svcCreateThread(Handle *thread, ThreadFunc entrypoint, u32 arg, u32 *stack_top, s32 thread_priority, s32 processor_id)
Creates a new thread.
StopPointType
Stop point types.
Definition: svc.h:359
@ STOPPOINT_BREAKPOINT
Breakpoint.
Definition: svc.h:361
@ STOPPOINT_WATCHPOINT
Watchpoint.
Definition: svc.h:362
@ STOPPOINT_SVC_FF
See SVC_STOP_POINT.
Definition: svc.h:360
Result svcGetDebugThreadContext(ThreadContext *context, Handle debug, u32 threadId, ThreadContextControlFlags controlFlags)
Fetches the saved registers of a thread, either inactive or awaiting svcContinueDebugEvent,...
Result svcGetProcessId(u32 *out, Handle handle)
Gets the ID of a process.
Result svcGetProcessList(s32 *processCount, u32 *processIds, s32 processIdMaxCount)
Gets a list of running processes.
Result svcGetHandleInfo(s64 *out, Handle handle, u32 param)
Gets a handle info.
Result svcGetThreadAffinityMask(u8 *affinitymask, Handle thread, s32 processorcount)
Gets a thread's affinity mask.
Result svcWaitSynchronization(Handle handle, s64 nanoseconds)
Waits for synchronization on a handle.
Result svcArbitrateAddress(Handle arbiter, u32 addr, ArbitrationType type, s32 value, s64 timeout_ns)
Arbitrate an address, can be used for synchronization.
void svcExitProcess(void) __attribute__((noreturn))
Exits the current process.
Result svcCreateSessionToPort(Handle *clientSession, Handle clientPort)
Connects to a port via a handle.
Result svcGetSystemInfo(s64 *out, u32 type, s32 param)
Gets the system info.
Result svcSetWifiEnabled(bool enabled)
Enables or disables Wi-Fi.
Result svcControlPerformanceCounter(u64 *out, PerfCounterOperation op, u32 param1, u64 param2)
Controls performance monitoring on the CP15 interface and the SCU.
Result svcCreateMemoryBlock(Handle *memblock, u32 addr, u32 size, MemPerm my_perm, MemPerm other_perm)
Creates a block of shared memory.
Result svcGetThreadInfo(s64 *out, Handle thread, ThreadInfoType type)
Checks if a thread handle is valid.
Result svcGetThreadPriority(s32 *out, Handle handle)
Retrieves the priority of a thread.
PerfCounterEvent
Performance counter event IDs (CP15 or SCU).
Definition: svc.h:239
@ PERFCOUNTEREVT_CORE_CYCLE_COUNT
One cycle elapsed.
Definition: svc.h:263
@ PERFCOUNTEREVT_CORE_CYCLE_COUNT_64
64 cycles elapsed.
Definition: svc.h:264
Result svcCreateSemaphore(Handle *semaphore, s32 initial_count, s32 max_count)
Creates a semaphore.
void svcBreakRO(UserBreakType breakReason, const void *croInfo, u32 croInfoSize) __asm__("svcBreak")
Breaks execution (LOAD_RO and UNLOAD_RO).
Result svcContinueDebugEvent(Handle debug, DebugFlags flags)
Continues the current debug event of a debugged process (not necessarily the same as svcGetProcessDeb...
Result svcSetResourceLimitValues(Handle resourceLimit, const ResourceLimitType *names, const s64 *values, s32 nameCount)
Sets the value limits of a resource limit set.
Result svcQueryDebugProcessMemory(MemInfo *info, PageInfo *out, Handle debug, u32 addr)
Queries memory information of a debugged process.
void svcBreak(UserBreakType breakReason)
Breaks execution.
Result svcSetProcessResourceLimits(Handle process, Handle resourceLimit)
Sets the resource limit set of a process.
Result svcSetGpuProt(bool useApplicationRestriction)
Sets the GPU protection register to restrict the range of the GPU DMA.
MemOp
svcControlMemory operation flags
Definition: svc.h:20
@ MEMOP_FREE
Memory un-mapping.
Definition: svc.h:21
@ MEMOP_OP_MASK
Operation bitmask.
Definition: svc.h:32
@ MEMOP_PROT
Change protection.
Definition: svc.h:26
@ MEMOP_ALLOC
Memory mapping.
Definition: svc.h:23
@ MEMOP_LINEAR_FLAG
Flag for linear memory operations.
Definition: svc.h:34
@ MEMOP_REGION_BASE
BASE memory region.
Definition: svc.h:30
@ MEMOP_REGION_MASK
Region bitmask.
Definition: svc.h:33
@ MEMOP_RESERVE
Reserve memory.
Definition: svc.h:22
@ MEMOP_ALLOC_LINEAR
Allocates linear memory.
Definition: svc.h:36
@ MEMOP_MAP
Mirror mapping.
Definition: svc.h:24
@ MEMOP_REGION_APP
APPLICATION memory region.
Definition: svc.h:28
@ MEMOP_REGION_SYSTEM
SYSTEM memory region.
Definition: svc.h:29
@ MEMOP_UNMAP
Mirror unmapping.
Definition: svc.h:25
@ DMARST_UNLOCK
Unlock the channel after transfer.
Definition: svc.h:161
@ DMARST_RESUME_DEVICE
Replace DMAFLUSHP instructions by NOP (they may not be regenerated even if this flag is not set).
Definition: svc.h:162
Result svcSetThreadAffinityMask(Handle thread, const u8 *affinitymask, s32 processorcount)
Sets a thread's affinity mask.
Result svcReadProcessMemory(void *buffer, Handle debug, u32 addr, u32 size)
Reads from a debugged process's memory.
Result svcSetProcessIdealProcessor(Handle process, s32 processorid)
Sets a process's ideal processor.
Result svcCreatePort(Handle *portServer, Handle *portClient, const char *name, s32 maxSessions)
Creates a port.
static u32 * getThreadStaticBuffers(void)
Gets the thread static buffer.
Definition: svc.h:551
Result svcControlMemory(u32 *addr_out, u32 addr0, u32 addr1, u32 size, MemOp op, MemPerm perm)
Controls memory mapping.
Result svcMapProcessMemory(Handle process, u32 destAddress, u32 size)
Maps a block of process memory, starting from address 0x00100000.
DebugFlags
Debug flags for an attached process, set by svcContinueDebugEvent.
Definition: svc.h:458
@ DBG_SIGNAL_SCHEDULE_EVENTS
Signal schedule in/out events. See ScheduleInOutEvent.
Definition: svc.h:461
@ DBG_SIGNAL_MAP_EVENTS
Signal map events. See MapEvent.
Definition: svc.h:463
@ DBG_SIGNAL_SYSCALL_EVENTS
Signal syscall in/out events. See SyscallInOutEvent.
Definition: svc.h:462
@ DBG_SIGNAL_FAULT_EXCEPTION_EVENTS
Signal fault exception events. See FaultExceptionEvent.
Definition: svc.h:460
@ DBG_INHIBIT_USER_CPU_EXCEPTION_HANDLERS
Inhibit user-defined CPU exception handlers (including watchpoints and breakpoints,...
Definition: svc.h:459
Result svcCancelTimer(Handle timer)
Cancels a timer.
DmaState
DMA transfer state.
Definition: svc.h:141
@ DMASTATE_WFP_SRC
DMA channel is in WFP state for the source device (2nd loop iteration onwards).
Definition: svc.h:144
@ DMASTATE_STARTING
DMA transfer involving at least one device is starting and has not reached DMAWFP yet.
Definition: svc.h:142
@ DMASTATE_WFP_DST
DMA channel is in WFP state for the destination device (2nd loop iteration onwards).
Definition: svc.h:143
@ DMASTATE_DONE
DMA transfer is done.
Definition: svc.h:146
@ DMASTATE_RUNNING
DMA transfer is running.
Definition: svc.h:145
Result svcArbitrateAddressNoTimeout(Handle arbiter, u32 addr, ArbitrationType type, s32 value)
Same as svcArbitrateAddress but with the timeout_ns parameter undefined.
Result svcCreateCodeSet(Handle *out, const CodeSetHeader *info, u32 textSegmentLma, u32 roSegmentLma, u32 dataSegmentLma)
Sets up virtual address space for a new process.
Result svcReleaseSemaphore(s32 *count, Handle semaphore, s32 release_count)
Releases a semaphore.
MemPerm
Memory permission flags.
Definition: svc.h:56
@ MEMPERM_DONTCARE
Don't care.
Definition: svc.h:62
@ MEMPERM_WRITE
Writable.
Definition: svc.h:58
@ MEMPERM_READWRITE
Readable and writable.
Definition: svc.h:60
@ MEMPERM_READ
Readable.
Definition: svc.h:57
@ MEMPERM_EXECUTE
Executable.
Definition: svc.h:59
@ MEMPERM_READEXECUTE
Readable and executable.
Definition: svc.h:61
MemState
The state of a memory block.
Definition: svc.h:40
@ MEMSTATE_ALIAS
Alias memory.
Definition: svc.h:50
@ MEMSTATE_CODE
Code memory.
Definition: svc.h:45
@ MEMSTATE_FREE
Free memory.
Definition: svc.h:41
@ MEMSTATE_SHARED
Shared memory.
Definition: svc.h:47
@ MEMSTATE_CONTINUOUS
Continuous memory.
Definition: svc.h:48
@ MEMSTATE_ALIASCODE
Aliased code memory.
Definition: svc.h:51
@ MEMSTATE_ALIASED
Aliased memory.
Definition: svc.h:49
@ MEMSTATE_PRIVATE
Private memory.
Definition: svc.h:46
@ MEMSTATE_IO
I/O memory.
Definition: svc.h:43
@ MEMSTATE_STATIC
Static memory.
Definition: svc.h:44
@ MEMSTATE_RESERVED
Reserved memory.
Definition: svc.h:42
@ MEMSTATE_LOCKED
Locked memory.
Definition: svc.h:52
Result svcGetThreadIdealProcessor(s32 *processorid, Handle thread)
Gets a thread's ideal processor.
Result svcBreakDebugProcess(Handle debug)
Breaks a debugged process.
Result svcGetResourceLimit(Handle *resourceLimit, Handle process)
Gets the resource limit set of a process.
Result svcQueryMemory(MemInfo *info, PageInfo *out, u32 addr)
Queries memory information.
Result svcCreateProcess(Handle *out, Handle codeset, const u32 *arm11KernelCaps, s32 numArm11KernelCaps)
Create a new process.
ExitThreadEventReason
Reasons for an exit thread event.
Definition: svc.h:319
@ EXITTHREAD_EVENT_EXIT_PROCESS
Process exited either normally or due to an uncaught exception.
Definition: svc.h:322
@ EXITTHREAD_EVENT_TERMINATE_PROCESS
Process has been terminated by svcTerminateProcess.
Definition: svc.h:323
@ EXITTHREAD_EVENT_TERMINATE
Thread terminated.
Definition: svc.h:321
@ EXITTHREAD_EVENT_EXIT
Thread exited.
Definition: svc.h:320
Result svcAcceptSession(Handle *session, Handle port)
Accepts a session.
Result svcGetThreadId(u32 *out, Handle handle)
Gets the ID of a thread.
Result svcQueryProcessMemory(MemInfo *info, PageInfo *out, Handle process, u32 addr)
Queries process memory information.
Result svcRestartDma(Handle dma, u32 dstAddr, u32 srcAddr, u32 size, s8 flags)
Restarts a DMA transfer, using the same configuration as before.
Result svcCreateAddressArbiter(Handle *arbiter)
Creates an address arbiter.
Result svcGetProcessIdealProcessor(s32 *processorid, Handle process)
Gets a process's ideal processor.
Result svcReplyAndReceive(s32 *index, const Handle *handles, s32 handleCount, Handle replyTarget)
Replies to and receives a new request.
Result svcUnmapProcessMemory(Handle process, u32 destAddress, u32 size)
Unmaps a block of process memory, starting from address 0x00100000.
DebugEventType
Debug event type.
Definition: svc.h:421
@ DBGEVENT_SCHEDULE_IN
Schedule in event.
Definition: svc.h:429
@ DBGEVENT_DLL_UNLOAD
DLL unload event.
Definition: svc.h:428
@ DBGEVENT_EXCEPTION
Exception event.
Definition: svc.h:426
@ DBGEVENT_EXIT_PROCESS
Process exit event.
Definition: svc.h:425
@ DBGEVENT_SYSCALL_IN
Syscall in event.
Definition: svc.h:431
@ DBGEVENT_SYSCALL_OUT
Syscall out event.
Definition: svc.h:432
@ DBGEVENT_SCHEDULE_OUT
Schedule out event.
Definition: svc.h:430
@ DBGEVENT_MAP
Map event.
Definition: svc.h:434
@ DBGEVENT_ATTACH_THREAD
Thread attached event.
Definition: svc.h:423
@ DBGEVENT_OUTPUT_STRING
Output string event.
Definition: svc.h:433
@ DBGEVENT_ATTACH_PROCESS
Process attached event.
Definition: svc.h:422
@ DBGEVENT_EXIT_THREAD
Thread exit event.
Definition: svc.h:424
@ DBGEVENT_DLL_LOAD
DLL load event.
Definition: svc.h:427
Result svcSetHardwareBreakPoint(s32 registerId, u32 control, u32 value)
Sets an hardware breakpoint or watchpoint.
Result svcSetTimer(Handle timer, s64 initial, s64 interval)
Sets a timer.
Result svcStoreProcessDataCache(Handle process, u32 addr, u32 size)
Cleans a process's data cache.
Result svcCreateResourceLimit(Handle *resourceLimit)
Creates a resource limit set.
ResourceLimitType
Types of resource limit.
Definition: svc.h:117
@ RESLIMIT_TIMER
Number of timers.
Definition: svc.h:124
@ RESLIMIT_SEMAPHORE
Number of semaphores.
Definition: svc.h:123
@ RESLIMIT_CPUTIME
CPU time. Value expressed in percentage regular until it reaches 90.
Definition: svc.h:127
@ RESLIMIT_COMMIT
Quantity of allocatable memory.
Definition: svc.h:119
@ RESLIMIT_EVENT
Number of events.
Definition: svc.h:121
@ RESLIMIT_BIT
Forces enum size to be 32 bits.
Definition: svc.h:129
@ RESLIMIT_ADDRESSARBITER
Number of address arbiters.
Definition: svc.h:126
@ RESLIMIT_MUTEX
Number of mutexes.
Definition: svc.h:122
@ RESLIMIT_THREAD
Number of threads.
Definition: svc.h:120
@ RESLIMIT_SHAREDMEMORY
Number of shared memory objects, see svcCreateMemoryBlock.
Definition: svc.h:125
@ RESLIMIT_PRIORITY
Thread priority.
Definition: svc.h:118
Result svcCreateEvent(Handle *event, ResetType reset_type)
Creates an event handle.
MemRegion
Memory regions.
Definition: svc.h:67
@ MEMREGION_SYSTEM
SYSTEM memory.
Definition: svc.h:70
@ MEMREGION_BASE
BASE memory.
Definition: svc.h:71
@ MEMREGION_ALL
All regions.
Definition: svc.h:68
@ MEMREGION_APPLICATION
APPLICATION memory.
Definition: svc.h:69
Result svcClearEvent(Handle handle)
Clears an event.
Result svcStopDma(Handle dma)
Stops an inter-process DMA transfer.
Result svcInvalidateProcessDataCache(Handle process, u32 addr, u32 size)
Invalidates a process's data cache.
static void dmaConfigInitDefault(DmaConfig *cfg)
Initializes a DmaConfig instance with sane defaults for RAM<>RAM tranfers.
Definition: svc.h:574
Result svcGetProcessIdOfThread(u32 *out, Handle handle)
Gets the process ID of a thread.
ExceptionEventType
Reasons for an exception event.
Definition: svc.h:341
@ EXCEVENT_UNDEFINED_SYSCALL
Undefined syscall.
Definition: svc.h:350
@ EXCEVENT_USER_BREAK
User break occurred.
Definition: svc.h:348
@ EXCEVENT_UNALIGNED_DATA_ACCESS
Unaligned data access.
Definition: svc.h:345
@ EXCEVENT_DEBUGGER_BREAK
Debugger break occurred.
Definition: svc.h:349
@ EXCEVENT_ATTACH_BREAK
Attached break.
Definition: svc.h:346
@ EXCEVENT_PREFETCH_ABORT
Prefetch abort.
Definition: svc.h:343
@ EXCEVENT_UNDEFINED_INSTRUCTION
Undefined instruction.
Definition: svc.h:342
@ EXCEVENT_DATA_ABORT
Data abort (other than the below kind).
Definition: svc.h:344
@ EXCEVENT_STOP_POINT
Stop point reached.
Definition: svc.h:347
@ DMACFG_SRC_IS_DEVICE
DMA source is a device/peripheral. Address will not auto-increment.
Definition: svc.h:151
@ DMACFG_USE_SRC_CONFIG
Use the provided source device configuration even if the DMA source is not a device.
Definition: svc.h:155
@ DMACFG_DST_IS_DEVICE
DMA destination is a device/peripheral. Address will not auto-increment.
Definition: svc.h:152
@ DMACFG_WAIT_AVAILABLE
Make svcStartInterProcessDma wait for the channel to be unlocked.
Definition: svc.h:153
@ DMACFG_USE_DST_CONFIG
Use the provided destination device configuration even if the DMA destination is not a device.
Definition: svc.h:156
@ DMACFG_KEEP_LOCKED
Keep the channel locked after the transfer. Required for svcRestartDma.
Definition: svc.h:154
Result svcGetDebugThreadParam(s64 *unused, u32 *out, Handle debug, u32 threadId, DebugThreadParameter parameter)
Gets a debugged thread's parameter.
Result svcKernelSetState(u32 type,...)
Sets the current kernel state.
ResetType
Reset types (for use with events and timers)
Definition: svc.h:105
@ RESET_STICKY
When the primitive is signaled, it will wake up all threads and it won't clear itself automatically.
Definition: svc.h:107
@ RESET_ONESHOT
When the primitive is signaled, it will wake up exactly one thread and will clear itself automaticall...
Definition: svc.h:106
@ RESET_PULSE
Only meaningful for timers: same as ONESHOT but it will periodically signal the timer instead of just...
Definition: svc.h:108
void svcSleepThread(s64 ns)
Puts the current thread to sleep.
Result svcGetProcessDebugEvent(DebugEventInfo *info, Handle debug)
Gets the current debug event of a debugged process.
Result svcSetThreadIdealProcessor(Handle thread, s32 processorid)
Sets a thread's ideal processor.
Result svcSetThreadPriority(Handle thread, s32 prio)
Changes the priority of a thread.
Result svcGetProcessAffinityMask(u8 *affinitymask, Handle process, s32 processorcount)
Gets a process's affinity mask.
Result svcTerminateDebugProcess(Handle debug)
Terminates a debugged process.
Result svcOpenThread(Handle *thread, Handle process, u32 threadId)
Gets the handle of a thread.
Result svcSetDebugThreadContext(Handle debug, u32 threadId, ThreadContext *context, ThreadContextControlFlags controlFlags)
Updates the saved registers of a thread, either inactive or awaiting svcContinueDebugEvent,...
Result svcUnbindInterrupt(u32 interruptId, Handle eventOrSemaphore)
Unbinds an event or semaphore handle from an ARM11 interrupt.
Result svcSetProcessAffinityMask(Handle process, const u8 *affinitymask, s32 processorcount)
Sets a process's affinity mask.
PerfCounterRegister
Performance counter register IDs (CP15 and SCU).
Definition: svc.h:212
@ PERFCOUNTERREG_CORE_CYCLE_COUNTER
CP15 CCNT.
Definition: svc.h:217
@ PERFCOUNTERREG_CORE_COUNT_REG_1
CP15 PMN1.
Definition: svc.h:216
@ PERFCOUNTERREG_SCU_7
SCU MN7. Prod-N3DS only. IRQ line missing.
Definition: svc.h:228
@ PERFCOUNTERREG_SCU_6
SCU MN6. Prod-N3DS only. IRQ line missing.
Definition: svc.h:227
@ PERFCOUNTERREG_SCU_3
SCU MN3.
Definition: svc.h:224
@ PERFCOUNTERREG_SCU_5
SCU MN5. Prod-N3DS only. IRQ line missing.
Definition: svc.h:226
@ PERFCOUNTERREG_SCU_1
SCU MN1.
Definition: svc.h:222
@ PERFCOUNTERREG_SCU_2
SCU MN2.
Definition: svc.h:223
@ PERFCOUNTERREG_SCU_0
SCU MN0.
Definition: svc.h:221
@ PERFCOUNTERREG_CORE_COUNT_REG_0
CP15 PMN0.
Definition: svc.h:215
@ PERFCOUNTERREG_SCU_4
SCU MN4. Prod-N3DS only. IRQ line missing.
Definition: svc.h:225
Result svcSignalEvent(Handle handle)
Signals an event.
Result svcStartInterProcessDma(Handle *dma, Handle dstProcess, u32 dstAddr, Handle srcProcess, u32 srcAddr, u32 size, const DmaConfig *cfg)
Begins an inter-process DMA transfer.
Result svcFlushProcessDataCache(Handle process, u32 addr, u32 size)
Flushes (cleans and invalidates) a process's data cache.
Result svcCreateMutex(Handle *mutex, bool initially_locked)
Creates a mutex.
static void dmaDeviceConfigInitDefault(DmaDeviceConfig *cfg)
Writes the default DMA device config that the kernel uses when DMACFG_*_IS_DEVICE and DMACFG_*_USE_CF...
Definition: svc.h:560
Result svcControlProcessMemory(Handle process, u32 addr0, u32 addr1, u32 size, u32 type, u32 perm)
Controls the memory mapping of a process.
Result svcGetDmaState(DmaState *state, Handle dma)
Gets the state of an inter-process DMA transfer.
int64_t s64
64-bit signed integer
Definition: types.h:29
#define BIT(n)
Creates a bitmask from a bit number.
Definition: types.h:47
uint64_t u64
64-bit unsigned integer
Definition: types.h:24
void(* ThreadFunc)(void *)
Thread entrypoint function.
Definition: types.h:43
uint8_t u8
would be nice if newlib had this already
Definition: types.h:21
int8_t s8
8-bit signed integer
Definition: types.h:26
int16_t s16
16-bit signed integer
Definition: types.h:27
u32 Handle
Resource handle.
Definition: types.h:41
s32 Result
Function result.
Definition: types.h:42
uint16_t u16
16-bit unsigned integer
Definition: types.h:22
int32_t s32
32-bit signed integer
Definition: types.h:28
uint32_t u32
32-bit unsigned integer
Definition: types.h:23