From c8c44064676f3db2abc34f88a1448261b40e035a Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Fri, 29 Mar 2024 02:27:26 -0700 Subject: [PATCH] svc: Add new InfoTypes --- nx/include/switch/kernel/svc.h | 2 ++ nx/source/kernel/virtmem.c | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/nx/include/switch/kernel/svc.h b/nx/include/switch/kernel/svc.h index 552c6620..b5ca1c1b 100644 --- a/nx/include/switch/kernel/svc.h +++ b/nx/include/switch/kernel/svc.h @@ -209,6 +209,8 @@ typedef enum { InfoType_FreeThreadCount = 24, ///< [11.0.0+] The number of free threads available to the process's resource limit. InfoType_ThreadTickCount = 25, ///< [13.0.0+] Number of ticks spent on thread. InfoType_IsSvcPermitted = 26, ///< [14.0.0+] Does process have access to SVC (only usable with \ref svcSynchronizePreemptionState at present). + InfoType_IoRegionHint = 27, ///< [16.0.0+] Low bits of the physical address for a KIoRegion. + InfoType_AliasRegionExtraSize = 28, ///< [18.0.0+] Extra size added to the reserved region. InfoType_ThreadTickCountDeprecated = 0xF0000002, ///< [1.0.0-12.1.0] Number of ticks spent on thread. } InfoType; diff --git a/nx/source/kernel/virtmem.c b/nx/source/kernel/virtmem.c index fe02f457..ed9a7a00 100644 --- a/nx/source/kernel/virtmem.c +++ b/nx/source/kernel/virtmem.c @@ -160,6 +160,13 @@ void virtmemSetup(void) { diagAbortWithResult(MAKERESULT(Module_Libnx, LibnxError_WeirdKernel)); } + // Account for the alias region extra size. + u64 alias_extra_size; + rc = svcGetInfo(&alias_extra_size, InfoType_AliasRegionExtraSize, CUR_PROCESS_HANDLE, 0); + if (R_SUCCEEDED(rc)) { + g_AliasRegion.end -= alias_extra_size; + } + // Retrieve memory region information for the reserved heap region. rc = _memregionInitWithInfo(&g_HeapRegion, InfoType_HeapRegionAddress, InfoType_HeapRegionSize); if (R_FAILED(rc)) {