From 5a892eedb73e7a46cea0ea0f97d3470d97e5d3ca Mon Sep 17 00:00:00 2001 From: Maschell Date: Sat, 20 Apr 2024 10:00:58 +0200 Subject: [PATCH] Move the wumsrelocator to 0x00800000 --- wumsloader/src/globals.h | 12 +++++++----- wumsloader/src/link.ld | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/wumsloader/src/globals.h b/wumsloader/src/globals.h index c973cbe..c71eaa9 100644 --- a/wumsloader/src/globals.h +++ b/wumsloader/src/globals.h @@ -17,15 +17,17 @@ extern std::vector gAllocatedAddresses; #define MEMORY_REGION_START 0x00800000 #define MEMORY_REGION_SIZE 0x00800000 -#define CUSTOM_RPX_LOADER_RETURN_CODE 0x00009000 // We have to skip the first 0x00009000 bytes because it's still used -#define RELOCATOR_SIZE 0x52000 // Maximum size of the wumsloader, needs to match the one defined in link.ld -#define ENVIRONMENT_PATH_LENGTH 0x100 // Length of the EnvironmentPath. -#define MEMORY_REGION_USABLE_MEM_REGION_END_LENGTH 0x04 // sizeof(uint32_t) +#define RELOCATOR_SIZE 0x50000 // Maximum size of the wumsloader, needs to match the one defined in link.ld +#define ENVIRONMENT_PATH_LENGTH 0x100 // Length of the EnvironmentPath. +#define MEMORY_REGION_USABLE_MEM_REGION_END_LENGTH 0x04 // sizeof(uint32_t) -#define MEMORY_REGION_ENVIRONMENT_STRING_ADRR (MEMORY_REGION_START + CUSTOM_RPX_LOADER_RETURN_CODE + RELOCATOR_SIZE) + +#define MEMORY_REGION_ENVIRONMENT_STRING_ADRR (MEMORY_REGION_START + RELOCATOR_SIZE) #define MEMORY_REGION_USABLE_MEM_REGION_END_VALUE_PTR ((uint32_t *) (MEMORY_REGION_ENVIRONMENT_STRING_ADRR + ENVIRONMENT_PATH_LENGTH)) #define MEMORY_REGION_USABLE_MEM_REGION_END_VALUE (*MEMORY_REGION_USABLE_MEM_REGION_END_VALUE_PTR) +// Technically we overwrite the CustomRPXLoader that is still loaded at 0x00800000... +// We can get away with it because the EnvironmentLoader exits instead of returning to the CustomRPXLoader. #define MEMORY_REGION_USABLE_HEAP_START ((uint32_t) MEMORY_REGION_USABLE_MEM_REGION_END_VALUE_PTR + MEMORY_REGION_USABLE_MEM_REGION_END_LENGTH) #define MEMORY_REGION_USABLE_HEAP_END MEMORY_REGION_USABLE_MEM_REGION_END_VALUE diff --git a/wumsloader/src/link.ld b/wumsloader/src/link.ld index 9817b48..ad09c45 100644 --- a/wumsloader/src/link.ld +++ b/wumsloader/src/link.ld @@ -3,7 +3,7 @@ OUTPUT(loader.elf); ENTRY(_start); SECTIONS { - . = 0x00809000; + . = 0x00800000; .text ALIGN(32) : { KEEP (*(.crt0)) KEEP (*(SORT_NONE(.init))) @@ -92,4 +92,4 @@ SECTIONS { } } -ASSERT((SIZEOF(.text) + SIZEOF(.data) + SIZEOF(.rodata) + SIZEOF(.eh_frame) + SIZEOF(.bss)) < 0x52000, "Memory overlapping with modules."); +ASSERT((SIZEOF(.text) + SIZEOF(.data) + SIZEOF(.rodata) + SIZEOF(.eh_frame) + SIZEOF(.bss)) < 0x50000, "Memory overlapping with modules.");