From 35fb3934bd3a66344c2ca4546bfee3ba43a90a57 Mon Sep 17 00:00:00 2001 From: Matthias Kruk Date: Wed, 4 Sep 2019 01:02:29 +0900 Subject: [PATCH] Don't leave the cr3 variable in pg_init() uninitialized; remove unused braces and calls to dbg_printf() --- kernel/arch/paging.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/kernel/arch/paging.c b/kernel/arch/paging.c index 91b3ee6..09ed515 100644 --- a/kernel/arch/paging.c +++ b/kernel/arch/paging.c @@ -89,6 +89,7 @@ void* pg_init(struct multiboot_info *info) { _mem_start = (u32_t)&_mem_start + sizeof(u32_t); mmap = (struct memory_map*)info->mmap_addr; mem_size = 0; + cr3 = 0; /* TODO: get rid of this */ while((u32_t)mmap < (info->mmap_addr + info->mmap_length)) { @@ -115,13 +116,14 @@ void* pg_init(struct multiboot_info *info) { _frame_map = _phys_alloc(_nframes << 2, 4); switch(_pg_flags & PG_MODE_MASK) { - case PG_MODE_LEGACY: { + case PG_MODE_LEGACY: cr3 = (u32_t)_phys_alloc(sizeof(page_table_t), PAGE_ALIGN); break; - } + case PG_MODE_PAE: cr3 = (u32_t)_phys_alloc(sizeof(pdpt_t), PDPT_ALIGN); break; + case PG_MODE_INTEL64: case PG_MODE_IA32E: PANIC("IA-32e mode paging not yet supported\n"); @@ -131,7 +133,7 @@ void* pg_init(struct multiboot_info *info) { while((u32_t)mmap < (info->mmap_addr + info->mmap_length)) { u32_t attrs; u64_t addr; -#if 1 +#if 0 dbg_printf("Region: 0x%016llx - 0x%016llx [%u]\n", mmap->addr, mmap->addr + mmap->len, mmap->type); #endif -- 2.47.3