Fixes multiboot memory detection for weird types
authorBarret Rhoden <brho@cs.berkeley.edu>
Fri, 22 Jan 2010 19:25:51 +0000 (11:25 -0800)
committerBarret Rhoden <brho@cs.berkeley.edu>
Fri, 22 Jan 2010 19:25:51 +0000 (11:25 -0800)
IAW the spec, type 1 is free, all others are reserved.  Some machines
(the new nehalem) had types greater than our array of strings.

kern/src/multiboot.c

index ab3994a..5c548d6 100644 (file)
@@ -54,28 +54,23 @@ multiboot_detect_memory(multiboot_info_t *mbi)
        printk("Maximum directly addressable physical memory: %dK\n", (int)(maxaddrpa/1024));
 }
 
-void
-multiboot_print_memory_map(multiboot_info_t *mbi) {
-       const char *NTS memory_type[] = {"", "FREE", "RESERVED", "UNDEFINED", "UNDEFINED4"};
-
-
+void multiboot_print_memory_map(multiboot_info_t *mbi)
+{
        if(CHECK_FLAG(mbi->flags, 6)) {
                memory_map_t *SNT mmap_b =
                        (memory_map_t *SNT)(mbi->mmap_addr + KERNBASE);
                memory_map_t *SNT mmap_e =
                        (memory_map_t *SNT)(mbi->mmap_addr + KERNBASE + mbi->mmap_length);
                memory_map_t *BND(mmap_b, mmap_e) mmap = TC(mmap_b);
-
-               cprintf ("mmap_addr = 0x%x, mmap_length = 0x%x\n", (unsigned long)mbi->mmap_addr,
-                          (unsigned long)mbi->mmap_length);
-
+               printk("mmap_addr = 0x%x, mmap_length = 0x%x\n",
+                      (unsigned long)mbi->mmap_addr, (unsigned long)mbi->mmap_length);
                while(mmap < mmap_e) {
-                       cprintf ("base = 0x%08x%08x, length = 0x%08x%08x, type = %s\n",
-                               (unsigned) mmap->base_addr_high,
-                               (unsigned) mmap->base_addr_low,
-                               (unsigned) mmap->length_high,
-                               (unsigned) mmap->length_low,
-                               (unsigned) memory_type[mmap->type]);
+                       printk("base = 0x%08x%08x, length = 0x%08x%08x, type = %s\n",
+                              (unsigned) mmap->base_addr_high,
+                              (unsigned) mmap->base_addr_low,
+                              (unsigned) mmap->length_high,
+                              (unsigned) mmap->length_low,
+                              mmap->type == 1 ? "FREE" : "RESERVED");
                        mmap = (memory_map_t *BND(mmap_b,mmap_e))((char *BND(mmap_b,mmap_e))mmap + mmap->size + sizeof(mmap->size));
                }
        }