zeroing bss and changing init ordering

This commit is contained in:
Liam Kerr 2026-02-11 00:12:14 +00:00
parent df0e78ede2
commit 19d981c878
3 changed files with 18 additions and 7 deletions

View file

@ -8,14 +8,13 @@
void kmain()
{
kputs("----------------------");
kprintf("Hello, from %s!", "SquidgeOS");
kputs("----------------------");
knewline();
zero_bss();
plic_init();
uart_init();
page_init();
interrupt_init();
kpanic_force();
kputs("----------------------");
kprintf("Hello, from %s!", "SquidgeOS");
kputs("----------------------");
knewline();
}

View file

@ -2,16 +2,27 @@
#include <stddef.h>
#include "drivers/uart.h"
#include "memory.h"
#include "lib/string.h"
#include "interrupts.h"
static struct Page *free_list = NULL;
HeapHeader *heap_free_list;
extern uint8_t _heap_start[]; // named in the linker script
// named in the linker script
extern uint8_t _heap_start[];
extern uint8_t _bss_start[];
extern uint8_t _bss_end[];
void zero_bss()
{
memset(_bss_start, 0, (size_t)_bss_end - (size_t)_bss_start);
}
void page_init()
{
kprint("Initialising page allocator...");
uintptr_t start = ((uintptr_t)_heap_start + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1);
uintptr_t end = 0x88000000; // Default QEMU RAM limit

View file

@ -16,6 +16,7 @@ typedef struct HeapHeader
struct HeapHeader *prev;
} HeapHeader;
void zero_bss();
void page_init();
void page_free(void *addr);
void *page_alloc();