Corrected runtime errors with multiboot_detect_memory() and page_init()
authorPaul Pearce <pearce@eecs.berkeley.edu>
Sat, 29 Aug 2009 01:12:13 +0000 (21:12 -0400)
committerPaul Pearce <pearce@eecs.berkeley.edu>
Sat, 29 Aug 2009 01:19:48 +0000 (21:19 -0400)
Corrected the argument to multiboot_detect_memory() in init.c to no longer
call KADDR, as KADDR relies on npages being set (and multiboot_detect_memory()
is the function that sets npages). We now add KERNBASE manually.

Removed a call to ROUNDUP() on the argument to boot_alloc() inside of
page_init(). This was unneeded, and ended up causing a runtime Ivy assertion
error.

kern/src/init.c
kern/src/pmap.c

index 8b74c2d..91b73aa 100644 (file)
@@ -41,11 +41,15 @@ void kernel_init(multiboot_info_t *mboot_info)
 
        print_cpuinfo();
 
-       // zra: using KADDR macro gives a runtime warning, but it is possibly more
-    //      clear what's going on this way?
+       // Old way, pre Zach's Ivy annotations
        //multiboot_detect_memory((multiboot_info_t*)((uint32_t)mboot_info + KERNBASE));
        //multiboot_print_memory_map((multiboot_info_t*)((uint32_t)mboot_info + KERNBASE));
-       multiboot_detect_memory((multiboot_info_t*COUNT(1))KADDR((physaddr_t)mboot_info));
+       
+       // Paul: Can't use KADDR as arg to multiboot_detect_memory
+       //  since multiboot_detect_memory is what sets npages. 
+       //  Must simulate KADDR macro (ugly).
+       multiboot_detect_memory((multiboot_info_t*SAFE)(void*TRUSTED)((physaddr_t)mboot_info + KERNBASE));
+       
        multiboot_print_memory_map((multiboot_info_t*COUNT(1))KADDR((physaddr_t)mboot_info));
 
        vm_init();
index 2b240b6..4b4c304 100644 (file)
@@ -53,8 +53,7 @@ void page_init(void)
         * 'npages' equals the number of physical pages in memory.
         * round up to the nearest page
         */
-       size_t page_array_size = ROUNDUP(npages*sizeof(page_t), PGSIZE);
-       pages = (page_t*)boot_alloc(page_array_size, PGSIZE);
+       pages = (page_t*)boot_alloc(npages*sizeof(page_t), PGSIZE);
        memset(pages, 0, npages*sizeof(page_t));
 
        /*