MIPS: Loongson: Add UEFI-like firmware interface (LEFI) support
[linux-2.6-block.git] / arch / mips / loongson / common / mem.c
index 8626a42f5b948ead7c7e9ffc9518179f0cc29006..b01d52473da81450d9486cf8da36f8b48cee082e 100644 (file)
 #include <asm/bootinfo.h>
 
 #include <loongson.h>
+#include <boot_param.h>
 #include <mem.h>
 #include <pci.h>
 
+#ifndef CONFIG_LEFI_FIRMWARE_INTERFACE
+
+u32 memsize, highmemsize;
+
 void __init prom_init_memory(void)
 {
        add_memory_region(0x0, (memsize << 20), BOOT_MEM_RAM);
@@ -49,6 +54,43 @@ void __init prom_init_memory(void)
 #endif /* !CONFIG_64BIT */
 }
 
+#else /* CONFIG_LEFI_FIRMWARE_INTERFACE */
+
+void __init prom_init_memory(void)
+{
+       int i;
+       u32 node_id;
+       u32 mem_type;
+
+       /* parse memory information */
+       for (i = 0; i < loongson_memmap->nr_map; i++) {
+               node_id = loongson_memmap->map[i].node_id;
+               mem_type = loongson_memmap->map[i].mem_type;
+
+               if (node_id == 0) {
+                       switch (mem_type) {
+                       case SYSTEM_RAM_LOW:
+                               add_memory_region(loongson_memmap->map[i].mem_start,
+                                       (u64)loongson_memmap->map[i].mem_size << 20,
+                                       BOOT_MEM_RAM);
+                               break;
+                       case SYSTEM_RAM_HIGH:
+                               add_memory_region(loongson_memmap->map[i].mem_start,
+                                       (u64)loongson_memmap->map[i].mem_size << 20,
+                                       BOOT_MEM_RAM);
+                               break;
+                       case MEM_RESERVED:
+                               add_memory_region(loongson_memmap->map[i].mem_start,
+                                       (u64)loongson_memmap->map[i].mem_size << 20,
+                                       BOOT_MEM_RESERVED);
+                               break;
+                       }
+               }
+       }
+}
+
+#endif /* CONFIG_LEFI_FIRMWARE_INTERFACE */
+
 /* override of arch/mips/mm/cache.c: __uncached_access */
 int __uncached_access(struct file *file, unsigned long addr)
 {