Sorted out proc refcounting with ARCs
[akaros.git] / kern / src / multiboot.c
index b66207a..5c548d6 100644 (file)
@@ -1,5 +1,10 @@
+#ifdef __SHARC__
+#pragma nosharc
+#define SINIT(x) x
+#endif
+
 #include <multiboot.h>
-#include <arch/types.h>
+#include <ros/common.h>
 #include <arch/mmu.h>
 #include <arch/arch.h>
 #include <ros/memlayout.h>
 #endif
 
 // These variables are set by i386_detect_memory()
-physaddr_t maxpa;// Maximum physical address
-physaddr_t maxaddrpa;    // Maximum directly addressable physical address
-void *SNT maxaddrpa_ptr;
-size_t npage;   // Amount of physical memory (in pages)
-size_t naddrpage;       // Amount of addressable physical memory (in pages)
-static size_t basemem;  // Amount of base memory (in bytes)
-static size_t extmem;   // Amount of extended memory (in bytes)
+physaddr_t RO maxpa;      // Maximum physical address in the system
+physaddr_t RO maxaddrpa;  // Maximum addressable physical address
+void *SNT RO maxaddrpa_ptr;
+size_t RO npages;         // Total number of physical memory pages
+size_t RO naddrpages;    // Number of addressable physical memory pages
+
+static size_t RO basemem;  // Amount of base memory (in bytes)
+static size_t RO extmem;   // Amount of extended memory (in bytes)
 
 void
 multiboot_detect_memory(multiboot_info_t *mbi)
 {
        // Tells us how many kilobytes there are
-       basemem = ROUNDDOWN(mbi->mem_lower*1024, PGSIZE);
-       extmem = ROUNDDOWN(mbi->mem_upper*1024, PGSIZE);
+       size_t b = ROUNDDOWN(mbi->mem_lower*1024, PGSIZE);
+       size_t e = ROUNDDOWN(mbi->mem_upper*1024, PGSIZE);
+       basemem = SINIT(b);
+       extmem = SINIT(e);
 
        // Calculate the maximum physical address based on whether
        // or not there is any extended memory.  See comment in <inc/memlayout.h>
        if (extmem)
-               maxpa = EXTPHYSMEM + extmem;
+               maxpa = SINIT(EXTPHYSMEM + extmem);
        else
-               maxpa = basemem;
+               maxpa = SINIT(basemem);
 
-       npage = maxpa / PGSIZE;
+       npages = SINIT(maxpa / PGSIZE);
 
        // IOAPIC - KERNBASE is the max amount of virtual addresses we can use
        // for the physical memory mapping (aka - the KERNBASE mapping)
-       maxaddrpa = MIN(maxpa, IOAPIC_BASE - KERNBASE);
-       maxaddrpa_ptr = (void *SNT)maxaddrpa;
+       maxaddrpa = SINIT(MIN(maxpa, IOAPIC_BASE - KERNBASE));
+       maxaddrpa_ptr = SINIT((void *SNT)maxaddrpa);
 
-       naddrpage = maxaddrpa / PGSIZE;
+       naddrpages = SINIT(maxaddrpa / PGSIZE);
 
        cprintf("Physical memory: %dK available, ", (int)(maxpa/1024));
        cprintf("base = %dK, extended = %dK\n", (int)(basemem/1024), (int)(extmem/1024));
        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));
                }
        }