diff options
author | Alex Auvolat <alex.auvolat@ens.fr> | 2014-12-02 16:43:34 +0100 |
---|---|---|
committer | Alex Auvolat <alex.auvolat@ens.fr> | 2014-12-02 16:43:34 +0100 |
commit | 76795abc2f08f180b7a895aaf26e80b971caa81c (patch) | |
tree | e12017fd5856afb1cdcfd9940dbf4661017dba16 /kernel/l0/kmain.c | |
parent | c7bcf94b1e70721d0f7bfb5ca383d996559c2559 (diff) | |
download | kogata-76795abc2f08f180b7a895aaf26e80b971caa81c.tar.gz kogata-76795abc2f08f180b7a895aaf26e80b971caa81c.zip |
Add physical page (frame) allocator.
Diffstat (limited to 'kernel/l0/kmain.c')
-rw-r--r-- | kernel/l0/kmain.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/kernel/l0/kmain.c b/kernel/l0/kmain.c index 7665cb0..b4e2ef1 100644 --- a/kernel/l0/kmain.c +++ b/kernel/l0/kmain.c @@ -5,6 +5,7 @@ #include <gdt.h> #include <idt.h> +#include <frame.h> void breakpoint_handler(registers_t *regs) { dbg_printf("Breakpoint! (int3)\n"); @@ -23,13 +24,25 @@ void kmain(struct multiboot_info_t *mbd, int32_t mb_magic) { idt_init(); dbg_printf("IDT set up.\n"); idt_set_ex_handler(EX_BREAKPOINT, breakpoint_handler); - - asm volatile("int $0x3"); + asm volatile("int $0x3"); // test breakpoint size_t total_ram = ((mbd->mem_upper + mbd->mem_lower) * 1024); dbg_printf("Total ram: %d Kb\n", total_ram / 1024); // paging_init(totalRam); + // used for allocation of data structures before malloc is set up + // a pointer to this pointer is passed to the functions that might have + // to allocate memory ; they just increment it of the allocated quantity + void* kernel_data_end = (void*)K_END_ADDR; + frame_init_allocator(total_ram, &kernel_data_end); + dbg_printf("kernel_data_end: 0x%p\n", kernel_data_end); + dbg_print_frame_stats(); + + // TODO: + // - setup allocator for physical pages (eg: buddy allocator, see OSDev wiki) + // - setup allocator for virtual memory space + // - setup paging + PANIC("Reached kmain end! Falling off the edge."); } |