2 * Copyright (C) 2005 MIPS Technologies, Inc. All rights reserved.
4 * This program is free software; you can distribute it and/or modify it
5 * under the terms of the GNU General Public License (Version 2) as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
18 #include <linux/init.h>
20 #include <linux/bootmem.h>
22 #include <asm/bootinfo.h>
25 #include <asm/mips-boards/prom.h>
29 enum simmem_memtypes {
33 struct prom_pmemblock mdesc[PROM_MAX_PMEMBLOCKS];
36 static char *mtypes[3] = {
37 "SIM reserved memory",
42 /* References to section boundaries */
45 struct prom_pmemblock * __init prom_getmdesc(void)
50 prom_printf("Setting default memory size 0x%08x\n", memsize);
52 memset(mdesc, 0, sizeof(mdesc));
54 mdesc[0].type = simmem_reserved;
55 mdesc[0].base = 0x00000000;
56 mdesc[0].size = 0x00001000;
58 mdesc[1].type = simmem_free;
59 mdesc[1].base = 0x00001000;
60 mdesc[1].size = 0x000ff000;
62 mdesc[2].type = simmem_reserved;
63 mdesc[2].base = 0x00100000;
64 mdesc[2].size = CPHYSADDR(PAGE_ALIGN(&_end)) - mdesc[2].base;
66 mdesc[3].type = simmem_free;
67 mdesc[3].base = CPHYSADDR(PAGE_ALIGN(&_end));
68 mdesc[3].size = memsize - mdesc[3].base;
73 static int __init prom_memtype_classify (unsigned int type)
80 return BOOT_MEM_RESERVED;
84 void __init prom_meminit(void)
86 struct prom_pmemblock *p;
92 unsigned long base, size;
94 type = prom_memtype_classify (p->type);
98 add_memory_region(base, size, type);
103 unsigned long __init prom_free_prom_memory(void)
106 unsigned long freed = 0;
109 for (i = 0; i < boot_mem_map.nr_map; i++) {
110 if (boot_mem_map.map[i].type != BOOT_MEM_ROM_DATA)
113 addr = boot_mem_map.map[i].addr;
114 while (addr < boot_mem_map.map[i].addr
115 + boot_mem_map.map[i].size) {
116 ClearPageReserved(virt_to_page(__va(addr)));
117 init_page_count(virt_to_page(__va(addr)));
118 free_page((unsigned long)__va(addr));
123 printk("Freeing prom memory: %ldkb freed\n", freed >> 10);