From b7be1862a3d906416343fcbabb205e152745243d Mon Sep 17 00:00:00 2001 From: aliaspider Date: Mon, 5 Oct 2015 21:45:17 +0100 Subject: [PATCH] (CTR/3DS) increase the default size of the linear heap. makefile: allow changing stack/linear heap size without requiring a clean. --- Makefile.ctr | 11 +++++++++-- ctr/ctr_config.c | 12 ++++++++++++ frontend/drivers/platform_ctr.c | 26 ++++++++------------------ gfx/drivers/ctr_gu.h | 4 ++-- 4 files changed, 31 insertions(+), 22 deletions(-) create mode 100644 ctr/ctr_config.c diff --git a/Makefile.ctr b/Makefile.ctr index 5c83abbc47..5a93523596 100644 --- a/Makefile.ctr +++ b/Makefile.ctr @@ -28,7 +28,7 @@ CTR_STACK_SIZE = 0x400000 else CTR_STACK_SIZE = 0x100000 endif -CTR_LINEAR_HEAP_SIZE = 0xC00000 +CTR_LINEAR_HEAP_SIZE = 0xD00000 include ctr/Makefile.cores @@ -42,9 +42,11 @@ endif APP_SYSTEM_MODE_EXT = 6 +CONFIG_OBJECT = ctr/ctr_config_$(CTR_STACK_SIZE)_$(CTR_LINEAR_HEAP_SIZE).o + OBJS := OBJS += gfx/drivers/ctr_sprite.o - +OBJS += $(CONFIG_OBJECT) ifeq ($(GRIFFIN_BUILD), 1) OBJS += griffin/griffin.o else @@ -359,6 +361,10 @@ else endif +$(CONFIG_OBJECT): ctr/ctr_config.c + rm -f ctr/ctr_config_*.o + $(CC) -c -o $@ $< $(CFLAGS) $(INCDIRS) + %.o: %.shader python $(AEMSTRO)/aemstro_as.py $< $(notdir $<).shbin $(DEVKITARM)/bin/bin2s $(notdir $<).shbin | $(PREFIX)as -o $@ @@ -417,6 +423,7 @@ clean: rm -f $(TARGET).bnr rm -f $(TARGET).icn rm -f *_shader_shbin.h + rm -f ctr/ctr_config_*.o .PHONY: clean diff --git a/ctr/ctr_config.c b/ctr/ctr_config.c new file mode 100644 index 0000000000..bcde951fa7 --- /dev/null +++ b/ctr/ctr_config.c @@ -0,0 +1,12 @@ + + +#ifndef CTR_STACK_SIZE +#define CTR_STACK_SIZE 0x100000 +#endif + +#ifndef CTR_LINEAR_HEAP_SIZE +#define CTR_LINEAR_HEAP_SIZE 0x600000 +#endif + +int __stacksize__ = CTR_STACK_SIZE; +unsigned int linear_heap_size = CTR_LINEAR_HEAP_SIZE; diff --git a/frontend/drivers/platform_ctr.c b/frontend/drivers/platform_ctr.c index 0288e287bb..174fb85ab8 100644 --- a/frontend/drivers/platform_ctr.c +++ b/frontend/drivers/platform_ctr.c @@ -46,21 +46,12 @@ void wait_for_input(void); #define CTR_APPMEMALLOC_PTR ((u32*)0x1FF80040) -#ifndef CTR_STACK_SIZE -#define CTR_STACK_SIZE 0x100000 -#endif - -#ifndef CTR_LINEAR_HEAP_SIZE -#define CTR_LINEAR_HEAP_SIZE 0x600000 -#endif - -int __stacksize__ = CTR_STACK_SIZE; - extern char* fake_heap_start; extern char* fake_heap_end; u32 __linear_heap; u32 __heapBase; -static u32 __heap_size_local, __linear_heap_size_local; +static u32 heap_size; +extern u32 linear_heap_size; extern void (*__system_retAddr)(void); @@ -79,18 +70,17 @@ void __system_allocateHeaps() { svcGetSystemInfo(&mem_used, 0, 1); - __linear_heap_size_local = CTR_LINEAR_HEAP_SIZE; - __heap_size_local = (app_memory - mem_used - __linear_heap_size_local - 0x10000) & 0xFFFFF000; + heap_size = (app_memory - mem_used - linear_heap_size - 0x10000) & 0xFFFFF000; // Allocate the application heap __heapBase = 0x08000000; - svcControlMemory(&tmp, __heapBase, 0x0, __heap_size_local, MEMOP_ALLOC, MEMPERM_READ | MEMPERM_WRITE); + svcControlMemory(&tmp, __heapBase, 0x0, heap_size, MEMOP_ALLOC, MEMPERM_READ | MEMPERM_WRITE); // Allocate the linear heap - svcControlMemory(&__linear_heap, 0x0, 0x0, __linear_heap_size_local, MEMOP_ALLOC_LINEAR, MEMPERM_READ | MEMPERM_WRITE); + svcControlMemory(&__linear_heap, 0x0, 0x0, linear_heap_size, MEMOP_ALLOC_LINEAR, MEMPERM_READ | MEMPERM_WRITE); // Set up newlib heap fake_heap_start = (char*)__heapBase; - fake_heap_end = fake_heap_start + __heap_size_local; + fake_heap_end = fake_heap_start + heap_size; } @@ -99,10 +89,10 @@ void __attribute__((noreturn)) __libctru_exit(int rc) u32 tmp=0; // Unmap the linear heap - svcControlMemory(&tmp, __linear_heap, 0x0, __linear_heap_size_local, MEMOP_FREE, 0x0); + svcControlMemory(&tmp, __linear_heap, 0x0, linear_heap_size, MEMOP_FREE, 0x0); // Unmap the application heap - svcControlMemory(&tmp, __heapBase, 0x0, __heap_size_local, MEMOP_FREE, 0x0); + svcControlMemory(&tmp, __heapBase, 0x0, heap_size, MEMOP_FREE, 0x0); // Close some handles __destroy_handle_list(); diff --git a/gfx/drivers/ctr_gu.h b/gfx/drivers/ctr_gu.h index 92a5ef22be..f0665258cb 100644 --- a/gfx/drivers/ctr_gu.h +++ b/gfx/drivers/ctr_gu.h @@ -60,7 +60,7 @@ void wait_for_input(void); extern Handle gspEvents[GSPEVENT_MAX]; extern u32* gpuCmdBuf; extern u32 gpuCmdBufOffset; -extern u32 __linear_heap_size; +extern u32 linear_heap_size; extern u32 __linear_heap; __attribute__((always_inline)) @@ -126,7 +126,7 @@ __attribute__((always_inline)) static INLINE void ctrGuFlushAndRun(bool queued) { //take advantage of GX_SetCommandList_First to flush gsp heap - ctrGuSetCommandList_First(queued, gpuCmdBuf, gpuCmdBufOffset*4, (u32*)__linear_heap, __linear_heap_size, NULL, 0); + ctrGuSetCommandList_First(queued, gpuCmdBuf, gpuCmdBufOffset*4, (u32*)__linear_heap, linear_heap_size, NULL, 0); ctrGuSetCommandList_Last(queued, gpuCmdBuf, gpuCmdBufOffset*4, 0x0); }