From 18d3a30864b0830e0a93229cdf9234de09e914bb Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Tue, 24 Apr 2018 07:21:21 -0600 Subject: [PATCH] Implement svcGetSystemInfo, optimize svcCreatePort. --- nx/include/switch/kernel/svc.h | 18 ++++++++++++++++++ nx/source/kernel/svc.s | 14 ++++++++++---- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/nx/include/switch/kernel/svc.h b/nx/include/switch/kernel/svc.h index 9b377d33..e38194a4 100644 --- a/nx/include/switch/kernel/svc.h +++ b/nx/include/switch/kernel/svc.h @@ -671,6 +671,24 @@ Result svcWriteDebugProcessMemory(Handle debug, void* buffer, u64 addr, u64 size ///@} +///@name Miscellaneous +///@{ + +/** + * @brief Retrieves privileged information about the system, or a certain kernel object. + * @param[out] out Variable to which store the information. + * @param[in] id0 First ID of the property to retrieve. + * @param[in] handle Handle of the object to retrieve information from, or \ref INVALID_HANDLE to retrieve information about the system. + * @param[in] id1 Second ID of the property to retrieve. + * @return Result code. + * @remark The full list of property IDs can be found on the switchbrew.org wiki. + * @note Syscall number 0x6F. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result svcGetSystemInfo(u64* out, u64 id0, Handle handle, u64 id1); + +///@} + ///@name Inter-process communication (IPC) ///@{ diff --git a/nx/source/kernel/svc.s b/nx/source/kernel/svc.s index b60b3cd9..19b25f1b 100644 --- a/nx/source/kernel/svc.s +++ b/nx/source/kernel/svc.s @@ -345,14 +345,20 @@ SVC_BEGIN svcWriteDebugProcessMemory ret SVC_END +SVC_BEGIN svcGetSystemInfo + str x0, [sp, #-16]! + svc 0x6F + ldr x2, [sp], #16 + str x1, [x2] + ret +SVC_END + SVC_BEGIN svcCreatePort stp x0, x1, [sp, #-16]! svc 0x70 - ldr x3, [sp] + ldp x3, x4, [sp], #16 str w1, [x3] - ldr x3, [sp, #8] - str w2, [x3] - add sp, sp, #16 + str w2, [x4] ret SVC_END