xref: /freebsd/stand/forth/menu-commands.4th (revision ca987d4641cdcd7f27e153db17c5bf064934faf5)
1*ca987d46SWarner Losh\ Copyright (c) 2006-2015 Devin Teske <dteske@FreeBSD.org>
2*ca987d46SWarner Losh\ All rights reserved.
3*ca987d46SWarner Losh\
4*ca987d46SWarner Losh\ Redistribution and use in source and binary forms, with or without
5*ca987d46SWarner Losh\ modification, are permitted provided that the following conditions
6*ca987d46SWarner Losh\ are met:
7*ca987d46SWarner Losh\ 1. Redistributions of source code must retain the above copyright
8*ca987d46SWarner Losh\    notice, this list of conditions and the following disclaimer.
9*ca987d46SWarner Losh\ 2. Redistributions in binary form must reproduce the above copyright
10*ca987d46SWarner Losh\    notice, this list of conditions and the following disclaimer in the
11*ca987d46SWarner Losh\    documentation and/or other materials provided with the distribution.
12*ca987d46SWarner Losh\
13*ca987d46SWarner Losh\ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14*ca987d46SWarner Losh\ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15*ca987d46SWarner Losh\ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16*ca987d46SWarner Losh\ ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17*ca987d46SWarner Losh\ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18*ca987d46SWarner Losh\ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19*ca987d46SWarner Losh\ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20*ca987d46SWarner Losh\ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21*ca987d46SWarner Losh\ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22*ca987d46SWarner Losh\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23*ca987d46SWarner Losh\ SUCH DAMAGE.
24*ca987d46SWarner Losh\
25*ca987d46SWarner Losh\ $FreeBSD$
26*ca987d46SWarner Losh
27*ca987d46SWarner Loshmarker task-menu-commands.4th
28*ca987d46SWarner Losh
29*ca987d46SWarner Loshinclude /boot/menusets.4th
30*ca987d46SWarner Losh
31*ca987d46SWarner Loshonly forth definitions
32*ca987d46SWarner Losh
33*ca987d46SWarner Loshvariable kernel_state
34*ca987d46SWarner Loshvariable root_state
35*ca987d46SWarner Losh0 kernel_state !
36*ca987d46SWarner Losh0 root_state !
37*ca987d46SWarner Losh
38*ca987d46SWarner Loshalso menu-namespace also menu-command-helpers
39*ca987d46SWarner Losh
40*ca987d46SWarner Losh\
41*ca987d46SWarner Losh\ Boot
42*ca987d46SWarner Losh\
43*ca987d46SWarner Losh
44*ca987d46SWarner Losh: init_boot ( N -- N )
45*ca987d46SWarner Losh	dup
46*ca987d46SWarner Losh	s" boot_single" getenv -1 <> if
47*ca987d46SWarner Losh		drop ( n n c-addr -- n n ) \ unused
48*ca987d46SWarner Losh		toggle_menuitem ( n n -- n n )
49*ca987d46SWarner Losh		s" set menu_keycode[N]=115" \ base command to execute
50*ca987d46SWarner Losh	else
51*ca987d46SWarner Losh		s" set menu_keycode[N]=98" \ base command to execute
52*ca987d46SWarner Losh	then
53*ca987d46SWarner Losh	17 +c! \ replace 'N' with ASCII numeral
54*ca987d46SWarner Losh	evaluate
55*ca987d46SWarner Losh;
56*ca987d46SWarner Losh
57*ca987d46SWarner Losh\
58*ca987d46SWarner Losh\ Alternate Boot
59*ca987d46SWarner Losh\
60*ca987d46SWarner Losh
61*ca987d46SWarner Losh: init_altboot ( N -- N )
62*ca987d46SWarner Losh	dup
63*ca987d46SWarner Losh	s" boot_single" getenv -1 <> if
64*ca987d46SWarner Losh		drop ( n c-addr -- n ) \ unused
65*ca987d46SWarner Losh		toggle_menuitem ( n -- n )
66*ca987d46SWarner Losh		s" set menu_keycode[N]=109" \ base command to execute
67*ca987d46SWarner Losh	else
68*ca987d46SWarner Losh		s" set menu_keycode[N]=115" \ base command to execute
69*ca987d46SWarner Losh	then
70*ca987d46SWarner Losh	17 +c! \ replace 'N' with ASCII numeral
71*ca987d46SWarner Losh	evaluate
72*ca987d46SWarner Losh;
73*ca987d46SWarner Losh
74*ca987d46SWarner Losh: altboot ( N -- NOTREACHED )
75*ca987d46SWarner Losh	s" boot_single" 2dup getenv -1 <> if
76*ca987d46SWarner Losh		drop ( c-addr/u c-addr -- c-addr/u ) \ unused
77*ca987d46SWarner Losh		unsetenv ( c-addr/u -- )
78*ca987d46SWarner Losh	else
79*ca987d46SWarner Losh		2drop ( c-addr/u -- ) \ unused
80*ca987d46SWarner Losh		s" set boot_single=YES" evaluate
81*ca987d46SWarner Losh	then
82*ca987d46SWarner Losh	0 boot ( state -- )
83*ca987d46SWarner Losh;
84*ca987d46SWarner Losh
85*ca987d46SWarner Losh\
86*ca987d46SWarner Losh\ ACPI
87*ca987d46SWarner Losh\
88*ca987d46SWarner Losh
89*ca987d46SWarner Losh: acpi_enable ( -- )
90*ca987d46SWarner Losh	s" set acpi_load=YES" evaluate \ XXX deprecated but harmless
91*ca987d46SWarner Losh	s" set hint.acpi.0.disabled=0" evaluate
92*ca987d46SWarner Losh	s" loader.acpi_disabled_by_user" unsetenv
93*ca987d46SWarner Losh;
94*ca987d46SWarner Losh
95*ca987d46SWarner Losh: acpi_disable ( -- )
96*ca987d46SWarner Losh	s" acpi_load" unsetenv \ XXX deprecated but harmless
97*ca987d46SWarner Losh	s" set hint.acpi.0.disabled=1" evaluate
98*ca987d46SWarner Losh	s" set loader.acpi_disabled_by_user=1" evaluate
99*ca987d46SWarner Losh;
100*ca987d46SWarner Losh
101*ca987d46SWarner Losh: toggle_acpi ( N -- N TRUE )
102*ca987d46SWarner Losh
103*ca987d46SWarner Losh	\ Make changes effective _before_ calling menu-redraw
104*ca987d46SWarner Losh
105*ca987d46SWarner Losh	acpienabled? if
106*ca987d46SWarner Losh		acpi_disable
107*ca987d46SWarner Losh	else
108*ca987d46SWarner Losh		acpi_enable
109*ca987d46SWarner Losh	then
110*ca987d46SWarner Losh
111*ca987d46SWarner Losh	menu-redraw
112*ca987d46SWarner Losh
113*ca987d46SWarner Losh	TRUE \ loop menu again
114*ca987d46SWarner Losh;
115*ca987d46SWarner Losh
116*ca987d46SWarner Losh\
117*ca987d46SWarner Losh\ Safe Mode
118*ca987d46SWarner Losh\
119*ca987d46SWarner Losh
120*ca987d46SWarner Losh: safemode_enabled? ( -- flag )
121*ca987d46SWarner Losh	s" kern.smp.disabled" getenv -1 <> dup if
122*ca987d46SWarner Losh		swap drop ( c-addr flag -- flag )
123*ca987d46SWarner Losh	then
124*ca987d46SWarner Losh;
125*ca987d46SWarner Losh
126*ca987d46SWarner Losh: safemode_enable ( -- )
127*ca987d46SWarner Losh	s" set kern.smp.disabled=1" evaluate
128*ca987d46SWarner Losh	s" set hw.ata.ata_dma=0" evaluate
129*ca987d46SWarner Losh	s" set hw.ata.atapi_dma=0" evaluate
130*ca987d46SWarner Losh	s" set hw.ata.wc=0" evaluate
131*ca987d46SWarner Losh	s" set hw.eisa_slots=0" evaluate
132*ca987d46SWarner Losh	s" set kern.eventtimer.periodic=1" evaluate
133*ca987d46SWarner Losh	s" set kern.geom.part.check_integrity=0" evaluate
134*ca987d46SWarner Losh;
135*ca987d46SWarner Losh
136*ca987d46SWarner Losh: safemode_disable ( -- )
137*ca987d46SWarner Losh	s" kern.smp.disabled" unsetenv
138*ca987d46SWarner Losh	s" hw.ata.ata_dma" unsetenv
139*ca987d46SWarner Losh	s" hw.ata.atapi_dma" unsetenv
140*ca987d46SWarner Losh	s" hw.ata.wc" unsetenv
141*ca987d46SWarner Losh	s" hw.eisa_slots" unsetenv
142*ca987d46SWarner Losh	s" kern.eventtimer.periodic" unsetenv
143*ca987d46SWarner Losh	s" kern.geom.part.check_integrity" unsetenv
144*ca987d46SWarner Losh;
145*ca987d46SWarner Losh
146*ca987d46SWarner Losh: init_safemode ( N -- N )
147*ca987d46SWarner Losh	safemode_enabled? if
148*ca987d46SWarner Losh		toggle_menuitem ( n -- n )
149*ca987d46SWarner Losh	then
150*ca987d46SWarner Losh;
151*ca987d46SWarner Losh
152*ca987d46SWarner Losh: toggle_safemode ( N -- N TRUE )
153*ca987d46SWarner Losh	toggle_menuitem
154*ca987d46SWarner Losh
155*ca987d46SWarner Losh	\ Now we're going to make the change effective
156*ca987d46SWarner Losh
157*ca987d46SWarner Losh	dup toggle_stateN @ 0= if
158*ca987d46SWarner Losh		safemode_disable
159*ca987d46SWarner Losh	else
160*ca987d46SWarner Losh		safemode_enable
161*ca987d46SWarner Losh	then
162*ca987d46SWarner Losh
163*ca987d46SWarner Losh	menu-redraw
164*ca987d46SWarner Losh
165*ca987d46SWarner Losh	TRUE \ loop menu again
166*ca987d46SWarner Losh;
167*ca987d46SWarner Losh
168*ca987d46SWarner Losh\
169*ca987d46SWarner Losh\ Single User Mode
170*ca987d46SWarner Losh\
171*ca987d46SWarner Losh
172*ca987d46SWarner Losh: singleuser_enabled? ( -- flag )
173*ca987d46SWarner Losh	s" boot_single" getenv -1 <> dup if
174*ca987d46SWarner Losh		swap drop ( c-addr flag -- flag )
175*ca987d46SWarner Losh	then
176*ca987d46SWarner Losh;
177*ca987d46SWarner Losh
178*ca987d46SWarner Losh: singleuser_enable ( -- )
179*ca987d46SWarner Losh	s" set boot_single=YES" evaluate
180*ca987d46SWarner Losh;
181*ca987d46SWarner Losh
182*ca987d46SWarner Losh: singleuser_disable ( -- )
183*ca987d46SWarner Losh	s" boot_single" unsetenv
184*ca987d46SWarner Losh;
185*ca987d46SWarner Losh
186*ca987d46SWarner Losh: init_singleuser ( N -- N )
187*ca987d46SWarner Losh	singleuser_enabled? if
188*ca987d46SWarner Losh		toggle_menuitem ( n -- n )
189*ca987d46SWarner Losh	then
190*ca987d46SWarner Losh;
191*ca987d46SWarner Losh
192*ca987d46SWarner Losh: toggle_singleuser ( N -- N TRUE )
193*ca987d46SWarner Losh	toggle_menuitem
194*ca987d46SWarner Losh	menu-redraw
195*ca987d46SWarner Losh
196*ca987d46SWarner Losh	\ Now we're going to make the change effective
197*ca987d46SWarner Losh
198*ca987d46SWarner Losh	dup toggle_stateN @ 0= if
199*ca987d46SWarner Losh		singleuser_disable
200*ca987d46SWarner Losh	else
201*ca987d46SWarner Losh		singleuser_enable
202*ca987d46SWarner Losh	then
203*ca987d46SWarner Losh
204*ca987d46SWarner Losh	TRUE \ loop menu again
205*ca987d46SWarner Losh;
206*ca987d46SWarner Losh
207*ca987d46SWarner Losh\
208*ca987d46SWarner Losh\ Verbose Boot
209*ca987d46SWarner Losh\
210*ca987d46SWarner Losh
211*ca987d46SWarner Losh: verbose_enabled? ( -- flag )
212*ca987d46SWarner Losh	s" boot_verbose" getenv -1 <> dup if
213*ca987d46SWarner Losh		swap drop ( c-addr flag -- flag )
214*ca987d46SWarner Losh	then
215*ca987d46SWarner Losh;
216*ca987d46SWarner Losh
217*ca987d46SWarner Losh: verbose_enable ( -- )
218*ca987d46SWarner Losh	s" set boot_verbose=YES" evaluate
219*ca987d46SWarner Losh;
220*ca987d46SWarner Losh
221*ca987d46SWarner Losh: verbose_disable ( -- )
222*ca987d46SWarner Losh	s" boot_verbose" unsetenv
223*ca987d46SWarner Losh;
224*ca987d46SWarner Losh
225*ca987d46SWarner Losh: init_verbose ( N -- N )
226*ca987d46SWarner Losh	verbose_enabled? if
227*ca987d46SWarner Losh		toggle_menuitem ( n -- n )
228*ca987d46SWarner Losh	then
229*ca987d46SWarner Losh;
230*ca987d46SWarner Losh
231*ca987d46SWarner Losh: toggle_verbose ( N -- N TRUE )
232*ca987d46SWarner Losh	toggle_menuitem
233*ca987d46SWarner Losh	menu-redraw
234*ca987d46SWarner Losh
235*ca987d46SWarner Losh	\ Now we're going to make the change effective
236*ca987d46SWarner Losh
237*ca987d46SWarner Losh	dup toggle_stateN @ 0= if
238*ca987d46SWarner Losh		verbose_disable
239*ca987d46SWarner Losh	else
240*ca987d46SWarner Losh		verbose_enable
241*ca987d46SWarner Losh	then
242*ca987d46SWarner Losh
243*ca987d46SWarner Losh	TRUE \ loop menu again
244*ca987d46SWarner Losh;
245*ca987d46SWarner Losh
246*ca987d46SWarner Losh\
247*ca987d46SWarner Losh\ Escape to Prompt
248*ca987d46SWarner Losh\
249*ca987d46SWarner Losh
250*ca987d46SWarner Losh: goto_prompt ( N -- N FALSE )
251*ca987d46SWarner Losh
252*ca987d46SWarner Losh	s" set autoboot_delay=NO" evaluate
253*ca987d46SWarner Losh
254*ca987d46SWarner Losh	cr
255*ca987d46SWarner Losh	." To get back to the menu, type `menu' and press ENTER" cr
256*ca987d46SWarner Losh	." or type `boot' and press ENTER to start FreeBSD." cr
257*ca987d46SWarner Losh	cr
258*ca987d46SWarner Losh
259*ca987d46SWarner Losh	FALSE \ exit the menu
260*ca987d46SWarner Losh;
261*ca987d46SWarner Losh
262*ca987d46SWarner Losh\
263*ca987d46SWarner Losh\ Cyclestate (used by kernel/root below)
264*ca987d46SWarner Losh\
265*ca987d46SWarner Losh
266*ca987d46SWarner Losh: init_cyclestate ( N K -- N )
267*ca987d46SWarner Losh	over cycle_stateN ( n k -- n k addr )
268*ca987d46SWarner Losh	begin
269*ca987d46SWarner Losh		tuck @  ( n k addr -- n addr k c )
270*ca987d46SWarner Losh		over <> ( n addr k c -- n addr k 0|-1 )
271*ca987d46SWarner Losh	while
272*ca987d46SWarner Losh		rot ( n addr k -- addr k n )
273*ca987d46SWarner Losh		cycle_menuitem
274*ca987d46SWarner Losh		swap rot ( addr k n -- n k addr )
275*ca987d46SWarner Losh	repeat
276*ca987d46SWarner Losh	2drop ( n k addr -- n )
277*ca987d46SWarner Losh;
278*ca987d46SWarner Losh
279*ca987d46SWarner Losh\
280*ca987d46SWarner Losh\ Kernel
281*ca987d46SWarner Losh\
282*ca987d46SWarner Losh
283*ca987d46SWarner Losh: init_kernel ( N -- N )
284*ca987d46SWarner Losh	kernel_state @  ( n -- n k )
285*ca987d46SWarner Losh	init_cyclestate ( n k -- n )
286*ca987d46SWarner Losh;
287*ca987d46SWarner Losh
288*ca987d46SWarner Losh: activate_kernel ( N -- N )
289*ca987d46SWarner Losh	dup cycle_stateN @	( n -- n n2 )
290*ca987d46SWarner Losh	dup kernel_state !	( n n2 -- n n2 )  \ copy for re-initialization
291*ca987d46SWarner Losh	48 +			( n n2 -- n n2' ) \ kernel_state to ASCII num
292*ca987d46SWarner Losh
293*ca987d46SWarner Losh	s" set kernel=${kernel_prefix}${kernel[N]}${kernel_suffix}"
294*ca987d46SWarner Losh	36 +c!		( n n2 c-addr/u -- n c-addr/u ) \ 'N' to ASCII num
295*ca987d46SWarner Losh	evaluate	( n c-addr/u -- n ) \ sets $kernel to full kernel-path
296*ca987d46SWarner Losh;
297*ca987d46SWarner Losh
298*ca987d46SWarner Losh: cycle_kernel ( N -- N TRUE )
299*ca987d46SWarner Losh	cycle_menuitem	\ cycle cycle_stateN to next value
300*ca987d46SWarner Losh	activate_kernel \ apply current cycle_stateN
301*ca987d46SWarner Losh	menu-redraw	\ redraw menu
302*ca987d46SWarner Losh	TRUE		\ loop menu again
303*ca987d46SWarner Losh;
304*ca987d46SWarner Losh
305*ca987d46SWarner Losh\
306*ca987d46SWarner Losh\ Root
307*ca987d46SWarner Losh\
308*ca987d46SWarner Losh
309*ca987d46SWarner Losh: init_root ( N -- N )
310*ca987d46SWarner Losh	root_state @    ( n -- n k )
311*ca987d46SWarner Losh	init_cyclestate ( n k -- n )
312*ca987d46SWarner Losh;
313*ca987d46SWarner Losh
314*ca987d46SWarner Losh: activate_root ( N -- N )
315*ca987d46SWarner Losh	dup cycle_stateN @	( n -- n n2 )
316*ca987d46SWarner Losh	dup root_state !	( n n2 -- n n2 )  \ copy for re-initialization
317*ca987d46SWarner Losh	48 +			( n n2 -- n n2' ) \ root_state to ASCII num
318*ca987d46SWarner Losh
319*ca987d46SWarner Losh	s" set root=${root_prefix}${root[N]}${root_suffix}"
320*ca987d46SWarner Losh	30 +c!		( n n2 c-addr/u -- n c-addr/u ) \ 'N' to ASCII num
321*ca987d46SWarner Losh	evaluate	( n c-addr/u -- n ) \ sets $root to full kernel-path
322*ca987d46SWarner Losh;
323*ca987d46SWarner Losh
324*ca987d46SWarner Losh: cycle_root ( N -- N TRUE )
325*ca987d46SWarner Losh	cycle_menuitem	\ cycle cycle_stateN to next value
326*ca987d46SWarner Losh	activate_root	\ apply current cycle_stateN
327*ca987d46SWarner Losh	menu-redraw	\ redraw menu
328*ca987d46SWarner Losh	TRUE		\ loop menu again
329*ca987d46SWarner Losh;
330*ca987d46SWarner Losh
331*ca987d46SWarner Losh\
332*ca987d46SWarner Losh\ Menusets
333*ca987d46SWarner Losh\
334*ca987d46SWarner Losh
335*ca987d46SWarner Losh: goto_menu ( N M -- N TRUE )
336*ca987d46SWarner Losh	menu-unset
337*ca987d46SWarner Losh	menuset-loadsetnum ( n m -- n )
338*ca987d46SWarner Losh	menu-redraw
339*ca987d46SWarner Losh	TRUE \ Loop menu again
340*ca987d46SWarner Losh;
341*ca987d46SWarner Losh
342*ca987d46SWarner Losh\
343*ca987d46SWarner Losh\ Defaults
344*ca987d46SWarner Losh\
345*ca987d46SWarner Losh
346*ca987d46SWarner Losh: set_default_boot_options ( N -- N TRUE )
347*ca987d46SWarner Losh	acpi_enable
348*ca987d46SWarner Losh	safemode_disable
349*ca987d46SWarner Losh	singleuser_disable
350*ca987d46SWarner Losh	verbose_disable
351*ca987d46SWarner Losh	2 goto_menu
352*ca987d46SWarner Losh;
353*ca987d46SWarner Losh
354*ca987d46SWarner Losh\
355*ca987d46SWarner Losh\ Set boot environment defaults
356*ca987d46SWarner Losh\
357*ca987d46SWarner Losh
358*ca987d46SWarner Losh: init_bootenv ( -- )
359*ca987d46SWarner Losh	s" set menu_caption[1]=${bemenu_current}${vfs.root.mountfrom}" evaluate
360*ca987d46SWarner Losh	s" set ansi_caption[1]=${beansi_current}${vfs.root.mountfrom}" evaluate
361*ca987d46SWarner Losh	s" set menu_caption[2]=${bemenu_bootfs}${zfs_be_active}" evaluate
362*ca987d46SWarner Losh	s" set ansi_caption[2]=${beansi_bootfs}${zfs_be_active}" evaluate
363*ca987d46SWarner Losh	s" set menu_caption[3]=${bemenu_page}${zfs_be_currpage}${bemenu_pageof}${zfs_be_pages}" evaluate
364*ca987d46SWarner Losh	s" set ansi_caption[3]=${beansi_page}${zfs_be_currpage}${bemenu_pageof}${zfs_be_pages}" evaluate
365*ca987d46SWarner Losh;
366*ca987d46SWarner Losh
367*ca987d46SWarner Losh\
368*ca987d46SWarner Losh\ Redraw the entire screen. A long BE name can corrupt the menu
369*ca987d46SWarner Losh\
370*ca987d46SWarner Losh
371*ca987d46SWarner Losh: be_draw_screen
372*ca987d46SWarner Losh	clear		\ Clear the screen (in screen.4th)
373*ca987d46SWarner Losh	print_version	\ print version string (bottom-right; see version.4th)
374*ca987d46SWarner Losh	draw-beastie	\ Draw FreeBSD logo at right (in beastie.4th)
375*ca987d46SWarner Losh	draw-brand	\ Draw brand.4th logo at top (in brand.4th)
376*ca987d46SWarner Losh	menu-init	\ Initialize menu and draw bounding box (in menu.4th)
377*ca987d46SWarner Losh;
378*ca987d46SWarner Losh
379*ca987d46SWarner Losh\
380*ca987d46SWarner Losh\ Select a boot environment
381*ca987d46SWarner Losh\
382*ca987d46SWarner Losh
383*ca987d46SWarner Losh: set_bootenv ( N -- N TRUE )
384*ca987d46SWarner Losh	dup s" set vfs.root.mountfrom=${bootenv_root[E]}" 38 +c! evaluate
385*ca987d46SWarner Losh	s" set currdev=${vfs.root.mountfrom}:" evaluate
386*ca987d46SWarner Losh	s" unload" evaluate
387*ca987d46SWarner Losh	free-module-options
388*ca987d46SWarner Losh	s" /boot/defaults/loader.conf" read-conf
389*ca987d46SWarner Losh	s" /boot/loader.conf" read-conf
390*ca987d46SWarner Losh	s" /boot/loader.conf.local" read-conf
391*ca987d46SWarner Losh	init_bootenv
392*ca987d46SWarner Losh	be_draw_screen
393*ca987d46SWarner Losh	menu-redraw
394*ca987d46SWarner Losh	TRUE
395*ca987d46SWarner Losh;
396*ca987d46SWarner Losh
397*ca987d46SWarner Losh\
398*ca987d46SWarner Losh\ Switch to the next page of boot environments
399*ca987d46SWarner Losh\
400*ca987d46SWarner Losh
401*ca987d46SWarner Losh: set_be_page ( N -- N TRUE )
402*ca987d46SWarner Losh	s" zfs_be_currpage" getenv dup -1 = if
403*ca987d46SWarner Losh		drop s" 1"
404*ca987d46SWarner Losh	else
405*ca987d46SWarner Losh		0 s>d 2swap
406*ca987d46SWarner Losh		>number ( ud caddr/u -- ud' caddr'/u' )	\ convert string to numbers
407*ca987d46SWarner Losh		2drop					\ drop the string
408*ca987d46SWarner Losh		1 um/mod ( ud u1 -- u2 u3 ) 		\ convert double ud' to single u3' and remainder u2
409*ca987d46SWarner Losh		swap drop ( ud2 u3 -- u3 )		\ drop the remainder u2
410*ca987d46SWarner Losh		1+					\ increment the page number
411*ca987d46SWarner Losh		s>d <# #s #>				\ convert back to a string
412*ca987d46SWarner Losh	then
413*ca987d46SWarner Losh	s" zfs_be_currpage" setenv
414*ca987d46SWarner Losh	s" reloadbe" evaluate
415*ca987d46SWarner Losh	3 goto_menu
416*ca987d46SWarner Losh;
417*ca987d46SWarner Losh
418*ca987d46SWarner Loshonly forth definitions
419