aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/mips-boards/generic/memory.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/mips/mips-boards/generic/memory.c')
-rw-r--r--arch/mips/mips-boards/generic/memory.c50
1 files changed, 26 insertions, 24 deletions
diff --git a/arch/mips/mips-boards/generic/memory.c b/arch/mips/mips-boards/generic/memory.c
index c89fcf9e9c22..be80c5dd4a0c 100644
--- a/arch/mips/mips-boards/generic/memory.c
+++ b/arch/mips/mips-boards/generic/memory.c
@@ -47,43 +47,45 @@ static char *mtypes[3] = {
47}; 47};
48#endif 48#endif
49 49
50/* determined physical memory size, not overridden by command line args */
51unsigned long physical_memsize = 0L;
52
50struct prom_pmemblock * __init prom_getmdesc(void) 53struct prom_pmemblock * __init prom_getmdesc(void)
51{ 54{
52 char *memsize_str; 55 char *memsize_str;
53 unsigned int memsize; 56 unsigned int memsize;
54 char cmdline[CL_SIZE], *ptr; 57 char cmdline[CL_SIZE], *ptr;
55 58
56 /* Check the command line first for a memsize directive */ 59 /* otherwise look in the environment */
57 strcpy(cmdline, arcs_cmdline); 60 memsize_str = prom_getenv("memsize");
58 ptr = strstr(cmdline, "memsize="); 61 if (!memsize_str) {
59 if (ptr && (ptr != cmdline) && (*(ptr - 1) != ' ')) 62 prom_printf("memsize not set in boot prom, set to default (32Mb)\n");
60 ptr = strstr(ptr, " memsize="); 63 physical_memsize = 0x02000000;
61 64 } else {
62 if (ptr) {
63 memsize = memparse(ptr + 8, &ptr);
64 }
65 else {
66 /* otherwise look in the environment */
67 memsize_str = prom_getenv("memsize");
68 if (!memsize_str) {
69 prom_printf("memsize not set in boot prom, set to default (32Mb)\n");
70 memsize = 0x02000000;
71 } else {
72#ifdef DEBUG 65#ifdef DEBUG
73 prom_printf("prom_memsize = %s\n", memsize_str); 66 prom_printf("prom_memsize = %s\n", memsize_str);
74#endif 67#endif
75 memsize = simple_strtol(memsize_str, NULL, 0); 68 physical_memsize = simple_strtol(memsize_str, NULL, 0);
76 }
77 } 69 }
78 70
79#ifdef CONFIG_CPU_BIG_ENDIAN 71#ifdef CONFIG_CPU_BIG_ENDIAN
80 /* 72 /* SOC-it swaps, or perhaps doesn't swap, when DMA'ing the last
81 * SOC-it swaps, or perhaps doesn't swap, when DMA'ing the last 73 word of physical memory */
82 * word of physical memory 74 physical_memsize -= PAGE_SIZE;
83 */
84 memsize -= PAGE_SIZE;
85#endif 75#endif
86 76
77 /* Check the command line for a memsize directive that overrides
78 the physical/default amount */
79 strcpy(cmdline, arcs_cmdline);
80 ptr = strstr(cmdline, "memsize=");
81 if (ptr && (ptr != cmdline) && (*(ptr - 1) != ' '))
82 ptr = strstr(ptr, " memsize=");
83
84 if (ptr)
85 memsize = memparse(ptr + 8, &ptr);
86 else
87 memsize = physical_memsize;
88
87 memset(mdesc, 0, sizeof(mdesc)); 89 memset(mdesc, 0, sizeof(mdesc));
88 90
89 mdesc[0].type = yamon_dontuse; 91 mdesc[0].type = yamon_dontuse;