An error in the logic related to FREE_BASE meant that instead of mapping the
RAM for the loader at load-base, a small section was being mapped at the
bottom of RAM instead.
Fix this by deferring the mapping of the load-base RAM to arch_init() when
we can access the load-base variable and map 8MB RAM with a 1:1 phys to
virt mapping.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland(a)ilande.co.uk>
---
arch/ppc/qemu/init.c | 8 ++++++++
arch/ppc/qemu/ofmem.c | 12 ------------
2 files changed, 8 insertions(+), 12 deletions(-)
diff --git a/arch/ppc/qemu/init.c b/arch/ppc/qemu/init.c
index af15682..f5acf87 100644
--- a/arch/ppc/qemu/init.c
+++ b/arch/ppc/qemu/init.c
@@ -844,6 +844,7 @@ arch_of_init(void)
uint32_t temp = 0;
char *boot_device;
ofmem_t *ofmem = ofmem_arch_get_private();
+ ucell load_base;
openbios_init();
modules_init();
@@ -1105,4 +1106,11 @@ arch_of_init(void)
bind_func("platform-boot", boot);
bind_func("(arch-go)", arch_go);
+
+ /* Allocate 8MB memory at load-base */
+ fword("load-base");
+ load_base = POP();
+ ofmem_claim_phys(load_base, 0x800000, 0);
+ ofmem_claim_virt(load_base, 0x800000, 0);
+ ofmem_map(load_base, load_base, 0x800000, 0);
}
diff --git a/arch/ppc/qemu/ofmem.c b/arch/ppc/qemu/ofmem.c
index 7b8ced0..7a78a1e 100644
--- a/arch/ppc/qemu/ofmem.c
+++ b/arch/ppc/qemu/ofmem.c
@@ -46,7 +46,6 @@ extern void setup_mmu(unsigned long code_base);
*
*/
-#define FREE_BASE 0x00004000UL
#define OF_CODE_START 0xfff00000UL
#define OF_CODE_SIZE 0x00100000
#define IO_BASE 0x80000000UL
@@ -81,12 +80,6 @@ get_ram_top(void)
return get_hash_base() - (32 + 64 + 64) * 1024 - OFMEM_SIZE;
}
-static unsigned long
-get_ram_bottom(void)
-{
- return FREE_BASE;
-}
-
static unsigned long get_heap_top(void)
{
return get_hash_base() - (32 + 64 + 64) * 1024;
@@ -578,11 +571,6 @@ ofmem_init(void)
{
ofmem_t *ofmem = ofmem_arch_get_private();
- /* Map the memory (don't map page 0 to allow catching of NULL dereferences) */
- ofmem_claim_phys(PAGE_SIZE, get_ram_bottom() - PAGE_SIZE, 0);
- ofmem_claim_virt(PAGE_SIZE, get_ram_bottom() - PAGE_SIZE, 0);
- ofmem_map(PAGE_SIZE, PAGE_SIZE, get_ram_bottom() - PAGE_SIZE, 0);
-
/* Mark the first page as non-free */
ofmem_claim_phys(0, PAGE_SIZE, 0);
ofmem_claim_virt(0, PAGE_SIZE, 0);
--
2.11.0