mirror of
https://gitlab.com/qemu-project/openbios.git
synced 2024-02-13 08:34:06 +08:00
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:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user