2 * Creation Date: <2003/10/25 14:07:17 samuel>
3 * Time-stamp: <2004/08/28 17:48:19 stepan>
7 * Copyright (C) 2003, 2004 Samuel Rydh (samuel@ibrium.se)
8 * Copyright (C) 2003, 2004 Stefan Reinauer
10 * Based upon unix.c (from OpenBIOS):
12 * Copyright (C) 2003 Patrick Mauritz, Stefan Reinauer
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
22 #include "libopenbios/bindings.h"
23 #include "kernel/stack.h"
24 #include "kernel/kernel.h"
25 #include "libc/string.h"
28 #define MEMORY_SIZE (256*1024) /* 256K ram for hosted system */
29 #define DICTIONARY_SIZE (512*1024) /* 512K for the dictionary */
33 /************************************************************************/
34 /* F U N C T I O N S */
35 /************************************************************************/
38 forth_segv_handler( char *segv_addr )
40 ucell addr = 0xdeadbeef;
42 if( PC >= (ucell) dict && PC <= (ucell) dict + dicthead )
45 printk("panic: segmentation violation at %x\n", (int)segv_addr);
46 printk("dict=0x%x here=0x%x(dict+0x%x) pc=0x%x(dict+0x%x)\n",
47 (int)dict, (int)(dict + dicthead), dicthead,
48 PC, PC - (ucell) dict);
49 printk("dstackcnt=%d rstackcnt=%d instruction=%x\n",
50 dstackcnt, rstackcnt, addr);
62 * allocate memory and prepare engine for memory management.
68 memory = malloc(MEMORY_SIZE);
70 panic("panic: not enough memory on host system.\n");
72 /* we push start and end of memory to the stack
73 * so that it can be used by the forth word QUIT
74 * to initialize the memory allocator
77 PUSH( (ucell)memory );
78 PUSH( (ucell)memory + MEMORY_SIZE );
82 initialize_forth( void )
84 dict = malloc(DICTIONARY_SIZE);
85 load_dictionary( forth_dictionary, sizeof(forth_dictionary) );
88 PUSH_xt( bind_noname_func(arch_of_init) );
89 fword("PREPOST-initializer");
91 PC = (ucell)findword("initialize-of");