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
This commit is contained in:
Blue Swirl
2009-01-04 14:47:11 +00:00
parent b700809e7f
commit a767eeb2d4
4 changed files with 19 additions and 24 deletions

View File

@@ -10,8 +10,7 @@ ENTRY(trap_table)
*/ */
BASE_ADDR = 0x00000000ffd00000; BASE_ADDR = 0x00000000ffd00000;
/* 512KB heap and 16KB stack */ /* 16KB stack */
HEAP_SIZE = 512 * 1024;
STACK_SIZE = 16384; STACK_SIZE = 16384;
VMEM_SIZE = 128 * 1024; VMEM_SIZE = 128 * 1024;
IOMEM_SIZE = 256 * 1024 + 768 * 1024; IOMEM_SIZE = 256 * 1024 + 768 * 1024;
@@ -52,15 +51,6 @@ SECTIONS
*(.bss.*) *(.bss.*)
*(COMMON) *(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); . = ALIGN(4096);
_vmem = .; _vmem = .;
. += VMEM_SIZE; . += VMEM_SIZE;

View File

@@ -32,7 +32,7 @@ int printk( const char *fmt, ... )
return i; return i;
} }
#define MEMSIZE 128*1024 #define MEMSIZE ((128 + 256 + 512) * 1024)
static char memory[MEMSIZE]; static char memory[MEMSIZE];
static void *memptr=memory; static void *memptr=memory;
static int memsize=MEMSIZE; static int memsize=MEMSIZE;

View File

@@ -37,7 +37,10 @@
#define PCI_CONFIG (APB_SPECIAL_BASE + 0x1000000ULL) #define PCI_CONFIG (APB_SPECIAL_BASE + 0x1000000ULL)
#define APB_MEM_BASE 0x1ff00000000ULL #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 // XXX
#define NVRAM_SIZE 0x2000 #define NVRAM_SIZE 0x2000
@@ -437,16 +440,17 @@ void udelay(unsigned int usecs)
static void init_memory(void) 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 /* we push start and end of memory to the stack
* so that the forth word QUIT can initialize memory * so that it can be used by the forth word QUIT
* management. For now we use hardcoded memory between * to initialize the memory allocator
* 0x10000 and 0x9ffff (576k). If we need more memory
* than that we have serious bloat.
*/ */
PUSH((ucell)&_heap); PUSH((ucell)memory);
PUSH((ucell)&_eheap); PUSH((ucell)memory + (ucell)MEMORY_SIZE);
} }
static void static void
@@ -508,7 +512,7 @@ int openbios(void)
collect_sys_info(&sys_info); collect_sys_info(&sys_info);
dict=intdict; dict = malloc(DICTIONARY_SIZE);
load_dictionary((char *)sys_info.dict_start, load_dictionary((char *)sys_info.dict_start,
(unsigned long)sys_info.dict_end (unsigned long)sys_info.dict_end
- (unsigned long)sys_info.dict_start); - (unsigned long)sys_info.dict_start);
@@ -540,5 +544,6 @@ int openbios(void)
enterforth((xt_t)PC); enterforth((xt_t)PC);
printk("falling off...\n"); printk("falling off...\n");
free(dict);
return 0; return 0;
} }

View File

@@ -4,8 +4,8 @@
#include "asm/types.h" #include "asm/types.h"
extern unsigned long va_shift; // Set in entry.S extern unsigned long va_shift; // Set in entry.S
extern char _start, _data, _heap, _eheap, _stack, _estack, _end, // Defined in ldscript
_vmem, _evmem,_iomem; // Defined in ldscript extern char _start, _data, _stack, _estack, _end, _vmem, _evmem, _iomem;
static inline unsigned long static inline unsigned long
va2pa(unsigned long va) va2pa(unsigned long va)