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 substantially reducing the memory requirement for the resulting image.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/arch/sparc64/ofmem_sparc64.c | 2 +- openbios-devel/arch/sparc64/openbios.c | 30 ++++++++++++++++++--------- 2 files changed, 21 insertions(+), 11 deletions(-)
diff --git a/openbios-devel/arch/sparc64/ofmem_sparc64.c b/openbios-devel/arch/sparc64/ofmem_sparc64.c index 984eae4..50224e6 100644 --- a/openbios-devel/arch/sparc64/ofmem_sparc64.c +++ b/openbios-devel/arch/sparc64/ofmem_sparc64.c @@ -20,7 +20,7 @@
#define OF_MALLOC_BASE ((char*)OFMEM + ALIGN_SIZE(sizeof(ofmem_t), 8))
-#define MEMSIZE ((256 + 512) * 1024) +#define MEMSIZE (128 * 1024) static union { char memory[MEMSIZE]; ofmem_t ofmem; diff --git a/openbios-devel/arch/sparc64/openbios.c b/openbios-devel/arch/sparc64/openbios.c index ab32a8f..1becf6d 100644 --- a/openbios-devel/arch/sparc64/openbios.c +++ b/openbios-devel/arch/sparc64/openbios.c @@ -21,7 +21,8 @@ #include "../../drivers/timer.h" // XXX #define NO_QEMU_PROTOS #include "arch/common/fw_cfg.h" -#include "libopenbios/ofmem.h" +#include "arch/sparc64/ofmem_sparc64.h" +#include "spitfire.h"
#define UUID_FMT "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x"
@@ -32,9 +33,7 @@ #define APB_SPECIAL_BASE 0x1fe00000000ULL #define APB_MEM_BASE 0x1ff00000000ULL
-#define MEMORY_SIZE (512*1024) /* 512K ram for hosted system */ - -static ucell *memory; +#define MEMORY_SIZE (1024*1024) /* 1M ram for hosted system */
// XXX #define NVRAM_SIZE 0x2000 @@ -553,17 +552,28 @@ void udelay(unsigned int usecs)
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 (align to 512K so we only take 1 TLB slot) */ + phys = ofmem_claim_phys(-1, MEMORY_SIZE, PAGE_SIZE_512K); + if (!phys) + printk("panic: not enough physical memory on host system.\n"); + + virt = ofmem_claim_virt(-1, MEMORY_SIZE, PAGE_SIZE_512K); + 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) | SPITFIRE_TTE_LOCKED);
/* 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 + (ucell)MEMORY_SIZE); + + PUSH(virt); + PUSH(virt + MEMORY_SIZE); }
static void