diff options
author | Albert Herranz <albert_herranz@yahoo.es> | 2009-12-12 01:31:53 -0500 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2009-12-13 00:24:31 -0500 |
commit | de32400dd26e743c5d500aa42d8d6818b79edb73 (patch) | |
tree | 5fee868e4fac044dca4fb3a18532b67b62c90c96 /arch/powerpc/mm | |
parent | 02d748a9ee56735641bade9b734dc2fa9be4df4c (diff) |
wii: use both mem1 and mem2 as ram
The Nintendo Wii video game console has two discontiguous RAM regions:
- MEM1: 24MB @ 0x00000000
- MEM2: 64MB @ 0x10000000
Unfortunately, the kernel currently does not support discontiguous RAM
memory regions on 32-bit PowerPC platforms.
This patch adds a series of workarounds to allow the use of the second
memory region (MEM2) as RAM by the kernel.
Basically, a single range of memory from the beginning of MEM1 to the
end of MEM2 is reported to the kernel, and a memory reservation is
created for the hole between MEM1 and MEM2.
With this patch the system is able to use all the available RAM and not
just ~27% of it.
This will no longer be needed when proper discontig memory support
for 32-bit PowerPC is added to the kernel.
Signed-off-by: Albert Herranz <albert_herranz@yahoo.es>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'arch/powerpc/mm')
-rw-r--r-- | arch/powerpc/mm/init_32.c | 4 | ||||
-rw-r--r-- | arch/powerpc/mm/mmu_decl.h | 10 | ||||
-rw-r--r-- | arch/powerpc/mm/pgtable_32.c | 32 | ||||
-rw-r--r-- | arch/powerpc/mm/ppc_mmu_32.c | 4 |
4 files changed, 43 insertions, 7 deletions
diff --git a/arch/powerpc/mm/init_32.c b/arch/powerpc/mm/init_32.c index 9ddcfb4dc139..703c7c2e0d9f 100644 --- a/arch/powerpc/mm/init_32.c +++ b/arch/powerpc/mm/init_32.c | |||
@@ -131,9 +131,13 @@ void __init MMU_init(void) | |||
131 | MMU_setup(); | 131 | MMU_setup(); |
132 | 132 | ||
133 | if (lmb.memory.cnt > 1) { | 133 | if (lmb.memory.cnt > 1) { |
134 | #ifndef CONFIG_WII | ||
134 | lmb.memory.cnt = 1; | 135 | lmb.memory.cnt = 1; |
135 | lmb_analyze(); | 136 | lmb_analyze(); |
136 | printk(KERN_WARNING "Only using first contiguous memory region"); | 137 | printk(KERN_WARNING "Only using first contiguous memory region"); |
138 | #else | ||
139 | wii_memory_fixups(); | ||
140 | #endif | ||
137 | } | 141 | } |
138 | 142 | ||
139 | total_lowmem = total_memory = lmb_end_of_DRAM() - memstart_addr; | 143 | total_lowmem = total_memory = lmb_end_of_DRAM() - memstart_addr; |
diff --git a/arch/powerpc/mm/mmu_decl.h b/arch/powerpc/mm/mmu_decl.h index d2e5321d5ea6..9aa39fe74f8a 100644 --- a/arch/powerpc/mm/mmu_decl.h +++ b/arch/powerpc/mm/mmu_decl.h | |||
@@ -136,6 +136,14 @@ extern phys_addr_t total_lowmem; | |||
136 | extern phys_addr_t memstart_addr; | 136 | extern phys_addr_t memstart_addr; |
137 | extern phys_addr_t lowmem_end_addr; | 137 | extern phys_addr_t lowmem_end_addr; |
138 | 138 | ||
139 | #ifdef CONFIG_WII | ||
140 | extern unsigned long wii_hole_start; | ||
141 | extern unsigned long wii_hole_size; | ||
142 | |||
143 | extern unsigned long wii_mmu_mapin_mem2(unsigned long top); | ||
144 | extern void wii_memory_fixups(void); | ||
145 | #endif | ||
146 | |||
139 | /* ...and now those things that may be slightly different between processor | 147 | /* ...and now those things that may be slightly different between processor |
140 | * architectures. -- Dan | 148 | * architectures. -- Dan |
141 | */ | 149 | */ |
@@ -155,5 +163,5 @@ extern void adjust_total_lowmem(void); | |||
155 | #elif defined(CONFIG_PPC32) | 163 | #elif defined(CONFIG_PPC32) |
156 | /* anything 32-bit except 4xx or 8xx */ | 164 | /* anything 32-bit except 4xx or 8xx */ |
157 | extern void MMU_init_hw(void); | 165 | extern void MMU_init_hw(void); |
158 | extern unsigned long mmu_mapin_ram(void); | 166 | extern unsigned long mmu_mapin_ram(unsigned long top); |
159 | #endif | 167 | #endif |
diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c index cb96cb2e17cc..b55bbe87acb8 100644 --- a/arch/powerpc/mm/pgtable_32.c +++ b/arch/powerpc/mm/pgtable_32.c | |||
@@ -283,18 +283,18 @@ int map_page(unsigned long va, phys_addr_t pa, int flags) | |||
283 | } | 283 | } |
284 | 284 | ||
285 | /* | 285 | /* |
286 | * Map in a big chunk of physical memory starting at PAGE_OFFSET. | 286 | * Map in a chunk of physical memory starting at start. |
287 | */ | 287 | */ |
288 | void __init mapin_ram(void) | 288 | void __init __mapin_ram_chunk(unsigned long offset, unsigned long top) |
289 | { | 289 | { |
290 | unsigned long v, s, f; | 290 | unsigned long v, s, f; |
291 | phys_addr_t p; | 291 | phys_addr_t p; |
292 | int ktext; | 292 | int ktext; |
293 | 293 | ||
294 | s = mmu_mapin_ram(); | 294 | s = offset; |
295 | v = PAGE_OFFSET + s; | 295 | v = PAGE_OFFSET + s; |
296 | p = memstart_addr + s; | 296 | p = memstart_addr + s; |
297 | for (; s < total_lowmem; s += PAGE_SIZE) { | 297 | for (; s < top; s += PAGE_SIZE) { |
298 | ktext = ((char *) v >= _stext && (char *) v < etext); | 298 | ktext = ((char *) v >= _stext && (char *) v < etext); |
299 | f = ktext ? PAGE_KERNEL_TEXT : PAGE_KERNEL; | 299 | f = ktext ? PAGE_KERNEL_TEXT : PAGE_KERNEL; |
300 | map_page(v, p, f); | 300 | map_page(v, p, f); |
@@ -307,6 +307,30 @@ void __init mapin_ram(void) | |||
307 | } | 307 | } |
308 | } | 308 | } |
309 | 309 | ||
310 | void __init mapin_ram(void) | ||
311 | { | ||
312 | unsigned long s, top; | ||
313 | |||
314 | #ifndef CONFIG_WII | ||
315 | top = total_lowmem; | ||
316 | s = mmu_mapin_ram(top); | ||
317 | __mapin_ram_chunk(s, top); | ||
318 | #else | ||
319 | if (!wii_hole_size) { | ||
320 | s = mmu_mapin_ram(total_lowmem); | ||
321 | __mapin_ram_chunk(s, total_lowmem); | ||
322 | } else { | ||
323 | top = wii_hole_start; | ||
324 | s = mmu_mapin_ram(top); | ||
325 | __mapin_ram_chunk(s, top); | ||
326 | |||
327 | top = lmb_end_of_DRAM(); | ||
328 | s = wii_mmu_mapin_mem2(top); | ||
329 | __mapin_ram_chunk(s, top); | ||
330 | } | ||
331 | #endif | ||
332 | } | ||
333 | |||
310 | /* Scan the real Linux page tables and return a PTE pointer for | 334 | /* Scan the real Linux page tables and return a PTE pointer for |
311 | * a virtual address in a context. | 335 | * a virtual address in a context. |
312 | * Returns true (1) if PTE was found, zero otherwise. The pointer to | 336 | * Returns true (1) if PTE was found, zero otherwise. The pointer to |
diff --git a/arch/powerpc/mm/ppc_mmu_32.c b/arch/powerpc/mm/ppc_mmu_32.c index 2d2a87e10154..f11c2cdcb0fe 100644 --- a/arch/powerpc/mm/ppc_mmu_32.c +++ b/arch/powerpc/mm/ppc_mmu_32.c | |||
@@ -72,7 +72,7 @@ unsigned long p_mapped_by_bats(phys_addr_t pa) | |||
72 | return 0; | 72 | return 0; |
73 | } | 73 | } |
74 | 74 | ||
75 | unsigned long __init mmu_mapin_ram(void) | 75 | unsigned long __init mmu_mapin_ram(unsigned long top) |
76 | { | 76 | { |
77 | unsigned long tot, bl, done; | 77 | unsigned long tot, bl, done; |
78 | unsigned long max_size = (256<<20); | 78 | unsigned long max_size = (256<<20); |
@@ -86,7 +86,7 @@ unsigned long __init mmu_mapin_ram(void) | |||
86 | 86 | ||
87 | /* Make sure we don't map a block larger than the | 87 | /* Make sure we don't map a block larger than the |
88 | smallest alignment of the physical address. */ | 88 | smallest alignment of the physical address. */ |
89 | tot = total_lowmem; | 89 | tot = top; |
90 | for (bl = 128<<10; bl < max_size; bl <<= 1) { | 90 | for (bl = 128<<10; bl < max_size; bl <<= 1) { |
91 | if (bl * 2 > tot) | 91 | if (bl * 2 > tot) |
92 | break; | 92 | break; |