1 /* tag: forth bootstrap environment
3 * Copyright (C) 2003-2006 Stefan Reinauer, Patrick Mauritz
5 * See the file "COPYING" for further information about
6 * the copyright and warranty status of this work.
9 #include "sysinclude.h"
25 #include "kernel/stack.h"
26 #include "sysinclude.h"
27 #include "kernel/kernel.h"
30 #include "openbios-version.h"
32 #define MAX_PATH_LEN 256
34 #define MEMORY_SIZE (1024*1024) /* 1M ram for hosted system */
35 #define DICTIONARY_SIZE (256*1024) /* 256k for the dictionary */
36 #define TRAMPOLINE_SIZE (4*sizeof(cell)) /* 4 cells for the trampoline */
39 static ucell
*latest
, *state
, *base
;
44 static int errors
= 0;
45 static int segfault
= 0;
46 static int verbose
= 0;
48 #define MAX_SRC_FILES 128
50 static FILE *srcfiles
[MAX_SRC_FILES
];
51 static char *srcfilenames
[MAX_SRC_FILES
];
52 static int srclines
[MAX_SRC_FILES
];
53 static unsigned int cursrc
= 0;
55 static char *srcbasedict
;
57 /* console variables */
60 #ifdef NATIVE_BITWIDTH_SMALLER_THAN_HOST_BITWIDTH
61 unsigned long base_address
;
64 /* include path handling */
65 typedef struct include_path include
;
71 static include includes
= { ".", NULL
};
73 static ucell
* relocation_address
=NULL
;
74 static int relocation_length
=0;
76 /* the word names are used to generate the prim words in the
77 * dictionary. This is done by the C written interpreter.
79 static const char *wordnames
[] = {
80 "(semis)", "", "(lit)", "", "", "", "", "(do)", "(?do)", "(loop)",
81 "(+loop)", "", "", "", "dup", "2dup", "?dup", "over", "2over", "pick", "drop",
82 "2drop", "nip", "roll", "rot", "-rot", "swap", "2swap", ">r", "r>",
83 "r@", "depth", "depth!", "rdepth", "rdepth!", "+", "-", "*", "u*",
84 "mu/mod", "abs", "negate", "max", "min", "lshift", "rshift", ">>a",
85 "and", "or", "xor", "invert", "d+", "d-", "m*", "um*", "@", "c@",
86 "w@", "l@", "!", "+!", "c!", "w!", "l!", "=", ">", "<", "u>", "u<",
87 "sp@", "move", "fill", "(emit)", "(key?)", "(key)", "execute",
88 "here", "here!", "dobranch", "do?branch", "unaligned-w@",
89 "unaligned-w!", "unaligned-l@", "unaligned-l!", "ioc@", "iow@",
90 "iol@", "ioc!", "iow!", "iol!", "i", "j", "call", "sys-debug",
91 "$include", "$encode-file", "(debug", "(debug-off)"
94 static void init_trampoline(void)
97 /* We're using side effects which is to some extent nasty */
98 printf("WARNING: no trampoline!\n");
104 trampoline
[2]=target_ucell(pointer2cell(trampoline
)+3*sizeof(ucell
));
109 * dictionary related functions.
112 static void relocation_table(unsigned char * dict_one
, unsigned char *dict_two
, int length
)
114 ucell
*d1
=(ucell
*)dict_one
, *d2
=(ucell
*)dict_two
;
117 int l
=(length
+(sizeof(cell
)-1))/sizeof(ucell
), i
;
119 /* prepare relocation table */
120 relocation_length
=(length
+BITS
-1)/BITS
;
121 reloc_table
= malloc(relocation_length
*sizeof(cell
));
122 memset(reloc_table
,0,relocation_length
*sizeof(cell
));
124 for (i
=0; i
<l
; i
++) {
130 reloc_table
[pos
] &= target_ucell(~((ucell
)1ULL << bit
));
132 // This check might bring false positives in data.
133 //if(d1[i] >= pointer2cell(dict_one) &&
134 // d1[i] <= pointer2cell(dict_one+length))
135 // printk("\nWARNING: inconsistent relocation (%x:%x)!\n", d1[i], d2[i]);
137 /* This is a pointer, it needs relocation, d2==dict */
138 reloc_table
[pos
] |= target_ucell((ucell
)1ULL << bit
);
139 d2
[i
] = target_ucell(target_ucell(d2
[i
]) - pointer2cell(d2
));
143 #ifdef CONFIG_DEBUG_DICTIONARY
144 printk("dict1 %lx dict2 %lx dict %lx\n",dict_one
, dict_two
, dict
);
145 for (i
=0; i
< relocation_length
; i
++)
146 printk("reloc %d %lx\n",i
+1, reloc_table
[i
]);
148 relocation_address
=reloc_table
;
151 static void write_dictionary(const char *filename
)
154 unsigned char *write_data
, *walk_data
;
156 dictionary_header_t
*header
;
160 * get memory for dictionary
163 write_len
= sizeof(dictionary_header_t
)+dicthead
+relocation_length
*sizeof(cell
);
164 write_data
= malloc(write_len
);
166 printk("panic: can't allocate memory for output dictionary (%d"
167 " bytes\n", write_len
);
170 memset(write_data
, 0, write_len
);
173 * prepare dictionary header
176 header
= (dictionary_header_t
*)write_data
;
177 *header
= (dictionary_header_t
){
180 .cellsize
= sizeof(ucell
),
181 #ifdef CONFIG_BIG_ENDIAN
189 .length
= target_ulong((uint32_t)dicthead
),
190 .last
= target_ucell((ucell
)((unsigned long)last
191 - (unsigned long)dict
)),
195 * prepare dictionary data
198 walk_data
=write_data
+sizeof(dictionary_header_t
);
199 memcpy (walk_data
, dict
, dicthead
);
202 * prepare relocation data.
203 * relocation_address is zero when writing a dictionary core.
206 if (relocation_address
) {
207 #ifdef CONFIG_DEBUG_DICTIONARY
208 printk("writing %d reloc cells \n",relocation_length
);
210 walk_data
+= dicthead
;
211 memcpy(walk_data
, relocation_address
,
212 relocation_length
*sizeof(cell
));
213 /* free relocation information */
214 free(relocation_address
);
215 relocation_address
=NULL
;
217 header
->relocation
=0;
224 walk_data
=write_data
;
225 while (walk_data
<write_data
+write_len
) {
226 checksum
+=read_long(walk_data
);
227 walk_data
+=sizeof(u32
);
229 checksum
=(u32
)-checksum
;
231 header
->checksum
=target_long(checksum
);
237 f
= fopen(filename
, "w");
239 printk("panic: can't write to dictionary '%s'.\n", filename
);
243 fwrite(write_data
, write_len
, 1, f
);
248 #ifdef CONFIG_DEBUG_DICTIONARY
249 printk("wrote dictionary to file %s.\n", filename
);
253 static ucell
read_dictionary(char *fil
)
261 if (stat(fil
, &finfo
))
264 ilen
= finfo
.st_size
;
266 if ((mem
= malloc(ilen
)) == NULL
) {
267 printk("panic: not enough memory.\n");
273 printk("panic: can't open dictionary.\n");
277 if (fread(mem
, ilen
, 1, f
) != 1) {
278 printk("panic: can't read dictionary.\n");
284 ret
= load_dictionary(mem
, ilen
);
292 * C Parser related functions
296 * skipws skips all whitespaces (space, tab, newline) from the input file
299 static void skipws(FILE * f
)
305 if (c
== ' ' || c
== '\t')
309 srclines
[cursrc
- 1]++;
319 * parse gets the next word from the input stream, delimited by
320 * delim. If delim is 0, any word delimiter will end the stream
321 * word delimiters are space, tab and newline. The resulting word
322 * will be put zero delimited to the char array line.
325 static int parse(FILE * f
, char *line
, char delim
)
332 if (delim
&& c
== delim
)
335 if ((!delim
) && (c
== ' ' || c
== '\t' || c
== '\n'))
341 /* Update current line number */
343 srclines
[cursrc
- 1]++;
352 * parse_word is a small helper that skips whitespaces before a word.
353 * it's behaviour is similar to the forth version parse-word.
356 static void parse_word(FILE * f
, char *line
)
363 static void writestring(const char *str
)
366 for (i
= 0; i
< strlen(str
); i
++) {
367 dict
[dicthead
+ i
] = str
[i
];
370 dict
[dicthead
- 1] = (char) strlen(str
) + 128;
373 #define writebyte(value) {write_byte(dict+dicthead,value); dicthead++;}
374 #define writecell(value) {write_cell(dict+dicthead, value); dicthead+=sizeof(cell);}
377 * reveal a word, ie. make it visible.
380 static void reveal(void)
389 static void paddict(ucell align
)
391 while (dicthead
% align
!= 0)
396 * generic forth word creator function.
399 static void fcreate(const char *word
, ucell cfaval
)
401 if (strlen(word
) == 0) {
402 printk("WARNING: tried to create unnamed word.\n");
407 /* get us at least 1 byte for flags */
409 paddict(sizeof(cell
));
410 /* set flags high bit. */
411 dict
[dicthead
- 1] = 128;
413 writecell(read_ucell(latest
));
414 *latest
= target_ucell(pointer2cell(dict
) + dicthead
- sizeof(cell
));
419 static ucell
*buildvariable(const char *name
, cell defval
)
421 fcreate(name
, DOVAR
); /* see dict.h for DOVAR and other CFA ids */
423 return (ucell
*) (dict
+ dicthead
- sizeof(cell
));
426 static void buildconstant(const char *name
, cell defval
)
428 fcreate(name
, DOCON
); /* see dict.h for DOCON and other CFA ids */
432 static void builddefer(const char *name
)
434 fcreate(name
, DODFR
); /* see dict.h for DODFR and other CFA ids */
436 writecell((ucell
)findword("(semis)"));
440 * Include file handling
443 static void add_includepath(char *path
)
445 include
*incl
= &includes
;
451 newpath
= malloc(sizeof(include
));
453 printk("panic: not enough memory for include path.\n");
457 incl
->next
= newpath
;
458 newpath
->path
= path
;
459 newpath
->next
= NULL
;
463 static FILE *fopen_include(const char *fil
)
465 char fullpath
[MAX_PATH_LEN
];
467 include
*incl
= &includes
;
470 snprintf(fullpath
, sizeof(fullpath
), "%s/%s", incl
->path
, fil
);
472 ret
= fopen(fullpath
, "r");
475 #ifdef CONFIG_DEBUG_INTERPRETER
476 printk("Including '%s'\n", name
);
478 srcfilenames
[ cursrc
] = malloc(strlen(fil
) + 1);
479 strcpy(srcfilenames
[ cursrc
], fil
);
480 srclines
[ cursrc
] = 1;
481 srcfiles
[ cursrc
++ ] = ret
;
493 * Forth exception handler
496 void exception(cell no
)
498 printk("%s:%d: ", srcfilenames
[cursrc
- 1], srclines
[cursrc
- 1]);
500 /* See also forth/bootstrap/interpreter.fs */
504 printk("Aborted.\n");
507 printk("Stack Overflow.\n");
510 printk("Stack Underflow.\n");
513 printk("Return Stack Overflow.\n");
516 printk("Return Stack Underflow.\n");
519 printk("undefined word.\n");
522 printk("out of memory.\n");
525 printk("undefined method.\n");
528 printk("no such device.\n");
531 printk("error %" FMT_CELL_d
" occured.\n", no
);
538 * This is the C version of the forth interpreter
541 static int interpret_source(char *fil
)
548 const ucell SEMIS
= (ucell
)findword("(semis)");
549 const ucell LIT
= (ucell
)findword("(lit)");
550 const ucell DOBRANCH
= (ucell
)findword("dobranch");
552 if ((f
= fopen_include(fil
)) == NULL
) {
553 printk("error while loading source file '%s'\n", fil
);
558 /* FIXME: We should read this file at
559 * once. No need to get it char by char
566 /* if there is actually no word, we continue right away */
567 if (strlen(tib
) == 0) {
571 /* Checking for builtin words that are needed to
572 * bootstrap the forth base dictionary.
575 if (!strcmp(tib
, "(")) {
580 if (!strcmp(tib
, "\\")) {
585 if (!strcmp(tib
, ":")) {
588 #ifdef CONFIG_DEBUG_INTERPRETER
589 printk("create colon word %s\n\n", tib
);
591 fcreate(tib
, DOCOL
); /* see dict.h for DOCOL and other CFA ids */
592 *state
= (ucell
) (-1);
596 if (!strcmp(tib
, ";")) {
597 #ifdef CONFIG_DEBUG_INTERPRETER
598 printk("finish colon definition\n\n");
600 writecell((cell
)SEMIS
);
606 if (!strcasecmp(tib
, "variable")) {
608 #ifdef CONFIG_DEBUG_INTERPRETER
609 printk("defining variable %s\n\n", tib
);
611 buildvariable(tib
, 0);
616 if (!strcasecmp(tib
, "constant")) {
618 #ifdef CONFIG_DEBUG_INTERPRETER
619 printk("defining constant %s\n\n", tib
);
621 buildconstant(tib
, POP());
626 if (!strcasecmp(tib
, "value")) {
628 #ifdef CONFIG_DEBUG_INTERPRETER
629 printk("defining value %s\n\n", tib
);
631 buildconstant(tib
, POP());
636 if (!strcasecmp(tib
, "defer")) {
638 #ifdef CONFIG_DEBUG_INTERPRETER
639 printk("defining defer word %s\n\n", tib
);
646 if (!strcasecmp(tib
, "include")) {
648 #ifdef CONFIG_DEBUG_INTERPRETER
649 printk("including file %s\n\n", tib
);
651 interpret_source(tib
);
655 if (!strcmp(tib
, "[']")) {
660 #ifdef CONFIG_DEBUG_INTERPRETER
662 ("writing address of %s to stack\n\n",
667 #ifdef CONFIG_DEBUG_INTERPRETER
668 printk("writing lit, addr(%s) to dict\n\n",
671 writecell(LIT
); /* lit */
675 /* we have no error detection here */
678 if (!strcasecmp(tib
, "s\"")) {
682 cnt
= parse(f
, tib
, '"');
683 #ifdef CONFIG_DEBUG_INTERPRETER
684 printk("compiling string %s\n", tib
);
686 loco
= dicthead
+ (6 * sizeof(cell
));
688 writecell(pointer2cell(dict
) + loco
);
690 writecell((ucell
)cnt
);
692 loco
= cnt
+ sizeof(cell
) - 1;
693 loco
&= ~(sizeof(cell
) - 1);
695 memcpy(dict
+ dicthead
, tib
, cnt
);
697 paddict(sizeof(cell
));
701 /* look if tib is in dictionary. */
702 /* should the dictionary be searched before the builtins ? */
705 u8 flags
= read_byte((u8
*)cell2pointer(res
) -
707 #ifdef CONFIG_DEBUG_INTERPRETER
708 printk("%s is 0x%" FMT_CELL_x
"\n", tib
, (ucell
) res
);
710 if (!(*state
) || (flags
& 3)) {
711 #ifdef CONFIG_DEBUG_INTERPRETER
712 printk("executing %s, %" FMT_CELL_d
715 (flags
& 1) ? "immediate" : "",
716 (flags
& 2) ? "compile-only" : "");
721 #ifdef CONFIG_DEBUG_INTERPRETER
722 printk("writing %s to dict\n\n", tib
);
724 writecell((cell
)res
);
729 /* if not look if it's a number */
731 num
= strtoll(tib
, &test
, read_ucell(base
));
733 num
= strtoull(tib
, &test
, read_ucell(base
));
738 printk("%s:%d: %s is not defined.\n\n", srcfilenames
[cursrc
- 1], srclines
[cursrc
- 1], tib
);
740 #ifdef CONFIG_DEBUG_INTERPRETER
748 #ifdef CONFIG_DEBUG_INTERPRETER
749 printk("pushed %" FMT_CELL_x
" to stack\n\n", num
);
753 #ifdef CONFIG_DEBUG_INTERPRETER
754 printk("writing lit, %" FMT_CELL_x
" to dict\n\n", num
);
756 writecell(LIT
); /* lit */
767 static int build_dictionary(void)
772 /* we need a temporary place for latest outside the dictionary */
775 /* starting a new dictionary: clear dicthead */
778 #ifdef CONFIG_DEBUG_DICTIONARY
779 printk("building dictionary, %d primitives.\nbuilt words:",
780 sizeof(wordnames
) / sizeof(void *));
783 for (i
= 0; i
< sizeof(wordnames
) / sizeof(void *); i
++) {
784 if (strlen(wordnames
[i
]) != 0) {
785 fcreate((char *) wordnames
[i
], i
);
786 #ifdef CONFIG_DEBUG_DICTIONARY
787 printk(" %s", wordnames
[i
]);
791 #ifdef CONFIG_DEBUG_DICTIONARY
795 /* get last/latest and state */
796 state
= buildvariable("state", 0);
797 last
= buildvariable("forth-last", 0);
798 latest
= buildvariable("latest", 0);
800 *latest
= target_ucell(pointer2cell(latest
)-2*sizeof(cell
));
802 base
=buildvariable("base", 10);
804 buildconstant("/c", sizeof(u8
));
805 buildconstant("/w", sizeof(u16
));
806 buildconstant("/l", sizeof(u32
));
807 buildconstant("/n", sizeof(ucell
));
808 buildconstant("/x", sizeof(u64
));
812 printk("Dictionary initialization finished.\n");
818 * functions used by primitives
825 interruptforth
|= FORTH_INTSTAT_STOP
;
826 /* return -1 in order to exit the loop in key() */
830 tmp
= getc( srcfiles
[cursrc
-1] );
832 ungetc(tmp
, srcfiles
[cursrc
-1]);
836 fclose(srcfiles
[--cursrc
]);
841 int get_inputbyte( void )
846 interruptforth
|= FORTH_INTSTAT_STOP
;
850 tmp
= getc( srcfiles
[cursrc
-1] );
852 /* Update current line number */
854 srclines
[cursrc
- 1]++;
861 fclose(srcfiles
[--cursrc
]);
863 return get_inputbyte();
866 void put_outputbyte( int c
)
873 * segmentation fault handler. linux specific?
877 segv_handler(int signo
__attribute__ ((unused
)),
878 siginfo_t
* si
, void *context
__attribute__ ((unused
)))
880 static int count
= 0;
881 ucell addr
= 0xdeadbeef;
884 printk("Died while dumping forth dictionary core.\n");
890 if (PC
>= pointer2cell(dict
) && PC
<= pointer2cell(dict
) + dicthead
)
891 addr
= read_cell(cell2pointer(PC
));
893 printk("panic: segmentation violation at %p\n", (char *)si
->si_addr
);
894 printk("dict=%p here=%p(dict+0x%" FMT_CELL_x
") pc=0x%" FMT_CELL_x
"(dict+0x%" FMT_CELL_x
")\n",
895 dict
, dict
+ dicthead
, dicthead
, PC
, PC
- pointer2cell(dict
));
896 printk("dstackcnt=%d rstackcnt=%d instruction=%" FMT_CELL_x
"\n",
897 dstackcnt
, rstackcnt
, addr
);
902 printk("Writing dictionary core file\n");
903 write_dictionary("forth.dict.core");
910 * allocate memory and prepare engine for memory management.
913 static void init_memory(void)
915 memset(memory
, 0, MEMORY_SIZE
);
917 /* we push start and end of memory to the stack
918 * so that it can be used by the forth word QUIT
919 * to initialize the memory allocator.
920 * Add a cell to the start address so we don't end
921 * up with a start address of zero during bootstrap
924 PUSH(pointer2cell(memory
)+sizeof(cell
));
925 PUSH(pointer2cell(memory
) + MEMORY_SIZE
-1);
930 include_file( const char *name
)
934 if( cursrc
>= sizeof(srcfiles
)/sizeof(srcfiles
[0]) ) {
935 printk("\npanic: Maximum include depth reached!\n");
939 file
= fopen_include( name
);
941 printk("\npanic: Failed opening file '%s'\n", name
);
948 encode_file( const char *name
)
950 FILE *file
= fopen_include(name
);
954 printk("\npanic: Can't open '%s'\n", name
);
957 fseek( file
, 0, SEEK_END
);
958 size
= ftell( file
);
959 fseek( file
, 0, SEEK_SET
);
962 printk("\nEncoding %s [%d bytes]\n", name
, size
);
964 fread( dict
+ dicthead
, size
, 1, file
);
965 PUSH( pointer2cell(dict
+ dicthead
) );
971 static void run_dictionary(char *basedict
, char *confile
)
976 read_dictionary(basedict
);
977 PC
= (ucell
)findword("initialize");
981 printk("Unable to find initialize word in dictionary %s; ignoring\n", basedict
);
988 srcfiles
[cursrc
-1] = stdin
;
996 printk("Jumping to dictionary %s...\n", basedict
);
998 /* If a console file has been specified, open it */
1000 console
= fopen(confile
, "w");
1002 srcbasedict
= basedict
;
1004 enterforth((xt_t
)PC
);
1006 /* Close the console file */
1011 static void new_dictionary(const char *source
)
1015 interpret_source((char *)source
);
1017 if (verbose
|| errors
> 0) {
1018 printk("interpretion finished. %d errors occured.\n",
1027 #define BANNER "OpenBIOS bootstrap kernel. (C) 2003-2006 Patrick Mauritz, Stefan Reinauer\n"\
1028 "This software comes with absolutely no warranty. "\
1029 "All rights reserved.\n\n"
1032 #define USAGE "Usage: %s [options] [dictionary file|source file]\n\n" \
1033 " -h|--help show this help\n" \
1034 " -V|--version print version and exit\n" \
1035 " -v|--verbose print debugging information\n" \
1036 " -I|--include dir add dir to include path\n" \
1037 " -d|--source-dictionary bootstrap.dict\n" \
1038 " use this dictionary as base\n" \
1039 " -D|--target-dictionary output.dict\n" \
1040 " write to output.dict\n" \
1041 " -c|--console output.log\n" \
1042 " write kernel console output to log file\n" \
1043 " -s|--segfault install segfault handler\n\n"
1045 #define USAGE "Usage: %s [options] [dictionary file|source file]\n\n" \
1046 " -h show this help\n" \
1047 " -V print version and exit\n" \
1048 " -v print debugging information\n" \
1049 " -I add dir to include path\n" \
1050 " -d bootstrap.dict\n" \
1051 " use this dictionary as base\n" \
1052 " -D output.dict\n" \
1053 " write to output.dict\n" \
1054 " -c output.log\n" \
1055 " write kernel console output to log file\n" \
1056 " -s install segfault handler\n\n"
1060 int main(int argc
, char *argv
[])
1062 struct sigaction sa
;
1064 unsigned char *ressources
=NULL
; /* All memory used by us */
1065 char *dictname
= NULL
;
1066 char *basedict
= NULL
;
1067 char *consolefile
= NULL
;
1069 unsigned char *bootstrapdict
[2];
1072 const char *optstring
= "VvhsI:d:D:c:?";
1076 int option_index
= 0;
1077 static struct option long_options
[] = {
1078 {"version", 0, NULL
, 'V'},
1079 {"verbose", 0, NULL
, 'v'},
1080 {"help", 0, NULL
, 'h'},
1081 {"segfault", 0, NULL
, 's'},
1082 {"include", 1, NULL
, 'I'},
1083 {"source-dictionary", 1, NULL
, 'd'},
1084 {"target-dictionary", 1, NULL
, 'D'},
1085 {"console", 1, NULL
, 'c'},
1092 c
= getopt_long(argc
, argv
, optstring
, long_options
,
1095 c
= getopt(argc
, argv
, optstring
);
1102 printk("Version " OPENBIOS_VERSION_STR
"\n");
1106 printk("Version " OPENBIOS_VERSION_STR
"\n" USAGE
,
1116 #ifdef CONFIG_DEBUG_INTERPRETER
1117 printk("adding '%s' to include path\n", optarg
);
1119 add_includepath(optarg
);
1133 consolefile
= optarg
;
1143 printk("Using source dictionary '%s'\n", basedict
);
1144 printk("Dumping final dictionary to '%s'\n", dictname
);
1147 if (argc
< optind
+ 1) {
1148 printk(USAGE
, argv
[0]);
1154 * Get all required resources
1158 ressources
= malloc(MEMORY_SIZE
+ (2 * DICTIONARY_SIZE
) + TRAMPOLINE_SIZE
);
1160 printk("panic: not enough memory on host system.\n");
1164 #ifdef NATIVE_BITWIDTH_SMALLER_THAN_HOST_BITWIDTH
1165 base_address
=(unsigned long)ressources
;
1168 memory
= (ucell
*)ressources
;
1170 bootstrapdict
[0] = ressources
+ MEMORY_SIZE
;
1171 bootstrapdict
[1] = ressources
+ MEMORY_SIZE
+ DICTIONARY_SIZE
;
1172 trampoline
= (ucell
*)(ressources
+ MEMORY_SIZE
+ DICTIONARY_SIZE
+ DICTIONARY_SIZE
);
1174 #ifdef CONFIG_DEBUG_INTERPRETER
1175 printf("memory: %p\n",memory
);
1176 printf("dict1: %p\n",bootstrapdict
[0]);
1177 printf("dict2: %p\n",bootstrapdict
[1]);
1178 printf("trampoline: %p\n",trampoline
);
1179 printf("size=%d, trampoline_size=%d\n",MEMORY_SIZE
+ (2 *
1180 DICTIONARY_SIZE
) + TRAMPOLINE_SIZE
,
1188 printk("Installing SIGSEGV handler...");
1190 sa
.sa_sigaction
= segv_handler
;
1191 sigemptyset(&sa
.sa_mask
);
1192 sa
.sa_flags
= SA_SIGINFO
| SA_NODEFER
;
1193 sigaction(SIGSEGV
, &sa
, NULL
);
1200 * Now do the real work
1203 for (cnt
=0; cnt
<2; cnt
++) {
1205 printk("Compiling dictionary %d/%d\n", cnt
+1, 2);
1207 dict
=bootstrapdict
[cnt
];
1209 new_dictionary(argv
[optind
]);
1211 for (c
=argc
-1; c
>=optind
; c
--)
1212 include_file(argv
[c
]);
1214 run_dictionary(basedict
, consolefile
);
1220 #ifndef CONFIG_DEBUG_INTERPRETER
1222 printk("dictionary not dumped to file.\n");
1226 relocation_table( bootstrapdict
[0], bootstrapdict
[1], dicthead
);
1227 write_dictionary( dictname
? dictname
: "bootstrap.dict");