revert the memory map to the old one (mostly)

This commit is contained in:
TuxSH 2020-05-18 22:15:34 +01:00
parent 905837468c
commit 704e08dc23
4 changed files with 9 additions and 7 deletions

View File

@ -139,8 +139,8 @@ u32 installK11Extension(u8 *pos, u32 size, bool needToInitSd, u32 baseK11VA, u32
static const u8 patternHook3_4[] = {0x00, 0x00, 0xA0, 0xE1, 0x03, 0xF0, 0x20, 0xE3, 0xFD, 0xFF, 0xFF, 0xEA}; //SGI0 setup code, etc. static const u8 patternHook3_4[] = {0x00, 0x00, 0xA0, 0xE1, 0x03, 0xF0, 0x20, 0xE3, 0xFD, 0xFF, 0xFF, 0xEA}; //SGI0 setup code, etc.
//Our kernel11 extension is initially loaded in VRAM //Our kernel11 extension is initially loaded in VRAM
//u32 kextTotalSize = *(u32 *)0x18000020 - K11EXT_VA; u32 kextTotalSize = *(u32 *)0x18000020 - K11EXT_VA;
u32 stolenSystemMemRegionSize = ISN3DS ? 0 : 0 << 10; // no need to steal any mem on N3DS. Currently, everything fits in BASE on O3DS too (?) u32 stolenSystemMemRegionSize = kextTotalSize; // no need to steal any more mem on N3DS. Currently, everything fits in BASE on O3DS too (?)
u32 dstKextPA = (ISN3DS ? 0x2E000000 : 0x26C00000) - stolenSystemMemRegionSize; // start of BASE memregion (note: linear heap ---> <--- the rest) u32 dstKextPA = (ISN3DS ? 0x2E000000 : 0x26C00000) - stolenSystemMemRegionSize; // start of BASE memregion (note: linear heap ---> <--- the rest)
u32 *hookVeneers = (u32 *)*freeK11Space; u32 *hookVeneers = (u32 *)*freeK11Space;

View File

@ -288,10 +288,7 @@ void main(FcramLayout *layout, KCoreContext *ctxs)
kextBasePa = p->basePA; kextBasePa = p->basePA;
stolenSystemMemRegionSize = p->stolenSystemMemRegionSize; stolenSystemMemRegionSize = p->stolenSystemMemRegionSize;
u32 kextSize = (u32)(__end__ - __start__);
layout->systemSize -= stolenSystemMemRegionSize; layout->systemSize -= stolenSystemMemRegionSize;
layout->baseAddr = layout->baseAddr - stolenSystemMemRegionSize + kextSize;
layout->baseSize = layout->baseSize + stolenSystemMemRegionSize - kextSize;
fcramLayout = *layout; fcramLayout = *layout;
coreCtxs = ctxs; coreCtxs = ctxs;
@ -313,4 +310,8 @@ void main(FcramLayout *layout, KCoreContext *ctxs)
rosalinaState = 0; rosalinaState = 0;
hasStartedRosalinaNetworkFuncsOnce = false; hasStartedRosalinaNetworkFuncsOnce = false;
// DSB, Flush Prefetch Buffer (more or less "isb")
__asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 4" :: "r" (0) : "memory");
__asm__ __volatile__ ("mcr p15, 0, %0, c7, c5, 4" :: "r" (0) : "memory");
} }

View File

@ -140,7 +140,7 @@ u32 Draw_AllocateFramebufferCache(void)
u32 remaining = (u32)osGetMemRegionFree(MEMREGION_SYSTEM); u32 remaining = (u32)osGetMemRegionFree(MEMREGION_SYSTEM);
u32 size = remaining < maxSize ? remaining : maxSize; u32 size = remaining < maxSize ? remaining : maxSize;
if (size < minSize || R_FAILED(svcControlMemory(&tmp, addr, 0, size, MEMOP_ALLOC, MEMPERM_READ | MEMPERM_WRITE))) if (size < minSize || R_FAILED(svcControlMemoryEx(&tmp, addr, 0, size, MEMOP_ALLOC, MEMREGION_SYSTEM | MEMPERM_READ | MEMPERM_WRITE, true)))
{ {
framebufferCache = NULL; framebufferCache = NULL;
framebufferCacheSize = 0; framebufferCacheSize = 0;

View File

@ -12,6 +12,7 @@
#include <3ds/synchronization.h> #include <3ds/synchronization.h>
#include <3ds/result.h> #include <3ds/result.h>
#include <string.h> #include <string.h>
#include "csvc.h"
s32 miniSocRefCount = 0; s32 miniSocRefCount = 0;
static u32 socContextAddr = 0x08000000; static u32 socContextAddr = 0x08000000;
@ -75,7 +76,7 @@ Result miniSocInit(void)
ret = srvGetServiceHandle(&miniSocHandle, "soc:U"); ret = srvGetServiceHandle(&miniSocHandle, "soc:U");
if(ret != 0) goto cleanup; if(ret != 0) goto cleanup;
ret = svcControlMemory(&tmp, socContextAddr, 0, socContextSize, MEMOP_ALLOC, MEMPERM_READ | MEMPERM_WRITE); ret = svcControlMemoryEx(&tmp, socContextAddr, 0, socContextSize, MEMOP_ALLOC, MEMREGION_SYSTEM | MEMPERM_READ | MEMPERM_WRITE, true);
if(ret != 0) goto cleanup; if(ret != 0) goto cleanup;
socContextAddr = tmp; socContextAddr = tmp;