From a767eeb2d4710a46b430b19774169925d6498121 Mon Sep 17 00:00:00 2001 From: Blue Swirl Date: Sun, 4 Jan 2009 14:47:11 +0000 Subject: [PATCH] Allocate Forth memory and dictionary using malloc like PPC (cf. r345) git-svn-id: svn://coreboot.org/openbios/openbios-devel@347 f158a5a8-5612-0410-a976-696ce0be7e32 --- arch/sparc64/ldscript | 12 +----------- arch/sparc64/lib.c | 2 +- arch/sparc64/openbios.c | 25 +++++++++++++++---------- include/sparc64/io.h | 4 ++-- 4 files changed, 19 insertions(+), 24 deletions(-) diff --git a/arch/sparc64/ldscript b/arch/sparc64/ldscript index e71ea12..28dfde5 100644 --- a/arch/sparc64/ldscript +++ b/arch/sparc64/ldscript @@ -10,8 +10,7 @@ ENTRY(trap_table) */ BASE_ADDR = 0x00000000ffd00000; -/* 512KB heap and 16KB stack */ -HEAP_SIZE = 512 * 1024; +/* 16KB stack */ STACK_SIZE = 16384; VMEM_SIZE = 128 * 1024; IOMEM_SIZE = 256 * 1024 + 768 * 1024; @@ -52,15 +51,6 @@ SECTIONS *(.bss.*) *(COMMON) - /* Put heap and stack here, so they are included in PT_LOAD segment - * and the bootloader is aware of it. */ - - . = ALIGN(16); - _heap = .; - . += HEAP_SIZE; - . = ALIGN(16); - _eheap = .; - . = ALIGN(4096); _vmem = .; . += VMEM_SIZE; diff --git a/arch/sparc64/lib.c b/arch/sparc64/lib.c index b234469..639cc90 100644 --- a/arch/sparc64/lib.c +++ b/arch/sparc64/lib.c @@ -32,7 +32,7 @@ int printk( const char *fmt, ... ) return i; } -#define MEMSIZE 128*1024 +#define MEMSIZE ((128 + 256 + 512) * 1024) static char memory[MEMSIZE]; static void *memptr=memory; static int memsize=MEMSIZE; diff --git a/arch/sparc64/openbios.c b/arch/sparc64/openbios.c index 12b463b..bd3ba28 100644 --- a/arch/sparc64/openbios.c +++ b/arch/sparc64/openbios.c @@ -37,7 +37,10 @@ #define PCI_CONFIG (APB_SPECIAL_BASE + 0x1000000ULL) #define APB_MEM_BASE 0x1ff00000000ULL -static unsigned char intdict[256 * 1024]; +#define MEMORY_SIZE (512*1024) /* 512K ram for hosted system */ +#define DICTIONARY_SIZE (256*1024) /* 256K for the dictionary */ + +static ucell *memory; // XXX #define NVRAM_SIZE 0x2000 @@ -437,16 +440,17 @@ 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"); - /* push start and end of available memory to the stack - * so that the forth word QUIT can initialize memory - * management. For now we use hardcoded memory between - * 0x10000 and 0x9ffff (576k). If we need more memory - * than that we have serious bloat. - */ + /* 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)&_heap); - PUSH((ucell)&_eheap); + PUSH((ucell)memory); + PUSH((ucell)memory + (ucell)MEMORY_SIZE); } static void @@ -508,7 +512,7 @@ int openbios(void) collect_sys_info(&sys_info); - dict=intdict; + dict = malloc(DICTIONARY_SIZE); load_dictionary((char *)sys_info.dict_start, (unsigned long)sys_info.dict_end - (unsigned long)sys_info.dict_start); @@ -540,5 +544,6 @@ int openbios(void) enterforth((xt_t)PC); printk("falling off...\n"); + free(dict); return 0; } diff --git a/include/sparc64/io.h b/include/sparc64/io.h index c62ede9..45383d7 100644 --- a/include/sparc64/io.h +++ b/include/sparc64/io.h @@ -4,8 +4,8 @@ #include "asm/types.h" extern unsigned long va_shift; // Set in entry.S -extern char _start, _data, _heap, _eheap, _stack, _estack, _end, - _vmem, _evmem,_iomem; // Defined in ldscript +// Defined in ldscript +extern char _start, _data, _stack, _estack, _end, _vmem, _evmem, _iomem; static inline unsigned long va2pa(unsigned long va)