15 #define CURRENT_PROCESS 0xffff8001
16 #define CURRENT_THREAD 0xffff8000
22 uint32_t memory_attribute;
24 uint32_t device_ref_count;
25 uint32_t ipc_ref_count;
30 uint64_t physical_addr;
43 char process_name[12];
45 uint64_t user_exception_context_addr;
56 uint64_t exception_type;
57 uint64_t fault_register;
61 } undefined_instruction;
63 uint32_t is_watchpoint;
75 uint8_t padding[0x80];
80 DEBUG_EVENT_EXIT_TYPE_PAUSED_THREAD = 0,
81 DEBUG_EVENT_EXIT_TYPE_RUNNING_THREAD = 1,
82 DEBUG_EVENT_EXIT_TYPE_TERMINATED_PROCESS = 2,
86 DEBUG_EVENT_ATTACH_PROCESS = 0,
87 DEBUG_EVENT_ATTACH_THREAD = 1,
88 DEBUG_EVENT_UNKNOWN = 2,
90 DEBUG_EVENT_EXCEPTION = 4,
94 DEBUG_EXCEPTION_UNDEFINED_INSTRUCTION = 0,
95 DEBUG_EXCEPTION_INSTRUCTION_ABORT = 1,
96 DEBUG_EXCEPTION_DATA_ABORT_MISC = 2,
97 DEBUG_EXCEPTION_PC_SP_ALIGNMENT_FAULT = 3,
98 DEBUG_EXCEPTION_DEBUGGER_ATTACHED = 4,
99 DEBUG_EXCEPTION_BREAKPOINT = 5,
100 DEBUG_EXCEPTION_USER_BREAK = 6,
101 DEBUG_EXCEPTION_DEBUGGER_BREAK = 7,
102 DEBUG_EXCEPTION_BAD_SVC_ID = 8,
466 result_t svcGetLastThreadInfo(
void *last_thread_context, uint64_t *unknown1, uint64_t *unknown2);
550 void svcSleepSystem();
593 result_t svcCreateInterruptEvent(
revent_h *event, uint64_t interrupt, uint32_t interrupt_type);
648 result_t svcMapDeviceAddressSpace(uint64_t *unknown1,
handle_t unknown2,
handle_t unknown3, uint64_t dev_addr, uint64_t dev_size, uint64_t map_addr, uint32_t perm);
661 result_t svcInvalidateProcessDataCache(
process_h process, uint64_t addr,
size_t size);
662 result_t svcStoreProcessDataCache(
process_h process, uint64_t addr,
size_t size);
663 result_t svcFlushProcessDataCache(
process_h process, uint64_t addr,
size_t size);
678 result_t svcContinueDebugEventOld(
debug_h debug, uint32_t continue_debug_flags_old, uint64_t thread_id);
679 result_t svcContinueDebugEvent(
debug_h debug, uint32_t continue_debug_flags, uint64_t *thread_id_list, uint32_t num_threads);
681 result_t svcGetProcessList(uint32_t *num_out, uint64_t *pids_out, uint32_t max_out);
683 result_t svcGetThreadList(uint32_t *num_out, uint64_t *tids_out, uint32_t max_out,
debug_h debug);
719 result_t svcSetHardwareBreakPoint(uint32_t hw_bkpt_id, uint64_t flags, uint64_t value_or_debug_handle);
721 result_t svcGetDebugThreadParam(uint64_t *param1, uint32_t *param2,
debug_h handle, uint64_t thread_id, uint32_t debug_thread_param);
725 result_t svcCreatePort(
handle_t *client,
handle_t *server, uint32_t max_sessions, uint32_t is_light, const
char *name_ptr);
785 SVC_ID_SET_HEAP_SIZE = 0x01,
786 SVC_ID_SET_MEMORY_PERMISSION = 0x02,
787 SVC_ID_SET_MEMORY_ATTRIBUTE = 0x03,
788 SVC_ID_MAP_MEMORY = 0x04,
789 SVC_ID_UNMAP_MEMORY = 0x05,
790 SVC_ID_QUERY_MEMORY = 0x06,
792 SVC_ID_EXIT_PROCESS = 0x07,
794 SVC_ID_CREATE_THREAD = 0x08,
795 SVC_ID_START_THREAD = 0x09,
796 SVC_ID_EXIT_THREAD = 0x0A,
797 SVC_ID_SLEEP_THREAD = 0x0B,
798 SVC_ID_GET_THREAD_PRIORITY = 0x0C,
799 SVC_ID_SET_THREAD_PRIORITY = 0x0D,
800 SVC_ID_GET_THREAD_CORE_MASK = 0x0E,
801 SVC_ID_SET_THREAD_CORE_MASK = 0x0F,
802 SVC_ID_GET_CURRENT_PROCESSOR_NUMBER = 0x10,
804 SVC_ID_SIGNAL_EVENT = 0x11,
805 SVC_ID_CLEAR_EVENT = 0x12,
807 SVC_ID_MAP_SHARED_MEMORY = 0x13,
808 SVC_ID_UNMAP_SHARED_MEMORY = 0x14,
809 SVC_ID_CREATE_TRANSFER_MEMORY = 0x15,
811 SVC_ID_CLOSE_HANDLE = 0x16,
813 SVC_ID_RESET_SIGNAL = 0x17,
814 SVC_ID_WAIT_SYNCHRONIZATION = 0x18,
815 SVC_ID_CANCEL_SYNCHRONIZATION = 0x19,
816 SVC_ID_ARBITRATE_LOCK = 0x1A,
817 SVC_ID_ARBITRATE_UNLOCK = 0x1B,
818 SVC_ID_WAIT_PROCESS_WIDE_KEY_ATOMIC = 0x1C,
819 SVC_ID_SIGNAL_PROCESS_WIDE_KEY = 0x1D,
820 SVC_ID_GET_SYSTEM_TICK = 0x1E,
822 SVC_ID_CONNECT_TO_NAMED_PORT = 0x1F,
823 SVC_ID_SEND_SYNC_REQUEST_LIGHT = 0x20,
824 SVC_ID_SEND_SYNC_REQUEST = 0x21,
825 SVC_ID_SEND_SYNC_REQUEST_WITH_USER_BUFFER = 0x22,
826 SVC_ID_SEND_ASYNC_REQUEST_WITH_USER_BUFFER = 0x23,
828 SVC_ID_GET_PROCESS_ID = 0x24,
829 SVC_ID_GET_THREAD_ID = 0x25,
832 SVC_ID_OUTPUT_DEBUG_STRING = 0x27,
833 SVC_ID_RETURN_FROM_EXCEPTION = 0x28,
835 SVC_ID_GET_INFO = 0x29,
836 SVC_ID_FLUSH_ENTIRE_DATA_CACHE = 0x2A,
837 SVC_ID_FLUSH_DATA_CACHE = 0x2B,
838 SVC_ID_GET_LAST_THREAD_INFO = 0x2C,
840 SVC_ID_GET_RESOURCE_LIMIT_LIMIT_VALUE = 0x30,
841 SVC_ID_GET_RESOURCE_LIMIT_CURRENT_VALUE = 0x31,
843 SVC_ID_SET_THREAD_ACTIVITY = 0x32,
844 SVC_ID_GET_THREAD_CONTEXT3 = 0x33,
846 SVC_ID_DUMP_INFO = 0x3C,
848 SVC_ID_CREATE_SESSION = 0x40,
849 SVC_ID_ACCEPT_SESSION = 0x41,
850 SVC_ID_REPLY_AND_RECEIVE_LIGHT = 0x42,
851 SVC_ID_REPLY_AND_RECEIVE = 0x43,
852 SVC_ID_REPLY_AND_RECEIVE_WITH_USER_BUFFER = 0x44,
853 SVC_ID_CREATE_EVENT = 0x4E,
854 SVC_ID_SLEEP_SYSTEM = 0x4D,
856 SVC_ID_READ_WRITE_REGISTER = 0x4E,
857 SVC_ID_SET_PROCESS_ACTIVITY = 0x4F,
859 SVC_ID_CREATE_SHARED_MEMORY = 0x50,
860 SVC_ID_MAP_TRANSFER_MEMORY = 0x51,
861 SVC_ID_UNMAP_TRANSFER_MEMORY = 0x52,
862 SVC_ID_CREATE_INTERRUPT_EVENT = 0x53,
863 SVC_ID_QUERY_PHYSICAL_ADDRESS = 0x54,
865 SVC_ID_QUERY_IO_MAPPING = 0x55,
866 SVC_ID_CREATE_DEVICE_ADDRESS_SPACE = 0x56,
867 SVC_ID_ATTACH_DEVICE_ADDRESS_SPACE = 0x57,
868 SVC_ID_DETACH_DEVICE_ADDRESS_SPACE = 0x58,
869 SVC_ID_MAP_DEVICE_ADDRESS_SPACE_BY_FORCE = 0x59,
870 SVC_ID_MAP_DEVICE_ADDRESS_SPACE_ALIGNED = 0x5A,
871 SVC_ID_MAP_DEVICE_ADDRESS_SPACE = 0x5B,
872 SVC_ID_UNMAP_DEVICE_ADDRESS_SPACE = 0x5C,
873 SVC_ID_INVALIDATE_PROCESS_DATA_CACHE = 0x5D,
874 SVC_ID_STORE_PROCESS_DATA_CACHE = 0x5E,
875 SVC_ID_FLUSH_PROCESS_DATA_CACHE = 0x5F,
877 SVC_ID_DEBUG_ACTIVE_PROCESS = 0x60,
878 SVC_ID_BREAK_DEBUG_PROCESS = 0x61,
879 SVC_ID_TERMINATE_DEBUG_PROCESS = 0x62,
880 SVC_ID_GET_DEBUG_EVENT = 0x63,
881 SVC_ID_CONTINUE_DEBUG_EVENT = 0x64,
882 SVC_ID_GET_PROCESS_LIST = 0x65,
883 SVC_ID_GET_THREAD_LIST = 0x66,
884 SVC_ID_GET_DEBUG_THREAD_CONTEXT = 0x67,
885 SVC_ID_SET_DEBUG_THREAD_CONTEXT = 0x68,
887 SVC_ID_QUERY_DEBUG_PROCESS_MEMORY = 0x69,
888 SVC_ID_READ_DEBUG_PROCESS_MEMORY = 0x6A,
889 SVC_ID_WRITE_DEBUG_PROCESS_MEMORY = 0x6B,
890 SVC_ID_SET_HARDWARE_BREAK_POINT = 0x6C,
891 SVC_ID_GET_DEBUG_THREAD_PARAM = 0x6D,
893 SVC_ID_CREATE_PORT = 0x70,
894 SVC_ID_MANAGE_NAMED_PORT = 0x71,
895 SVC_ID_CONNECT_TO_PORT = 0x72,
897 SVC_ID_SET_PROCESS_MEMORY_PERMISSION = 0x73,
898 SVC_ID_MAP_PROCESS_MEMORY = 0x74,
899 SVC_ID_UNMAP_PROCESS_MEMORY = 0x75,
900 SVC_ID_QUERY_PROCESS_MEMORY = 0x76,
901 SVC_ID_MAP_PROCESS_CODE_MEMORY = 0x77,
902 SVC_ID_UNMAP_PROCESS_CODE_MEMORY = 0x78,
904 SVC_ID_CREATE_PROCESS = 0x79,
905 SVC_ID_START_PROCESS = 0x7A,
906 SVC_ID_TERMINATE_PROCESS = 0x7B,
907 SVC_ID_GET_PROCESS_INFO = 0x7C,
909 SVC_ID_CREATE_RESOURCE_LIMIT = 0x7D,
910 SVC_ID_SET_RESOURCE_LIMIT_LIMIT_VALUE = 0x7E,
912 SVC_ID_CALL_SECURE_MONITOR = 0x7F,
result_t svcBreak(uint64_t reason, uint64_t unknown, uint64_t info)
Break to debugger.
result_t svcGetProcessId(uint64_t *pid, handle_t thread_or_process_handle)
Get a process's ID.
result_t svcConnectToNamedPort(session_h *out, char name[8])
Connect to a named port.
result_t svcSleepThread(uint64_t nanos)
Sleep thread for specified time.
result_t svcUnmapPhysicalMemory(void *addr, size_t size)
Unmaps memory mapped by svcMapPhysicalMemory.
result_t svcSetMemoryAttribute(void *addr, uint64_t size, uint32_t state0, uint32_t state1)
Sets memory attributes.
result_t svcReplyAndReceiveWithUserBuffer(uint32_t *handle_idx, void *buffer, uint64_t size, session_h *handles, uint32_t num_handles, session_h reply_session, uint64_t timeout)
See svcReplyAndReceive.
result_t svcMapDeviceAddressSpaceByForce(dev_addr_space_h space, process_h process, uint64_t dev_addr, uint64_t dev_size, uint64_t map_addr, uint32_t perm)
Map device address space by force.
void svcArbitrateUnlock(void *lock)
Arbitrate unlock.
result_t svcReplyAndReceive(uint32_t *handle_idx, session_h *handles, uint32_t num_handles, session_h reply_session, uint64_t timeout)
Sends a reply to the given session, then receives a request.
result_t svcReadDebugProcessMemory(void *buffer, debug_h debug, uint64_t addr, uint64_t size)
Read debug process memory.
result_t svcSetThreadCoreMask(thread_h thread, uint32_t in, uint64_t in2)
Set thread core mask.
handle_t debug_h
Debug handle.
Definition: types.h:46
result_t svcSignalProcessWideKey(void *ptr, uint32_t value)
Wait process wide key atomic.
handle_t event_h
Either revent_h or wevent_h.
Definition: types.h:49
result_t svcMapProcessCodeMemory(process_h process, void *dst, void *src, uint64_t size)
Map process code memory.
void svcFlushEntireDataCache()
Flushes the entire data cache.
result_t svcSendAsyncRequestWithUserBuffer(revent_h *event_handle, void *buffer, uint64_t size, session_h session)
Send an IPC request asynchronously.
result_t svcStartProcess(process_h process, uint32_t main_thread_prio, uint32_t default_cpuid, uint32_t main_thread_stack_size)
Starts the given process.
void svcOutputDebugString(char *str, uint64_t size)
Output a debug string.
result_t svcSetThreadPriority(thread_h thread, uint32_t priority)
Set a thread's priority.
result_t svcSignalEvent(wevent_h event)
Signal an event.
result_t svcStartThread(thread_h thread)
Start a thread.
result_t svcCreateTransferMemory(transfer_memory_h *out, void *addr, uint64_t size, uint32_t permission)
Create transfer memory.
result_t svcMapPhysicalMemory(void *addr, size_t size)
Maps size bytes of type-5 memory at addr.
result_t svcGetThreadId(thread_h *handle_out, thread_h handle_in)
Get a thread ID.
handle_t thread_h
Thread handle.
Definition: types.h:39
uint64_t svcGetSystemTick()
Get the system time tick.
result_t svcCreateEvent(wevent_h *wevent, revent_h *revent)
Creates an event object.
result_t svcGetResourceLimitLimitValue(uint64_t *value, handle_t limit_handle, uint32_t limitable_resource)
Gets the limit value for a resource limit.
result_t svcAcceptSession(session_h *out, port_h port)
Accepts an IPC session on the given port.
result_t svcSendSyncRequest(session_h session)
Send sync request.
void(* thread_entry)(void *)
Thread entrypoint function.
Definition: types.h:53
result_t svcWaitSynchronization(uint32_t *handle_index, handle_t *handles, uint32_t num_handles, uint64_t timeout)
Wait synchronization.
handle_t shared_memory_h
Shared Memory handle.
Definition: types.h:40
result_t svcMapSharedMemory(shared_memory_h block, void *addr, uint64_t size, uint32_t permission)
Map shared memory.
Definition: graphic_buffer_queue.h:83
uint32_t result_t
Function result.
Definition: types.h:51
handle_t revent_h
revent handle
Definition: types.h:47
result_t svcDetachDeviceAddressSpace(uint32_t device_name, dev_addr_space_h space)
Detach device address space.
result_t svcMapProcessMemory(void *src, process_h process, uint64_t dst, uint64_t size)
Map memory in the given process.
result_t svcDebugActiveProcess(debug_h *out, uint64_t process_id)
Debug active process.
handle_t session_h
Session handle.
Definition: types.h:42
result_t svcGetThreadPriority(uint32_t *priority, thread_h thread)
Get the thread priority.
handle_t process_h
Process handle.
Definition: types.h:45
result_t svcGetInfo(void *info, uint64_t info_id, handle_t handle, uint64_t info_sub_id)
Get info.
void svcReturnFromException(uint64_t result)
Return from exception.
void __attribute__((__noreturn__)) svcExitProcess()
Exit the process.
result_t svcWriteDebugProcessMemory(debug_h debug, void *buffer, uint64_t addr, uint64_t size)
Write debug process memory.
result_t svcGetResourceLimitCurrentValue(uint64_t *value, handle_t limit_handle, uint32_t limitable_resource)
Gets the current value for a resource limit.
result_t svcUnmapTransferMemory(transfer_memory_h handle, void *addr, uint64_t size)
Unmap transfer memory.
result_t svcSetMemoryPermission(void *addr, uint64_t size, uint32_t permission)
Sets memory permissions.
result_t svcQueryDebugProcessMemory(memory_info_t *memory_info, uint32_t *page_info, debug_h debug, uint64_t addr)
Query debug process memory.
result_t svcSetThreadActivity(thread_h thread_handle, bool active)
Allows or disallows scheduling of a thread.
result_t svcReadWriteRegister(uint32_t *out_value, uint64_t addr, uint32_t rw_mask, uint32_t in_value)
Read/Write register.
result_t svcCreateThread(thread_h *out, thread_entry entry, void *arg, void *stacktop, int32_t priority, int32_t processor_id)
Create a new thread.
handle_t wevent_h
wevent handle
Definition: types.h:48
void svcArbitrateLock(thread_h current_thread, void *lock, thread_h requesting_thread)
Arbitrate lock.
result_t svcWaitProcessWideKeyAtomic(void *ptr0, void *ptr1, thread_h thread, uint64_t timeout)
Wait process wide key atomic.
result_t svcCreateProcess(process_h *process, void *procinfo, void *caps, uint32_t cap_num)
Creates a new process.
handle_t port_h
Port handle.
Definition: types.h:43
uint32_t handle_t
Resource handle.
Definition: types.h:38
handle_t resource_limit_h
Resource limit handle.
Definition: types.h:50
result_t svcSetProcessMemoryPermission(process_h process, uint64_t addr, uint64_t size, uint32_t prot)
Reprotect memory in the given process.
result_t svcMapMemory(void *dest, void *src, uint64_t size)
Map memory.
handle_t dev_addr_space_h
Dev Address Space handle.
Definition: types.h:44
result_t svcCancelSynchronization(handle_t handle)
Cancel synchronization.
uint32_t svcGetCurrentProcessorNumber()
Get the current processor number.
result_t svcQueryMemory(memory_info_t *memory_info, uint32_t *page_info, void *addr)
Query memory.
result_t svcClearEvent(event_h event)
Clear an event.
result_t svcCreateSession(session_h *server, session_h *client, bool is_light, uint32_t unknown)
Creates an IPC session.
result_t svcResetSignal(handle_t signal)
Resets a signal.
result_t svcAttachDeviceAddressSpace(uint32_t device_name, dev_addr_space_h space)
Attach device address space.
result_t svcMapTransferMemory(transfer_memory_h handle, void *addr, uint64_t size, uint32_t perm)
Map transfer memory.
result_t svcCloseHandle(handle_t handle)
Closes the specified handle.
result_t svcCreateSharedMemory(shared_memory_h *out, uint64_t size, uint32_t self_permissions, uint32_t foreign_permissions)
Create a block of shared memory.
result_t svcUnmapProcessCodeMemory(process_h process, void *dst, void *src, uint64_t size)
Unmap process code memory.
result_t svcUnmapProcessMemory(void *src, process_h process, uint64_t dst, uint64_t size)
Unmap memory mapped via svcMapProcessMemory.
result_t svcFlushDataCache(void *addr, size_t size)
Flushes data cache for a certain memory region.
result_t svcUnmapDeviceAddressSpace(dev_addr_space_h space, process_h process, uint64_t map_addr, uint64_t map_size, uint32_t perm)
Unmap device address space.
result_t svcUnmapMemory(void *dest, void *src, uint64_t size)
Unmap memory.
result_t svcSetHeapSize(void **outAddr, uint32_t size)
Sets the size of the heap.
handle_t transfer_memory_h
Transfer Memory handle.
Definition: types.h:41
result_t svcSendSyncRequestWithUserBuffer(void *buffer, uint64_t size, session_h session)
Send sync request with user buffer.
result_t svcMapDeviceAddressSpaceAligned(dev_addr_space_h space, process_h process, uint64_t dev_addr, uint64_t dev_size, uint64_t map_addr, uint32_t perm)
Map device address space aligned.
result_t svcQueryIoMapping(void *virt_addr, uint64_t phys_addr, uint64_t size)
Query IO mapping.
result_t svcUnmapSharedMemory(shared_memory_h block, void *addr, uint64_t size)
Unmap shared memory.