diff --git a/nx/include/switch/kernel/svc.h b/nx/include/switch/kernel/svc.h index 7dc08b76..0ed124ba 100644 --- a/nx/include/switch/kernel/svc.h +++ b/nx/include/switch/kernel/svc.h @@ -500,6 +500,25 @@ Result svcGetInfo(u64* out, u64 id0, Handle handle, u64 id1); ///@} +///@name Memory management +///@{ + +/** + * @brief Maps new heap memory at the desired address. [3.0.0+] + * @return Result code. + * @note Syscall number 0x2A. + */ +Result svcMapPhysicalMemory(void *address, u64 size); + +/** + * @brief Undoes the effects of \ref svcMapPhysicalMemory. [3.0.0+] + * @return Result code. + * @note Syscall number 0x2B. + */ +Result svcUnmapPhysicalMemory(void *address, u64 size); + +///@} + ///@name Process and thread management ///@{ @@ -581,6 +600,36 @@ Result svcCreateEvent(Handle* server_handle, Handle* client_handle); ///@} +///@name Memory management +///@{ + +/** + * @brief Maps unsafe memory (usable for GPU DMA) for a system module at the desired address. [5.0.0+] + * @return Result code. + * @note Syscall number 0x48. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result svcMapPhysicalMemoryUnsafe(void *address, u64 size); + +/** + * @brief Undoes the effects of \ref svcMapPhysicalMemoryUnsafe. [5.0.0+] + * @return Result code. + * @note Syscall number 0x49. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result svcUnmapPhysicalMemoryUnsafe(void *address, u64 size); + +/** + * @brief Sets the system-wide limit for unsafe memory mappable using \ref svcMapPhysicalMemoryUnsafe. [5.0.0+] + * @return Result code. + * @note Syscall number 0x4A. + * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. + */ +Result svcSetUnsafeLimit(u64 size); + +///@} + + ///@name Just-in-time (JIT) compilation support ///@{ diff --git a/nx/source/kernel/svc.s b/nx/source/kernel/svc.s index 5d492654..41d308c0 100644 --- a/nx/source/kernel/svc.s +++ b/nx/source/kernel/svc.s @@ -229,6 +229,16 @@ SVC_BEGIN svcGetInfo ret SVC_END +SVC_BEGIN svcMapPhysicalMemory + svc 0x2A + ret +SVC_END + +SVC_BEGIN svcUnmapPhysicalMemory + svc 0x2B + ret +SVC_END + SVC_BEGIN svcGetResourceLimitLimitValue str x0, [sp, #-16]! svc 0x30 @@ -292,6 +302,21 @@ SVC_BEGIN svcCreateEvent ret SVC_END +SVC_BEGIN svcMapPhysicalMemoryUnsafe + svc 0x48 + ret +SVC_END + +SVC_BEGIN svcUnmapPhysicalMemoryUnsafe + svc 0x49 + ret +SVC_END + +SVC_BEGIN svcSetUnsafeLimit + svc 0x4A + ret +SVC_END + SVC_BEGIN svcCreateJitMemory str x0, [sp, #-16]! svc 0x4B