Print this page
11581 'debug' loader option is a little obscure
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Rob Johnston <rob.johnston@joyent.com>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/boot/sys/boot/forth/menu-commands.4th.man.txt
+++ new/usr/src/boot/sys/boot/forth/menu-commands.4th.man.txt
1 1 () ()
2 2
3 3
4 4
5 5 Copyright (c) 2006-2015 Devin Teske <dteske@FreeBSD.org> All rights
6 6 reserved. Redistribution and use in source and binary forms, with or without
7 7 modification, are permitted provided that the following conditions are met:
8 8 1. Redistributions of source code must retain the above copyright notice,
9 9 this list of conditions and the following disclaimer. 2. Redistributions in
10 10 binary form must reproduce the above copyright notice, this list of
11 11 conditions and the following disclaimer in the documentation and/or other
12 12 materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE
13 13 AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
↓ open down ↓ |
13 lines elided |
↑ open up ↑ |
14 14 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
15 15 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
16 16 AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
17 17 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
18 18 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
19 19 OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
20 20 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
21 21 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22 22 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Copyright 2015 Toomas Soome
23 23 <tsoome@me.com> Copyright 2019 OmniOS Community Edition (OmniOSce)
24 -Association.
24 +Association. Copyright 2019 Joyent, Inc.
25 25
26 26 marker task-menu-commands.4th
27 27
28 28 include /boot/forth/menusets.4th
29 29
30 30 only forth definitions
31 31
32 32 variable osconsole_state variable acpi_state variable kernel_state variable
33 -root_state variable kmdb_state variable debug_state 0 kmdb_state ! 0
34 -debug_state ! 0 osconsole_state ! 0 acpi_state ! 0 kernel_state ! 0
35 -root_state !
33 +root_state variable kmdb_state variable drop_into_kmdb_state 0 kmdb_state ! 0
34 +drop_into_kmdb_state ! 0 osconsole_state ! 0 acpi_state ! 0 kernel_state !
35 +0 root_state !
36 36
37 37 also menu-namespace also menu-command-helpers
38 38
39 39 Boot
40 40
41 41 : init_boot ( N -- N ) dup s" smartos" getenv? if s" set
42 42 menu_keycode[N]=98" base command to execute else s"
43 43 boot_single" getenv -1 <> if drop ( n n c-addr -- n n ) unused
44 44 toggle_menuitem ( n n -- n n ) s" set
45 45 menu_keycode[N]=115" base command to execute else s"
46 46 set menu_keycode[N]=98" base command to execute then then 17
47 47 +c! replace 'N' with ASCII numeral evaluate ;
48 48
49 49 Alternate Boot
50 50
51 51 : init_altboot ( N -- N ) dup s" smartos" getenv? if s" set
52 52 menu_keycode[N]=114" base command to execute else s"
53 53 boot_single" getenv -1 <> if drop ( n c-addr -- n ) unused
54 54 toggle_menuitem ( n -- n ) s" set
55 55 menu_keycode[N]=109" base command to execute else s"
56 56 set menu_keycode[N]=115" base command to execute then then
57 57 17 +c! replace 'N' with ASCII numeral evaluate ;
58 58
59 59 : altboot ( N -- NOTREACHED ) s" smartos" getenv? if s" alt-boot-
60 60 args" getenv dup -1 <> if s" boot-args" setenv ( c-addr/u -- )
61 61 then ." NoInstall/Recovery mode boot. login/pw: root/root"
62 62 cr else s" boot_single" 2dup getenv -1 <> if drop (
63 63 c-addr/u c-addr -- c-addr/u ) unused unsetenv ( c-addr/u -- )
64 64 else 2drop ( c-addr/u -- ) unused s"
65 65 set boot_single=YES" evaluate then then 0 boot ( state --
66 66 ) ;
67 67
68 68 Single User Mode
69 69
70 70 : singleuser_enabled? ( -- flag ) s" boot_single" getenv -1 <> dup if
71 71 swap drop ( c-addr flag -- flag ) then ;
72 72
73 73 : singleuser_enable ( -- ) s" set boot_single=YES" evaluate ;
74 74
75 75 : singleuser_disable ( -- ) s" boot_single" unsetenv ;
76 76
77 77 : init_singleuser ( N -- N ) singleuser_enabled? if toggle_menuitem (
78 78 n -- n ) then ;
79 79
80 80 : toggle_singleuser ( N -- N TRUE ) toggle_menuitem menu-redraw
81 81
82 82 Now we're going to make the change effective
83 83
84 84 dup toggle_stateN @ 0= if singleuser_disable else
85 85 singleuser_enable then
86 86
87 87 TRUE loop menu again ;
88 88
89 89 Verbose Boot
90 90
91 91 : verbose_enabled? ( -- flag ) s" boot_verbose" getenv -1 <> dup if
92 92 swap drop ( c-addr flag -- flag ) then ;
93 93
94 94 : verbose_enable ( -- ) s" set boot_verbose=YES" evaluate ;
95 95
96 96 : verbose_disable ( -- ) s" boot_verbose" unsetenv ;
97 97
98 98 : init_verbose ( N -- N ) verbose_enabled? if toggle_menuitem (
99 99 n -- n ) then ;
100 100
101 101 : toggle_verbose ( N -- N TRUE ) toggle_menuitem menu-redraw
102 102
103 103 Now we're going to make the change effective
104 104
105 105 dup toggle_stateN @ 0= if verbose_disable else
106 106 verbose_enable then
↓ open down ↓ |
61 lines elided |
↑ open up ↑ |
107 107
108 108 TRUE loop menu again ;
109 109
110 110 kmdb
111 111
112 112 : kmdb_enabled? ( -- flag ) s" boot_kmdb" getenv -1 <> dup if swap
113 113 drop ( c-addr flag -- flag ) then ;
114 114
115 115 : kmdb_enable ( -- ) s" set boot_kmdb=YES" evaluate ;
116 116
117 -: kmdb_disable ( -- ) s" boot_kmdb" unsetenv s" boot_debug" unsetenv ;
117 +: kmdb_disable ( -- ) s" boot_kmdb" unsetenv s" boot_drop_into_kmdb"
118 +unsetenv ;
118 119
119 120 : init_kmdb ( N -- N ) dup kmdb_state ! store entry number for
120 -kmdb+debug kmdb_enabled? if toggle_menuitem ( n -- n ) then ;
121 +kmdb+drop_into_kmdb kmdb_enabled? if toggle_menuitem ( n -- n )
122 + then ;
121 123
122 124 : toggle_kmdb ( N -- N TRUE ) toggle_menuitem dup toggle_stateN @ 0=
123 -if ( kmdb is not set ) debug_state @ if ( debug is set? )
124 - debug_state @ toggle_stateN @ if ( debug is enabled? )
125 - debug_state @ toggle_menuitem drop then
126 - then then menu-redraw
125 +if ( kmdb is not set ) drop_into_kmdb_state @ if ( drop_into_kmdb is
126 +set? ) drop_into_kmdb_state @ toggle_stateN @ if ( drop_into_kmdb
127 +is enabled? ) drop_into_kmdb_state @ toggle_menuitem drop
128 + then then then menu-redraw
127 129
128 130 Now we're going to make the change effective
129 131
130 132 dup toggle_stateN @ 0= if kmdb_disable else
131 133 kmdb_enable then
132 134
133 135 TRUE loop menu again ;
134 136
135 - kmdb + debug
137 + drop into kmdb
136 138
137 -: debug_disable ( -- ) s" boot_debug" unsetenv ;
139 +: drop_into_kmdb_disable ( -- ) s" boot_drop_into_kmdb" unsetenv ;
138 140
139 -: debug_enabled? ( -- flag ) \[u00A0]-d is only allowed with -k s"
140 -boot_debug" getenv -1 <> kmdb_enabled? and dup if swap drop ( c-addr
141 -flag -- flag ) else debug_disable make sure env is not
142 -set then ;
141 +: drop_into_kmdb_enabled? ( -- flag ) -d is only allowed with -k s"
142 +boot_drop_into_kmdb" getenv -1 <> kmdb_enabled? and dup if swap drop (
143 +c-addr flag -- flag ) else drop_into_kmdb_disable make
144 +sure env is not set then ;
143 145
144 -: debug_enable ( -- ) kmdb_enable s" set boot_debug=YES" evaluate ;
146 +: drop_into_kmdb_enable ( -- ) kmdb_enable s" set
147 +boot_drop_into_kmdb=YES" evaluate ;
145 148
146 -: init_debug ( N -- N ) dup debug_state ! store entry number for kmdb
147 - kmdb_enabled? debug_enabled? and if toggle_menuitem ( n -- n )
148 - then ;
149 +: init_drop_into_kmdb ( N -- N ) dup drop_into_kmdb_state ! store
150 +entry number for kmdb kmdb_enabled? drop_into_kmdb_enabled? and if
151 + toggle_menuitem ( n -- n ) then ;
149 152
150 -: toggle_debug ( N -- N TRUE ) toggle_menuitem kmdb_enabled? 0= if
151 - kmdb_state @ toggle_menuitem drop then menu-redraw
153 +: toggle_drop_into_kmdb ( N -- N TRUE ) toggle_menuitem kmdb_enabled?
154 +0= if kmdb_state @ toggle_menuitem drop then menu-redraw
152 155
153 156 Now we're going to make the change effective
154 157
155 - dup toggle_stateN @ 0= if debug_disable else
156 - debug_enable then
158 + dup toggle_stateN @ 0= if drop_into_kmdb_disable else
159 + drop_into_kmdb_enable then
157 160
158 161 TRUE loop menu again ;
159 162
160 163 Reconfiguration boot
161 164
162 165 : reconfigure_enabled? ( -- flag ) s" boot_reconfigure" getenv -1 <> dup
163 166 if swap drop ( c-addr flag -- flag ) then ;
164 167
165 168 : reconfigure_enable ( -- ) s" set boot_reconfigure=YES" evaluate ;
166 169
167 170 : reconfigure_disable ( -- ) s" boot_reconfigure" unsetenv ;
168 171
169 172 : init_reconfigure ( N -- N ) reconfigure_enabled? if
170 173 toggle_menuitem ( n -- n ) then ;
171 174
172 175 : toggle_reconfigure ( N -- N TRUE ) toggle_menuitem menu-redraw
173 176
174 177 Now we're going to make the change effective
175 178
176 179 dup toggle_stateN @ 0= if reconfigure_disable else
177 180 reconfigure_enable then
178 181
179 182 TRUE loop menu again ;
180 183
181 184 Escape to Prompt
182 185
183 186 : goto_prompt ( N -- N FALSE )
184 187
185 188 s" set autoboot_delay=NO" evaluate
186 189
187 190 cr ." To get back to the menu, type `menu' and press ENTER" cr ."
188 191 or type `boot' and press ENTER to start illumos." cr cr
189 192
190 193 FALSE exit the menu ;
191 194
192 195 Cyclestate (used by osconsole/acpi/kernel/root below)
193 196
194 197 : init_cyclestate ( N K -- N ) over cycle_stateN ( n k -- n k addr )
195 198 begin tuck @ ( n k addr -- n addr k c ) over <> ( n
196 199 addr k c -- n addr k 0|-1 ) while rot ( n addr k -- addr k n )
197 200 cycle_menuitem swap rot ( addr k n -- n k addr ) repeat
198 201 2drop ( n k addr -- n ) ;
199 202
200 203 OS Console getenv os_console, if not set getenv console, if not set, default
201 204 to "text" allowed serial consoles: ttya .. ttyd if new console will be added
202 205 (graphics?), this section needs to be updated : init_osconsole ( N -- N ) s"
203 206 os_console" getenv dup -1 = if drop s" console" getenv dup
204 207 -1 = if drop 0 default to text then then
205 208 ( n c-addr/u | n 0 )
206 209
207 210 dup 0<> if ( n c-addr/u ) 2dup s" ttyd" compare
208 211 0= if 2drop 4 else 2dup s" ttyc" compare 0= if
209 212 2drop 3 else 2dup s" ttyb" compare 0= if
210 213 2drop 2 else 2dup s" ttya" compare 0= if
211 214 2drop 1 else 2drop 0 anything
212 215 else defaults to text then then then then then
213 216 osconsole_state ! ;
214 217
215 218 : activate_osconsole ( N -- N ) dup cycle_stateN @ ( n -- n n2 ) dup
216 219 osconsole_state ! ( n n2 -- n n2 ) copy for re-initialization
217 220
218 221 case 0 of s" text" endof 1 of s" ttya" endof 2 of s" ttyb"
219 222 endof 3 of s" ttyc" endof 4 of s" ttyd" endof dup s" unknown
220 223 state: " type . cr endcase s" os_console" setenv ;
221 224
222 225 : cycle_osconsole ( N -- N TRUE ) cycle_menuitem cycle cycle_stateN to next
223 226 value activate_osconsole apply current cycle_stateN menu-redraw
224 227 redraw menu TRUE loop menu again ;
225 228
226 229 ACPI : init_acpi ( N -- N ) s" acpi-user-options" getenv dup -1 <> if
227 230 evaluate use ?number parse step
228 231
229 232 translate option to cycle state case 1 of 1
230 233 acpi_state ! endof 2 of 2 acpi_state ! endof 4 of 3 acpi_state
231 234 ! endof 8 of 4 acpi_state ! endof 0 acpi_state !
232 235 endcase else drop then ;
233 236
234 237 : activate_acpi ( N -- N ) dup cycle_stateN @ ( n -- n n2 ) dup
235 238 acpi_state ! ( n n2 -- n n2 ) copy for re-initialization
236 239
237 240 if N == 0, it's default, just unset env. dup 0= if drop
238 241 s" acpi-user-options" unsetenv else case 1
239 242 of s" 1" endof 2 of s" 2" endof 3 of s" 4" endof 4
240 243 of s" 8" endof endcase s" acpi-user-options" setenv then ;
241 244
242 245 : cycle_acpi ( N -- N TRUE ) cycle_menuitem cycle cycle_stateN to next value
243 246 activate_acpi apply current cycle_stateN menu-redraw redraw menu
244 247 TRUE loop menu again ;
245 248
246 249 Kernel
247 250
248 251 : init_kernel ( N -- N ) kernel_state @ ( n -- n k ) init_cyclestate (
249 252 n k -- n ) ;
250 253
251 254 : activate_kernel ( N -- N ) dup cycle_stateN @ ( n -- n n2 ) dup
252 255 kernel_state ! ( n n2 -- n n2 ) copy for re-initialization 48 +
253 256 ( n n2 -- n n2' ) kernel_state to ASCII num
254 257
255 258 s" set kernel=${kernel_prefix}${kernel[N]}${kernel_suffix}" 36 +c!
256 259 ( n n2 c-addr/u -- n c-addr/u ) 'N' to ASCII num evaluate ( n
257 260 c-addr/u -- n ) sets $kernel to full kernel-path ;
258 261
259 262 : cycle_kernel ( N -- N TRUE ) cycle_menuitem cycle cycle_stateN to next
260 263 value activate_kernel apply current cycle_stateN menu-redraw redraw
261 264 menu TRUE loop menu again ;
262 265
263 266 Root
264 267
265 268 : init_root ( N -- N ) root_state @ ( n -- n k ) init_cyclestate ( n k
266 269 -- n ) ;
267 270
268 271 : activate_root ( N -- N ) dup cycle_stateN @ ( n -- n n2 ) dup
269 272 root_state ! ( n n2 -- n n2 ) copy for re-initialization 48 +
270 273 ( n n2 -- n n2' ) root_state to ASCII num
271 274
272 275 s" set root=${root_prefix}${root[N]}${root_suffix}" 30 +c! ( n
273 276 n2 c-addr/u -- n c-addr/u ) 'N' to ASCII num evaluate ( n c-addr/u -- n
274 277 ) sets $root to full kernel-path ;
275 278
276 279 : cycle_root ( N -- N TRUE ) cycle_menuitem cycle cycle_stateN to next value
277 280 activate_root apply current cycle_stateN menu-redraw redraw menu
278 281 TRUE loop menu again ;
↓ open down ↓ |
112 lines elided |
↑ open up ↑ |
279 282
280 283 Menusets
281 284
282 285 : goto_menu ( N M -- N TRUE ) menu-unset menuset-loadsetnum ( n m --
283 286 n ) menu-redraw TRUE Loop menu again ;
284 287
285 288 Defaults
286 289
287 290 : unset_boot_options 0 acpi_state ! s" acpi-user-options" unsetenv
288 291 s" boot-args" unsetenv s" boot_ask" unsetenv singleuser_disable
289 - verbose_disable kmdb_disable \[u00A0]disables debug as well
290 - reconfigure_disable ;
292 + verbose_disable kmdb_disable \[u00A0]disables drop_into_kmdb
293 +as well reconfigure_disable ;
291 294
292 295 : set_default_boot_options ( N -- N TRUE ) unset_boot_options 2 goto_menu ;
293 296
294 297 Set boot environment defaults
295 298
296 299
297 300 : init_bootenv ( -- ) s" set
298 301 menu_caption[1]=${bemenu_current}${zfs_be_active}" evaluate s" set
299 302 ansi_caption[1]=${beansi_current}${zfs_be_active}" evaluate s" set
300 303 menu_caption[2]=${bemenu_bootfs}${currdev}" evaluate s" set
301 304 ansi_caption[2]=${beansi_bootfs}${currdev}" evaluate s" set
302 305 menu_caption[3]=${bemenu_page}${zfs_be_currpage}${bemenu_pageof}${zfs_be_pages}"
303 306 evaluate s" set
304 307 ansi_caption[3]=${beansi_page}${zfs_be_currpage}${bemenu_pageof}${zfs_be_pages}"
305 308 evaluate ;
306 309
307 310 Redraw the entire screen. A long BE name can corrupt the menu
308 311
309 312 : be_draw_screen clear Clear the screen (in screen.4th)
310 313 print_version print version string (bottom-right; see version.4th)
311 314 draw-beastie Draw FreeBSD logo at right (in beastie.4th) draw-
312 315 brand Draw brand.4th logo at top (in brand.4th) menu-init Initialize
313 316 menu and draw bounding box (in menu.4th) ;
314 317
315 318 Select a boot environment
316 319
317 320 : set_bootenv ( N -- N TRUE ) dup s" bootenv_root[E]" 13 +c! getenv s"
318 321 currdev" getenv compare 0= if s" zfs_be_active" getenv type ." is
319 322 already active" else dup s" set currdev=${bootenv_root[E]}" 27
320 323 +c! evaluate dup s" bootenvmenu_caption[E]" 20 +c! getenv s"
321 324 zfs_be_active" setenv ." Activating " s" currdev" getenv type cr
322 325 s" unload" evaluate free-module-options
323 326 unset_boot_options s" /boot/defaults/loader.conf" read-conf
324 327 s" /boot/loader.conf" read-conf s" /boot/loader.conf.local"
325 328 read-conf init_bootenv
326 329
327 330 s" 1" s" zfs_be_currpage" setenv s" be-set-page" evaluate
328 331 then
329 332
330 333 500 ms sleep so user can see the message
331 334 be_draw_screen menu-redraw TRUE ;
332 335
333 336 Chainload this entry. Normally we do not return, in case of error from chain
334 337 load, we continue with normal menu code.
335 338
336 339 : set_be_chain ( N -- no return | N TRUE ) dup s" chain ${bootenv_root[E]}"
337 340 21 +c! evaluate catch drop
338 341
339 342 menu-redraw TRUE ;
340 343
341 344 Switch to the next page of boot environments
342 345
343 346 : set_be_page ( N -- N TRUE ) s" zfs_be_currpage" getenv dup -1 = if
344 347 drop s" 1" else s2n 1+ increment the
345 348 page number dup s" zfs_be_pages" getenv s2n > if
346 349 drop 1 then n2s then
347 350
348 351 s" zfs_be_currpage" setenv s" be-set-page" evaluate 3 goto_menu ;
349 352
350 353 only forth definitions
351 354
352 355
353 356
354 357 August 28, 2019 ()
↓ open down ↓ |
54 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX