Instead of using our internal memory pool to run the Forth machine, allocate the memory using OFMEM. This enables us to dramatically increase the memory available to Forth clients whilst reducing the memory requirement for the resulting image.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/arch/sparc32/ofmem_sparc32.c | 2 +- openbios-devel/arch/sparc32/openbios.c | 27 ++++++++++++++++++--------- 2 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/openbios-devel/arch/sparc32/ofmem_sparc32.c b/openbios-devel/arch/sparc32/ofmem_sparc32.c index 20eab20..e2f4159 100644 --- a/openbios-devel/arch/sparc32/ofmem_sparc32.c +++ b/openbios-devel/arch/sparc32/ofmem_sparc32.c @@ -21,7 +21,7 @@
#define OF_MALLOC_BASE ((char*)OFMEM + ALIGN_SIZE(sizeof(ofmem_t), 8))
-#define MEMSIZE (384 * 1024) +#define MEMSIZE (256 * 1024) static union { char memory[MEMSIZE]; ofmem_t ofmem; diff --git a/openbios-devel/arch/sparc32/openbios.c b/openbios-devel/arch/sparc32/openbios.c index d5d453d..74a0da2 100644 --- a/openbios-devel/arch/sparc32/openbios.c +++ b/openbios-devel/arch/sparc32/openbios.c @@ -27,12 +27,10 @@ #include "arch/common/fw_cfg.h" #include "libopenbios/ofmem.h"
-#define MEMORY_SIZE (128*1024) /* 128K ram for hosted system */ +#define MEMORY_SIZE (1024*1024) /* 1M 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)
-static ucell *memory; - int qemu_machine_type;
struct hwdef { @@ -807,17 +805,28 @@ static void setup_stdio(void)
static void init_memory(void) { - memory = malloc(MEMORY_SIZE); - if (!memory) - printk("panic: not enough memory on host system.\n"); + phys_addr_t phys; + ucell virt; + + /* Claim the memory from OFMEM */ + phys = ofmem_claim_phys(-1, MEMORY_SIZE, PAGE_SIZE); + if (!phys) + printk("panic: not enough physical memory on host system.\n"); + + virt = ofmem_claim_virt(-1, MEMORY_SIZE, PAGE_SIZE); + 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));
/* 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 */ - - PUSH((ucell)memory); - PUSH((ucell)memory + MEMORY_SIZE); + + PUSH(virt); + PUSH(virt + MEMORY_SIZE); }
static void