From 047c505b96287d82dff47c105c909a9965fde9ac Mon Sep 17 00:00:00 2001 From: Tharo <17233964+Thar0@users.noreply.github.com> Date: Thu, 19 Dec 2024 05:38:44 +0000 Subject: [PATCH] Remove gSystemHeap and the system_heap spec segment, use _buffersSegmentEnd to represent the start of the system heap (#1767) --- include/buffers.h | 1 - include/segment_symbols.h | 2 +- linker_scripts/final/extra.ld | 2 +- spec | 7 ------- src/buffers/system_heap.c | 6 ------ src/code/main.c | 2 +- tools/disasm/variables.txt | 2 +- 7 files changed, 4 insertions(+), 18 deletions(-) delete mode 100644 src/buffers/system_heap.c diff --git a/include/buffers.h b/include/buffers.h index 4159173a9e..22cf065894 100644 --- a/include/buffers.h +++ b/include/buffers.h @@ -25,7 +25,6 @@ extern u8 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE]; extern STACK(gGfxSPTaskStack, 0x400); extern GfxPool gGfxPools[2]; extern u8 gAudioHeap[0x138000]; -extern u8 gSystemHeap[]; typedef union { diff --git a/include/segment_symbols.h b/include/segment_symbols.h index 922f818d7c..c29b228384 100644 --- a/include/segment_symbols.h +++ b/include/segment_symbols.h @@ -78,7 +78,7 @@ DECLARE_SEGMENT(code) DECLARE_ROM_SEGMENT(code) DECLARE_BSS_SEGMENT(code) -DECLARE_SEGMENT(system_heap) +DECLARE_SEGMENT(buffers) DECLARE_OVERLAY_SEGMENT(kaleido_scope) DECLARE_OVERLAY_SEGMENT(player_actor) diff --git a/linker_scripts/final/extra.ld b/linker_scripts/final/extra.ld index fddac01c98..74a533edd9 100644 --- a/linker_scripts/final/extra.ld +++ b/linker_scripts/final/extra.ld @@ -3,5 +3,5 @@ ENTRY(entrypoint); ASSERT ((_bootSegmentRomEnd <= 0x101000), "Error: _bootSegmentRomEnd is larger than 1 MB"); // TODO: This should be checking for an address a lot earlier than this one. -ASSERT ((_system_heapSegmentStart < 0x80780000), "Error: The game is overflowing the RAM limit for non-overlay segments."); +ASSERT ((_buffersSegmentEnd < 0x80780000), "Error: The game is overflowing the RAM limit for non-overlay segments."); ASSERT ((_framebuffer_hiSegmentStart == 0x80780000), "Error: framebuffer_hi shifted?"); diff --git a/spec b/spec index 3d0b8d3678..b0df5c0b68 100644 --- a/spec +++ b/spec @@ -794,13 +794,6 @@ beginseg include "$(BUILD_DIR)/src/buffers/audio_heap.o" endseg -beginseg - name "system_heap" - flags NOLOAD - // This segment is just a dummy that is used to know where the other buffers (non framebuffers) end - include "$(BUILD_DIR)/src/buffers/system_heap.o" -endseg - beginseg name "framebuffer_hi" flags NOLOAD diff --git a/src/buffers/system_heap.c b/src/buffers/system_heap.c deleted file mode 100644 index df3d79003b..0000000000 --- a/src/buffers/system_heap.c +++ /dev/null @@ -1,6 +0,0 @@ -#include "buffers.h" - -// Don't add symbols here unless you know what you are doing. - -// Dummy, marks the start of system_heap space whose actual size depends on the spec -u8 gSystemHeap[UNK_SIZE] ALIGNED(16); diff --git a/src/code/main.c b/src/code/main.c index 953cac7c03..13dd030c54 100644 --- a/src/code/main.c +++ b/src/code/main.c @@ -60,7 +60,7 @@ void Main(void* arg) { Check_RegionIsSupported(); Check_ExpansionPak(); - sysHeap = (uintptr_t)SEGMENT_START(system_heap); + sysHeap = (uintptr_t)SEGMENT_END(buffers); fb = FRAMEBUFFERS_START_ADDR; gSystemHeapSize = fb - sysHeap; SystemHeap_Init((void*)sysHeap, gSystemHeapSize); diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 57aa4a263b..3d0ea3c5e5 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -4204,7 +4204,7 @@ 0x80209AA0:("gGfxSPTaskStack","u8","[0x400]",0x400), 0x80209EA0:("gGfxPools","GfxPool","[2]",0x40620), 0x8024A4C0:("gAudioHeap","u8","[0x138000]",0x138000), - 0x803824C0:("gSystemHeap","u8","[UNK_SIZE]",0x3fdb40), + 0x803824C0:("_buffersSegmentEnd","u8","[UNK_SIZE]",0x3fdb40), 0x80780000:("gHiBuffer","BufferHigh","",0x80000), 0x80800860:("titleRotation","s16","",0x2), 0x80800868:("D_80800868","UNK_TYPE1","",0x1),