mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 20:42:44 +02:00
Implement more SVCs (#74)
Implement svcSetThreadPriority. Implement svcGetCurrentProcessorNumber. Implement svcSignalEvent. Implement svcSendSyncRequestWithUserBuffer. Implement svcSendAsyncRequestWithUserBuffer. Implement svcGetThreadId. Implement svcReplyAndReceiveWithUserBuffer. Implement svcCreateEvent. Implement svcReadWriteRegister. Implement svcCreateInterruptEvent. Implement svcMapDeviceAddressSpaceByForce. Implement svcTerminateProcess. Fix svcMapDeviceAddressSpaceAligned. Fix svcUnmapDeviceAddressSpace.
This commit is contained in:
parent
c2b4f586f2
commit
b2b8e1ec67
@ -211,11 +211,39 @@ void NORETURN svcExitThread(void);
|
||||
*/
|
||||
Result svcSleepThread(u64 nano);
|
||||
|
||||
/**
|
||||
* @brief Gets a thread's priority.
|
||||
* @return Result code.
|
||||
* @note Syscall number 0x0C.
|
||||
*/
|
||||
Result svcGetThreadPriority(u32* priority, Handle handle);
|
||||
|
||||
/**
|
||||
* @brief Sets a thread's priority.
|
||||
* @return Result code.
|
||||
* @note Syscall number 0x0D.
|
||||
*/
|
||||
Result svcSetThreadPriority(Handle handle, u32 priority);
|
||||
|
||||
/**
|
||||
* @brief Gets the current processor's number.
|
||||
* @return The current processor's number.
|
||||
* @note Syscall number 0x10.
|
||||
*/
|
||||
u32 svcGetCurrentProcessorNumber(void);
|
||||
|
||||
///@}
|
||||
|
||||
///@name Synchronization
|
||||
///@{
|
||||
|
||||
/**
|
||||
* @brief Sets an event's signalled status.
|
||||
* @return Result code.
|
||||
* @note Syscall number 0x11.
|
||||
*/
|
||||
Result svcSignalEvent(Handle handle);
|
||||
|
||||
/**
|
||||
* @brief Clears an event's signalled status.
|
||||
* @return Result code.
|
||||
@ -280,7 +308,6 @@ Result svcResetSignal(Handle handle);
|
||||
///@name Synchronization
|
||||
///@{
|
||||
|
||||
|
||||
/**
|
||||
* @brief Waits on one or more synchronization objects, optionally with a timeout.
|
||||
* @return Result code.
|
||||
@ -364,6 +391,22 @@ Result svcConnectToNamedPort(Handle* session, const char* name);
|
||||
*/
|
||||
Result svcSendSyncRequest(Handle session);
|
||||
|
||||
/**
|
||||
* @brief Sends an IPC synchronization request to a session from an user allocated buffer.
|
||||
* @return Result code.
|
||||
* @remark size must be allocated to 0x1000 bytes.
|
||||
* @note Syscall number 0x22.
|
||||
*/
|
||||
Result svcSendSyncRequestWithUserBuffer(void* usrBuffer, u64 size, Handle session);
|
||||
|
||||
/**
|
||||
* @brief Sends an IPC synchronization request to a session from an user allocated buffer (asynchronous version).
|
||||
* @return Result code.
|
||||
* @remark size must be allocated to 0x1000 bytes.
|
||||
* @note Syscall number 0x23.
|
||||
*/
|
||||
Result svcSendAsyncRequestWithUserBuffer(Handle* handle, void* usrBuffer, u64 size, Handle session);
|
||||
|
||||
///@}
|
||||
|
||||
///@name Process and thread management
|
||||
@ -376,6 +419,13 @@ Result svcSendSyncRequest(Handle session);
|
||||
*/
|
||||
Result svcGetProcessId(u64 *processID, Handle handle);
|
||||
|
||||
/**
|
||||
* @brief Gets the TID associated with a process.
|
||||
* @return Result code.
|
||||
* @note Syscall number 0x25.
|
||||
*/
|
||||
Result svcGetThreadId(u64 *threadID, Handle handle);
|
||||
|
||||
///@}
|
||||
|
||||
///@name Miscellaneous
|
||||
@ -464,6 +514,26 @@ Result svcAcceptSession(Handle *session_handle, Handle port_handle);
|
||||
*/
|
||||
Result svcReplyAndReceive(s32* index, const Handle* handles, s32 handleCount, Handle replyTarget, u64 timeout);
|
||||
|
||||
/**
|
||||
* @brief Performs IPC input/output from an user allocated buffer.
|
||||
* @return Result code.
|
||||
* @note Syscall number 0x44.
|
||||
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
|
||||
*/
|
||||
Result svcReplyAndReceiveWithUserBuffer(s32* index, void* usrBuffer, u64 size, const Handle* handles, s32 handleCount, Handle replyTarget, u64 timeout);
|
||||
|
||||
///@}
|
||||
|
||||
///@name Synchronization
|
||||
///@{
|
||||
|
||||
/**
|
||||
* @brief Creates a system event.
|
||||
* @return Result code.
|
||||
* @note Syscall number 0x45.
|
||||
*/
|
||||
Result svcCreateEvent(Handle* client_handle, Handle* server_handle);
|
||||
|
||||
///@}
|
||||
|
||||
///@name Just-in-time (JIT) compilation support
|
||||
@ -487,9 +557,21 @@ Result svcMapJitMemory(Handle jit_handle, JitMapOperation op, void* dst_addr, u6
|
||||
|
||||
///@}
|
||||
|
||||
///@name Inter-process memory sharing
|
||||
///@name Device memory-mapped I/O (MMIO)
|
||||
///@{
|
||||
|
||||
/**
|
||||
* @brief Reads/writes a protected MMIO register.
|
||||
* @return Result code.
|
||||
* @note Syscall number 0x4E.
|
||||
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
|
||||
*/
|
||||
Result svcReadWriteRegister(u32* outVal, u64 regAddr, u32 rwMask, u32 inVal);
|
||||
|
||||
///@}
|
||||
|
||||
///@name Inter-process memory sharing
|
||||
///@{
|
||||
|
||||
/**
|
||||
* @brief Creates a block of shared memory.
|
||||
@ -520,6 +602,14 @@ Result svcUnmapTransferMemory(Handle tmem_handle, void* addr, size_t size);
|
||||
///@name Device memory-mapped I/O (MMIO)
|
||||
///@{
|
||||
|
||||
/**
|
||||
* @brief Creates an event and binds it to a specific hardware interrupt.
|
||||
* @return Result code.
|
||||
* @note Syscall number 0x53.
|
||||
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
|
||||
*/
|
||||
Result svcCreateInterruptEvent(Handle* handle, u64 irqNum, u32 flag);
|
||||
|
||||
/**
|
||||
* @brief Queries information about a certain virtual address, including its physical address.
|
||||
* @return Result code.
|
||||
@ -565,6 +655,15 @@ Result svcAttachDeviceAddressSpace(u64 device, Handle handle);
|
||||
*/
|
||||
Result svcDetachDeviceAddressSpace(u64 device, Handle handle);
|
||||
|
||||
/**
|
||||
* @brief Maps an attached device address space to an userspace address.
|
||||
* @return Result code.
|
||||
* @remark The userspace destination address must have the \ref MemState_MapDeviceAllowed bit set.
|
||||
* @note Syscall number 0x59.
|
||||
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
|
||||
*/
|
||||
Result svcMapDeviceAddressSpaceByForce(Handle handle, Handle proc_handle, u64 map_addr, u64 dev_size, u64 dev_addr, u32 perm);
|
||||
|
||||
/**
|
||||
* @brief Maps an attached device address space to an userspace address.
|
||||
* @return Result code.
|
||||
@ -572,7 +671,7 @@ Result svcDetachDeviceAddressSpace(u64 device, Handle handle);
|
||||
* @note Syscall number 0x5A.
|
||||
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
|
||||
*/
|
||||
Result svcMapDeviceAddressSpaceAligned(Handle handle, Handle proc_handle, u64 dev_addr, u64 dev_size, u64 map_addr, u64 perm);
|
||||
Result svcMapDeviceAddressSpaceAligned(Handle handle, Handle proc_handle, u64 map_addr, u64 dev_size, u64 dev_addr, u32 perm);
|
||||
|
||||
/**
|
||||
* @brief Unmaps an attached device address space from an userspace address.
|
||||
@ -580,7 +679,7 @@ Result svcMapDeviceAddressSpaceAligned(Handle handle, Handle proc_handle, u64 de
|
||||
* @note Syscall number 0x5C.
|
||||
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
|
||||
*/
|
||||
Result svcUnmapDeviceAddressSpace(Handle handle, Handle proc_handle, u64 map_addr, u64 map_size, u64 perm);
|
||||
Result svcUnmapDeviceAddressSpace(Handle handle, Handle proc_handle, u64 map_addr, u64 map_size, u64 dev_addr);
|
||||
|
||||
///@}
|
||||
|
||||
@ -805,6 +904,14 @@ Result svcCreateProcess(Handle* out, void* proc_info, u32* caps, u64 cap_num);
|
||||
*/
|
||||
Result svcStartProcess(Handle proc, s32 main_prio, s32 default_cpu, u32 stack_size);
|
||||
|
||||
/**
|
||||
* @brief Terminates a running process.
|
||||
* @return Result code.
|
||||
* @note Syscall number 0x7B.
|
||||
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
|
||||
*/
|
||||
Result svcTerminateProcess(Handle proc);
|
||||
|
||||
///@}
|
||||
|
||||
///@name ( ͡° ͜ʖ ͡°)
|
||||
|
@ -75,6 +75,29 @@ SVC_BEGIN svcSleepThread
|
||||
ret
|
||||
SVC_END
|
||||
|
||||
SVC_BEGIN svcGetThreadPriority
|
||||
str x0, [sp, #-16]!
|
||||
svc 0xC
|
||||
ldr x2, [sp], #16
|
||||
str w1, [x2]
|
||||
ret
|
||||
SVC_END
|
||||
|
||||
SVC_BEGIN svcSetThreadPriority
|
||||
svc 0xD
|
||||
ret
|
||||
SVC_END
|
||||
|
||||
SVC_BEGIN svcGetCurrentProcessorNumber
|
||||
svc 0x10
|
||||
ret
|
||||
SVC_END
|
||||
|
||||
SVC_BEGIN svcSignalEvent
|
||||
svc 0x11
|
||||
ret
|
||||
SVC_END
|
||||
|
||||
SVC_BEGIN svcClearEvent
|
||||
svc 0x12
|
||||
ret
|
||||
@ -122,22 +145,27 @@ SVC_BEGIN svcCancelSynchronization
|
||||
SVC_END
|
||||
|
||||
SVC_BEGIN svcArbitrateLock
|
||||
svc 0x1a
|
||||
svc 0x1A
|
||||
ret
|
||||
SVC_END
|
||||
|
||||
SVC_BEGIN svcArbitrateUnlock
|
||||
svc 0x1b
|
||||
svc 0x1B
|
||||
ret
|
||||
SVC_END
|
||||
|
||||
SVC_BEGIN svcWaitProcessWideKeyAtomic
|
||||
svc 0x1c
|
||||
svc 0x1C
|
||||
ret
|
||||
SVC_END
|
||||
|
||||
SVC_BEGIN svcSignalProcessWideKey
|
||||
svc 0x1d
|
||||
svc 0x1D
|
||||
ret
|
||||
SVC_END
|
||||
|
||||
SVC_BEGIN svcGetSystemTick
|
||||
svc 0x1E
|
||||
ret
|
||||
SVC_END
|
||||
|
||||
@ -149,13 +177,21 @@ SVC_BEGIN svcConnectToNamedPort
|
||||
ret
|
||||
SVC_END
|
||||
|
||||
SVC_BEGIN svcGetSystemTick
|
||||
svc 0x1E
|
||||
SVC_BEGIN svcSendSyncRequest
|
||||
svc 0x21
|
||||
ret
|
||||
SVC_END
|
||||
|
||||
SVC_BEGIN svcSendSyncRequest
|
||||
svc 0x21
|
||||
SVC_BEGIN svcSendSyncRequestWithUserBuffer
|
||||
svc 0x22
|
||||
ret
|
||||
SVC_END
|
||||
|
||||
SVC_BEGIN svcSendAsyncRequestWithUserBuffer
|
||||
str x0, [sp, #-16]!
|
||||
svc 0x23
|
||||
ldr x2, [sp], #16
|
||||
str w1, [x2]
|
||||
ret
|
||||
SVC_END
|
||||
|
||||
@ -167,6 +203,14 @@ SVC_BEGIN svcGetProcessId
|
||||
ret
|
||||
SVC_END
|
||||
|
||||
SVC_BEGIN svcGetThreadId
|
||||
str x0, [sp, #-16]!
|
||||
svc 0x25
|
||||
ldr x2, [sp], #16
|
||||
str x1, [x2]
|
||||
ret
|
||||
SVC_END
|
||||
|
||||
SVC_BEGIN svcBreak
|
||||
svc 0x26
|
||||
ret
|
||||
@ -215,6 +259,23 @@ SVC_BEGIN svcReplyAndReceive
|
||||
ret
|
||||
SVC_END
|
||||
|
||||
SVC_BEGIN svcReplyAndReceiveWithUserBuffer
|
||||
str x0, [sp, #-16]!
|
||||
svc 0x44
|
||||
ldr x2, [sp], #16
|
||||
str w1, [x2]
|
||||
ret
|
||||
SVC_END
|
||||
|
||||
SVC_BEGIN svcCreateEvent
|
||||
stp x0, x1, [sp, #-16]!
|
||||
svc 0x45
|
||||
ldp x3, x4, [sp], #16
|
||||
str w1, [x3]
|
||||
str w2, [x4]
|
||||
ret
|
||||
SVC_END
|
||||
|
||||
SVC_BEGIN svcCreateJitMemory
|
||||
str x0, [sp, #-16]!
|
||||
svc 0x4B
|
||||
@ -228,6 +289,14 @@ SVC_BEGIN svcMapJitMemory
|
||||
ret
|
||||
SVC_END
|
||||
|
||||
SVC_BEGIN svcReadWriteRegister
|
||||
str x0, [sp, #-16]!
|
||||
svc 0x4E
|
||||
ldr x2, [sp], #16
|
||||
str w1, [x2]
|
||||
ret
|
||||
SVC_END
|
||||
|
||||
SVC_BEGIN svcCreateSharedMemory
|
||||
str x0, [sp, #-16]!
|
||||
svc 0x50
|
||||
@ -246,6 +315,14 @@ SVC_BEGIN svcUnmapTransferMemory
|
||||
ret
|
||||
SVC_END
|
||||
|
||||
SVC_BEGIN svcCreateInterruptEvent
|
||||
str x0, [sp, #-16]!
|
||||
svc 0x53
|
||||
ldr x2, [sp], #16
|
||||
str w1, [x2]
|
||||
ret
|
||||
SVC_END
|
||||
|
||||
SVC_BEGIN svcQueryPhysicalAddress
|
||||
str x0, [sp, #-16]!
|
||||
svc 0x54
|
||||
@ -281,6 +358,11 @@ SVC_BEGIN svcDetachDeviceAddressSpace
|
||||
ret
|
||||
SVC_END
|
||||
|
||||
SVC_BEGIN svcMapDeviceAddressSpaceByForce
|
||||
svc 0x59
|
||||
ret
|
||||
SVC_END
|
||||
|
||||
SVC_BEGIN svcMapDeviceAddressSpaceAligned
|
||||
svc 0x5A
|
||||
ret
|
||||
@ -416,6 +498,11 @@ SVC_BEGIN svcStartProcess
|
||||
ret
|
||||
SVC_END
|
||||
|
||||
SVC_BEGIN svcTerminateProcess
|
||||
svc 0x7B
|
||||
ret
|
||||
SVC_END
|
||||
|
||||
SVC_BEGIN svcCallSecureMonitor
|
||||
str x0, [sp, #-16]!
|
||||
mov x8, x0
|
||||
|
Loading…
Reference in New Issue
Block a user