diff options
Diffstat (limited to 'sys/boot')
36 files changed, 3254 insertions, 297 deletions
diff --git a/sys/boot/common/Makefile.inc b/sys/boot/common/Makefile.inc index 9893278..be6c3301 100644 --- a/sys/boot/common/Makefile.inc +++ b/sys/boot/common/Makefile.inc @@ -44,8 +44,15 @@ SRCS+= pnp.c # Forth interpreter .if defined(BOOT_FORTH) SRCS+= interp_forth.c +MAN+= ../forth/beastie.4th.8 +MAN+= ../forth/brand.4th.8 +MAN+= ../forth/check-password.4th.8 +MAN+= ../forth/color.4th.8 +MAN+= ../forth/delay.4th.8 MAN+= ../forth/loader.conf.5 MAN+= ../forth/loader.4th.8 +MAN+= ../forth/menu.4th.8 +MAN+= ../forth/version.4th.8 .endif .if defined(BOOT_PROMPT_123) diff --git a/sys/boot/common/load_elf_obj.c b/sys/boot/common/load_elf_obj.c index dcd71ef..54d9b10 100644 --- a/sys/boot/common/load_elf_obj.c +++ b/sys/boot/common/load_elf_obj.c @@ -196,7 +196,7 @@ static int __elfN(obj_loadimage)(struct preloaded_file *fp, elf_file_t ef, u_int64_t off) { Elf_Ehdr *hdr; - Elf_Shdr *shdr; + Elf_Shdr *shdr, *cshdr, *lshdr; vm_offset_t firstaddr, lastaddr; int i, nsym, res, ret, shdrbytes, symstrindex; @@ -294,12 +294,35 @@ __elfN(obj_loadimage)(struct preloaded_file *fp, elf_file_t ef, u_int64_t off) /* Clear the whole area, including bss regions. */ kern_bzero(firstaddr, lastaddr - firstaddr); - /* Now read it all in. */ - for (i = 0; i < hdr->e_shnum; i++) { - if (shdr[i].sh_addr == 0 || shdr[i].sh_type == SHT_NOBITS) - continue; - if (kern_pread(ef->fd, (vm_offset_t)shdr[i].sh_addr, - shdr[i].sh_size, (off_t)shdr[i].sh_offset) != 0) { + /* Figure section with the lowest file offset we haven't loaded yet. */ + for (cshdr = NULL; /* none */; /* none */) + { + /* + * Find next section to load. The complexity of this loop is + * O(n^2), but with the number of sections being typically + * small, we do not care. + */ + lshdr = cshdr; + + for (i = 0; i < hdr->e_shnum; i++) { + if (shdr[i].sh_addr == 0 || + shdr[i].sh_type == SHT_NOBITS) + continue; + /* Skip sections that were loaded already. */ + if (lshdr != NULL && + lshdr->sh_offset >= shdr[i].sh_offset) + continue; + /* Find section with smallest offset. */ + if (cshdr == lshdr || + cshdr->sh_offset > shdr[i].sh_offset) + cshdr = &shdr[i]; + } + + if (cshdr == lshdr) + break; + + if (kern_pread(ef->fd, (vm_offset_t)cshdr->sh_addr, + cshdr->sh_size, (off_t)cshdr->sh_offset) != 0) { printf("\nelf" __XSTRING(__ELF_WORD_SIZE) "_obj_loadimage: read failed\n"); goto out; diff --git a/sys/boot/forth/beastie.4th b/sys/boot/forth/beastie.4th index 1130ed0..75d6e02 100644 --- a/sys/boot/forth/beastie.4th +++ b/sys/boot/forth/beastie.4th @@ -1,7 +1,8 @@ \ Copyright (c) 2003 Scott Long <scottl@freebsd.org> \ Copyright (c) 2003 Aleksander Fafula <alex@fafula.com> +\ Copyright (c) 2006-2011 Devin Teske <devinteske@hotmail.com> \ All rights reserved. -\ +\ \ Redistribution and use in source and binary forms, with or without \ modification, are permitted provided that the following conditions \ are met: @@ -10,7 +11,7 @@ \ 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 @@ -22,35 +23,24 @@ \ 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. -\ +\ \ $FreeBSD$ marker task-beastie.4th -include /boot/screen.4th -include /boot/frames.4th +include /boot/color.4th +include /boot/delay.4th -hide +variable logoX +variable logoY -variable menuidx -variable menubllt -variable menuX -variable menuY -variable promptwidth +\ Initialize logo placement to defaults +46 logoX ! +4 logoY ! -variable bootkey -variable bootacpikey -variable bootsafekey -variable bootverbosekey -variable bootsinglekey -variable escapekey -variable rebootkey +: beastie-logo ( x y -- ) \ color BSD mascot (19 rows x 34 columns) -46 constant dot - -\ The BSD Daemon. He is 19 rows high and 34 columns wide -: beastie-logo ( x y -- ) -2dup at-xy ." [1;31m, ," 1+ +2dup at-xy ." [31m, ," 1+ 2dup at-xy ." /( )`" 1+ 2dup at-xy ." \ \___ / |" 1+ 2dup at-xy ." /- [37m_[31m `-/ '" 1+ @@ -59,7 +49,7 @@ variable rebootkey 2dup at-xy ." [34mO O [37m) [31m/ |" 1+ 2dup at-xy ." [37m`-^--'[31m`< '" 1+ 2dup at-xy ." (_.) _ ) /" 1+ -2dup at-xy ." `.___/` / " 1+ +2dup at-xy ." `.___/` /" 1+ 2dup at-xy ." `-----' /" 1+ 2dup at-xy ." [33m<----.[31m __ / __ \" 1+ 2dup at-xy ." [33m<----|====[31mO)))[33m==[31m) \) /[33m====|" 1+ @@ -68,173 +58,201 @@ variable rebootkey 2dup at-xy ." \ / /\" 1+ 2dup at-xy ." [36m______[31m( (_ / \______/" 1+ 2dup at-xy ." [36m,' ,-----' |" 1+ -at-xy ." `--{__________) [0m" + at-xy ." `--{__________)[37m" + + \ Put the cursor back at the bottom + 0 25 at-xy ; -: beastiebw-logo ( x y -- ) - 2dup at-xy ." , ," 1+ - 2dup at-xy ." /( )`" 1+ - 2dup at-xy ." \ \___ / |" 1+ - 2dup at-xy ." /- _ `-/ '" 1+ - 2dup at-xy ." (/\/ \ \ /\" 1+ - 2dup at-xy ." / / | ` \" 1+ - 2dup at-xy ." O O ) / |" 1+ - 2dup at-xy ." `-^--'`< '" 1+ - 2dup at-xy ." (_.) _ ) /" 1+ - 2dup at-xy ." `.___/` /" 1+ - 2dup at-xy ." `-----' /" 1+ - 2dup at-xy ." <----. __ / __ \" 1+ - 2dup at-xy ." <----|====O)))==) \) /====" 1+ - 2dup at-xy ." <----' `--' `.__,' \" 1+ - 2dup at-xy ." | |" 1+ - 2dup at-xy ." \ / /\" 1+ - 2dup at-xy ." ______( (_ / \______/" 1+ - 2dup at-xy ." ,' ,-----' |" 1+ - at-xy ." `--{__________)" +: beastiebw-logo ( x y -- ) \ B/W BSD mascot (19 rows x 34 columns) + + 2dup at-xy ." , ," 1+ + 2dup at-xy ." /( )`" 1+ + 2dup at-xy ." \ \___ / |" 1+ + 2dup at-xy ." /- _ `-/ '" 1+ + 2dup at-xy ." (/\/ \ \ /\" 1+ + 2dup at-xy ." / / | ` \" 1+ + 2dup at-xy ." O O ) / |" 1+ + 2dup at-xy ." `-^--'`< '" 1+ + 2dup at-xy ." (_.) _ ) /" 1+ + 2dup at-xy ." `.___/` /" 1+ + 2dup at-xy ." `-----' /" 1+ + 2dup at-xy ." <----. __ / __ \" 1+ + 2dup at-xy ." <----|====O)))==) \) /====|" 1+ + 2dup at-xy ." <----' `--' `.__,' \" 1+ + 2dup at-xy ." | |" 1+ + 2dup at-xy ." \ / /\" 1+ + 2dup at-xy ." ______( (_ / \______/" 1+ + 2dup at-xy ." ,' ,-----' |" 1+ + at-xy ." `--{__________)" + + \ Put the cursor back at the bottom + 0 25 at-xy ; -: fbsdbw-logo ( x y -- ) - 2dup at-xy ." ______" 1+ - 2dup at-xy ." | ____| __ ___ ___ " 1+ - 2dup at-xy ." | |__ | '__/ _ \/ _ \" 1+ - 2dup at-xy ." | __|| | | __/ __/" 1+ - 2dup at-xy ." | | | | | | |" 1+ - 2dup at-xy ." |_| |_| \___|\___|" 1+ - 2dup at-xy ." ____ _____ _____" 1+ - 2dup at-xy ." | _ \ / ____| __ \" 1+ - 2dup at-xy ." | |_) | (___ | | | |" 1+ - 2dup at-xy ." | _ < \___ \| | | |" 1+ - 2dup at-xy ." | |_) |____) | |__| |" 1+ - 2dup at-xy ." | | | |" 1+ - at-xy ." |____/|_____/|_____/" +: fbsdbw-logo ( x y -- ) \ "FreeBSD" logo in B/W (13 rows x 21 columns) + + \ We used to use the beastie himself as our default... until the + \ eventual complaint derided his reign of the advanced boot-menu. + \ + \ This is the replacement of beastie to satiate the haters of our + \ beloved helper-daemon (ready to track down and spear bugs with + \ his trident and sporty sneakers; see above). + \ + \ Since we merely just changed the default and not the default- + \ location, below is an adjustment to the passed-in coordinates, + \ forever influenced by the proper location of beastie himself + \ kept as the default loader_logo_x/loader_logo_y values. + \ + 5 + swap 6 + swap + + 2dup at-xy ." ______" 1+ + 2dup at-xy ." | ____| __ ___ ___ " 1+ + 2dup at-xy ." | |__ | '__/ _ \/ _ \" 1+ + 2dup at-xy ." | __|| | | __/ __/" 1+ + 2dup at-xy ." | | | | | | |" 1+ + 2dup at-xy ." |_| |_| \___|\___|" 1+ + 2dup at-xy ." ____ _____ _____" 1+ + 2dup at-xy ." | _ \ / ____| __ \" 1+ + 2dup at-xy ." | |_) | (___ | | | |" 1+ + 2dup at-xy ." | _ < \___ \| | | |" 1+ + 2dup at-xy ." | |_) |____) | |__| |" 1+ + 2dup at-xy ." | | | |" 1+ + at-xy ." |____/|_____/|_____/" + + \ Put the cursor back at the bottom + 0 25 at-xy ; -: print-logo ( x y -- ) - s" loader_logo" getenv - dup -1 = if - drop - fbsdbw-logo - exit - then - 2dup s" fbsdbw" compare-insensitive 0= if - 2drop - fbsdbw-logo - exit - then - 2dup s" beastiebw" compare-insensitive 0= if - 2drop - beastiebw-logo - exit - then - 2dup s" beastie" compare-insensitive 0= if - 2drop - beastie-logo - exit - then - 2dup s" none" compare-insensitive 0= if - 2drop - \ no logo - exit - then - 2drop - fbsdbw-logo +: orb-logo ( x y -- ) \ color Orb mascot (15 rows x 30 columns) + + 3 + \ beastie adjustment (see `fbsdbw-logo' comments above) + + 2dup at-xy ." [31m``` [31;1m`[31m" 1+ + 2dup at-xy ." s` `.....---...[31;1m....--.``` -/[31m" 1+ + 2dup at-xy ." +o .--` [31;1m/y:` +.[31m" 1+ + 2dup at-xy ." yo`:. [31;1m:o `+-[31m" 1+ + 2dup at-xy ." y/ [31;1m-/` -o/[31m" 1+ + 2dup at-xy ." .- [31;1m::/sy+:.[31m" 1+ + 2dup at-xy ." / [31;1m`-- /[31m" 1+ + 2dup at-xy ." `: [31;1m:`[31m" 1+ + 2dup at-xy ." `: [31;1m:`[31m" 1+ + 2dup at-xy ." / [31;1m/[31m" 1+ + 2dup at-xy ." .- [31;1m-.[31m" 1+ + 2dup at-xy ." -- [31;1m-.[31m" 1+ + 2dup at-xy ." `:` [31;1m`:`" 1+ + 2dup at-xy ." [31;1m.-- `--." 1+ + at-xy ." .---.....----.[37m" + + \ Put the cursor back at the bottom + 0 25 at-xy ; -: acpipresent? ( -- flag ) - s" hint.acpi.0.rsdp" getenv - dup -1 = if - drop false exit - then - 2drop - true +: orbbw-logo ( x y -- ) \ B/W Orb mascot (15 rows x 32 columns) + + 3 + \ beastie adjustment (see `fbsdbw-logo' comments above) + + 2dup at-xy ." ``` `" 1+ + 2dup at-xy ." s` `.....---.......--.``` -/" 1+ + 2dup at-xy ." +o .--` /y:` +." 1+ + 2dup at-xy ." yo`:. :o `+-" 1+ + 2dup at-xy ." y/ -/` -o/" 1+ + 2dup at-xy ." .- ::/sy+:." 1+ + 2dup at-xy ." / `-- /" 1+ + 2dup at-xy ." `: :`" 1+ + 2dup at-xy ." `: :`" 1+ + 2dup at-xy ." / /" 1+ + 2dup at-xy ." .- -." 1+ + 2dup at-xy ." -- -." 1+ + 2dup at-xy ." `:` `:`" 1+ + 2dup at-xy ." .-- `--." 1+ + at-xy ." .---.....----." + + \ Put the cursor back at the bottom + 0 25 at-xy ; -: acpienabled? ( -- flag ) - s" hint.acpi.0.disabled" getenv - dup -1 <> if - s" 0" compare 0<> if - false exit - then +\ This function draws any number of beastie logos at (loader_logo_x, +\ loader_logo_y) if defined, else (46,4) (to the right of the menu). To choose +\ your beastie, set the variable `loader_logo' to the respective logo name. +\ +\ Currently available: +\ +\ NAME DESCRIPTION +\ beastie Color ``Helper Daemon'' mascot (19 rows x 34 columns) +\ beastiebw B/W ``Helper Daemon'' mascot (19 rows x 34 columns) +\ fbsdbw "FreeBSD" logo in B/W (13 rows x 21 columns) +\ orb Color ``Orb'' mascot (15 rows x 30 columns) +\ orbbw B/W ``Orb'' mascot (15 rows x 32 columns) (default) +\ +\ NOTE: Setting `loader_logo' to an undefined value (such as "none") will +\ prevent beastie from being drawn. +\ +: draw-beastie ( -- ) \ at (loader_logo_x,loader_logo_y), else (46,4) + + s" loader_logo_x" getenv dup -1 <> if + ?number 1 = if logoX ! then else drop then - true -; - -: printmenuitem ( -- n ) - menuidx @ - 1+ dup - menuidx ! - menuY @ + dup menuX @ swap at-xy - menuidx @ . - menuX @ 1+ swap at-xy - menubllt @ emit - menuidx @ 48 + -; - -: beastie-menu ( -- ) - 0 menuidx ! - dot menubllt ! - 8 menuY ! - 5 menuX ! - clear - 46 4 print-logo - 42 20 2 2 box - 13 6 at-xy ." Welcome to FreeBSD!" - printmenuitem ." Boot FreeBSD [default]" bootkey ! - s" arch-i386" environment? if + s" loader_logo_y" getenv dup -1 <> if + ?number 1 = if logoY ! then + else drop - acpipresent? if - printmenuitem ." Boot FreeBSD with ACPI " bootacpikey ! - acpienabled? if - ." disabled" - else - ." enabled" - then + then + + s" loader_logo" getenv dup -1 = if + logoX @ logoY @ + loader_color? if + orb-logo else - menuidx @ - 1+ - menuidx ! - -2 bootacpikey ! + orbbw-logo then - else - -2 bootacpikey ! + drop exit then - printmenuitem ." Boot FreeBSD in Safe Mode" bootsafekey ! - printmenuitem ." Boot FreeBSD in single user mode" bootsinglekey ! - printmenuitem ." Boot FreeBSD with verbose logging" bootverbosekey ! - printmenuitem ." Escape to loader prompt" escapekey ! - printmenuitem ." Reboot" rebootkey ! - menuX @ 20 at-xy - ." Select option, [Enter] for default" - menuX @ 21 at-xy - s" or [Space] to pause timer " dup 2 - promptwidth ! - type -; -: tkey - seconds + - begin 1 while - over 0<> if - dup seconds u< if - drop - -1 - exit - then - menuX @ promptwidth @ + 21 at-xy dup seconds - . - then - key? if - drop - key - exit - then - 50 ms - repeat + 2dup s" beastie" compare-insensitive 0= if + logoX @ logoY @ beastie-logo + 2drop exit + then + 2dup s" beastiebw" compare-insensitive 0= if + logoX @ logoY @ beastiebw-logo + 2drop exit + then + 2dup s" fbsdbw" compare-insensitive 0= if + logoX @ logoY @ fbsdbw-logo + 2drop exit + then + 2dup s" orb" compare-insensitive 0= if + logoX @ logoY @ orb-logo + 2drop exit + then + 2dup s" orbbw" compare-insensitive 0= if + logoX @ logoY @ orbbw-logo + 2drop exit + then + + 2drop ; -set-current +: clear-beastie ( -- ) \ clears beastie from the screen + logoX @ logoY @ + 2dup at-xy 34 spaces 1+ 2dup at-xy 34 spaces 1+ + 2dup at-xy 34 spaces 1+ 2dup at-xy 34 spaces 1+ + 2dup at-xy 34 spaces 1+ 2dup at-xy 34 spaces 1+ + 2dup at-xy 34 spaces 1+ 2dup at-xy 34 spaces 1+ + 2dup at-xy 34 spaces 1+ 2dup at-xy 34 spaces 1+ + 2dup at-xy 34 spaces 1+ 2dup at-xy 34 spaces 1+ + 2dup at-xy 34 spaces 1+ 2dup at-xy 34 spaces 1+ + 2dup at-xy 34 spaces 1+ 2dup at-xy 34 spaces 1+ + 2dup at-xy 34 spaces 1+ 2dup at-xy 34 spaces 1+ + 2dup at-xy 34 spaces 2drop + + \ Put the cursor back at the bottom + 0 25 at-xy +; -: beastie-start +: beastie-start ( -- ) \ starts the menu s" beastie_disable" getenv dup -1 <> if s" YES" compare-insensitive 0= if @@ -243,62 +261,15 @@ set-current else drop then - beastie-menu - s" autoboot_delay" getenv - dup -1 = if - drop - 10 + + s" loader_delay" getenv + -1 = if + s" include /boot/menu.rc" evaluate else - 2dup s" -1" compare 0= if - 0 boot - then - 0 s>d 2swap >number 2drop drop + drop + ." Loading Menu (Ctrl-C to Abort)" cr + s" set delay_command='include /boot/menu.rc'" evaluate + s" set delay_showdots" evaluate + delay_execute then - begin - dup tkey - 0 25 at-xy - dup 32 = if nip 0 swap then - dup -1 = if 0 boot then - dup 13 = if 0 boot then - dup bootkey @ = if 0 boot then - dup bootacpikey @ = if - acpienabled? if - s" 1" s" hint.acpi.0.disabled" setenv - s" 1" s" loader.acpi_disabled_by_user" setenv - else - s" 0" s" hint.acpi.0.disabled" setenv - then - 0 boot - then - dup bootsafekey @ = if - s" arch-i386" environment? if - drop - s" 1" s" hint.acpi.0.disabled" setenv - s" 1" s" loader.acpi_disabled_by_user" setenv - s" 1" s" hint.apic.0.disabled" setenv - then - s" 0" s" hw.ata.ata_dma" setenv - s" 0" s" hw.ata.atapi_dma" setenv - s" 0" s" hw.ata.wc" setenv - s" 0" s" hw.eisa_slots" setenv - s" 1" s" hint.kbdmux.0.disabled" setenv - 0 boot - then - dup bootverbosekey @ = if - s" YES" s" boot_verbose" setenv - 0 boot - then - dup bootsinglekey @ = if - s" YES" s" boot_single" setenv - 0 boot - then - dup escapekey @ = if - 2drop - s" NO" s" autoboot_delay" setenv - exit - then - rebootkey @ = if 0 reboot then - again ; - -previous diff --git a/sys/boot/forth/beastie.4th.8 b/sys/boot/forth/beastie.4th.8 new file mode 100644 index 0000000..5108769 --- /dev/null +++ b/sys/boot/forth/beastie.4th.8 @@ -0,0 +1,171 @@ +.\" Copyright (c) 2011 Devin Teske +.\" 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. +.\" +.\" $FreeBSD$ +.\" +.Dd May 16, 2011 +.Dt BEASTIE.4TH 8 +.Os +.Sh NAME +.Nm beastie.4th +.Nd FreeBSD ASCII art boot module. +.Sh DESCRIPTION +The file that goes by the name of +.Nm +is a set of commands designed to draw the ASCII art FreeBSD mascot +.Nd known simply as +.Ic beastie +.Nd to the right of the boot loader menu. +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 beastie.4th +.Pp +This line is present in the default +.Pa /boot/loader.rc +file, so it is not needed (and should not be re-issued) in a normal setup. +.Pp +The commands provided by it are: +.Pp +.Bl -tag -width disable-module_module -compact -offset indent +.It Ic draw-beastie +Draws the FreeBSD logo. +.Pp +The logo that is drawn is configured by setting the +.Ic loader_logo +variable in +.Xr loader.conf 5 +to one of +.Dq Li beastie , +.Dq Li beastiebw , +.Dq Li fbsdbw , +.Dq Li orb , +and +.Dq Li orbbw +(the default). +.Pp +The position of the logo can be configured by setting the +.Ic loader_logo_x +and +.Ic loader_logo_y +variables in +.Xr loader.conf 5 . +The default values are 46 (x) and 4 (y). +.Pp +.It Ic clear-beastie +Clears the screen of beastie. +.Pp +.It Ic beastie-start +Initializes the interactive boot loader menu. +.Pp +The +.Ic loader_delay +variable can be configured in +.Xr loader.conf 5 +to the number of seconds you would like to delay loading the boot menu. +During the delay the user can press Ctrl-C to fall back to autoboot or ENTER +to proceed. +The default behavior is to not delay. +.El +.Pp +The environment variables that effect its behavior are: +.Bl -tag -width bootfile -offset indent +.It Va loader_logo +Selects the desired logo in the beastie boot menu. Possible values are: +.Dq Li fbsdbw , +.Dq Li beastie , +.Dq Li beastiebw , +.Dq Li orb , +.Dq Li orbbw +(default), and +.Dq Li none . +.It Va loader_logo_x +Sets the desired column position of the logo. Default is 46. +.It Va loader_logo_y +Sets the desired row position of the logo. Default is 4. +.It Va beastie_disable +If set to +.Dq YES , +the beastie boot menu will be skipped. +.It Va loader_delay +If set to a number higher than zero, introduces a delay before starting the +beastie boot menu. During the delay the user can press either Ctrl-C to skip +the menu or ENTER to proceed to the menu. The default is to not delay when +loading the menu. +.El +.Sh FILES +.Bl -tag -width /boot/loader.4th -compact +.It Pa /boot/loader +The +.Xr loader 8 . +.It Pa /boot/beastie.4th +.Nm +itself. +.It Pa /boot/loader.rc +.Xr loader 8 +bootstrapping script. +.El +.Sh EXAMPLES +Standard i386 +.Pa /boot/loader.rc : +.Pp +.Bd -literal -offset indent -compact +include /boot/beastie.4th +beastie-start +.Ed +.Pp +Set a different logo in +.Xr loader.conf 5 : +.Pp +.Bd -literal -offset indent -compact +loader_logo="beastie" +.Ed +.Sh SEE ALSO +.Xr loader.conf 5 , +.Xr loader 8 , +.Xr loader.4th 8 +.Sh HISTORY +The +.Nm +set of commands first appeared in +.Fx 5.1 . +.Sh AUTHORS +The +.Nm +set of commands was written by +.An -nosplit +.An Scott Long Aq scottl@FreeBSD.org , +.An Aleksander Fafula Aq alex@fafula.com +and +.An Devin Teske Aq devinteske@hotmail.com . diff --git a/sys/boot/forth/brand.4th b/sys/boot/forth/brand.4th new file mode 100644 index 0000000..bc64174 --- /dev/null +++ b/sys/boot/forth/brand.4th @@ -0,0 +1,91 @@ +\ Copyright (c) 2006-2011 Devin Teske <devinteske@hotmail.com> +\ 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. +\ +\ $FreeBSD$ + +marker task-brand.4th + +variable brandX +variable brandY + +\ Initialize logo placement +2 brandX ! +1 brandY ! + +: fbsd-logo ( x y -- ) \ "FreeBSD" [wide] logo in B/W (7 rows x 42 columns) + + 2dup at-xy ." ______ ____ _____ _____ " 1+ + 2dup at-xy ." | ____| | _ \ / ____| __ \ " 1+ + 2dup at-xy ." | |___ _ __ ___ ___ | |_) | (___ | | | |" 1+ + 2dup at-xy ." | ___| '__/ _ \/ _ \| _ < \___ \| | | |" 1+ + 2dup at-xy ." | | | | | __/ __/| |_) |____) | |__| |" 1+ + 2dup at-xy ." | | | | | | || | | |" 1+ + at-xy ." |_| |_| \___|\___||____/|_____/|_____/ " + + \ Put the cursor back at the bottom + 0 25 at-xy +; + +\ This function draws any number of company logos at (loader_brand_x, +\ loader_brand_y) if defined, or (2,1) (top-left) if not defined. To choose +\ your logo, set the variable `loader_brand' to the respective logo name. +\ +\ Currently available: +\ +\ NAME DESCRIPTION +\ fbsd FreeBSD logo +\ +\ NOTE: Setting `loader_brand' to an undefined value (such as "none") will +\ prevent any brand from being drawn. +\ +: draw-brand ( -- ) + + s" loader_brand_x" getenv dup -1 <> if + ?number 1 = if + brandX ! + then + else + drop + then + + s" loader_brand_y" getenv dup -1 <> if + ?number 1 = if + brandY ! + then + else + drop + then + + s" loader_brand" getenv dup -1 = if + brandX @ brandY @ fbsd-logo + drop exit + then + + 2dup s" fbsd" compare-insensitive 0= if + brandX @ brandY @ fbsd-logo + 2drop exit + then + + 2drop +; diff --git a/sys/boot/forth/brand.4th.8 b/sys/boot/forth/brand.4th.8 new file mode 100644 index 0000000..1a1cc84 --- /dev/null +++ b/sys/boot/forth/brand.4th.8 @@ -0,0 +1,125 @@ +.\" Copyright (c) 2011 Devin Teske +.\" 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. +.\" +.\" $FreeBSD$ +.\" +.Dd May 18, 2011 +.Dt BRAND.4TH 8 +.Os +.Sh NAME +.Nm brand.4th +.Nd FreeBSD ASCII art boot module. +.Sh DESCRIPTION +The file that goes by the name of +.Nm +is a set of commands designed to draw the ASCII art BSD brand above the boot +loader menu. +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 brand.4th +.Pp +This line is present in the default +.Pa /boot/menu.rc +file, so it is not needed (and should not be re-issued) in a normal setup. +.Pp +The commands provided by it are: +.Pp +.Bl -tag -width disable-module_module -compact -offset indent +.It Ic draw-brand +Draws the BSD brand. +.Pp +The brand that is drawn is configured by setting the +.Ic loader_brand +variable in +.Xr loader.conf 5 +to one of +.Dq Li fbsd +(the default) or +.Dq Li none . +.Pp +The position of the logo can be configured by setting the +.Ic loader_brand_x +and +.Ic loader_brand_y +variables in +.Xr loader.conf 5 . +The default values are 2 (x) and 1 (y). +.El +.Pp +The environment variables that effect its behavior are: +.Bl -tag -width bootfile -offset indent +.It Va loader_brand +Selects the desired brand in the beastie boot menu. Possible values are: +.Dq Li fbsd +(default) or +.Dq Li none . +.It Va loader_brand_x +Sets the desired column position of the brand. Default is 2. +.It Va loader_brand_y +Sets the desired row position of the brand. Default is 1. +.El +.Sh FILES +.Bl -tag -width /boot/loader.4th -compact +.It Pa /boot/loader +The +.Xr loader 8 . +.It Pa /boot/brand.4th +.Nm +itself. +.It Pa /boot/loader.rc +.Xr loader 8 +bootstrapping script. +.El +.Sh EXAMPLES +Set FreeBSD brand in +.Xr loader.conf 5 : +.Pp +.Bd -literal -offset indent -compact +loader_brand="fbsd" +.Ed +.Sh SEE ALSO +.Xr loader.conf 5 , +.Xr loader 8 , +.Sh HISTORY +The +.Nm +set of commands first appeared in +.Fx 9.0 . +.Sh AUTHORS +The +.Nm +set of commands was written by +.An -nosplit +.An Devin Teske Aq devinteske@hotmail.com . diff --git a/sys/boot/forth/check-password.4th b/sys/boot/forth/check-password.4th new file mode 100644 index 0000000..0a1fa5d --- /dev/null +++ b/sys/boot/forth/check-password.4th @@ -0,0 +1,156 @@ +\ Copyright (c) 2006-2011 Devin Teske <devinteske@hotmail.com> +\ 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. +\ +\ $FreeBSD$ + +marker task-check-password.4th + +include /boot/screen.4th + +13 constant enter_key \ The decimal ASCII value for Enter key +8 constant bs_key \ The decimal ASCII value for Backspace key +16 constant readmax \ Maximum number of characters for the password + +variable readX \ Current X offset (column)(used by read) +variable read-start \ Starting X offset (column)(used by read) + +create readval 16 allot \ input obtained (maximum 16 characters) +variable readlen \ input length + +\ This function blocks program flow (loops forever) until a key is pressed. +\ The key that was pressed is added to the top of the stack in the form of its +\ decimal ASCII representation. Note: the stack cannot be empty when this +\ function starts or an underflow exception will occur. Simplest way to prevent +\ this is to pass 0 as a stack parameter (ie. `0 sgetkey'). This function is +\ called by the read function. You need not call it directly. NOTE: arrow keys +\ show as 0 on the stack +\ +: sgetkey ( -- ) + + begin \ Loop forever + key? if \ Was a key pressed? (see loader(8)) + + drop \ Remove stack-cruft + key \ Get the key that was pressed + + \ Check key pressed (see loader(8)) and input limit + dup 0<> if ( and ) readlen @ readmax < if + + \ Echo an asterisk (unless Backspace/Enter) + dup bs_key <> if ( and ) dup enter_key <> if + ." *" \ Echo an asterisk + then then + + exit \ Exit from the function + then then + + \ Always allow Backspace and Enter + dup bs_key = if exit then + dup enter_key = if exit then + + then + 50 ms \ Sleep for 50 milliseconds (see loader(8)) + again +; + +: read ( -- String prompt ) + + 0 25 at-xy \ Move the cursor to the bottom-left + dup 1+ read-start ! \ Store X offset after the prompt + read-start @ readX ! \ copy value to the current X offset + 0 readlen ! \ Initialize the read length + type \ Print the prompt + + begin \ Loop forever + + 0 sgetkey \ Block here, waiting for a key to be pressed + + \ We are not going to echo the password to the screen (for + \ security reasons). If Enter is pressed, we process the + \ password, otherwise augment the key to a string. + + \ If the key that was entered was not Enter, advance + dup enter_key <> if + readX @ 1+ readX ! \ Advance the column + readlen @ 1+ readlen ! \ Increment input length + then + + \ Handle backspacing + dup bs_key = if + readX @ 2 - readX ! \ Set new cursor position + readlen @ 2 - readlen ! \ Decrement input length + + \ Don't move behind starting position + readX @ read-start @ < if + read-start @ readX ! + then + readlen @ 0< if + 0 readlen ! + then + + \ Reposition cursor and erase character + readX @ 25 at-xy 1 spaces readX @ 25 at-xy + then + + dup enter_key = if + drop \ Clean up stack cruft + 10 emit \ Echo new line + exit + then + + \ If not Backspace or Enter, store the character + dup bs_key <> if ( and ) dup enter_key <> if + + \ store the character in our buffer + dup readval readlen @ 1- + c! + + then then + + drop \ drop the last key that was entered + + again \ Enter was not pressed; repeat +; + +: check-password ( -- ) + + \ Exit if a password was not set + s" password" getenv dup -1 = if + drop exit + then + + begin \ Loop as long as it takes to get the right password + + s" Password: " \ Output a prompt for a password + read \ Read the user's input until Enter + + 2dup readval readlen @ compare 0= if + 2drop exit \ Correct password + then + + \ Bad Password + 3000 ms + ." loader: incorrect password" 10 emit + + again \ Not the right password; repeat +; diff --git a/sys/boot/forth/check-password.4th.8 b/sys/boot/forth/check-password.4th.8 new file mode 100644 index 0000000..ec2323e --- /dev/null +++ b/sys/boot/forth/check-password.4th.8 @@ -0,0 +1,123 @@ +.\" Copyright (c) 2011 Devin Teske +.\" 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. +.\" +.\" $FreeBSD$ +.\" +.Dd May 18, 2011 +.Dt CHECK-PASSWORD.4TH 8 +.Os +.Sh NAME +.Nm check-password.4th +.Nd FreeBSD password-checking boot module. +.Sh DESCRIPTION +The file that goes by the name of +.Nm +is a set of commands designed to prevent booting without the proper password. +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 check-password.4th +.Pp +This line is present in +.Pa /boot/loader.4th +file, so it is not needed (and should not be re-issued) in a normal setup. +.Pp +The commands provided by it are: +.Pp +.Bl -tag -width disable-module_module -compact -offset indent +.It Ic check-password +Once called, the user cannot continue until the correct password is entered. +If the user enters the correct password the function returns. +.Pp +The password that is required is configured by setting the +.Ic password +variable in +.Xr loader.conf 5 . +.Pp +Subsequent calls after a successful password +has been entered will not cause reprompting +\(em the function will silently return. +.El +.Pp +The environment variables that effect its behavior are: +.Bl -tag -width bootfile -offset indent +.It Va password +Sets the password (up to 16 characters long) that is required by +.Ic check-password +to be entered before the system is allowed to boot. If unset (default) or NULL, +.Ic check-password +will silently abort. +.El +.Sh FILES +.Bl -tag -width /boot/loader.4th -compact +.It Pa /boot/loader +The +.Xr loader 8 . +.It Pa /boot/check-password.4th +.Nm +itself. +.It Pa /boot/loader.rc +.Xr loader 8 +bootstrapping script. +.El +.Sh EXAMPLES +Standard i386 +.Pa /boot/loader.rc : +.Pp +.Bd -literal -offset indent -compact +include /boot/loader.4th +check-password +.Ed +.Pp +Set a password in +.Xr loader.conf 5 : +.Pp +.Bd -literal -offset indent -compact +password="abc123" +.Ed +.Sh SEE ALSO +.Xr loader.conf 5 , +.Xr loader 8 , +.Xr loader.4th 8 +.Sh HISTORY +The +.Nm +set of commands first appeared in +.Fx 9.0 . +.Sh AUTHORS +The +.Nm +set of commands was written by +.An -nosplit +.An Devin Teske Aq devinteske@hotmail.com . diff --git a/sys/boot/forth/color.4th b/sys/boot/forth/color.4th new file mode 100644 index 0000000..4d43593 --- /dev/null +++ b/sys/boot/forth/color.4th @@ -0,0 +1,48 @@ +\ Copyright (c) 2011 Devin Teske <devinteske@hotmail.com> +\ 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. +\ +\ $FreeBSD$ + +marker task-color.4th + +\ This function returns TRUE if the `loader_color' environment variable is set +\ to YES, yes, or 1. Otherwise, FALSE is returned. +\ +: loader_color? ( -- N ) + + s" loader_color" getenv dup -1 <> if + + 2dup s" YES" compare-insensitive 0= if + 2drop + TRUE exit + then + 2dup s" 1" compare 0= if + 2drop + TRUE exit + then + drop + then + + drop FALSE exit +; diff --git a/sys/boot/forth/color.4th.8 b/sys/boot/forth/color.4th.8 new file mode 100644 index 0000000..5a734dd --- /dev/null +++ b/sys/boot/forth/color.4th.8 @@ -0,0 +1,117 @@ +.\" Copyright (c) 2011 Devin Teske +.\" 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. +.\" +.\" $FreeBSD$ +.\" +.Dd May 18, 2011 +.Dt COLOR.4TH 8 +.Os +.Sh NAME +.Nm color.4th +.Nd FreeBSD color-detection boot module. +.Sh DESCRIPTION +The file that goes by the name of +.Nm +is a set of commands designed to simplify color logic. +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 color.4th +.Pp +This line is present in +.Pa /boot/beastie.4th +file, so it is not needed (and should not be re-issued) in a normal setup. +.Pp +The commands provided by it are: +.Pp +.Bl -tag -width disable-module_module -compact -offset indent +.It Ic loader_color? +Returns TRUE if the +.Ic loader_color +environment variable is set to +.Dq YES +(case-insensitive) or +.Dq 1 . +Otherwise returns FALSE. +.El +.Pp +The environment variables that effect its behavior are: +.Bl -tag -width bootfile -offset indent +.It Va loader_color +If set to +.Dq YES +(case-insensitive) or +.Dq 1 , +causes +.Ic loader_color? +to return TRUE, indicating to many other modules that color should be used +whenever/wherever possible. +.El +.Sh FILES +.Bl -tag -width /boot/loader.4th -compact +.It Pa /boot/loader +The +.Xr loader 8 . +.It Pa /boot/color.4th +.Nm +itself. +.It Pa /boot/loader.rc +.Xr loader 8 +bootstrapping script. +.El +.Sh EXAMPLES +Standard i386 +.Pa /boot/loader.rc : +.Pp +Use color where applicable: +.Pp +.Bd -literal -offset indent -compact +loader_color="YES" +.Ed +.Sh SEE ALSO +.Xr loader.conf 5 , +.Xr loader 8 , +.Xr beastie.4th 8 , +.Xr loader.4th 8 +.Sh HISTORY +The +.Nm +set of commands first appeared in +.Fx 9.0 . +.Sh AUTHORS +The +.Nm +set of commands was written by +.An -nosplit +.An Devin Teske Aq devinteske@hotmail.com . diff --git a/sys/boot/forth/delay.4th b/sys/boot/forth/delay.4th new file mode 100644 index 0000000..3068e65 --- /dev/null +++ b/sys/boot/forth/delay.4th @@ -0,0 +1,112 @@ +\ Copyright (c) 2008-2011 Devin Teske <devinteske@hotmail.com> +\ 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. +\ +\ $FreeBSD$ + +marker task-delay.4th + +2 constant delay_default \ Default delay (in seconds) +3 constant etx_key \ End-of-Text character produced by Ctrl+C +13 constant enter_key \ Carriage-Return character produce by ENTER +27 constant esc_key \ Escape character produced by ESC or Ctrl+[ + +variable delay_tstart \ state variable used for delay timing +variable delay_delay \ determined configurable delay duration +variable delay_cancelled \ state variable for user cancellation +variable delay_showdots \ whether continually print dots while waiting + +: delay_execute ( -- ) + + \ make sure that we have a command to execute + s" delay_command" getenv dup -1 = if + drop exit + then + + \ read custom time-duration (if set) + s" loader_delay" getenv dup -1 = if + drop \ no custom duration (remove dup'd bunk -1) + delay_default \ use default setting (replacing bunk -1) + else + \ make sure custom duration is a number + ?number 0= if + delay_default \ use default if otherwise + then + then + + \ initialize state variables + delay_delay ! \ stored value is on the stack from above + seconds delay_tstart ! \ store the time we started + 0 delay_cancelled ! \ boolean flag indicating user-cancelled event + + false delay_showdots ! \ reset to zero and read from environment + s" delay_showdots" getenv dup -1 <> if + 2drop \ don't need the value, just existance + true delay_showdots ! + else + drop + then + + \ Loop until we have exceeded the desired time duration + begin + 25 ms \ sleep for 25 milliseconds (40 iterations/sec) + + \ throw some dots up on the screen if desired + delay_showdots @ if + ." ." \ dots visually aid in the perception of time + then + + \ was a key depressed? + key? if + key \ obtain ASCII value for keystroke + dup enter_key = if + -1 delay_delay ! \ break loop + then + dup etx_key = swap esc_key = OR if + -1 delay_delay ! \ break loop + -1 delay_cancelled ! \ set cancelled flag + then + then + + \ if the time duration is set to zero, loop forever + \ waiting for either ENTER or Ctrl-C/Escape to be pressed + delay_delay @ 0> if + \ calculate elapsed time + seconds delay_tstart @ - delay_delay @ > + else + -1 \ break loop + then + until + + \ if we were throwing up dots, throw up a line-break + delay_showdots @ if + cr + then + + \ did the user press either Ctrl-C or Escape? + delay_cancelled @ if + 2drop \ we don't need the command string anymore + else + evaluate \ evaluate/execute the command string + then +; diff --git a/sys/boot/forth/delay.4th.8 b/sys/boot/forth/delay.4th.8 new file mode 100644 index 0000000..3fe5b5b --- /dev/null +++ b/sys/boot/forth/delay.4th.8 @@ -0,0 +1,126 @@ +.\" Copyright (c) 2011 Devin Teske +.\" 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. +.\" +.\" $FreeBSD$ +.\" +.Dd May 18, 2011 +.Dt DELAY.4TH 8 +.Os +.Sh NAME +.Nm delay.4th +.Nd FreeBSD debugging boot module. +.Sh DESCRIPTION +The file that goes by the name of +.Nm +is a set of commands designed to add debugging capabilities to +.Xr loader 8 . +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 delay.4th +.Pp +This line is present in +.Pa /boot/beastie.4th +file, so it is not needed (and should not be re-issued) in a normal setup. +.Pp +The commands provided by it are: +.Pp +.Bl -tag -width disable-module_module -compact -offset indent +.It Ic delay_execute +Executes the [string] procedure stored in the +.Ic delay_command +environment variable after +.Ic loader_delay +seconds. +.Pp +If the optional +.Ic delay_showdots +environment variable is set, a continuous series of dots is printed. +.Pp +During the duration, the user can either press Ctrl-C (or Esc) to abort or +ENTER to proceed immediately. +.El +.Pp +The environment variables that effect its behavior are: +.Bl -tag -width bootfile -offset indent +.It Va delay_command +The command to be executed by +.Ic delay_execute . +.It Va loader_delay +The duration (in seconds) to delay before executing +.Ic delay_command . +.It Va delay_showdots +If set, will cause +.Ic delay_execute +to print a continuous series of dots during the delay duration. +.El +.Sh FILES +.Bl -tag -width /boot/loader.4th -compact +.It Pa /boot/loader +The +.Xr loader 8 . +.It Pa /boot/delay.4th +.Nm +itself. +.It Pa /boot/loader.rc +.Xr loader 8 +bootstrapping script. +.El +.Sh EXAMPLES +Introducing a 5-second delay before including another file from +.Pa /boot/loader.rc : +.Pp +.Bd -literal -offset indent -compact +include /boot/delay.4th +set delay_command="include /boot/other.4th" +set delay_showdots +set loader_delay=5 +delay_execute +.Ed +.Sh SEE ALSO +.Xr loader.conf 5 , +.Xr loader 8 , +.Xr beastie.4th 8 , +.Xr loader.4th 8 +.Sh HISTORY +The +.Nm +set of commands first appeared in +.Fx 9.0 . +.Sh AUTHORS +The +.Nm +set of commands was written by +.An -nosplit +.An Devin Teske Aq devinteske@hotmail.com . diff --git a/sys/boot/forth/loader.4th b/sys/boot/forth/loader.4th index 7b22b6d..c765147 100644 --- a/sys/boot/forth/loader.4th +++ b/sys/boot/forth/loader.4th @@ -89,30 +89,7 @@ builtin: boot-conf only forth definitions also support-functions -\ ***** check-password -\ -\ If a password was defined, execute autoboot and ask for -\ password if autoboot returns. -\ Do not exit unless the right password is given. - -: check-password - password .addr @ if - 0 autoboot - false >r - begin - bell emit bell emit - ." Password: " - password .len @ read-password - dup password .len @ = if - 2dup password .addr @ password .len @ - compare 0= if r> drop true >r then - then - drop free drop - r@ - until - r> drop - then -; +include /boot/check-password.4th \ ***** start \ diff --git a/sys/boot/forth/loader.conf.5 b/sys/boot/forth/loader.conf.5 index 6abb7ea..c8c61c6 100644 --- a/sys/boot/forth/loader.conf.5 +++ b/sys/boot/forth/loader.conf.5 @@ -215,14 +215,20 @@ be displayed. If set to .Dq YES , the beastie boot menu will be skipped. -.It Va loader_logo Pq Dq Li fbsdbw +.It Va loader_logo Pq Dq Li orbbw Selects a desired logo in the beastie boot menu. Possible values are: +.Dq Li orbbw , +.Dq Li orb , .Dq Li fbsdbw , .Dq Li beastiebw , .Dq Li beastie , and .Dq Li none . +.It Va loader_color +If set to +.Dq YES , +the beastie boot menu will be displayed using ANSI coloring where possible. .El .Sh FILES .Bl -tag -width /boot/defaults/loader.conf -compact diff --git a/sys/boot/forth/menu-commands.4th b/sys/boot/forth/menu-commands.4th new file mode 100644 index 0000000..828a148 --- /dev/null +++ b/sys/boot/forth/menu-commands.4th @@ -0,0 +1,190 @@ +\ Copyright (c) 2006-2011 Devin Teske <devinteske@hotmail.com> +\ 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. +\ +\ $FreeBSD$ + +marker task-menu-commands.4th + +: acpi_enable ( -- ) + s" set acpi_load=YES" evaluate \ XXX deprecated but harmless + s" set hint.acpi.0.disabled=0" evaluate + s" loader.acpi_disabled_by_user" unsetenv +; + +: acpi_disable ( -- ) + s" acpi_load" unsetenv \ XXX deprecated but harmless + s" set hint.acpi.0.disabled=1" evaluate + s" set loader.acpi_disabled_by_user=1" evaluate +; + +: toggle_acpi ( N -- N TRUE ) + + \ Make changes effective _before_ calling menu-redraw + + acpienabled? if + acpi_disable + else + acpi_enable + then + + menu-redraw + + TRUE \ loop menu again +; + +: toggle_safemode ( N -- N TRUE ) + toggle_menuitem + + \ Now we're going to make the change effective + + s" toggle_stateN @" \ base name of toggle state var + -rot 2dup 12 + c! rot \ replace 'N' with ASCII numeral + + evaluate 0= if + s" hint.apic.0.disabled" unsetenv + s" hw.ata.ata_dma" unsetenv + s" hw.ata.atapi_dma" unsetenv + s" hw.ata.wc" unsetenv + s" hw.eisa_slots" unsetenv + s" hint.kbdmux.0.disabled" unsetenv + else + \ + \ Toggle ACPI elements if necessary + \ + acpipresent? if acpienabled? if + menuacpi @ dup 0<> if + toggle_menuitem ( N -- N ) + then + drop + acpi_disable + then then + + s" set hint.apic.0.disabled=1" evaluate + s" set hw.ata.ata_dma=0" evaluate + s" set hw.ata.atapi_dma=0" evaluate + s" set hw.ata.wc=0" evaluate + s" set hw.eisa_slots=0" evaluate + s" set hint.kbdmux.0.disabled=1" evaluate + then + + menu-redraw + + TRUE \ loop menu again +; + +: toggle_singleuser ( N -- N TRUE ) + toggle_menuitem + menu-redraw + + \ Now we're going to make the change effective + + s" toggle_stateN @" \ base name of toggle state var + -rot 2dup 12 + c! rot \ replace 'N' with ASCII numeral + + evaluate 0= if + s" boot_single" unsetenv + else + s" set boot_single=YES" evaluate + then + + TRUE \ loop menu again +; + +: toggle_verbose ( N -- N TRUE ) + toggle_menuitem + menu-redraw + + \ Now we're going to make the change effective + + s" toggle_stateN @" \ base name of toggle state var + -rot 2dup 12 + c! rot \ replace 'N' with ASCII numeral + + evaluate 0= if + s" boot_verbose" unsetenv + else + s" set boot_verbose=YES" evaluate + then + + TRUE \ loop menu again +; + +: goto_prompt ( N -- N FALSE ) + + s" set autoboot_delay=NO" evaluate + + cr + ." To get back to the menu, type `menu' and press ENTER" cr + ." or type `boot' and press ENTER to start FreeBSD." cr + cr + + FALSE \ exit the menu +; + +: cycle_kernel ( N -- N TRUE ) + cycle_menuitem + menu-redraw + + \ Now we're going to make the change effective + + s" cycle_stateN" \ base name of array state var + -rot 2dup 11 + c! rot \ replace 'N' with ASCII numeral + evaluate \ translate name into address + @ \ dereference address into value + 48 + \ convert to ASCII numeral + + \ Since we are [in this file] going to override the standard `boot' + \ routine with a custom one, you should know that we use $kernel + \ when referencing the desired kernel. Set $kernel below. + + s" set kernel=${kernel_prefix}${kernel[N]}${kernel_suffix}" + \ command to assemble full kernel-path + -rot tuck 36 + c! swap \ replace 'N' with array index value + evaluate \ sets $kernel to full kernel-path + + TRUE \ loop menu again +; + +: cycle_root ( N -- N TRUE ) + cycle_menuitem + menu-redraw + + \ Now we're going to make the change effective + + s" cycle_stateN" \ base name of array state var + -rot 2dup 11 + c! rot \ replace 'N' with ASCII numeral + evaluate \ translate name into address + @ \ dereference address into value + 48 + \ convert to ASCII numeral + + \ Since we are [in this file] going to override the standard `boot' + \ routine with a custom one, you should know that we use $root when + \ booting. Set $root below. + + s" set root=${root_prefix}${root[N]}${root_prefix}" + \ command to assemble full kernel-path + -rot tuck 30 + c! swap \ replace 'N' with array index value + evaluate \ sets $kernel to full kernel-path + + TRUE \ loop menu again +; diff --git a/sys/boot/forth/menu.4th b/sys/boot/forth/menu.4th new file mode 100644 index 0000000..110ec1c --- /dev/null +++ b/sys/boot/forth/menu.4th @@ -0,0 +1,971 @@ +\ Copyright (c) 2003 Scott Long <scottl@freebsd.org> +\ Copyright (c) 2003 Aleksander Fafula <alex@fafula.com> +\ Copyright (c) 2006-2011 Devin Teske <devinteske@hotmail.com> +\ 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. +\ +\ $FreeBSD$ + +marker task-menu.4th + +\ Frame drawing +include /boot/frames.4th + +f_double \ Set frames to double (see frames.4th). Replace with + \ f_single if you want single frames. +46 constant dot \ ASCII definition of a period (in decimal) + + 4 constant menu_timeout_default_x \ default column position of timeout +23 constant menu_timeout_default_y \ default row position of timeout msg +10 constant menu_timeout_default \ default timeout (in seconds) + +\ Customize the following values with care + + 1 constant menu_start \ Numerical prefix of first menu item +dot constant bullet \ Menu bullet (appears after numerical prefix) + 5 constant menu_x \ Row position of the menu (from the top) + 10 constant menu_y \ Column position of the menu (from left side) + +\ Menu Appearance +variable menuidx \ Menu item stack for number prefixes +variable menurow \ Menu item stack for positioning +variable menubllt \ Menu item bullet + +\ Menu Positioning +variable menuX \ Menu X offset (columns) +variable menuY \ Menu Y offset (rows) + +\ Menu-item key association/detection +variable menukey1 +variable menukey2 +variable menukey3 +variable menukey4 +variable menukey5 +variable menukey6 +variable menukey7 +variable menukey8 +variable menureboot +variable menurebootadded +variable menuacpi +variable menuoptions + +\ Menu timer [count-down] variables +variable menu_timeout_enabled \ timeout state (internal use only) +variable menu_time \ variable for tracking the passage of time +variable menu_timeout \ determined configurable delay duration +variable menu_timeout_x \ column position of timeout message +variable menu_timeout_y \ row position of timeout message + +\ Boolean option status variables +variable toggle_state1 +variable toggle_state2 +variable toggle_state3 +variable toggle_state4 +variable toggle_state5 +variable toggle_state6 +variable toggle_state7 +variable toggle_state8 + +\ Array option status variables +variable cycle_state1 +variable cycle_state2 +variable cycle_state3 +variable cycle_state4 +variable cycle_state5 +variable cycle_state6 +variable cycle_state7 +variable cycle_state8 + +\ Containers for storing the initial caption text +create init_text1 255 allot +create init_text2 255 allot +create init_text3 255 allot +create init_text4 255 allot +create init_text5 255 allot +create init_text6 255 allot +create init_text7 255 allot +create init_text8 255 allot + +: arch-i386? ( -- BOOL ) \ Returns TRUE (-1) on i386, FALSE (0) otherwise. + s" arch-i386" environment? dup if + drop + then +; + +\ This function prints a menu item at menuX (row) and menuY (column), returns +\ the incremental decimal ASCII value associated with the menu item, and +\ increments the cursor position to the next row for the creation of the next +\ menu item. This function is called by the menu-create function. You need not +\ call it directly. +\ +: printmenuitem ( menu_item_str -- ascii_keycode ) + + menurow dup @ 1+ swap ! ( increment menurow ) + menuidx dup @ 1+ swap ! ( increment menuidx ) + + \ Calculate the menuitem row position + menurow @ menuY @ + + + \ Position the cursor at the menuitem position + dup menuX @ swap at-xy + + \ Print the value of menuidx + loader_color? if + ." [1m" + then + menuidx @ . + loader_color? if + ." [37m" + then + + \ Move the cursor forward 1 column + dup menuX @ 1+ swap at-xy + + menubllt @ emit \ Print the menu bullet using the emit function + + \ Move the cursor to the 3rd column from the current position + \ to allow for a space between the numerical prefix and the + \ text caption + menuX @ 3 + swap at-xy + + \ Print the menu caption (we expect a string to be on the stack + \ prior to invoking this function) + type + + \ Here we will add the ASCII decimal of the numerical prefix + \ to the stack (decimal ASCII for `1' is 49) as a "return value" + menuidx @ 48 + +; + +: toggle_menuitem ( N -- N ) \ toggles caption text and internal menuitem state + + \ ASCII numeral equal to user-selected menu item must be on the stack. + \ We do not modify the stack, so the ASCII numeral is left on top. + + s" init_textN" \ base name of buffer + -rot 2dup 9 + c! rot \ replace 'N' with ASCII num + + evaluate c@ 0= if + \ NOTE: no need to check toggle_stateN since the first time we + \ are called, we will populate init_textN. Further, we don't + \ need to test whether menu_caption[x] (ansi_caption[x] when + \ loader_color=1) is available since we would not have been + \ called if the caption was NULL. + + \ base name of environment variable + loader_color? if + s" ansi_caption[x]" + else + s" menu_caption[x]" + then + -rot 2dup 13 + c! rot \ replace 'x' with ASCII numeral + + getenv dup -1 <> if + + s" init_textN" \ base name of buffer + 4 pick \ copy ASCII num to top + rot tuck 9 + c! swap \ replace 'N' with ASCII num + evaluate + + \ now we have the buffer c-addr on top + \ ( followed by c-addr/u of current caption ) + + \ Copy the current caption into our buffer + 2dup c! -rot \ store strlen at first byte + begin + rot 1+ \ bring alt addr to top and increment + -rot -rot \ bring buffer addr to top + 2dup c@ swap c! \ copy current character + 1+ \ increment buffer addr + rot 1- \ bring buffer len to top and decrement + dup 0= \ exit loop if buffer len is zero + until + 2drop \ buffer len/addr + drop \ alt addr + + else + drop + then + then + + \ Now we are certain to have init_textN populated with the initial + \ value of menu_caption[x] (ansi_caption[x] with loader_color enabled). + \ We can now use init_textN as the untoggled caption and + \ toggled_text[x] (toggled_ansi[x] with loader_color enabled) as the + \ toggled caption and store the appropriate value into menu_caption[x] + \ (again, ansi_caption[x] with loader_color enabled). Last, we'll + \ negate the toggled state so that we reverse the flow on subsequent + \ calls. + + s" toggle_stateN @" \ base name of toggle state var + -rot 2dup 12 + c! rot \ replace 'N' with ASCII numeral + + evaluate 0= if + \ state is OFF, toggle to ON + + \ base name of toggled text var + loader_color? if + s" toggled_ansi[x]" + else + s" toggled_text[x]" + then + -rot 2dup 13 + c! rot \ replace 'x' with ASCII num + + getenv dup -1 <> if + \ Assign toggled text to menu caption + + \ base name of caption var + loader_color? if + s" ansi_caption[x]" + else + s" menu_caption[x]" + then + 4 pick \ copy ASCII num to top + rot tuck 13 + c! swap \ replace 'x' with ASCII num + + setenv \ set new caption + else + \ No toggled text, keep the same caption + + drop + then + + true \ new value of toggle state var (to be stored later) + else + \ state is ON, toggle to OFF + + s" init_textN" \ base name of initial text buffer + -rot 2dup 9 + c! rot \ replace 'N' with ASCII numeral + evaluate \ convert string to c-addr + count \ convert c-addr to c-addr/u + + \ base name of caption var + loader_color? if + s" ansi_caption[x]" + else + s" menu_caption[x]" + then + 4 pick \ copy ASCII num to top + rot tuck 13 + c! swap \ replace 'x' with ASCII numeral + + setenv \ set new caption + false \ new value of toggle state var (to be stored below) + then + + \ now we'll store the new toggle state (on top of stack) + s" toggle_stateN" \ base name of toggle state var + 3 pick \ copy ASCII numeral to top + rot tuck 12 + c! swap \ replace 'N' with ASCII numeral + evaluate \ convert string to addr + ! \ store new value +; + +: cycle_menuitem ( N -- N ) \ cycles through array of choices for a menuitem + + \ ASCII numeral equal to user-selected menu item must be on the stack. + \ We do not modify the stack, so the ASCII numeral is left on top. + + s" cycle_stateN" \ base name of array state var + -rot 2dup 11 + c! rot \ replace 'N' with ASCII numeral + + evaluate \ we now have a pointer to the proper variable + dup @ \ resolve the pointer (but leave it on the stack) + 1+ \ increment the value + + \ Before assigning the (incremented) value back to the pointer, + \ let's test for the existence of this particular array element. + \ If the element exists, we'll store index value and move on. + \ Otherwise, we'll loop around to zero and store that. + + dup 48 + \ duplicate Array index and convert to ASCII numeral + + \ base name of array caption text + loader_color? if + s" ansi_caption[x][y]" + else + s" menu_caption[x][y]" + then + -rot tuck 16 + c! swap \ replace 'y' with Array index + 4 pick rot tuck 13 + c! swap \ replace 'x' with menu choice + + \ Now test for the existence of our incremented array index in the + \ form of $menu_caption[x][y] ($ansi_caption[x][y] with loader_color + \ enabled) as set in loader.rc(5), et. al. + + getenv dup -1 = if + \ No caption set for this array index. Loop back to zero. + + drop ( getenv cruft ) + drop ( incremented array index ) + 0 ( new array index that will be stored later ) + + \ base name of caption var + loader_color? if + s" ansi_caption[x][0]" + else + s" menu_caption[x][0]" + then + 4 pick rot tuck 13 + c! swap \ replace 'x' with menu choice + + getenv dup -1 = if + \ This is highly unlikely to occur, but to make + \ sure that things move along smoothly, allocate + \ a temporary NULL string + + s" " + then + then + + \ At this point, we should have the following on the stack (in order, + \ from bottom to top): + \ + \ N - Ascii numeral representing the menu choice (inherited) + \ Addr - address of our internal cycle_stateN variable + \ N - zero-based number we intend to store to the above + \ C-Addr - string value we intend to store to menu_caption[x] + \ (or ansi_caption[x] with loader_color enabled) + \ + \ Let's perform what we need to with the above. + + \ base name of menuitem caption var + loader_color? if + s" ansi_caption[x]" + else + s" menu_caption[x]" + then + 6 pick rot tuck 13 + c! swap \ replace 'x' with menu choice + setenv \ set the new caption + + swap ! \ update array state variable +; + +: acpipresent? ( -- flag ) \ Returns TRUE if ACPI is present, FALSE otherwise + s" hint.acpi.0.rsdp" getenv + dup -1 = if + drop false exit + then + 2drop + true +; + +: acpienabled? ( -- flag ) \ Returns TRUE if ACPI is enabled, FALSE otherwise + s" hint.acpi.0.disabled" getenv + dup -1 <> if + s" 0" compare 0<> if + false exit + then + else + drop + then + true +; + +\ This function prints the appropriate menuitem basename to the stack if an +\ ACPI option is to be presented to the user, otherwise returns -1. Used +\ internally by menu-create, you need not (nor should you) call this directly. +\ +: acpimenuitem ( -- C-Addr | -1 ) + + arch-i386? if + acpipresent? if + acpienabled? if + loader_color? if + s" toggled_ansi[x]" + else + s" toggled_text[x]" + then + else + loader_color? if + s" ansi_caption[x]" + else + s" menu_caption[x]" + then + then + else + menuidx dup @ 1+ swap ! ( increment menuidx ) + -1 + then + else + -1 + then +; + +\ This function creates the list of menu items. This function is called by the +\ menu-display function. You need not be call it directly. +\ +: menu-create ( -- ) + + \ Print the frame caption at (x,y) + s" loader_menu_title" getenv dup -1 = if + drop s" Welcome to FreeBSD" + then + 24 over 2 / - 9 at-xy type + + \ Print our menu options with respective key/variable associations. + \ `printmenuitem' ends by adding the decimal ASCII value for the + \ numerical prefix to the stack. We store the value left on the stack + \ to the key binding variable for later testing against a character + \ captured by the `getkey' function. + + \ Note that any menu item beyond 9 will have a numerical prefix on the + \ screen consisting of the first digit (ie. 1 for the tenth menu item) + \ and the key required to activate that menu item will be the decimal + \ ASCII of 48 plus the menu item (ie. 58 for the tenth item, aka. `:') + \ which is misleading and not desirable. + \ + \ Thus, we do not allow more than 8 configurable items on the menu + \ (with "Reboot" as the optional ninth and highest numbered item). + + \ + \ Initialize the ACPI option status. + \ + 0 menuacpi ! + s" menu_acpi" getenv -1 <> if + c@ dup 48 > over 57 < and if ( '1' <= c1 <= '8' ) + menuacpi ! + arch-i386? if acpipresent? if + \ + \ Set menu toggle state to active state + \ (required by generic toggle_menuitem) + \ + menuacpi @ + s" acpienabled? toggle_stateN !" + -rot tuck 25 + c! swap + evaluate + then then + else + drop + then + then + + \ + \ Initialize the menu_options visual separator. + \ + 0 menuoptions ! + s" menu_options" getenv -1 <> if + c@ dup 48 > over 57 < and if ( '1' <= c1 <= '8' ) + menuoptions ! + else + drop + then + then + + \ Initialize "Reboot" menu state variable (prevents double-entry) + false menurebootadded ! + + 49 \ Iterator start (loop range 49 to 56; ASCII '1' to '8') + begin + \ If the "Options:" separator, print it. + dup menuoptions @ = if + \ Optionally add a reboot option to the menu + s" menu_reboot" getenv -1 <> if + drop + s" Reboot" printmenuitem menureboot ! + true menurebootadded ! + then + + menuX @ + menurow @ 2 + menurow ! + menurow @ menuY @ + + at-xy + ." Options:" + then + + \ If this is the ACPI menu option, act accordingly. + dup menuacpi @ = if + acpimenuitem ( -- C-Addr | -1 ) + else + loader_color? if + s" ansi_caption[x]" + else + s" menu_caption[x]" + then + then + + ( C-Addr | -1 ) + dup -1 <> if + \ replace 'x' with current iteration + -rot 2dup 13 + c! rot + + \ test for environment variable + getenv dup -1 <> if + printmenuitem ( C-Addr -- N ) + + s" menukeyN !" \ generate cmd to store result + -rot 2dup 7 + c! rot + + evaluate + else + drop + then + else + drop + + s" menu_command[x]" + -rot 2dup 13 + c! rot ( replace 'x' ) + unsetenv + then + + 1+ dup 56 > \ add 1 to iterator, continue if less than 57 + until + drop \ iterator + + \ Optionally add a reboot option to the menu + menurebootadded @ true <> if + s" menu_reboot" getenv -1 <> if + drop \ no need for the value + s" Reboot" \ menu caption (required by printmenuitem) + + printmenuitem + menureboot ! + else + 0 menureboot ! + then + then +; + +\ Takes a single integer on the stack and updates the timeout display. The +\ integer must be between 0 and 9 (we will only update a single digit in the +\ source message). +\ +: menu-timeout-update ( N -- ) + + dup 9 > if ( N N 9 -- N ) + drop ( N -- ) + 9 ( maximum: -- N ) + then + + dup 0 < if ( N N 0 -- N ) + drop ( N -- ) + 0 ( minimum: -- N ) + then + + 48 + ( convert single-digit numeral to ASCII: N 48 -- N ) + + s" Autoboot in N seconds. [Space] to pause" ( N -- N Addr C ) + + 2 pick 48 - 0> if ( N Addr C N 48 -- N Addr C ) + + \ Modify 'N' (Addr+12) above to reflect time-left + + -rot ( N Addr C -- C N Addr ) + tuck ( C N Addr -- C Addr N Addr ) + 12 + ( C Addr N Addr -- C Addr N Addr2 ) + c! ( C Addr N Addr2 -- C Addr ) + swap ( C Addr -- Addr C ) + + menu_timeout_x @ + menu_timeout_y @ + at-xy ( position cursor: Addr C N N -- Addr C ) + + type ( print message: Addr C -- ) + + else ( N Addr C N -- N Addr C ) + + menu_timeout_x @ + menu_timeout_y @ + at-xy ( position cursor: N Addr C N N -- N Addr C ) + + spaces ( erase message: N Addr C -- N Addr ) + 2drop ( N Addr -- ) + + then + + 0 25 at-xy ( position cursor back at bottom-left ) +; + +\ This function blocks program flow (loops forever) until a key is pressed. +\ The key that was pressed is added to the top of the stack in the form of its +\ decimal ASCII representation. This function is called by the menu-display +\ function. You need not call it directly. +\ +: getkey ( -- ascii_keycode ) + + begin \ loop forever + + menu_timeout_enabled @ 1 = if + ( -- ) + seconds ( get current time: -- N ) + dup menu_time @ <> if ( has time elapsed?: N N N -- N ) + + \ At least 1 second has elapsed since last loop + \ so we will decrement our "timeout" (really a + \ counter, insuring that we do not proceed too + \ fast) and update our timeout display. + + menu_time ! ( update time record: N -- ) + menu_timeout @ ( "time" remaining: -- N ) + dup 0> if ( greater than 0?: N N 0 -- N ) + 1- ( decrement counter: N -- N ) + dup menu_timeout ! + ( re-assign: N N Addr -- N ) + then + ( -- N ) + + dup 0= swap 0< or if ( N <= 0?: N N -- ) + \ halt the timer + 0 menu_timeout ! ( 0 Addr -- ) + 0 menu_timeout_enabled ! ( 0 Addr -- ) + then + + \ update the timer display ( N -- ) + menu_timeout @ menu-timeout-update + + menu_timeout @ 0= if + \ We've reached the end of the timeout + \ (user did not cancel by pressing ANY + \ key) + + s" menu_timeout_command" getenv dup + -1 = if + drop \ clean-up + else + evaluate + then + then + + else ( -- N ) + \ No [detectable] time has elapsed (in seconds) + drop ( N -- ) + then + ( -- ) + then + + key? if \ Was a key pressed? (see loader(8)) + + \ An actual key was pressed (if the timeout is running, + \ kill it regardless of which key was pressed) + menu_timeout @ 0<> if + 0 menu_timeout ! + 0 menu_timeout_enabled ! + + \ clear screen of timeout message + 0 menu-timeout-update + then + + \ get the key that was pressed and exit (if we + \ get a non-zero ASCII code) + key dup 0<> if + exit + else + drop + then + then + 50 ms \ sleep for 50 milliseconds (see loader(8)) + + again +; + +: menu-erase ( -- ) \ Erases menu and resets positioning variable to positon 1. + + \ Clear the screen area associated with the interactive menu + menuX @ menuY @ + 2dup at-xy 38 spaces 1+ 2dup at-xy 38 spaces 1+ + 2dup at-xy 38 spaces 1+ 2dup at-xy 38 spaces 1+ + 2dup at-xy 38 spaces 1+ 2dup at-xy 38 spaces 1+ + 2dup at-xy 38 spaces 1+ 2dup at-xy 38 spaces 1+ + 2dup at-xy 38 spaces 1+ 2dup at-xy 38 spaces 1+ + 2dup at-xy 38 spaces 1+ 2dup at-xy 38 spaces + 2drop + + \ Reset the starting index and position for the menu + menu_start 1- menuidx ! + 0 menurow ! +; + +\ Erase and redraw the menu. Useful if you change a caption and want to +\ update the menu to reflect the new value. +\ +: menu-redraw ( -- ) + menu-erase + menu-create +; + +\ This function initializes the menu. Call this from your `loader.rc' file +\ before calling any other menu-related functions. +\ +: menu-init ( -- ) + menu_start + 1- menuidx ! \ Initialize the starting index for the menu + 0 menurow ! \ Initialize the starting position for the menu + 42 13 2 9 box \ Draw frame (w,h,x,y) + 0 25 at-xy \ Move cursor to the bottom for output +; + +\ Main function. Call this from your `loader.rc' file. +\ +: menu-display ( -- ) + + 0 menu_timeout_enabled ! \ start with automatic timeout disabled + + \ check indication that automatic execution after delay is requested + s" menu_timeout_command" getenv -1 <> if ( Addr C -1 -- | Addr ) + drop ( just testing existence right now: Addr -- ) + + \ initialize state variables + seconds menu_time ! ( store the time we started ) + 1 menu_timeout_enabled ! ( enable automatic timeout ) + + \ read custom time-duration (if set) + s" autoboot_delay" getenv dup -1 = if + drop \ no custom duration (remove dup'd bunk -1) + menu_timeout_default \ use default setting + else + 2dup ?number 0= if ( if not a number ) + \ disable timeout if "NO", else use default + s" NO" compare-insensitive 0= if + 0 menu_timeout_enabled ! + 0 ( assigned to menu_timeout below ) + else + menu_timeout_default + then + else + -rot 2drop + + \ disable timeout if less than zero + dup 0< if + drop + 0 menu_timeout_enabled ! + 0 ( assigned to menu_timeout below ) + then + then + then + menu_timeout ! ( store value on stack from above ) + + menu_timeout_enabled @ 1 = if + \ read custom column position (if set) + s" loader_menu_timeout_x" getenv dup -1 = if + drop \ no custom column position + menu_timeout_default_x \ use default setting + else + \ make sure custom position is a number + ?number 0= if + menu_timeout_default_x \ or use default + then + then + menu_timeout_x ! ( store value on stack from above ) + + \ read custom row position (if set) + s" loader_menu_timeout_y" getenv dup -1 = if + drop \ no custom row position + menu_timeout_default_y \ use default setting + else + \ make sure custom position is a number + ?number 0= if + menu_timeout_default_y \ or use default + then + then + menu_timeout_y ! ( store value on stack from above ) + then + then + + menu-create + + begin \ Loop forever + + 0 25 at-xy \ Move cursor to the bottom for output + getkey \ Block here, waiting for a key to be pressed + + dup -1 = if + drop exit \ Caught abort (abnormal return) + then + + \ Boot if the user pressed Enter/Ctrl-M (13) or + \ Ctrl-Enter/Ctrl-J (10) + dup over 13 = swap 10 = or if + drop ( no longer needed ) + s" boot" evaluate + exit ( pedantic; never reached ) + then + + \ Evaluate the decimal ASCII value against known menu item + \ key associations and act accordingly + + 49 \ Iterator start (loop range 49 to 56; ASCII '1' to '8') + begin + s" menukeyN @" + + \ replace 'N' with current iteration + -rot 2dup 7 + c! rot + + evaluate rot tuck = if + + \ Adjust for missing ACPI menuitem on non-i386 + arch-i386? true <> menuacpi @ 0<> and if + menuacpi @ over 2dup < -rot = or + over 58 < and if + ( key >= menuacpi && key < 58: N -- N ) + 1+ + then + then + + \ base env name for the value (x is a number) + s" menu_command[x]" + + \ Copy ASCII number to string at offset 13 + -rot 2dup 13 + c! rot + + \ Test for the environment variable + getenv dup -1 <> if + \ Execute the stored procedure + evaluate + + \ We expect there to be a non-zero + \ value left on the stack after + \ executing the stored procedure. + \ If so, continue to run, else exit. + + 0= if + drop \ key pressed + drop \ loop iterator + exit + else + swap \ need iterator on top + then + then + + \ Re-adjust for missing ACPI menuitem + arch-i386? true <> menuacpi @ 0<> and if + swap + menuacpi @ 1+ over 2dup < -rot = or + over 59 < and if + 1- + then + swap + then + else + swap \ need iterator on top + then + + \ + \ Check for menu keycode shortcut(s) + \ + s" menu_keycode[x]" + -rot 2dup 13 + c! rot + getenv dup -1 = if + drop + else + ?number 0<> if + rot tuck = if + swap + s" menu_command[x]" + -rot 2dup 13 + c! rot + getenv dup -1 <> if + evaluate + 0= if + 2drop + exit + then + else + drop + then + else + swap + then + then + then + + 1+ dup 56 > \ increment iterator + \ continue if less than 57 + until + drop \ loop iterator + + menureboot @ = if 0 reboot then + + again \ Non-operational key was pressed; repeat +; + +\ This function unsets all the possible environment variables associated with +\ creating the interactive menu. Call this when you want to clear the menu +\ area in preparation for another menu. +\ +: menu-clear ( -- ) + + 49 \ Iterator start (loop range 49 to 56; ASCII '1' to '8') + begin + \ basename for caption variable + loader_color? if + s" ansi_caption[x]" + else + s" menu_caption[x]" + then + -rot 2dup 13 + c! rot \ replace 'x' with current iteration + unsetenv \ not erroneous to unset unknown var + + s" 0 menukeyN !" \ basename for key association var + -rot 2dup 9 + c! rot \ replace 'N' with current iteration + evaluate \ assign zero (0) to key assoc. var + + 1+ dup 56 > \ increment, continue if less than 57 + until + drop \ iterator + + \ clear the "Reboot" menu option flag + s" menu_reboot" unsetenv + 0 menureboot ! + + \ clear the ACPI menu option flag + s" menu_acpi" unsetenv + 0 menuacpi ! + + \ clear the "Options" menu separator flag + s" menu_options" unsetenv + 0 menuoptions ! + + menu-erase +; + +\ Assign configuration values +bullet menubllt ! +10 menuY ! +5 menuX ! + +\ Initialize our boolean state variables +0 toggle_state1 ! +0 toggle_state2 ! +0 toggle_state3 ! +0 toggle_state4 ! +0 toggle_state5 ! +0 toggle_state6 ! +0 toggle_state7 ! +0 toggle_state8 ! + +\ Initialize our array state variables +0 cycle_state1 ! +0 cycle_state2 ! +0 cycle_state3 ! +0 cycle_state4 ! +0 cycle_state5 ! +0 cycle_state6 ! +0 cycle_state7 ! +0 cycle_state8 ! + +\ Initialize string containers +0 init_text1 c! +0 init_text2 c! +0 init_text3 c! +0 init_text4 c! +0 init_text5 c! +0 init_text6 c! +0 init_text7 c! +0 init_text8 c! diff --git a/sys/boot/forth/menu.4th.8 b/sys/boot/forth/menu.4th.8 new file mode 100644 index 0000000..45388f5 --- /dev/null +++ b/sys/boot/forth/menu.4th.8 @@ -0,0 +1,307 @@ +.\" Copyright (c) 2011 Devin Teske +.\" 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. +.\" +.\" $FreeBSD$ +.\" +.Dd May 18, 2011 +.Dt MENU.4TH 8 +.Os +.Sh NAME +.Nm menu.4th +.Nd FreeBSD dynamic menu boot module. +.Sh DESCRIPTION +The file that goes by the name of +.Nm +is a set of commands designed to display a dynamic menu system managed through +a system of carefully named environment variables. +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 menu.4th +.Pp +This line is present in the default +.Pa /boot/menu.rc +file, so it is not needed (and should not be re-issued) in a normal setup. +.Pp +The commands provided by it are: +.Pp +.Bl -tag -width disable-module_module -compact -offset indent +.It Ic menu-init +Draws the menu bounding box and initializes some internal state variables. +This should be called before any other menu-related functions. +.It Ic menu-display +Displays the menu (configured via the below documented environment variables) +and blocks on keyboard input, awaiting user action. +.It Ic menu-erase +Clears the screen area within the menu bounding box. +.It Ic menu-redraw +Calls +.Ic menu-erase +and then redraws the menu. +.It Ic menu-clear +Unsets all possible environment variables used +to configure the menu and then calls +.Ic menu-erase . +.El +.Pp +The environment variables that effect its behavior are: +.Bl -tag -width bootfile -offset indent +.It Va loader_color +If set to +.Dq Li YES +(case-insensitive) or +.Dq Li 1 , +causes the menu to be displayed in color wherever possible. This includes the +use of ANSI bold for numbers appearing to the left of menuitems and the use of +special +.Dq Li ansi +variables describd below. +.It Va autoboot_delay +Number of seconds +.Ic menu-display +will wait before executing +.Va menu_timeout_command +.Ic ( boot +by default) unless a key is pressed. +If set to +.Dq Li NO +(case-insensitive) or +.Dq Li -1 , +.Ic menu-display +will wait for user input and never execute +.Ic menu_timeout_command . +Default is +.Dq Li 10 . +See +.Xr loader 8 +for additional information. +.It Va menu_timeout_command +The command to be executed after +.Va autoboot_delay +seconds if a key is not pressed. The default is +.Ic boot . +.It Va loader_menu_timeout_x +Sets the desired column position of the timeout countdown text. Default is 4. +.It Va loader_menu_timeout_y +Sets the desired row position of the timeout countdown text. Default is 23. +.It Va loader_menu_title +The text to display centered above the menu. Default is +.Dq Li "Welcome to FreeBSD" . +.It Va menu_caption[x] +The text to be displayed for the numbered menuitem +.Dq Li x . +.It Va menu_command[x] +The command to be executed when the number associated with menuitem +.Dq Li x +is pressed. See the list of included FICL words below for some ideas. +.It Va menu_keycode[x] +An optional decimal ASCII keycode to be associated with menuitem +.Dq Li x . +When pressed, will cause the execution of +.Va menu_command[x] . +.It Va ansi_caption[x] +If +.Va loader_color +is set, use this caption for menuitem +.Dq Li x +instead of +.Va menu_caption[x] . +.It Va toggled_text[x] +For menuitems where +.Va menu_command[x] +is set to +.Dq Li toggle_menuitem +(or a derivative thereof), the text displayed +will toggle between this and +.Va menu_caption[x] . +.It Va toggled_ansi[x] +Like +.Va toggled_text[x] +except used when +.Va loader_color +is enabled. +.It Va menu_caption[x][y] +For menuitems where +.Va menu_command[x] +is set to +.Dq Li cycle_menuitem +(or a derivative thereof), the text displayed will cycle between this and other +.Va menu_caption[x][y] +entries. +.It Va ansi_caption[x][y] +Like +.Va menu_caption[x][y] +except used when +.Va loader_color +is enabled. +.It Va menu_acpi +When set to a number +.Dq Li x +associated with a given menuitem, that menuitem will only appear when +running on i386-compatible hardware, +.Va hint.acpi.0.rsdp +is set (indicating the presence of hardware ACPI support as detected by +.Xr loader 8 ) , +and +.Va hint.acpi.0.disabled +is not set. +On non-i386 hardware, menuitems configured after the +.Dq Li menu_acpi +menuitem will use a lower number (to compensate for the missing ACPI menuitem) +but continue to function as expected. +On i386-compatible hardware lacking ACPI support (as detected by +.Xr loader 8 ) , +subsequent menuitems will retain their associated numbers. +.It Va hint.acpi.0.rsdp +Set automatically by +.Xr loader 8 +on i386-compatible hardware when ACPI support is detected at boot time. +Effects the display of the +.Dq Li menu_acpi +menuitem (if configured). +.It Va hint.acpi.0.disabled +Effects the display of the +.Va menu_acpi +menuitem. If set, the menuitem will display +.Va toggled_text[x] +.Va ( toggled_ansi[x] +if +.Va loader_color +is set), otherwise +.Va menu_caption[x] +.Va ( ansi_caption[x] +if +.Va loader_color +is set). +.It Va menu_options +When set to a number +.Dq Li x , +a single blank-line and an +.Dq Li Options +header are inserted between +.Va menu_caption[x-1] +and +.Va menu_caption[x] +(if configured). +.It Va menu_reboot +If set, adds a built-in +.Dq Li Reboot +menuitem to the end of the last configured menuitem. If +.Va menu_options +is configured, the +.Dq Li Reboot +menuitem will be inserted before the +.Dq Options +separator. +.El +.Pp +In addition, it provides the following FICL words: +.Pp +.Bl -tag -width disable-module_module -compact -offset indent +.It Ic arch-i386? ( -- BOOL ) +Returns true (-1) on i386 and false (0) otherwise. +.It Ic acpipresent? ( -- BOOL ) +Returns true (-1) if ACPI is present and false (0) otherwise. +.It Ic acpienabled? ( -- BOOL ) +Returns true (-1) if ACPI is enabled and false (0) otherwise. +.It Ic toggle_menuitem ( N -- N ) +Toggles menuitem +.Dq Li N +between +.Va menu_caption[x] +and +.Va toggled_text[x] +(where +.Dq Li N +represents the ASCII decimal value for +.Dq Li x ) . +.It Ic cycle_menuitem ( N -- N ) +Cycles menuitem +.Dq Li N +between +.Va menu_caption[x][y] +entries (where +.Va N +represents the ASCII decimal value for +.Va x ) . +.El +.Pp +For all values of +.Dq Li x +above, use any number between 1 through 9. Sorry, double-digits are not +currently supported. +.Sh FILES +.Bl -tag -width /boot/loader.4th -compact +.It Pa /boot/loader +The +.Xr loader 8 . +.It Pa /boot/menu.4th +.Nm +itself. +.It Pa /boot/loader.rc +.Xr loader 8 +bootstrapping script. +.El +.Sh EXAMPLES +A simple boot menu: +.Pp +.Bd -literal -offset indent -compact +include /boot/menu.4th +menu-init +set menu_caption[1]="Boot" +set menu_command[1]="boot" +set menu_options=2 +set menu_caption[2]="Option: NO" +set toggled_text[2]="Option: YES" +set menu_command[2]="toggle_menuitem" +set menu_timeout_command="boot" +set menu_reboot +menu-display +.Ed +.Sh SEE ALSO +.Xr loader.conf 5 , +.Xr loader 8 , +.Xr loader.4th 8 , +.Xr beastie.4th 8 +.Sh HISTORY +The +.Nm +set of commands first appeared in +.Fx 9.0 . +.Sh AUTHORS +The +.Nm +set of commands was written by +.An -nosplit +.An Devin Teske Aq devinteske@hotmail.com . diff --git a/sys/boot/forth/menu.rc b/sys/boot/forth/menu.rc new file mode 100644 index 0000000..d8af4b2 --- /dev/null +++ b/sys/boot/forth/menu.rc @@ -0,0 +1,76 @@ +\ Menu.rc +\ $FreeBSD$ +\ +\ Load required Forth modules +include /boot/version.4th +include /boot/brand.4th +include /boot/menu.4th +include /boot/menu-commands.4th +include /boot/shortcuts.4th + +\ Screen prep +clear \ clear the screen (see `screen.4th') +print_version \ print version string (bottom-right; see `version.4th') +draw-beastie \ draw freebsd mascot (on right; see `beastie.4th') +draw-brand \ draw the FreeBSD title (top-left; see `brand.4th') +menu-init \ initialize the menu area (see `menu.4th') + +\ Initialize main menu constructs (see `menu.4th') +\ NOTE: To use the `ansi' variants, add `loader_color=1' to loader.conf(5) + +set menu_caption[1]="Boot [ENTER]" +set menu_command[1]="boot" +set ansi_caption[1]="[1mB[37moot [1m[ENTER][37m" +set menu_keycode[1]="98" + +set menu_caption[2]="[Esc]ape to loader prompt" +set menu_command[2]="goto_prompt" +set menu_keycode[2]="27" +set ansi_caption[2]="[1mEsc[37mape to loader prompt" + +\ Enable built-in "Reboot" trailing menuitem +\ NOTE: appears before menu_options if configured +\ +set menu_reboot + +\ Enable "Options:" separator. When set to a numerical value (1-8), a visual +\ separator is inserted before that menuitem number. +\ +set menu_options=4 + +set menu_caption[4]="[A]CPI Support: Disabled" +set toggled_text[4]="[A]CPI Support: Enabled" +set menu_command[4]="toggle_acpi" +set menu_keycode[4]="97" +set menu_acpi=4 +set ansi_caption[4]="[1mA[37mCPI Support: [34;1mDisabled[37m" +set toggled_ansi[4]="[1mA[37mCPI Support: [32mEnabled[37m" + +set menu_caption[5]="Boot Safe [M]ode: NO" +set toggled_text[5]="Boot Safe [M]ode: YES" +set menu_command[5]="toggle_safemode" +set menu_keycode[5]="109" +set ansi_caption[5]="Boot Safe [1mM[37mode: [34;1mNO[37m" +set toggled_ansi[5]="Boot Safe [1mM[37mode: [32mYES[37m" + +set menu_caption[6]="Boot [S]ingle User: NO" +set toggled_text[6]="Boot [S]ingle User: YES" +set menu_command[6]="toggle_singleuser" +set menu_keycode[6]="115" +set ansi_caption[6]="Boot [1mS[37mingle User: [34;1mNO[37m" +set toggled_ansi[6]="Boot [1mS[37mingle User: [32mYES[37m" + +set menu_caption[7]="Boot [V]erbose: NO" +set toggled_text[7]="Boot [V]erbose: YES" +set menu_command[7]="toggle_verbose" +set menu_keycode[7]="118" +set ansi_caption[7]="Boot [1mV[37merbose: [34;1mNO[37m" +set toggled_ansi[7]="Boot [1mV[37merbose: [32mYES[37m" + +\ Enable automatic booting (add ``autoboot_delay=N'' to loader.conf(5) to +\ customize the timeout; default is 10-seconds) +\ +set menu_timeout_command="boot" + +\ Display the main menu (see `menu.4th') +menu-display diff --git a/sys/boot/forth/shortcuts.4th b/sys/boot/forth/shortcuts.4th new file mode 100644 index 0000000..55a369b --- /dev/null +++ b/sys/boot/forth/shortcuts.4th @@ -0,0 +1,50 @@ +\ Copyright (c) 2008-2011 Devin Teske <devinteske@hotmail.com> +\ 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. +\ +\ $FreeBSD$ + +\ FICL words intended to be used as shortcuts for carrying out common tasks or +\ producing common results. Generally, words defined here are simply groupings +\ of other custom words that pull from multiple libraries (for example, if you +\ want to define a custom word that uses words defined in three different +\ libraries, this is a good place to define such a word). +\ +\ This script should be included after you have included any/all other +\ libraries. This will prevent calling a word defined here before any required +\ words have been defined. + +marker task-shortcuts.4th + +\ This "shortcut" word will not be used directly, but is defined here to +\ offer the user a quick way to get back into the interactive PXE menu +\ after they have escaped to the shell (perhaps by accident). +\ +: menu ( -- ) + clear \ Clear the screen (in screen.4th) + print_version \ print version string (bottom-right; see version.4th) + draw-beastie \ Draw FreeBSD logo at right (in beastie.4th) + draw-brand \ Draw FIS logo at top (in brand.4th) + menu-init \ Initialize menu and draw bounding box (in menu.4th) + menu-display \ Launch interactive menu (in menu.4th) +; diff --git a/sys/boot/forth/support.4th b/sys/boot/forth/support.4th index 5484e06..3dbeae8 100644 --- a/sys/boot/forth/support.4th +++ b/sys/boot/forth/support.4th @@ -54,7 +54,6 @@ \ Exported global variables; \ \ string conf_files configuration files to be loaded -\ string password password \ cell modules_options pointer to first module information \ value verbose? indicates if user wants a verbose loading \ value any_conf_read? indicates if a conf file was succesfully read @@ -164,7 +163,6 @@ structure: file_metadata string conf_files string nextboot_conf_file -string password create module_options sizeof module.next allot 0 module_options ! create last_module_option sizeof module.next allot 0 last_module_option ! 0 value verbose? @@ -610,8 +608,6 @@ only forth also support-functions also file-processing definitions also : execute? s" exec" assignment_type? ; -: password? s" password" assignment_type? ; - : module_load? load_module_suffix suffix_type? ; : module_loadname? module_loadname_suffix suffix_type? ; @@ -752,10 +748,6 @@ only forth also support-functions also file-processing definitions also ['] evaluate catch if EEXEC throw then ; -: set_password - value_buffer strget unquote password string= -; - : process_assignment name_buffer .len @ 0= if exit then loader_conf_files? if set_conf_files exit then @@ -763,7 +755,6 @@ only forth also support-functions also file-processing definitions also nextboot_conf? if set_nextboot_conf exit then verbose_flag? if set_verbose exit then execute? if execute_command exit then - password? if set_password exit then module_load? if set_module_flag exit then module_loadname? if set_module_loadname exit then module_type? if set_module_type exit then @@ -1532,30 +1523,6 @@ also builtins ?dup 0= if ['] load_modules catch then ; -\ read and store only as many bytes as we need, drop the extra -: read-password { size | buf len -- } - size allocate if ENOMEM throw then - to buf - 0 to len - begin - key - dup backspace = if - drop - len if - backspace emit bl emit backspace emit - len 1 - to len - else - bell emit - then - else - dup <cr> = if cr drop buf len exit then - [char] * emit - len size < if buf len chars + c! else drop then - len 1+ to len - then - again -; - \ Go back to straight forth vocabulary only forth also definitions diff --git a/sys/boot/forth/version.4th b/sys/boot/forth/version.4th new file mode 100644 index 0000000..c59f825 --- /dev/null +++ b/sys/boot/forth/version.4th @@ -0,0 +1,60 @@ +\ Copyright (c) 2006-2011 Devin Teske <devinteske@hotmail.com> +\ 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. +\ +\ $FreeBSD$ + +marker task-version.4th + +variable versionX +variable versionY + +\ Initialize text placement to defaults +80 versionX ! \ NOTE: this is the ending column (text is right-justified) +24 versionY ! + +: print_version ( -- ) + + \ Get the text placement position (if set) + s" loader_version_x" getenv dup -1 <> if + ?number drop versionX ! -1 + then drop + s" loader_version_y" getenv dup -1 <> if + ?number drop versionY ! -1 + then drop + + \ Exit if a version was not set + s" loader_version" getenv dup -1 = if + drop exit + then + + \ Right justify the text + dup versionX @ swap - versionY @ at-xy + + \ Print the version (optionally in cyan) + loader_color? if + ." [36m" type ." [37m" + else + type + then +; diff --git a/sys/boot/forth/version.4th.8 b/sys/boot/forth/version.4th.8 new file mode 100644 index 0000000..fff2268 --- /dev/null +++ b/sys/boot/forth/version.4th.8 @@ -0,0 +1,126 @@ +.\" Copyright (c) 2011 Devin Teske +.\" 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. +.\" +.\" $FreeBSD$ +.\" +.Dd May 19, 2011 +.Dt VERSION.4TH 8 +.Os +.Sh NAME +.Nm version.4th +.Nd FreeBSD version string boot module. +.Sh DESCRIPTION +The file that goes by the name of +.Nm +is a set of commands designed to draw the boot loader +version at the bottom-right of the screen. +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 version.4th +.Pp +This line is present in the default +.Pa /boot/menu.rc +file, so it is not needed (and should not be re-issued) in a normal setup. +.Pp +The commands provided by it are: +.Pp +.Bl -tag -width disable-module_module -compact -offset indent +.It Ic print_version +Prints the contents of the +.Va loader_version +environment variable right-justified at the column +.Va loader_version_x +and row +.Va loader_version_y . +.El +.Pp +The environment variables that effect its behavior are: +.Bl -tag -width bootfile -offset indent +.It Va loader_version +Set automatically by +.Xr loader 8 , +but you can override it by setting in +.Xr loader.conf 5 . +This should be the version of boot loader used. +.It Va loader_version_x +Sets the desired ending column position of +.Va loader_version . +Default is 80. +.It Va loader_version_y +Sets the desired ending row position of +.Va loader_version . +Default is 24. +.It Va loader_color +If set to +.Dq Li YES +(case-insensitive) or +.Dq Li 1 , +causes the version to be printed in ANSI Cyan. +.El +.Sh FILES +.Bl -tag -width /boot/loader.4th -compact +.It Pa /boot/loader +The +.Xr loader 8 . +.It Pa /boot/version.4th +.Nm +itself. +.It Pa /boot/loader.rc +.Xr loader 8 +bootstrapping script. +.El +.Sh EXAMPLES +Override +.Xr loader 8 +version in +.Xr loader.conf 5 : +.Pp +.Bd -literal -offset indent -compact +loader_version="loader 1.1" +.Ed +.Sh SEE ALSO +.Xr loader.conf 5 , +.Xr loader 8 , +.Sh HISTORY +The +.Nm +set of commands first appeared in +.Fx 9.0 . +.Sh AUTHORS +The +.Nm +set of commands was written by +.An -nosplit +.An Devin Teske Aq devinteske@hotmail.com . diff --git a/sys/boot/i386/libi386/biosacpi.c b/sys/boot/i386/libi386/biosacpi.c index f511eb7..ff8b1ca 100644 --- a/sys/boot/i386/libi386/biosacpi.c +++ b/sys/boot/i386/libi386/biosacpi.c @@ -61,7 +61,7 @@ biosacpi_detect(void) return; /* export values from the RSDP */ - sprintf(buf, "%p", VTOP(rsdp)); + sprintf(buf, "%u", VTOP(rsdp)); setenv("hint.acpi.0.rsdp", buf, 1); revision = rsdp->Revision; if (revision == 0) diff --git a/sys/boot/i386/loader/Makefile b/sys/boot/i386/loader/Makefile index b834ea0..f4babff 100644 --- a/sys/boot/i386/loader/Makefile +++ b/sys/boot/i386/loader/Makefile @@ -104,11 +104,16 @@ FILESMODE_${LOADER}= ${BINMODE} -b .PATH: ${.CURDIR}/../../forth FILES+= loader.help loader.4th support.4th loader.conf FILES+= screen.4th frames.4th beastie.4th +FILES+= brand.4th check-password.4th color.4th delay.4th +FILES+= menu.4th menu-commands.4th shortcuts.4th version.4th FILESDIR_loader.conf= /boot/defaults .if !exists(${DESTDIR}/boot/loader.rc) FILES+= loader.rc .endif +.if !exists(${DESTDIR}/boot/menu.rc) +FILES+= menu.rc +.endif .endif # XXX crt0.o needs to be first for pxeboot(8) to work diff --git a/sys/boot/i386/zfsboot/Makefile b/sys/boot/i386/zfsboot/Makefile index 06ff863..65df86f 100644 --- a/sys/boot/i386/zfsboot/Makefile +++ b/sys/boot/i386/zfsboot/Makefile @@ -15,7 +15,7 @@ ORG1= 0x7c00 ORG2= 0x2000 CFLAGS= -DBOOTPROG=\"zfsboot\" \ - -Os -g \ + -Os \ -fno-guess-branch-probability \ -fomit-frame-pointer \ -fno-unit-at-a-time \ diff --git a/sys/boot/ia64/common/Makefile b/sys/boot/ia64/common/Makefile index 3204edc..d90898f 100644 --- a/sys/boot/ia64/common/Makefile +++ b/sys/boot/ia64/common/Makefile @@ -6,7 +6,7 @@ MK_SSP= no LIB= ia64 INTERNALLIB= -SRCS= autoload.c bootinfo.c copy.c devicename.c exec.c +SRCS= autoload.c bootinfo.c copy.c devicename.c exec.c icache.c CFLAGS+= -I${.CURDIR}/../../efi/include CFLAGS+= -I${.CURDIR}/../../efi/include/${MACHINE_CPUARCH} @@ -33,9 +33,15 @@ loader.help: help.common .PATH: ${.CURDIR}/../../forth FILES+= loader.4th support.4th loader.conf +FILES+= screen.4th frames.4th +FILES+= beastie.4th brand.4th check-password.4th color.4th delay.4th +FILES+= menu.4th menu-commands.4th shortcuts.4th version.4th .if !exists(${DESTDIR}/boot/loader.rc) FILES+= loader.rc .endif +.if !exists(${DESTDIR}/boot/menu.rc) +FILES+= menu.rc +.endif FILESDIR_loader.conf= /boot/defaults .include <bsd.lib.mk> diff --git a/sys/boot/ia64/common/exec.c b/sys/boot/ia64/common/exec.c index dd9c9ba..65886fa 100644 --- a/sys/boot/ia64/common/exec.c +++ b/sys/boot/ia64/common/exec.c @@ -258,6 +258,8 @@ ia64_loadseg(Elf_Ehdr *eh, Elf_Phdr *ph, uint64_t delta) if (ph->p_flags & PF_X) { ia64_text_start = ph->p_vaddr + delta; ia64_text_size = ph->p_memsz; + + ia64_sync_icache(ia64_text_start, ia64_text_size); } else { ia64_data_start = ph->p_vaddr + delta; ia64_data_size = ph->p_memsz; diff --git a/sys/boot/ia64/common/icache.c b/sys/boot/ia64/common/icache.c new file mode 100644 index 0000000..77a35d7 --- /dev/null +++ b/sys/boot/ia64/common/icache.c @@ -0,0 +1,51 @@ +/*- + * Copyright (c) 2011 Marcel Moolenaar + * 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 ``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 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. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <stand.h> +#include <machine/ia64_cpu.h> + +#include "libia64.h" + +void +ia64_sync_icache(vm_offset_t va, size_t sz) +{ + uintptr_t pa; + size_t cnt, max; + + while (sz > 0) { + max = sz; + pa = (uintptr_t)ia64_va2pa(va, &max); + for (cnt = 0; cnt < max; cnt += 32) + ia64_fc_i(pa + cnt); + ia64_sync_i(); + va += max; + sz -= max; + } + ia64_srlz_i(); +} diff --git a/sys/boot/ia64/common/libia64.h b/sys/boot/ia64/common/libia64.h index 29912f5..4bc7638 100644 --- a/sys/boot/ia64/common/libia64.h +++ b/sys/boot/ia64/common/libia64.h @@ -64,6 +64,7 @@ void ia64_loadseg(void *, void *, uint64_t); ssize_t ia64_copyin(const void *, vm_offset_t, size_t); ssize_t ia64_copyout(vm_offset_t, void *, size_t); +void ia64_sync_icache(vm_offset_t, size_t); ssize_t ia64_readin(int, vm_offset_t, size_t); void *ia64_va2pa(vm_offset_t, size_t *); diff --git a/sys/boot/ia64/efi/efimd.c b/sys/boot/ia64/efi/efimd.c index 0f7f02a..0b29e12 100644 --- a/sys/boot/ia64/efi/efimd.c +++ b/sys/boot/ia64/efi/efimd.c @@ -230,3 +230,35 @@ ia64_platform_enter(const char *kernel) return (0); } + +COMMAND_SET(pbvm, "pbvm", "show PBVM details", command_pbvm); + +static int +command_pbvm(int argc, char *argv[]) +{ + uint64_t limit, pg, start; + u_int idx; + + printf("Page table @ %p, size %x\n", ia64_pgtbl, ia64_pgtblsz); + + if (ia64_pgtbl == NULL) + return (0); + + limit = ~0; + start = ~0; + idx = 0; + while (ia64_pgtbl[idx] != 0) { + pg = ia64_pgtbl[idx]; + if (pg != limit) { + if (start != ~0) + printf("%#lx-%#lx\n", start, limit); + start = pg; + } + limit = pg + IA64_PBVM_PAGE_SIZE; + idx++; + } + if (start != ~0) + printf("%#lx-%#lx\n", start, limit); + + return (0); +} diff --git a/sys/boot/ia64/efi/main.c b/sys/boot/ia64/efi/main.c index 485a26d..ec12b42 100644 --- a/sys/boot/ia64/efi/main.c +++ b/sys/boot/ia64/efi/main.c @@ -153,9 +153,7 @@ main(int argc, CHAR16 *argv[]) */ cons_probe(); - printf("\n"); - printf("%s, Revision %s\n", bootprog_name, bootprog_rev); - printf("(%s, %s)\n", bootprog_maker, bootprog_date); + printf("\n%s, Revision %s\n", bootprog_name, bootprog_rev); find_pal_proc(); @@ -214,6 +212,18 @@ static int command_quit(int argc, char *argv[]) { exit(0); + /* NOTREACHED */ + return (CMD_OK); +} + +COMMAND_SET(reboot, "reboot", "reboot the system", command_reboot); + +static int +command_reboot(int argc, char *argv[]) +{ + + RS->ResetSystem(EfiResetWarm, EFI_SUCCESS, 0, NULL); + /* NOTREACHED */ return (CMD_OK); } @@ -585,3 +595,24 @@ command_hcdp(int argc, char *argv[]) printf("<EOT>\n"); return (CMD_OK); } + +COMMAND_SET(about, "about", "about the loader", command_about); + +extern uint64_t _start_plabel[]; + +static int +command_about(int argc, char *argv[]) +{ + EFI_LOADED_IMAGE *img; + + printf("%s\n", bootprog_name); + printf("revision %s\n", bootprog_rev); + printf("built by %s\n", bootprog_maker); + printf("built on %s\n", bootprog_date); + + printf("\n"); + + BS->HandleProtocol(IH, &imgid, (VOID**)&img); + printf("image loaded at %p\n", img->ImageBase); + printf("entry at %#lx (%#lx)\n", _start_plabel[0], _start_plabel[1]); +} diff --git a/sys/boot/ia64/efi/version b/sys/boot/ia64/efi/version index 3a947c8..17d14ea 100644 --- a/sys/boot/ia64/efi/version +++ b/sys/boot/ia64/efi/version @@ -3,6 +3,8 @@ $FreeBSD$ NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. The format of this file is important. Make sure the current version number is on line 6. +3.1: Add the about, reboot and pbvm commands. + I-cache coherency is maintained. 3.0: Add support for PBVM. 2.2: Create direct mapping based on start address instead of mapping first 256M. diff --git a/sys/boot/pc98/loader/Makefile b/sys/boot/pc98/loader/Makefile index e1f47cd..d289cce 100644 --- a/sys/boot/pc98/loader/Makefile +++ b/sys/boot/pc98/loader/Makefile @@ -82,6 +82,8 @@ loader.help: help.common help.pc98 .PATH: ${.CURDIR}/../../forth FILES= loader loader.help loader.4th support.4th loader.conf FILES+= screen.4th frames.4th beastie.4th +FILES+= brand.4th check-password.4th color.4th delay.4th +FILES+= menu.4th menu-commands.4th shortcuts.4th version.4th # XXX INSTALLFLAGS_loader= -b FILESMODE_loader= ${BINMODE} -b FILESDIR_loader.conf= /boot/defaults @@ -90,6 +92,10 @@ FILESDIR_loader.conf= /boot/defaults FILES+= ${.CURDIR}/../../i386/loader/loader.rc .endif +.if !exists(${DESTDIR}/boot/menu.rc) +FILES+= menu.rc +.endif + # XXX crt0.o needs to be first for pxeboot(8) to work OBJS= ${BTXCRT} diff --git a/sys/boot/powerpc/ofw/Makefile b/sys/boot/powerpc/ofw/Makefile index 776f98e..079f552 100644 --- a/sys/boot/powerpc/ofw/Makefile +++ b/sys/boot/powerpc/ofw/Makefile @@ -103,10 +103,17 @@ loader.help: help.common help.ofw .PATH: ${.CURDIR}/../../forth FILES= loader.help loader.4th support.4th loader.conf +FILES+= screen.4th frames.4th +FILES+= beastie.4th brand.4th check-password.4th color.4th delay.4th +FILES+= menu.4th menu-commands.4th shortcuts.4th version.4th FILESDIR_loader.conf= /boot/defaults .if !exists(${DESTDIR}/boot/loader.rc) FILES+= loader.rc .endif +.if !exists(${DESTDIR}/boot/menu.rc) +FILES+= menu.rc +.endif + .include <bsd.prog.mk> diff --git a/sys/boot/powerpc/ps3/Makefile b/sys/boot/powerpc/ps3/Makefile index b3a37be..b05470b 100644 --- a/sys/boot/powerpc/ps3/Makefile +++ b/sys/boot/powerpc/ps3/Makefile @@ -113,10 +113,17 @@ loader.help: help.common help.ps3 .PATH: ${.CURDIR}/../../forth FILES= loader.help loader.4th support.4th loader.conf +FILES+= screen.4th frames.4th +FILES+= beastie.4th brand.4th check-password.4th color.4th delay.4th +FILES+= menu.4th menu-commands.4th shortcuts.4th version.4th FILESDIR_loader.conf= /boot/defaults .if !exists(${DESTDIR}/boot/loader.rc) FILES+= loader.rc .endif +.if !exists(${DESTDIR}/boot/menu.rc) +FILES+= menu.rc +.endif + .include <bsd.prog.mk> diff --git a/sys/boot/sparc64/loader/Makefile b/sys/boot/sparc64/loader/Makefile index 46c6baa..d32fbab 100644 --- a/sys/boot/sparc64/loader/Makefile +++ b/sys/boot/sparc64/loader/Makefile @@ -84,10 +84,17 @@ loader.help: help.common help.sparc64 .PATH: ${.CURDIR}/../../forth FILES= loader.help loader.4th support.4th loader.conf +FILES+= screen.4th frames.4th +FILES+= beastie.4th brand.4th check-password.4th color.4th delay.4th +FILES+= menu.4th menu-commands.4th shortcuts.4th version.4th FILESDIR_loader.conf= /boot/defaults .if !exists(${DESTDIR}/boot/loader.rc) FILES+= loader.rc .endif +.if !exists(${DESTDIR}/boot/menu.rc) +FILES+= menu.rc +.endif + .include <bsd.prog.mk> |