public static KMemoryRegionManager[] GetMemoryRegions(MemorySize size, MemoryArrange arrange) { ulong poolEnd = KSystemControl.GetDramEndAddress(size); ulong applicationPoolSize = KSystemControl.GetApplicationPoolSize(arrange); ulong appletPoolSize = KSystemControl.GetAppletPoolSize(arrange); MemoryRegion servicePool; MemoryRegion nvServicesPool; MemoryRegion appletPool; MemoryRegion applicationPool; ulong nvServicesPoolSize = KSystemControl.GetMinimumNonSecureSystemPoolSize(); applicationPool = new MemoryRegion(poolEnd - applicationPoolSize, applicationPoolSize); ulong nvServicesPoolEnd = applicationPool.Address - appletPoolSize; nvServicesPool = new MemoryRegion(nvServicesPoolEnd - nvServicesPoolSize, nvServicesPoolSize); appletPool = new MemoryRegion(nvServicesPoolEnd, appletPoolSize); // Note: There is an extra region used by the kernel, however // since we are doing HLE we are not going to use that memory, so give all // the remaining memory space to services. ulong servicePoolSize = nvServicesPool.Address - DramMemoryMap.SlabHeapEnd; servicePool = new MemoryRegion(DramMemoryMap.SlabHeapEnd, servicePoolSize); return(new KMemoryRegionManager[] { GetMemoryRegion(applicationPool), GetMemoryRegion(appletPool), GetMemoryRegion(servicePool), GetMemoryRegion(nvServicesPool) }); }