10 #define CUR_PROCESS_HANDLE 0xFFFF8001 13 #define CUR_THREAD_HANDLE 0xFFFF8000 u64 svcGetSystemTick(void)
Gets the current system tick.
How many events can a process have.
Definition: svc.h:112
void svcExitProcess(void)
Exits the current process.
Result svcConnectToNamedPort(Handle *session, const char *name)
Connects to a registered named port.
Unmap slave.
Definition: svc.h:105
Result svcMapTransferMemory(Handle tmem_handle, void *addr, size_t size, u32 perm)
Maps a block of transfer memory.
Result svcGetResourceLimitCurrentValue(u64 *out, Handle reslimit_h, LimitableResource which)
Gets the maximum value a LimitableResource can have, for a Resource Limit handle. ...
Result svcConnectToPort(Handle *session, Handle port)
Manages a named port.
Process has begun exiting.
Definition: svc.h:129
#define PACKED
Packs a struct (and other types?) so it won't include padding bytes.
Definition: types.h:56
Result svcSetProcessMemoryPermission(Handle proc, u64 addr, u64 size, u32 perm)
Sets the memory permissions for the specified memory with the supplied process handle.
Mapped using svcMapMemory.
Definition: svc.h:28
Result svcGetThreadPriority(u32 *priority, Handle handle)
Gets a thread's priority.
Result svcMapJitMemory(Handle jit_handle, JitMapOperation op, void *dst_addr, u64 size, u64 perm)
Maps JIT memory in the caller's address space [4.0.0+].
Mapped using svcMapProcessMemory.
Definition: svc.h:32
Is borrowed memory.
Definition: svc.h:66
Mapped using svcMapProcessCodeMemory.
Definition: svc.h:25
IPC buffer allowed.
Definition: svc.h:56
void svcExitThread(void)
Exits the current thread.
Execute permission.
Definition: svc.h:77
Result svcSetUnsafeLimit(u64 size)
Sets the system-wide limit for unsafe memory mappable using svcMapPhysicalMemoryUnsafe.
Result svcAcceptSession(Handle *session_handle, Handle port_handle)
Accepts an IPC session.
static Result svcWaitSynchronizationSingle(Handle handle, u64 timeout)
Waits on a single synchronization object, optionally with a timeout.
Definition: svc.h:349
Mapped by kernel capability parsing in svcCreateProcess.
Definition: svc.h:19
Permission change allowed.
Definition: svc.h:44
Process executing normally.
Definition: svc.h:128
Result svcMapPhysicalMemoryUnsafe(void *address, u64 size)
Maps unsafe memory (usable for GPU DMA) for a system module at the desired address.
Result svcMapPhysicalMemory(void *address, u64 size)
Maps new heap memory at the desired address.
Result svcManageNamedPort(Handle *portServer, const char *name, s32 maxSessions)
Manages a named port.
Permission
Memory permission bitmasks.
Definition: svc.h:73
u32 attr
Memory attributes (see MemoryAttribute).
Definition: svc.h:88
Map device allowed (svcMapDeviceAddressSpace and svcMapDeviceAddressSpaceByForce).
Definition: svc.h:54
Result svcDetachDeviceAddressSpace(u64 device, Handle handle)
Detaches a device address space from a device.
IPC buffers with descriptor flags=0.
Definition: svc.h:27
Result svcUnmapDeviceAddressSpace(Handle handle, Handle proc_handle, u64 map_addr, u64 map_size, u64 dev_addr)
Unmaps an attached device address space from an userspace address.
u64 svcCallSecureMonitor(SecmonArgs *regs)
Calls a secure monitor function (TrustZone, EL3).
Result svcSignalProcessWideKey(u32 *key, s32 num)
Performs a condition variable wake-up operation in userspace.
MemoryAttribute
Memory attribute bitmasks.
Definition: svc.h:65
Result svcUnmapProcessCodeMemory(Handle proc, u64 dst, u64 src, u64 size)
Undoes the effects of svcMapProcessCodeMemory.
Result svcUnmapPhysicalMemoryUnsafe(void *address, u64 size)
Undoes the effects of svcMapPhysicalMemoryUnsafe.
Mapped in kernel during svcCreateThread.
Definition: svc.h:36
u32 type
Memory type (see lower 8 bits of MemoryState).
Definition: svc.h:87
Result svcQueryIoMapping(u64 *virtaddr, u64 physaddr, u64 size)
Returns a virtual address mapped to a given IO range.
Result svcUnmapProcessMemory(void *dst, Handle proc, u64 src, u64 size)
Undoes the effects of svcMapProcessMemory.
ProcessState
Process States.
Definition: svc.h:123
JitMapOperation
JIT mapping operations.
Definition: svc.h:101
IPC type 1 send allowed.
Definition: svc.h:48
u32 Handle
Kernel object handle.
Definition: types.h:45
Result svcUnmapSharedMemory(Handle handle, void *addr, size_t size)
Unmaps a block of shared memory.
Memory information structure.
Definition: svc.h:84
Result svcCreateDeviceAddressSpace(Handle *handle, u64 dev_addr, u64 dev_size)
Creates a virtual address space for binding device address spaces.
Result svcReplyAndReceiveWithUserBuffer(s32 *index, void *usrBuffer, u64 size, const Handle *handles, s32 handleCount, Handle replyTarget, u64 timeout)
Performs IPC input/output from an user allocated buffer.
Mapped by kernel capability parsing in svcCreateProcess.
Definition: svc.h:18
What state is a process in.
Definition: svc.h:119
Result svcMapDeviceAddressSpaceAligned(Handle handle, Handle proc_handle, u64 map_addr, u64 dev_size, u64 dev_addr, u32 perm)
Maps an attached device address space to an userspace address.
Result svcUnmapPhysicalMemory(void *address, u64 size)
Undoes the effects of svcMapPhysicalMemory.
u32 Result
Function error code result type.
Definition: types.h:46
Transfer memory allowed.
Definition: svc.h:52
Result svcWaitProcessWideKeyAtomic(u32 *key, u32 *tag_location, u32 self_tag, u64 timeout)
Performs a condition variable wait operation in userspace.
Result svcSignalEvent(Handle handle)
Sets an event's signalled status.
IPC type 3 send allowed.
Definition: svc.h:47
uint8_t u8
8-bit unsigned integer.
Definition: types.h:21
Result svcGetProcessList(u32 *num_out, u64 *pids_out, u32 max_pids)
Retrieves a list of all running processes.
Result svcArbitrateLock(u32 wait_tag, u32 *tag_location, u32 self_tag)
Arbitrates a mutex lock operation in userspace.
Result svcReadDebugProcessMemory(void *buffer, Handle debug, u64 addr, u64 size)
Reads memory from a process that is being debugged.
Result svcCreateResourceLimit(Handle *out)
Creates a new Resource Limit handle.
Result svcGetDebugThreadContext(u8 *out, Handle debug, u64 threadID, u32 flags)
Gets the context of a thread in a debugging session.
Result svcSetThreadPriority(Handle handle, u32 priority)
Sets a thread's priority.
uint64_t u64
64-bit unsigned integer.
Definition: types.h:24
Process that has just creashed.
Definition: svc.h:127
Result svcCreateSession(Handle *server_handle, Handle *client_handle, u32 unk0, u64 unk1)
Creates an IPC session.
Result svcGetInfo(u64 *out, u64 id0, Handle handle, u64 id1)
Retrieves information about the system, or a certain kernel object.
Read/execute permissions.
Definition: svc.h:79
MemoryType
Memory type enumeration (lower 8 bits of MemoryState)
Definition: svc.h:16
How many sessions can a process own.
Definition: svc.h:114
Don't care.
Definition: svc.h:80
Result svcGetDebugEvent(u8 *event_out, Handle *debug)
Gets an incoming debug event from a debugging session.
Map process allowed.
Definition: svc.h:59
Mapped using svcMapTransferMemory when the owning process has perm=0.
Definition: svc.h:30
Result svcSetMemoryAttribute(void *addr, u64 size, u32 val0, u32 val1)
Set the memory attributes of a (page-aligned) range of memory.
u32 device_refcount
Device reference count.
Definition: svc.h:90
uint32_t u32
32-bit unsigned integer.
Definition: types.h:23
Process permission change allowed.
Definition: svc.h:49
How much memory can a process map.
Definition: svc.h:110
Result svcResetSignal(Handle handle)
Resets a signal.
u32 ipc_refcount
IPC reference count.
Definition: svc.h:91
Result svcDebugActiveProcess(Handle *debug, u64 processID)
Debugs an active process.
Result svcStartThread(Handle handle)
Starts a freshly created thread.
u32 padding
Padding.
Definition: svc.h:92
Result svcCreateThread(Handle *out, void *entry, void *arg, void *stack_top, int prio, int cpuid)
Creates a thread.
No permissions.
Definition: svc.h:74
Mapped using svcMapMemory.
Definition: svc.h:24
Result svcCreateTransferMemory(Handle *out, void *addr, size_t size, u32 perm)
Creates a block of transfer memory.
Is pool allocated.
Definition: svc.h:57
Result svcMapProcessCodeMemory(Handle proc, u64 dst, u64 src, u64 size)
Maps normal heap in a certain process as executable code (used when loading NROs).
Result svcSleepThread(u64 nano)
Sleeps the current thread for the specified amount of time.
int32_t s32
32-bit signed integer.
Definition: types.h:29
Result svcMapDeviceAddressSpaceByForce(Handle handle, Handle proc_handle, u64 map_addr, u64 dev_size, u64 dev_addr, u32 perm)
Maps an attached device address space to an userspace address.
Read/write permissions.
Definition: svc.h:78
Result svcContinueDebugEvent(Handle debug, u32 flags, u64 unk)
Continues a debugging session.
Result svcMapProcessMemory(void *dst, Handle proc, u64 src, u64 size)
Maps the src address from the supplied process handle into the current process.
Process execution suspended by debugger.
Definition: svc.h:131
Result svcCancelSynchronization(Handle thread)
Waits a svcWaitSynchronization operation being done on a synchronization object in another thread...
Result svcStartProcess(Handle proc, s32 main_prio, s32 default_cpu, u32 stack_size)
Starts executing a freshly created process.
Mapped in kernel during svcMapJitMemory.
Definition: svc.h:37
Mapped using svcMapSharedMemory.
Definition: svc.h:23
Result svcWriteDebugProcessMemory(Handle debug, void *buffer, u64 addr, u64 size)
Writes to memory in a process that is being debugged.
Result svcClearEvent(Handle handle)
Clears an event's signalled status.
Process has finished exiting.
Definition: svc.h:130
Result svcQueryMemory(MemoryInfo *meminfo_ptr, u32 *pageinfo, u64 addr)
Query information about an address.
Result svcAttachDeviceAddressSpace(u64 device, Handle handle)
Attaches a device address space to a device.
How many threads can a process spawn.
Definition: svc.h:111
Result svcCreateJitMemory(Handle *jit_handle, void *src_addr, u64 size)
Creates JIT memory in the caller's address space [4.0.0+].
Reserved.
Definition: svc.h:33
u32 svcGetCurrentProcessorNumber(void)
Gets the current processor's number.
Secure monitor arguments.
Definition: svc.h:96
IPC buffers with descriptor flags=3.
Definition: svc.h:35
Unmap owner.
Definition: svc.h:104
Result svcTerminateProcess(Handle proc)
Terminates a running process.
Result svcSetThreadActivity(Handle thread, bool paused)
Configures the pause/unpause status of a thread.
Result svcUnmapTransferMemory(Handle tmem_handle, void *addr, size_t size)
Unmaps a block of transfer memory.
Result svcCreateSharedMemory(Handle *out, size_t size, u32 local_perm, u32 other_perm)
Creates a block of shared memory.
Process attached to debugger.
Definition: svc.h:125
JIT memory allowed.
Definition: svc.h:61
Is IPC mapped (when IpcRefCount > 0).
Definition: svc.h:67
Result svcWaitSynchronization(s32 *index, const Handle *handles, s32 handleCount, u64 timeout)
Waits on one or more synchronization objects, optionally with a timeout.
Result svcGetProcessId(u64 *processID, Handle handle)
Gets the PID associated with a process.
Result svcSetHeapSize(void **out_addr, u64 size)
Set the process heap to a given size.
Mapped during svcCreateProcess.
Definition: svc.h:20
Unmapped memory.
Definition: svc.h:17
IPC type 0 send allowed.
Definition: svc.h:46
Is uncached.
Definition: svc.h:69
Type field (see MemoryType).
Definition: svc.h:43
#define BIT(n)
Creates a bitmask from a bit number.
Definition: types.h:51
Result svcMapSharedMemory(Handle handle, void *addr, size_t size, u32 perm)
Maps a block of shared memory.
LimitableResource
Limitable Resources.
Definition: svc.h:109
Unmap process code memory allowed.
Definition: svc.h:51
Mapped using svcMapTransferMemory when the owning process has perm!=0.
Definition: svc.h:31
Attribute change allowed.
Definition: svc.h:60
Result svcGetProcessInfo(u64 *out, Handle proc, ProcessInfoType which)
Gets a ProcessInfoType for a process.
How many transfer memories can a process make.
Definition: svc.h:113
Mapped using svcSetHeapSize.
Definition: svc.h:22
Result svcBreak(u32 breakReason, u64 inval1, u64 inval2)
Breaks execution.
Result svcCreateInterruptEvent(Handle *handle, u64 irqNum, u32 flag)
Creates an event and binds it to a specific hardware interrupt.
Query physical address allowed.
Definition: svc.h:53
Result svcSetMemoryPermission(void *addr, u64 size, u32 perm)
Set the memory permissions of a (page-aligned) range of memory.
Is device mapped (when DeviceRefCount > 0).
Definition: svc.h:68
Result svcCreatePort(Handle *portServer, Handle *portClient, s32 max_sessions, bool is_light, const char *name)
Creates a port.
Map slave.
Definition: svc.h:103
Result svcBreakDebugProcess(Handle debug)
Breaks an active debugging session.
Newly-created process.
Definition: svc.h:124
Result svcQueryDebugProcessMemory(MemoryInfo *meminfo_ptr, u32 *pageinfo, Handle debug, u64 addr)
Queries memory information from a process that is being debugged.
IPC buffers with descriptor flags=1.
Definition: svc.h:34
Map owner.
Definition: svc.h:102
Result svcMapMemory(void *dst_addr, void *src_addr, u64 size)
Maps a memory range into a different range.
u32 perm
Memory permissions (see Permission).
Definition: svc.h:89
Result svcUnmapMemory(void *dst_addr, void *src_addr, u64 size)
Unmaps a region that was previously mapped with svcMapMemory.
Result svcReadWriteRegister(u32 *outVal, u64 regAddr, u32 rwMask, u32 inVal)
Reads/writes a protected MMIO register.
MemoryState
Memory state bitmasks.
Definition: svc.h:42
u64 size
Size.
Definition: svc.h:86
Process detached from debugger.
Definition: svc.h:126
Result svcArbitrateUnlock(u32 *tag_location)
Arbitrates a mutex unlock operation in userspace.
Force read/writable by debug syscalls.
Definition: svc.h:45
Alias for MemState_IsPoolAllocated.
Definition: svc.h:58
Result svcCloseHandle(Handle handle)
Closes a handle, decrementing the reference count of the corresponding kernel object.
Result svcCreateEvent(Handle *server_handle, Handle *client_handle)
Creates a system event.
Result svcOutputDebugString(const char *str, u64 size)
Outputs debug text, if used during debugging.
u64 addr
Base address.
Definition: svc.h:85
Result svcSendSyncRequest(Handle session)
Sends an IPC synchronization request to a session.
Result svcCreateProcess(Handle *out, void *proc_info, u32 *caps, u64 cap_num)
Creates a new process.
Result svcGetResourceLimitLimitValue(u64 *out, Handle reslimit_h, LimitableResource which)
Gets the maximum value a LimitableResource can have, for a Resource Limit handle. ...
Transition from MemType_CodeStatic performed by svcSetProcessMemoryPermission.
Definition: svc.h:21
Result svcGetThreadId(u64 *threadID, Handle handle)
Gets the TID associated with a process.
Result svcReplyAndReceive(s32 *index, const Handle *handles, s32 handleCount, Handle replyTarget, u64 timeout)
Performs IPC input/output.
Write permission.
Definition: svc.h:76
Mapped during svcCreateThread.
Definition: svc.h:29
Result svcSetResourceLimitLimitValue(Handle reslimit, LimitableResource which, u64 value)
Sets the value for a LimitableResource for a Resource Limit handle.
Result svcGetSystemInfo(u64 *out, u64 id0, Handle handle, u64 id1)
Retrieves privileged information about the system, or a certain kernel object.
Map allowed.
Definition: svc.h:50
Mapped in kernel during svcMapJitMemory.
Definition: svc.h:38
Result svcSendSyncRequestWithUserBuffer(void *usrBuffer, u64 size, Handle session)
Sends an IPC synchronization request to a session from an user allocated buffer.
Transition from MemType_ModuleCodeStatic performed by svcSetProcessMemoryPermission.
Definition: svc.h:26
Map device aligned allowed.
Definition: svc.h:55
Result svcQueryPhysicalAddress(u64 out[3], u64 virtaddr)
Queries information about a certain virtual address, including its physical address.
Read permission.
Definition: svc.h:75
Result svcSendAsyncRequestWithUserBuffer(Handle *handle, void *usrBuffer, u64 size, Handle session)
Sends an IPC synchronization request to a session from an user allocated buffer (asynchronous version...
ProcessInfoType
Process Information.
Definition: svc.h:118