bootloader: Make releasing the heap the platform loader's responsibility.
Otherwise, platform loaders couldn't make heap allocations inside platform_start_kernel(), which some loaders (e.g. EFI) do. Implement calling heap_release() for the BIOS loaders at least. This gets us back the ~1.5MB of bootloader heap memory there.
This commit is contained in:
@@ -1,23 +1,28 @@
|
|||||||
/*
|
/*
|
||||||
** Copyright 2003, Axel Dörfler, [email protected]. All rights reserved.
|
* Copyright 2003, Axel Dörfler, [email protected]. All rights reserved.
|
||||||
** Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef KERNEL_BOOT_HEAP_H
|
#ifndef KERNEL_BOOT_HEAP_H
|
||||||
#define KERNEL_BOOT_HEAP_H
|
#define KERNEL_BOOT_HEAP_H
|
||||||
|
|
||||||
|
|
||||||
#include <SupportDefs.h>
|
#include <SupportDefs.h>
|
||||||
#include <boot/stage2_args.h>
|
#include <boot/stage2_args.h>
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern void heap_release(struct stage2_args *args);
|
|
||||||
extern void heap_print_statistics();
|
|
||||||
extern status_t heap_init(struct stage2_args *args);
|
extern status_t heap_init(struct stage2_args *args);
|
||||||
|
extern void heap_print_statistics();
|
||||||
|
extern void heap_release();
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif /* KERNEL_BOOT_HEAP_H */
|
#endif /* KERNEL_BOOT_HEAP_H */
|
||||||
|
|||||||
@@ -383,7 +383,7 @@ FreeChunk::SetToAllocated(void* allocated)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
heap_release(stage2_args* args)
|
heap_release()
|
||||||
{
|
{
|
||||||
heap_print_statistics();
|
heap_print_statistics();
|
||||||
|
|
||||||
|
|||||||
@@ -161,13 +161,13 @@ main(stage2_args *args)
|
|||||||
gKernelArgs.boot_volume_size = gBootVolume.ContentSize();
|
gKernelArgs.boot_volume_size = gBootVolume.ContentSize();
|
||||||
|
|
||||||
platform_cleanup_devices();
|
platform_cleanup_devices();
|
||||||
// TODO: cleanup, heap_release() etc.
|
// Further cleanup (e.g. heap_release) is the platform's responsibility.
|
||||||
heap_print_statistics();
|
|
||||||
platform_start_kernel();
|
platform_start_kernel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
heap_release(args);
|
heap_release();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -354,6 +354,8 @@ long_start_kernel()
|
|||||||
long_gdt_init();
|
long_gdt_init();
|
||||||
debug_cleanup();
|
debug_cleanup();
|
||||||
long_mmu_init();
|
long_mmu_init();
|
||||||
|
heap_release();
|
||||||
|
|
||||||
convert_kernel_args();
|
convert_kernel_args();
|
||||||
|
|
||||||
// Save the kernel entry point address.
|
// Save the kernel entry point address.
|
||||||
|
|||||||
@@ -139,6 +139,7 @@ platform_start_kernel(void)
|
|||||||
smp_init_other_cpus();
|
smp_init_other_cpus();
|
||||||
debug_cleanup();
|
debug_cleanup();
|
||||||
mmu_init_for_kernel();
|
mmu_init_for_kernel();
|
||||||
|
heap_release();
|
||||||
|
|
||||||
// We're about to enter the kernel -- disable console output.
|
// We're about to enter the kernel -- disable console output.
|
||||||
stdout = NULL;
|
stdout = NULL;
|
||||||
|
|||||||
Reference in New Issue
Block a user