diff --git a/sys/boot/forth/beastie.4th b/sys/boot/forth/beastie.4th new file mode 100644 index 000000000000..96c4a04637fb --- /dev/null +++ b/sys/boot/forth/beastie.4th @@ -0,0 +1,206 @@ +\ Copyright (c) 2003 Scott Long +\ 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-beastie.4th + +include /boot/screen.4th +include /boot/frames.4th + +hide + +variable menuidx +variable menubllt +variable menuX +variable menuY +variable promptwidth + +variable bootkey +variable bootacpikey +variable bootsafekey +variable bootverbosekey +variable bootsinglekey +variable escapekey +variable rebootkey + +46 constant dot + +\ The BSD Daemon. He is 19 rows high and 34 columns wide +: print-beastie ( 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 ." `--{__________)" +; + +: acpienabled? ( -- flag ) + s" acpi_load" getenv + dup -1 = if + drop false exit + then + s" YES" compare-insensitive 0<> if + false exit + then + s" hint.acpi.0.disabled" getenv + dup -1 <> if + s" 0" compare 0<> if + false exit + then + 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-beastie + 42 20 2 2 box + 13 6 at-xy ." Welcome to FreeBSD!" + printmenuitem ." Boot FreeBSD [default]" bootkey ! + s" arch-i386" environment? if + printmenuitem ." Boot FreeBSD with ACPI " bootacpikey ! + acpienabled? if + ." disabled" + else + ." enabled" + then + else + -2 bootacpikey ! + 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 + dup + 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 +; + +set-current + +: beastie-start + beastie-menu + s" autoboot_delay" getenv + dup -1 = if + drop + 10 + else + 0 0 2swap >number drop drop drop + then + begin true while + dup tkey + 0 25 at-xy + dup 32 = if nip 0 swap then + dup -1 = if s" boot" evaluate then + dup 13 = if s" boot" evaluate then + dup bootkey @ = if s" boot" evaluate then + dup bootacpikey @ = if + acpienabled? if + s" acpi_load" unsetenv + s" 1" s" hint.acpi.0.disabled" setenv + else + s" YES" s" acpi_load" setenv + s" 0" s" hint.acpi.0.disabled" setenv + then + s" boot" evaluate + then + dup bootsafekey @ = if + s" arch-i386" environment? if + s" acpi_load" unsetenv + s" 1" s" hint.acpi.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" boot" evaluate + then + dup bootverbosekey @ = if + s" YES" s" boot_verbose" setenv + s" boot" evaluate + then + dup bootsinglekey @ = if + s" YES" s" boot_single" setenv + s" boot" evaluate + then + dup escapekey @ = if 2drop exit then + rebootkey @ = if s" reboot" evaluate then + repeat +; + +previous diff --git a/sys/boot/forth/frames.4th b/sys/boot/forth/frames.4th new file mode 100644 index 000000000000..ff91c5b7ec87 --- /dev/null +++ b/sys/boot/forth/frames.4th @@ -0,0 +1,90 @@ +\ Words implementing frame drawing +\ XXX Filled boxes are left as an exercise for the reader... ;-/ +\ $FreeBSD$ + +marker task-frames.4th + +variable h_el +variable v_el +variable lt_el +variable lb_el +variable rt_el +variable rb_el +variable fill + +\ Single frames +196 constant sh_el +179 constant sv_el +218 constant slt_el +192 constant slb_el +191 constant srt_el +217 constant srb_el +\ Double frames +205 constant dh_el +186 constant dv_el +201 constant dlt_el +200 constant dlb_el +187 constant drt_el +188 constant drb_el +\ Fillings +0 constant fill_none +32 constant fill_blank +176 constant fill_dark +177 constant fill_med +178 constant fill_bright + + +: hline ( len x y -- ) \ Draw horizontal single line + at-xy \ move cursor + 0 do + h_el @ emit + loop +; + +: f_single ( -- ) \ set frames to single + sh_el h_el ! + sv_el v_el ! + slt_el lt_el ! + slb_el lb_el ! + srt_el rt_el ! + srb_el rb_el ! +; + +: f_double ( -- ) \ set frames to double + dh_el h_el ! + dv_el v_el ! + dlt_el lt_el ! + dlb_el lb_el ! + drt_el rt_el ! + drb_el rb_el ! +; + +: vline ( len x y -- ) \ Draw vertical single line + 2dup 4 pick + 0 do + at-xy + v_el @ emit + 1+ + 2dup + loop + 2drop 2drop drop +; + +: box ( w h x y -- ) \ Draw a box + 2dup 1+ 4 pick 1- -rot + vline \ Draw left vert line + 2dup 1+ swap 5 pick + swap 4 pick 1- -rot + vline \ Draw right vert line + 2dup swap 1+ swap 5 pick 1- -rot + hline \ Draw top horiz line + 2dup swap 1+ swap 4 pick + 5 pick 1- -rot + hline \ Draw bottom horiz line + 2dup at-xy lt_el @ emit \ Draw left-top corner + 2dup 4 pick + at-xy lb_el @ emit \ Draw left bottom corner + 2dup swap 5 pick + swap at-xy rt_el @ emit \ Draw right top corner + 2 pick + swap 3 pick + swap at-xy rb_el @ emit + 2drop +; + +f_single +fill_none fill ! diff --git a/sys/boot/forth/screen.4th b/sys/boot/forth/screen.4th new file mode 100644 index 000000000000..3ea79e453d80 --- /dev/null +++ b/sys/boot/forth/screen.4th @@ -0,0 +1,36 @@ +\ Screen manipulation related words. +\ $FreeBSD$ + +marker task-screen.4th + +: escc ( -- ) \ emit Esc-[ + 91 27 emit emit +; + +: ho ( -- ) \ Home cursor + escc 72 emit \ Esc-[H +; + +: cld ( -- ) \ Clear from current position to end of display + escc 74 emit \ Esc-[J +; + +: clear ( -- ) \ clear screen + ho cld +; + +: at-xy ( x y -- ) \ move cursor to x rows, y cols (1-based coords) + escc .# 59 emit .# 72 emit \ Esc-[%d;%dH +; + +: fg ( x -- ) \ Set foreground color + escc 3 .# .# 109 emit \ Esc-[3%dm +; + +: bg ( x -- ) \ Set background color + escc 4 .# .# 109 emit \ Esc-[4%dm +; + +: me ( -- ) \ Mode end (clear attributes) + escc 109 emit +; diff --git a/sys/boot/i386/loader/Makefile b/sys/boot/i386/loader/Makefile index af8d51fec8f2..e944e5e034db 100644 --- a/sys/boot/i386/loader/Makefile +++ b/sys/boot/i386/loader/Makefile @@ -102,6 +102,7 @@ ${PROG}.help: help.common help.i386 .PATH: ${.CURDIR}/../../forth FILES= ${PROG}.help loader.4th support.4th loader.conf +FILES+= screen.4th frames.4th beastie.4th FILESDIR_loader.conf= /boot/defaults .if !exists(${DESTDIR}/boot/loader.rc)