Deleted Added
full compact
loader.4th (65630) loader.4th (65883)
1\ Copyright (c) 1999 Daniel C. Sobral <dcs@freebsd.org>
2\ All rights reserved.
3\
4\ Redistribution and use in source and binary forms, with or without
5\ modification, are permitted provided that the following conditions
6\ are met:
7\ 1. Redistributions of source code must retain the above copyright
8\ notice, this list of conditions and the following disclaimer.

--- 8 unchanged lines hidden (view full) ---

17\ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18\ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19\ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20\ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21\ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23\ SUCH DAMAGE.
24\
1\ Copyright (c) 1999 Daniel C. Sobral <dcs@freebsd.org>
2\ All rights reserved.
3\
4\ Redistribution and use in source and binary forms, with or without
5\ modification, are permitted provided that the following conditions
6\ are met:
7\ 1. Redistributions of source code must retain the above copyright
8\ notice, this list of conditions and the following disclaimer.

--- 8 unchanged lines hidden (view full) ---

17\ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18\ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19\ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20\ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21\ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23\ SUCH DAMAGE.
24\
25\ $FreeBSD: head/sys/boot/forth/loader.4th 65630 2000-09-09 04:52:34Z dcs $
25\ $FreeBSD: head/sys/boot/forth/loader.4th 65883 2000-09-15 08:05:52Z dcs $
26
27s" arch-alpha" environment? [if] [if]
28 s" loader_version" environment? [if]
29 3 < [if]
30 .( Loader version 0.3+ required) cr
31 abort
32 [then]
33 [else]

--- 11 unchanged lines hidden (view full) ---

45 [else]
46 .( Could not get loader version!) cr
47 abort
48 [then]
49[then] [then]
50
51include /boot/support.4th
52
26
27s" arch-alpha" environment? [if] [if]
28 s" loader_version" environment? [if]
29 3 < [if]
30 .( Loader version 0.3+ required) cr
31 abort
32 [then]
33 [else]

--- 11 unchanged lines hidden (view full) ---

45 [else]
46 .( Could not get loader version!) cr
47 abort
48 [then]
49[then] [then]
50
51include /boot/support.4th
52
53only forth definitions also support-functions
54
55\ ***** boot-conf
56\
57\ Prepares to boot as specified by loaded configuration files.
58
53\ ***** boot-conf
54\
55\ Prepares to boot as specified by loaded configuration files.
56
59also support-functions definitions
60
61: set-tempoptions ( addrN lenN ... addr1 len1 N -- addr len 1 | 0 )
62 \ No options, set the default ones
63 dup 0= if
64 s" kernel_options" getenv dup -1 = if
65 drop
66 else
67 s" temp_options" setenv
68 then
69 exit
70 then
71
72 \ Skip filename
73 2 pick
74 c@
75 [char] - <> if
76 swap >r swap >r
77 1 >r \ Filename present
78 1 - \ One less argument
79 else
80 0 >r \ Filename not present
81 then
82
83 \ If no other arguments exist, use default options
84 ?dup 0= if
85 s" kernel_options" getenv dup -1 = if
86 drop
87 else
88 s" temp_options" setenv
89 then
90 \ Put filename back on the stack, if necessary
91 r> if r> r> 1 else 0 then
92 exit
93 then
94
95 \ Concatenate remaining arguments into a single string
96 >r strdup r>
97 1 ?do
98 \ Allocate new buffer
99 2over nip over + 1+
100 allocate if out_of_memory throw then
101 \ Copy old buffer over
102 0 2swap over >r strcat
103 \ Free old buffer
104 r> free if free_error throw then
105 \ Copy a space
106 s" " strcat
107 \ Copy next string (do not free)
108 2swap strcat
109 loop
110
111 \ Set temp_options variable, free whatever memory that needs freeing
112 over >r
113 s" temp_options" setenv
114 r> free if free_error throw then
115
116 \ Put filename back on the stack, if necessary
117 r> if r> r> 1 else 0 then
118;
119
120: get-arguments ( -- addrN lenN ... addr1 len1 N )
121 0
122 begin
123 \ Get next word on the command line
124 parse-word
125 ?dup while
126 2>r ( push to the rstack, so we can retrieve in the correct order )
127 1+
128 repeat
129 drop ( empty string )
130 dup
131 begin
132 dup
133 while
134 2r> rot
135 >r rot r>
136 1 -
137 repeat
138 drop
139;
140
141also builtins
142
143: load-conf ( args 1 | 0 "args" -- flag )
144 0= if ( interpreted ) get-arguments then
145 set-tempoptions
146 s" temp_options" getenv -1 <> if 2swap 2 else 1 then
147 load_kernel_and_modules
148;
149
150only forth also support-functions also builtins definitions
151
152: boot
57only forth also support-functions also builtins definitions
58
59: boot
60 0= if ( interpreted ) get-arguments then
61
153 \ Unload only if a path was passed
62 \ Unload only if a path was passed
154 >in @ parse-word rot >in !
155 if
63 dup if
64 >r over r> swap
156 c@ [char] - <> if
157 0 1 unload drop
158 else
65 c@ [char] - <> if
66 0 1 unload drop
67 else
159 get-arguments 1 boot exit
68 1 boot exit
160 then
161 else
69 then
70 else
162 0 1 boot exit
71 1 boot exit
163 then
164 load-conf
165 ?dup 0= if 0 1 boot then
166;
167
168: boot-conf
72 then
73 load-conf
74 ?dup 0= if 0 1 boot then
75;
76
77: boot-conf
78 0= if ( interpreted ) get-arguments then
169 0 1 unload drop
170 load-conf
171 ?dup 0= if 0 1 autoboot then
172;
173
174also forth definitions also builtins
79 0 1 unload drop
80 load-conf
81 ?dup 0= if 0 1 autoboot then
82;
83
84also forth definitions also builtins
85
175builtin: boot
176builtin: boot-conf
86builtin: boot
87builtin: boot-conf
88
177only forth definitions also support-functions
178
179\ ***** check-password
180\
181\ If a password was defined, execute autoboot and ask for
182\ password if autoboot returns.
183
184: check-password

--- 182 unchanged lines hidden ---
89only forth definitions also support-functions
90
91\ ***** check-password
92\
93\ If a password was defined, execute autoboot and ask for
94\ password if autoboot returns.
95
96: check-password

--- 182 unchanged lines hidden ---