1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 14:25:06 +00:00

Kernel: Invoke heap constructors separately early on

By having a separate list of constructors for the kernel heap
code, we can properly use constructors without re-running them
after the heap was already initialized. This solves some problems
where values were wiped out because they were overwritten by
running their constructors later in the initialization process.
This commit is contained in:
Tom 2020-08-10 09:44:35 -06:00 committed by Andreas Kling
parent de5e542930
commit 08ff25f4ef
4 changed files with 20 additions and 8 deletions

View file

@ -76,6 +76,8 @@
// Defined in the linker script
typedef void (*ctor_func_t)();
extern ctor_func_t start_heap_ctors;
extern ctor_func_t end_heap_ctors;
extern ctor_func_t start_ctors;
extern ctor_func_t end_ctors;
@ -107,6 +109,9 @@ extern "C" [[noreturn]] void init()
s_bsp_processor.early_initialize(0);
// Invoke the constructors needed for the kernel heap
for (ctor_func_t* ctor = &start_heap_ctors; ctor < &end_heap_ctors; ctor++)
(*ctor)();
kmalloc_init();
slab_alloc_init();