[OpenBIOS] [PATCH 2/2] SPARC32: Move Forth dictionary location to a fixed location.

Mark Cave-Ayland mark.cave-ayland at ilande.co.uk
Mon Apr 8 12:44:44 CEST 2013


Instead of using the automatic allocator to determine the location of the
Forth dictionary, allocate it at a fixed location just underneath the ROM
itself at 0xffd00000.

This patch also prevents corruption within the RAM of the Forth machine
by ensuring that we allocate virtual memory outside of OpenBIOS itself,
plus reduces the size of the Forth dictionary to 128K so that it meets
the memory constraints required to boot Linux and also kadb from older
versions of SunOS (as reported by Artyom Tarasenko).

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland at ilande.co.uk>
---
 openbios-devel/arch/sparc32/ofmem_sparc32.c         |    2 +-
 openbios-devel/arch/sparc32/openbios.c              |    9 ++++++---
 openbios-devel/include/arch/sparc32/ofmem_sparc32.h |    3 +++
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/openbios-devel/arch/sparc32/ofmem_sparc32.c b/openbios-devel/arch/sparc32/ofmem_sparc32.c
index e2f4159..54cb766 100644
--- a/openbios-devel/arch/sparc32/ofmem_sparc32.c
+++ b/openbios-devel/arch/sparc32/ofmem_sparc32.c
@@ -61,7 +61,7 @@ ucell ofmem_arch_get_heap_top(void)
 
 ucell ofmem_arch_get_virt_top(void)
 {
-	return (ucell)TOP_OF_RAM;
+	return (ucell)OFMEM_VIRT_TOP;
 }
 
 phys_addr_t ofmem_arch_get_phys_top(void)
diff --git a/openbios-devel/arch/sparc32/openbios.c b/openbios-devel/arch/sparc32/openbios.c
index 53c6760..95a5d37 100644
--- a/openbios-devel/arch/sparc32/openbios.c
+++ b/openbios-devel/arch/sparc32/openbios.c
@@ -25,9 +25,9 @@
 #include "packages/video.h"
 #define NO_QEMU_PROTOS
 #include "arch/common/fw_cfg.h"
-#include "libopenbios/ofmem.h"
+#include "arch/sparc32/ofmem_sparc32.h"
 
-#define MEMORY_SIZE     (512*1024)       /* 512K ram for hosted system */
+#define MEMORY_SIZE     (128*1024)       /* 128K ram for hosted system */
 #define UUID_FMT "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x"
 #define FW_CFG_SUN4M_DEPTH   (FW_CFG_ARCH_LOCAL + 0x00)
 
@@ -813,13 +813,16 @@ static void init_memory(void)
     if (!phys)
         printk("panic: not enough physical memory on host system.\n");
     
-    virt = ofmem_claim_virt(-1, MEMORY_SIZE, PAGE_SIZE);
+    virt = ofmem_claim_virt(OF_CODE_START - MEMORY_SIZE, MEMORY_SIZE, 0);
     if (!virt)
         printk("panic: not enough virtual memory on host system.\n");
 
     /* Generate the mapping (and lock translation into the TLBs) */
     ofmem_map(phys, virt, MEMORY_SIZE, ofmem_arch_default_translation_mode(phys));
 
+    /* Mark everything up until OFMEM_VIRT_TOP as in use */
+    ofmem_claim_virt(OFMEM_VIRT_TOP, OF_CODE_START - MEMORY_SIZE - OFMEM_VIRT_TOP, 0);
+    
     /* we push start and end of memory to the stack
      * so that it can be used by the forth word QUIT
      * to initialize the memory allocator
diff --git a/openbios-devel/include/arch/sparc32/ofmem_sparc32.h b/openbios-devel/include/arch/sparc32/ofmem_sparc32.h
index 7a35b44..efc21b4 100644
--- a/openbios-devel/include/arch/sparc32/ofmem_sparc32.h
+++ b/openbios-devel/include/arch/sparc32/ofmem_sparc32.h
@@ -16,6 +16,9 @@
 
 #include "libopenbios/ofmem.h"
 
+#define OF_CODE_START 0xffd00000
+#define OFMEM_VIRT_TOP 0xfe000000
+
 struct mem;
 extern struct mem cdvmem;
 
-- 
1.7.10.4




More information about the OpenBIOS mailing list