From 2de24e689e30aa1533466b135b8e7051176f5364 Mon Sep 17 00:00:00 2001
From: "Daniel C. Sobral" <dcs@FreeBSD.org>
Date: Sat, 24 Apr 1999 17:25:35 +0000
Subject: [PATCH] Add loader.4th man page (worst man page I ever wrote --
 reviews are welcomed). Correct a nasty bug in loader.4th before anyone
 notices, add a couple of features.

---
 sys/boot/forth/loader.4th     |  80 ++++++++++++++-
 sys/boot/forth/loader.4th.8   | 182 ++++++++++++++++++++++++++++++++++
 sys/boot/i386/loader/Makefile |   4 +-
 3 files changed, 263 insertions(+), 3 deletions(-)
 create mode 100644 sys/boot/forth/loader.4th.8

diff --git a/sys/boot/forth/loader.4th b/sys/boot/forth/loader.4th
index ef299c618f88..363aab211862 100644
--- a/sys/boot/forth/loader.4th
+++ b/sys/boot/forth/loader.4th
@@ -22,7 +22,7 @@
 \ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 \ SUCH DAMAGE.
 \
-\	$Id$
+\	$Id: loader.4th,v 1.1 1999/03/09 14:06:55 dcs Exp $
 
 include /boot/support.4th
 
@@ -76,6 +76,82 @@ only forth definitions also support-functions
   then
 ; immediate
 
+\ ***** enable-module
+\
+\       Turn a module loading on.
+
+: enable-module ( <module> -- )
+  bl parse module_options @ >r
+  begin
+    r@
+  while
+    2dup
+    r@ module.name dup .addr @ swap .len @
+    compare 0= if
+      2drop
+      r@ module.name dup .addr @ swap .len @ type
+      true r> module.flag !
+      ."  will be loaded." cr
+      exit
+    then
+    r> module.next @ >r
+  repeat
+  r> drop
+  type ."  wasn't found." cr
+;
+
+\ ***** disable-module
+\
+\       Turn a module loading off.
+
+: disable-module ( <module> -- )
+  bl parse module_options @ >r
+  begin
+    r@
+  while
+    2dup
+    r@ module.name dup .addr @ swap .len @
+    compare 0= if
+      2drop
+      r@ module.name dup .addr @ swap .len @ type
+      false r> module.flag !
+      ."  will not be loaded." cr
+      exit
+    then
+    r> module.next @ >r
+  repeat
+  r> drop
+  type ."  wasn't found." cr
+;
+
+\ ***** toggle-module
+\
+\       Turn a module loading on/off.
+
+: toggle-module ( <module> -- )
+  bl parse module_options @ >r
+  begin
+    r@
+  while
+    2dup
+    r@ module.name dup .addr @ swap .len @
+    compare 0= if
+      2drop
+      r@ module.name dup .addr @ swap .len @ type
+      r@ module.flag @ 0= dup r> module.flag !
+      if
+        ."  will be loaded." cr
+      else
+        ."  will not be loaded." cr
+      then
+      exit
+    then
+    r> module.next @ >r
+  repeat
+  r> drop
+  type ."  wasn't found." cr
+;
+
 \ ***** show-module
 \
 \	Show loading information about a module.
@@ -101,6 +177,8 @@ only forth definitions also support-functions
     then
     r> module.next @ >r
   repeat
+  r> drop
+  type ."  wasn't found." cr
 ;
 
 \ Words to be used inside configuration files
diff --git a/sys/boot/forth/loader.4th.8 b/sys/boot/forth/loader.4th.8
new file mode 100644
index 000000000000..15dfc1ed5a8a
--- /dev/null
+++ b/sys/boot/forth/loader.4th.8
@@ -0,0 +1,182 @@
+.\" Copyright (c) 1999 Daniel C. Sobral
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\"	$Id$
+.\"
+.\" Note: The date here should be updated whenever a non-trivial
+.\" change is made to the manual page.
+.Dd April 25, 1999
+.Dt LOADER.4TH 8
+.Os
+.Sh NAME
+.Nm loader.4th
+.Nd loader.conf processing tools
+.Sh DESCRIPTION
+The file that goes by the name of
+.Nm
+is a set of commands designed to manipulate
+.Xr loader.conf 5
+files. The default
+.Pa /boot/loader.rc
+includes
+.Nm
+and uses one of it's commands to automatically read and process
+the standard
+.Xr loader.conf 5
+files. Other commands exists to help the user specify alternate
+configurations.
+.Pp
+The commands of
+.Nm
+by themselves are not enough for most uses. Please refer to the
+examples below for the most common situations, and to
+.Xr loader 8
+for additional commands.
+.Pp
+Before using any of the commands provided in
+.Nm ,
+it must be included
+through the command:
+.Pp
+.Dl include loader.4th
+.Pp
+This line is present on the default
+.Pa /boot/loader.rc
+file, so it isn't needed (and should not be re-issued) in a normal setup.
+.Pp
+The commands provided by it are:
+.Bl -tag -width disable-module_module -offset indent
+.It Ic boot-conf
+Boot as specified by the
+.Xr loader.conf 5
+files read. It uses
+.Ic autoboot ,
+so it can be stopped.
+.It Ic start
+Reads
+.Pa /boot/defaults/loader.conf ,
+all other
+.Xr loader.conf 5
+files specified in it, and then proceeds to boot as specified in them. This
+is command used on the default
+.Pa /boot/loader.rc
+file, and it uses the
+.Pa autoboot
+command (see
+.Xr loader 8 ),
+so it can be stopped for further interaction with
+.Xr loader 8 .
+.It Ic read-conf Ar filename
+Reads and processes a
+.Xr loader.conf 5
+file. Does not proceeds to boot.
+.It Ic enable-module Ar module
+Enables the loading of
+.Ar module .
+.It Ic disable-module Ar module
+Disables the loading of
+.Ar module .
+.It Ic toggle-module Ar module
+Toggles the loading of
+.Ar module
+on and off.
+.It Ic show-module Ar module
+Shows the information gathered in the
+.Xr loader.conf 5
+files about the module
+.Ar module .
+.It Ic retry
+Used inside
+.Xr loader.conf 5
+files to specify the action after a module loading fails.
+.It Ic ignore
+Used inside
+.Xr loader.conf 5
+files to specify the action after a module loading fails.
+.El
+.Sh FILES
+.Bl -tag -width /boot/loader.4th -compact
+.It Pa /boot/loader
+The
+.Xr loader 8 .
+.It Pa /boot/loader.4th
+.Nm
+itself.
+.It Pa /boot/loader.rc
+.Xr loader 8
+bootstrapping script.
+.It Pa /boot/defaults/loader.conf
+File loaded by the
+.Ic start
+command.
+.El
+.Sh EXAMPLES
+Standard
+.Pa /boot/loader.rc :
+.Pp
+.Bd -literal -offset indent -compact
+include /boot/loader.4th
+start
+.Ed
+.Pp
+Loads a different kernel with the standard configuration:
+.Pp
+.Bd -literal -offset indent -compact
+set kernel="kernel.old"
+unload
+boot-conf
+.Ed
+.Pp
+Reads an additional configuration file and then proceeds to boot:
+.Pp
+.Bd -literal -offset indent -compact
+unload
+read-conf /boot/special.conf
+boot-conf
+.Ed
+.Pp
+Disable the loading of the splash screen module and bitmap and then
+proceeds to boot:
+.Pp
+.Bd -literal -offset -indent -compact
+unload
+disable-module splash_bmp
+disable-module bitmap
+boot-conf
+.Ed
+.Pp
+.Sh SEE ALSO
+.Xr loader.conf 5 ,
+.Xr loader 8
+.Sh HISTORY
+.Nm
+first appeared in
+.Fx 3.2 .
+.Sh AUTHORS
+.Nm
+was written by
+.An Daniel C. Sobral Aq dcs@freebsd.org .
+.Sh BUGS
+A british espionage series.
+
diff --git a/sys/boot/i386/loader/Makefile b/sys/boot/i386/loader/Makefile
index 58441a4c1f3c..66810bc6f2fb 100644
--- a/sys/boot/i386/loader/Makefile
+++ b/sys/boot/i386/loader/Makefile
@@ -1,9 +1,9 @@
-# $Id: Makefile,v 1.31 1999/03/15 08:52:23 dcs Exp $
+# $Id: Makefile,v 1.32 1999/04/18 09:21:12 dcs Exp $
 
 BASE=		loader
 PROG=		${BASE}
 MAN5=		loader.conf.5
-MAN8=		loader.8
+MAN8=		loader.8 ../../forth/loader.4th.8
 #NOMAN=
 STRIP=
 NEWVERSWHAT=	"bootstrap loader"