X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=arch%2Fmips%2Fmips-boards%2Fgeneric%2Fmemory.c;fp=arch%2Fmips%2Fmips-boards%2Fgeneric%2Fmemory.c;h=2c8afd77a20b2a4f9df12a4923b4a8e8c8409627;hb=64ba3f394c830ec48a1c31b53dcae312c56f1604;hp=be80c5dd4a0c2861dd058984f35d9787dd75cb57;hpb=be1e6109ac94a859551f8e1774eb9a8469fe055c;p=linux-2.6.git diff --git a/arch/mips/mips-boards/generic/memory.c b/arch/mips/mips-boards/generic/memory.c index be80c5dd4..2c8afd77a 100644 --- a/arch/mips/mips-boards/generic/memory.c +++ b/arch/mips/mips-boards/generic/memory.c @@ -18,15 +18,14 @@ * PROM library functions for acquiring/using memory descriptors given to * us from the YAMON. */ +#include #include #include #include -#include #include #include #include -#include #include @@ -47,8 +46,11 @@ static char *mtypes[3] = { }; #endif -/* determined physical memory size, not overridden by command line args */ -unsigned long physical_memsize = 0L; +/* References to section boundaries */ +extern char _end; + +#define PFN_ALIGN(x) (((unsigned long)(x) + (PAGE_SIZE - 1)) & PAGE_MASK) + struct prom_pmemblock * __init prom_getmdesc(void) { @@ -56,36 +58,28 @@ struct prom_pmemblock * __init prom_getmdesc(void) unsigned int memsize; char cmdline[CL_SIZE], *ptr; - /* otherwise look in the environment */ - memsize_str = prom_getenv("memsize"); - if (!memsize_str) { - prom_printf("memsize not set in boot prom, set to default (32Mb)\n"); - physical_memsize = 0x02000000; - } else { -#ifdef DEBUG - prom_printf("prom_memsize = %s\n", memsize_str); -#endif - physical_memsize = simple_strtol(memsize_str, NULL, 0); - } - -#ifdef CONFIG_CPU_BIG_ENDIAN - /* SOC-it swaps, or perhaps doesn't swap, when DMA'ing the last - word of physical memory */ - physical_memsize -= PAGE_SIZE; -#endif - - /* Check the command line for a memsize directive that overrides - the physical/default amount */ + /* Check the command line first for a memsize directive */ strcpy(cmdline, arcs_cmdline); ptr = strstr(cmdline, "memsize="); if (ptr && (ptr != cmdline) && (*(ptr - 1) != ' ')) ptr = strstr(ptr, " memsize="); - if (ptr) + if (ptr) { memsize = memparse(ptr + 8, &ptr); - else - memsize = physical_memsize; - + } + else { + /* otherwise look in the environment */ + memsize_str = prom_getenv("memsize"); + if (!memsize_str) { + prom_printf("memsize not set in boot prom, set to default (32Mb)\n"); + memsize = 0x02000000; + } else { +#ifdef DEBUG + prom_printf("prom_memsize = %s\n", memsize_str); +#endif + memsize = simple_strtol(memsize_str, NULL, 0); + } + } memset(mdesc, 0, sizeof(mdesc)); mdesc[0].type = yamon_dontuse; @@ -115,7 +109,7 @@ struct prom_pmemblock * __init prom_getmdesc(void) mdesc[3].type = yamon_dontuse; mdesc[3].base = 0x00100000; - mdesc[3].size = CPHYSADDR(PFN_ALIGN((unsigned long)&_end)) - mdesc[3].base; + mdesc[3].size = CPHYSADDR(PFN_ALIGN(&_end)) - mdesc[3].base; mdesc[4].type = yamon_free; mdesc[4].base = CPHYSADDR(PFN_ALIGN(&_end)); @@ -180,7 +174,7 @@ unsigned long __init prom_free_prom_memory(void) while (addr < boot_mem_map.map[i].addr + boot_mem_map.map[i].size) { ClearPageReserved(virt_to_page(__va(addr))); - init_page_count(virt_to_page(__va(addr))); + set_page_count(virt_to_page(__va(addr)), 1); free_page((unsigned long)__va(addr)); addr += PAGE_SIZE; freed += PAGE_SIZE;