diff --git a/src/system/boot/loader/heap.cpp b/src/system/boot/loader/heap.cpp index cce03ef1f7..644ee3d2bc 100644 --- a/src/system/boot/loader/heap.cpp +++ b/src/system/boot/loader/heap.cpp @@ -52,6 +52,9 @@ const static size_t kAlignment = 8; // all memory chunks will be a multiple of this + +const static size_t kDefaultHeapSize = (1024 + 256) * 1024; + // default initial heap size, unless overridden by platform loader const static size_t kLargeAllocationThreshold = 16 * 1024; // allocations of this size or larger are allocated via // platform_allocate_region() @@ -401,6 +404,9 @@ heap_print_statistics() status_t heap_init(stage2_args* args) { + if (args->heap_size == 0) + args->heap_size = kDefaultHeapSize; + void* base; void* top; if (platform_init_heap(args, &base, &top) < B_OK) diff --git a/src/system/boot/platform/amiga_m68k/start.cpp b/src/system/boot/platform/amiga_m68k/start.cpp index 8881ca7209..f0c50f6ad1 100644 --- a/src/system/boot/platform/amiga_m68k/start.cpp +++ b/src/system/boot/platform/amiga_m68k/start.cpp @@ -20,8 +20,6 @@ #include "rom_calls.h" -#define HEAP_SIZE 65536 - // GCC defined globals extern void (*__ctor_list)(void); extern void (*__ctor_end)(void); @@ -132,7 +130,7 @@ _start(void) call_ctors(); // call C++ constructors before doing anything else - args.heap_size = HEAP_SIZE; + args.heap_size = 0; args.arguments = NULL; //serial_init(); diff --git a/src/system/boot/platform/atari_m68k/start.cpp b/src/system/boot/platform/atari_m68k/start.cpp index c0f6503bcc..381f0d9431 100644 --- a/src/system/boot/platform/atari_m68k/start.cpp +++ b/src/system/boot/platform/atari_m68k/start.cpp @@ -20,8 +20,6 @@ #include "toscalls.h" -#define HEAP_SIZE 65536 - // GCC defined globals extern void (*__ctor_list)(void); extern void (*__ctor_end)(void); @@ -140,7 +138,7 @@ _start(void) // call C++ constructors before doing anything else Bconout(DEV_CON, 'I'); - args.heap_size = HEAP_SIZE; + args.heap_size = 0; args.arguments = NULL; // so we can dprintf diff --git a/src/system/boot/platform/bios_ia32/start.cpp b/src/system/boot/platform/bios_ia32/start.cpp index 89c870a1d2..152f7a4b0f 100644 --- a/src/system/boot/platform/bios_ia32/start.cpp +++ b/src/system/boot/platform/bios_ia32/start.cpp @@ -31,9 +31,6 @@ #include "smp.h" -#define HEAP_SIZE ((1024 + 256) * 1024) - - // GCC defined globals extern void (*__ctor_list)(void); extern void (*__ctor_end)(void); @@ -184,7 +181,7 @@ _start(void) call_ctors(); // call C++ constructors before doing anything else - args.heap_size = HEAP_SIZE; + args.heap_size = 0; args.arguments = NULL; serial_init(); diff --git a/src/system/boot/platform/efi/start.cpp b/src/system/boot/platform/efi/start.cpp index fefead9327..2ccb802f46 100644 --- a/src/system/boot/platform/efi/start.cpp +++ b/src/system/boot/platform/efi/start.cpp @@ -233,7 +233,6 @@ extern "C" efi_status efi_main(efi_handle image, efi_system_table *systemTable) { stage2_args args; - memset(&args, 0, sizeof(stage2_args)); kImage = image; diff --git a/src/system/boot/platform/next_m68k/start.cpp b/src/system/boot/platform/next_m68k/start.cpp index a69a32903c..df5bd9e8d5 100644 --- a/src/system/boot/platform/next_m68k/start.cpp +++ b/src/system/boot/platform/next_m68k/start.cpp @@ -19,7 +19,6 @@ #include "keyboard.h" #include "nextrom.h" -#define HEAP_SIZE 65536 // GCC defined globals extern void (*__ctor_list)(void); @@ -246,7 +245,7 @@ start_next(const char *boot_args, struct mon_global *monitor) // call C++ constructors before doing anything else mg->mg_putc('I'); - args.heap_size = HEAP_SIZE; + args.heap_size = 0; args.arguments = NULL; //serial_init(); diff --git a/src/system/boot/platform/openfirmware/start.cpp b/src/system/boot/platform/openfirmware/start.cpp index c854e1863a..6e62dc6025 100644 --- a/src/system/boot/platform/openfirmware/start.cpp +++ b/src/system/boot/platform/openfirmware/start.cpp @@ -23,9 +23,6 @@ #include "real_time_clock.h" -#define HEAP_SIZE (512 * 1024) - - // GCC defined globals extern void (*__ctor_list)(void); extern void (*__ctor_end)(void); @@ -104,7 +101,7 @@ start(void *openFirmwareEntry) // stage2 args - might be set via the command line one day stage2_args args; - args.heap_size = HEAP_SIZE; + args.heap_size = 0; args.arguments = NULL; if (of_init((intptr_t (*)(void*))openFirmwareEntry) != B_OK) diff --git a/src/system/boot/platform/riscv/start.cpp b/src/system/boot/platform/riscv/start.cpp index acd0ccd935..669a3ca9bb 100644 --- a/src/system/boot/platform/riscv/start.cpp +++ b/src/system/boot/platform/riscv/start.cpp @@ -24,8 +24,6 @@ #include "graphics.h" -#define HEAP_SIZE (1024*1024) - // GCC defined globals extern void (*__ctor_list)(void); extern void (*__ctor_end)(void); @@ -205,7 +203,7 @@ _start(int hartId, void* fdt) call_ctors(); stage2_args args; - args.heap_size = HEAP_SIZE; + args.heap_size = 0; args.arguments = NULL; traps_init(); diff --git a/src/system/boot/platform/u-boot/start.cpp b/src/system/boot/platform/u-boot/start.cpp index d7d38045a4..8a4a15e689 100644 --- a/src/system/boot/platform/u-boot/start.cpp +++ b/src/system/boot/platform/u-boot/start.cpp @@ -30,9 +30,6 @@ extern "C" { }; -#define HEAP_SIZE (128 * 1024) - - typedef struct uboot_gd { // those are the only few members that we can trust // others depend on compile-time config @@ -191,7 +188,7 @@ start_gen(int argc, const char **argv, struct image_header *uimage, void *fdt) clear_bss(); // call C++ constructors before doing anything else call_ctors(); - args.heap_size = HEAP_SIZE; + args.heap_size = 0; args.arguments = NULL; args.arguments_count = 0; args.platform.boot_tgz_data = NULL;