summaryrefslogtreecommitdiffstats
path: root/share/examples/bootforth
diff options
context:
space:
mode:
authordcs <dcs@FreeBSD.org>1999-05-14 18:06:27 +0000
committerdcs <dcs@FreeBSD.org>1999-05-14 18:06:27 +0000
commitc4a4e43379d03c23d1c1380b5403db2e18bf0c61 (patch)
tree76e39285df4d929f502026d3cc9ea77464085fcb /share/examples/bootforth
parent2e962e0f39a316d8de7e2033c2e4015f92758761 (diff)
downloadFreeBSD-src-c4a4e43379d03c23d1c1380b5403db2e18bf0c61.zip
FreeBSD-src-c4a4e43379d03c23d1c1380b5403db2e18bf0c61.tar.gz
Add a menu example making use of loader.4th(8) facilities.
Merge candidate, as it is just an example...
Diffstat (limited to 'share/examples/bootforth')
-rw-r--r--share/examples/bootforth/README17
-rw-r--r--share/examples/bootforth/loader.rc34
-rw-r--r--share/examples/bootforth/menuconf.4th110
3 files changed, 159 insertions, 2 deletions
diff --git a/share/examples/bootforth/README b/share/examples/bootforth/README
index d86251b..9766d3f 100644
--- a/share/examples/bootforth/README
+++ b/share/examples/bootforth/README
@@ -3,15 +3,21 @@ new bootloader) together with terminal emulation code (available when
compiling /sys/boot/i386/libi386 with -DTERM_EMU).
Normally, you can place the files in /boot as they are here, and they will be
-automatically loaded by /boot/loader.
+automatically loaded by /boot/loader. You must choose between boot.4th or
+loader.rc, though. Copy one or the other, but not both. Also, menu.4th is
+only used by boot.4th, and menuconf.4th is only used by loader.rc, so you
+don't need to copy both files.
The files are:
boot.4th example of file which is always loaded by /boot/loader, if
present in /boot/
+loader.rc example of file which is always loader by /boot/loader, if
+ present in /boot/
screen.4th helpful words for screen manipulation.
frames.4th basic frame drawing primitives. Requires screen.4th.
menu.4th example of simple startup menu.
+menuconf.4th another example of simples startup menu.
You're encouraged to add more features to these files - I'm not a Forth
hacker, unfortunately...
@@ -19,4 +25,11 @@ hacker, unfortunately...
Andrzej Bialecki
<abial@freebsd.org>
-$Id$
+If you use loader.rc/menuconf.4th, be sure to create /boot/stable.conf and
+/boot/current.conf, like described in loader.conf(5), with appropriate
+configuration to distinguish one from the other.
+
+Daniel C. Sobral
+<dcs@freebsd.org>
+
+$Id: README,v 1.1 1998/12/22 12:15:45 abial Exp $
diff --git a/share/examples/bootforth/loader.rc b/share/examples/bootforth/loader.rc
new file mode 100644
index 0000000..b0fd9ca
--- /dev/null
+++ b/share/examples/bootforth/loader.rc
@@ -0,0 +1,34 @@
+\ Example of the file which is automatically loaded by /boot/loader
+\ on startup.
+\ $Id: boot.4th,v 1.1 1998/12/22 12:15:45 abial Exp $
+
+cr .( Loading Forth extensions:)
+
+\ Load configuration file words
+
+cr .( - loader.4th...)
+
+include /boot/loader.4th
+
+\ Load the screen manipulation words
+
+cr .( - screen.4th...)
+s" /boot/screen.4th" fopen dup fload fclose
+
+\ Load frame support
+cr .( - frames.4th...)
+s" /boot/frames.4th" fopen dup fload fclose
+
+\ Load our little menu
+cr .( - menuconf.4th...)
+s" /boot/menuconf.4th" fopen dup fload fclose
+
+\ Initialize loader.4th stuff
+
+cr cr .( Initializing loader.4th...)
+initialize
+
+\ Show the menu
+cr
+main_menu
+
diff --git a/share/examples/bootforth/menuconf.4th b/share/examples/bootforth/menuconf.4th
new file mode 100644
index 0000000..ae053ec
--- /dev/null
+++ b/share/examples/bootforth/menuconf.4th
@@ -0,0 +1,110 @@
+\ Simple greeting screen, presenting basic options.
+\ XXX This is far too trivial - I don't have time now to think
+\ XXX about something more fancy... :-/
+\ $Id$
+
+: title
+ f_single
+ 60 11 10 4 box
+ 29 4 at-xy 15 fg 7 bg
+ ." Welcome to BootFORTH!"
+ me
+;
+
+: menu
+ 2 fg
+ 20 7 at-xy
+ ." 1. Start FreeBSD /boot/stable.conf."
+ 20 8 at-xy
+ ." 2. Start FreeBSD /boot/current.conf."
+ 20 9 at-xy
+ ." 3. Start FreeBSD /boot/loader.rc."
+ 20 10 at-xy
+ ." 4. Reboot."
+ me
+;
+
+: tkey ( d -- flag | char )
+ seconds +
+ begin 1 while
+ dup seconds u< if
+ drop
+ -1
+ exit
+ then
+ key? if
+ drop
+ key
+ exit
+ then
+ repeat
+;
+
+: prompt
+ 14 fg
+ 20 12 at-xy
+ ." Enter your option (1,2,3,4): "
+ 10 tkey
+ dup 32 = if
+ drop key
+ then
+ dup 0< if
+ drop 51
+ then
+ dup emit
+ me
+;
+
+: help_text
+ 10 18 at-xy ." * Choose 1 or 2 to run special configuration file."
+ 10 19 at-xy ." * Choose 3 to proceed with standard bootstrapping."
+ 12 20 at-xy ." See '?' for available commands, and 'words' for"
+ 12 21 at-xy ." complete list of Forth words."
+ 10 22 at-xy ." * Choose 4 in order to warm boot your machine."
+;
+
+: (reboot) 0 reboot ;
+
+: main_menu
+ begin 1 while
+ clear
+ f_double
+ 79 23 1 1 box
+ title
+ menu
+ help_text
+ prompt
+ cr cr cr
+ dup 49 = if
+ drop
+ 1 25 at-xy cr
+ ." Loading /boot/stable.conf. Please wait..." cr
+ s" /boot/stable.conf" read-conf
+ boot-conf
+ then
+ dup 50 = if
+ drop
+ 1 25 at-xy cr
+ ." Loading /boot/current.conf. Please wait..." cr
+ s" /boot/current.conf" read-conf
+ boot-conf
+ then
+ dup 51 = if
+ drop
+ 1 25 at-xy cr
+ ." Proceeding with standard boot. Please wait..." cr
+ boot-conf
+ then
+ dup 52 = if
+ drop
+ 1 25 at-xy cr
+ ['] (reboot) catch abort" Error rebooting"
+ then
+ 20 12 at-xy
+ ." Key " emit ." is not a valid option!"
+ 20 13 at-xy
+ ." Press any key to continue..."
+ key drop
+ repeat
+;
+
OpenPOWER on IntegriCloud