/* * Multiboot C Entry */ #include #include #include #include #include "../dev/console.h" #include #include #include void MachineBoot_Entry(unsigned long magic, unsigned long addr); #define PAGE_ALIGN __attribute__((aligned(PGSIZE))) #define DATA_SECTION __attribute__((section(".data"))) extern void Machine_EarlyInit(); extern void Machine_Init(); extern void PAlloc_AddRegion(uintptr_t start, uintptr_t len); #define MAX_REGIONS 16 static uintptr_t memRegionStart[MAX_REGIONS]; static uintptr_t memRegionLen[MAX_REGIONS]; static int memRegionIdx; void MachineBoot_Entry(unsigned long magic, unsigned long addr) { // initialize metal mode mtl_init(); paging_init(); // Main initialization Machine_Init(); return; } void MachineBoot_AddMem() { int i; uintptr_t initRamEnd = 32*1024*1024; for (i = 0; i < memRegionIdx; i++) { uintptr_t start = memRegionStart[i]; uintptr_t len = memRegionLen[i]; if (start + len < initRamEnd) continue; if (start < initRamEnd) { len = initRamEnd - start; start = initRamEnd; } kprintf("AddRegion: %08llx %08llx\n", start, len); PAlloc_AddRegion(start + MEM_DIRECTMAP_BASE, len); } }