Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / openbios / forth / bootstrap / start.fs
1 \ tag: forth bootstrap starter.
2
3 \ Copyright (C) 2003 Patrick Mauritz, Stefan Reinauer
4
5 \ See the file "COPYING" for further information about
6 \ the copyright and warranty status of this work.
7
8
9 include bootstrap.fs        \ all base words
10 include interpreter.fs      \ interpreter
11 include builtin.fs          \ builtin terminal.
12
13 : include ( >filename<eol> -- )
14   linefeed parse $include
15 ;
16
17 : encode-file ( >filename< > -- dictptr size )
18   parse-word $encode-file
19 ;
20
21 : bye 
22   s" Farewell!" cr type cr cr 
23   0 rdepth! 
24   ;
25
26 \ quit starts the outer interpreter of the forth system.
27 \ zech describes quit as being the outer interpreter, but
28 \ we split it apart to keep the interpreter elsewhere.
29
30 : quit                      ( -- )
31   2 rdepth!
32   outer-interpreter
33 ;
34
35 \ initialize is the first forth word run by the kernel.
36 \ this word is automatically executed by the C core on start 
37 \ and it's never left unless something goes really wrong or
38 \ the user decides to leave the engine.
39
40 variable init-chain
41
42 \ :noname <definition> ; initializer
43 : initializer ( xt -- )
44   here swap , 0 ,            \ xt, next
45   init-chain
46   begin dup @ while @ na1+ repeat
47   !
48 ;
49
50 : initialize-forth          ( startmem endmem -- )
51   over - init-mem
52   init-pockets
53   init-tmp-comp
54   init-builtin-terminal
55
56   init-chain @              \ execute initializers
57   begin dup while
58     dup @ execute
59     na1+ @
60   repeat
61   drop
62 ;
63
64 \ compiler entrypoint
65 : initialize                ( startmem endmem -- )
66   initialize-forth
67   s" OpenBIOS kernel started." type cr
68   quit
69 ;