diff options
author | Toomas Soome <tsoome@me.com> | 2020-11-21 21:27:25 +0200 |
---|---|---|
committer | Toomas Soome <tsoome@me.com> | 2020-12-01 23:45:44 +0200 |
commit | 63f9f2ff473e9cb7f455f032fe3d04a95ec4b537 (patch) | |
tree | 417278aa9fbd33379be63a0b00385a57eb84366c | |
parent | 166994016fed8bc2ed47612b34708b33007a891b (diff) | |
download | illumos-joyent-63f9f2ff473e9cb7f455f032fe3d04a95ec4b537.tar.gz |
13332 loader: iterate consoles to draw loader menu screen
Reviewed by: Andy Fiddaman <andy@omnios.org>
Approved by: Dan McDonald <danmcd@joyent.com>
-rw-r--r-- | usr/src/boot/Makefile.version | 2 | ||||
-rw-r--r-- | usr/src/boot/sys/boot/forth/Makefile.inc | 3 | ||||
-rw-r--r-- | usr/src/boot/sys/boot/forth/beastie.4th | 14 | ||||
-rw-r--r-- | usr/src/boot/sys/boot/forth/brand-illumos.4th | 18 | ||||
-rw-r--r-- | usr/src/boot/sys/boot/forth/brand.4th | 14 | ||||
-rw-r--r-- | usr/src/boot/sys/boot/forth/color.4th | 18 | ||||
-rw-r--r-- | usr/src/boot/sys/boot/forth/illumos-brand.png | bin | 0 -> 37587 bytes | |||
-rw-r--r-- | usr/src/boot/sys/boot/forth/illumos-logo.png (renamed from usr/src/boot/sys/boot/forth/illumos.png) | bin | 11979 -> 11979 bytes | |||
-rw-r--r-- | usr/src/boot/sys/boot/forth/logo-illumos.4th | 11 | ||||
-rw-r--r-- | usr/src/boot/sys/boot/forth/menu.4th | 2 | ||||
-rw-r--r-- | usr/src/boot/sys/boot/forth/support.4th | 76 | ||||
-rw-r--r-- | usr/src/common/ficl/loader.c | 51 | ||||
-rw-r--r-- | usr/src/pkg/manifests/system-boot-loader.mf | 3 |
13 files changed, 178 insertions, 34 deletions
diff --git a/usr/src/boot/Makefile.version b/usr/src/boot/Makefile.version index d4000c0baf..fd51c7e769 100644 --- a/usr/src/boot/Makefile.version +++ b/usr/src/boot/Makefile.version @@ -34,4 +34,4 @@ LOADER_VERSION = 1.1 # Use date like formatting here, YYYY.MM.DD.XX, without leading zeroes. # The version is processed from left to right, the version number can only # be increased. -BOOT_VERSION = $(LOADER_VERSION)-2020.11.27.1 +BOOT_VERSION = $(LOADER_VERSION)-2020.11.27.2 diff --git a/usr/src/boot/sys/boot/forth/Makefile.inc b/usr/src/boot/sys/boot/forth/Makefile.inc index eb2576bd64..e3fd239af7 100644 --- a/usr/src/boot/sys/boot/forth/Makefile.inc +++ b/usr/src/boot/sys/boot/forth/Makefile.inc @@ -24,4 +24,5 @@ FORTH += screen.4th FORTH += shortcuts.4th FORTH += support.4th FORTH += version.4th -FILES += illumos.png +FILES += illumos-logo.png +FILES += illumos-brand.png diff --git a/usr/src/boot/sys/boot/forth/beastie.4th b/usr/src/boot/sys/boot/forth/beastie.4th index cba112281a..874e19a9d9 100644 --- a/usr/src/boot/sys/boot/forth/beastie.4th +++ b/usr/src/boot/sys/boot/forth/beastie.4th @@ -2,7 +2,7 @@ \ Copyright (c) 2003 Aleksander Fafula <alex@fafula.com> \ Copyright (c) 2006-2015 Devin Teske <dteske@FreeBSD.org> \ All rights reserved. -\ +\ \ Redistribution and use in source and binary forms, with or without \ modification, are permitted provided that the following conditions \ are met: @@ -11,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 @@ -23,8 +23,6 @@ \ 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 @@ -40,11 +38,11 @@ variable logoY \ 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. -\ +\ \ NOTE: Each is defined as a logo function in /boot/logo-${loader_logo}.4th \ NOTE: If `/boot/logo-${loader_logo}.4th' does not exist or does not define \ a `logo' function, no beastie is drawn. -\ +\ : draw-beastie ( -- ) \ at (loader_logo_x,loader_logo_y), else (46,4) s" loader_logo_x" getenv dup -1 <> if @@ -82,6 +80,10 @@ variable logoY then ; +: draw-beastie + ['] draw-beastie console-iterate +; + also support-functions : beastie-start ( -- ) \ starts the menu diff --git a/usr/src/boot/sys/boot/forth/brand-illumos.4th b/usr/src/boot/sys/boot/forth/brand-illumos.4th index 9859623aa6..3122af6ec0 100644 --- a/usr/src/boot/sys/boot/forth/brand-illumos.4th +++ b/usr/src/boot/sys/boot/forth/brand-illumos.4th @@ -1,6 +1,6 @@ \ Copyright (c) 2006-2015 Devin Teske <dteske@FreeBSD.org> \ All rights reserved. -\ +\ \ Redistribution and use in source and binary forms, with or without \ modification, are permitted provided that the following conditions \ are met: @@ -9,7 +9,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 @@ -21,8 +21,6 @@ \ 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$ 2 brandX ! 1 brandY ! \ Initialize brand placement defaults @@ -34,6 +32,18 @@ : brand ( x y -- ) \ "illumos" [wide] logo in B/W (5 rows x 39 columns) + framebuffer? if + s" term-putimage" sfind if + \ note, we use 0, 0 for image upper left as origin, + \ and 0, 7 for lower right to preserve aspect ratio + >r 0 0 0 0 7 + s" /boot/illumos-brand.png" + r> execute if 2drop exit then + else + drop + then + then + s" _ _ _ " brand+ s" (_)| || | _ _ _ __ ___ ___ ___ " brand+ s" | || || || | | || '_ ` _ \ / _ \ / __|" brand+ diff --git a/usr/src/boot/sys/boot/forth/brand.4th b/usr/src/boot/sys/boot/forth/brand.4th index 2caadcbaf5..c86b955602 100644 --- a/usr/src/boot/sys/boot/forth/brand.4th +++ b/usr/src/boot/sys/boot/forth/brand.4th @@ -1,6 +1,6 @@ \ Copyright (c) 2006-2015 Devin Teske <dteske@FreeBSD.org> \ All rights reserved. -\ +\ \ Redistribution and use in source and binary forms, with or without \ modification, are permitted provided that the following conditions \ are met: @@ -9,7 +9,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 @@ -21,8 +21,6 @@ \ 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 @@ -36,11 +34,11 @@ variable brandY \ This function draws any number of company brands at (loader_brand_x, \ loader_brand_y) if defined, or (2,1) (top-left). To choose your brand, set \ the variable `loader_brand' to the respective brand name. -\ +\ \ NOTE: Each is defined as a brand function in /boot/brand-${loader_brand}.4th \ NOTE: If `/boot/brand-${loader_brand}.4th' does not exist or does not define \ a `brand' function, no brand is drawn. -\ +\ : draw-brand ( -- ) \ at (loader_brand_x,loader_brand_y), else (2,1) s" loader_brand_x" getenv dup -1 <> if @@ -72,3 +70,7 @@ variable brandY else drop then then ; + +: draw-brand + ['] draw-brand console-iterate +; diff --git a/usr/src/boot/sys/boot/forth/color.4th b/usr/src/boot/sys/boot/forth/color.4th index 65e6de905a..09b2c39ebf 100644 --- a/usr/src/boot/sys/boot/forth/color.4th +++ b/usr/src/boot/sys/boot/forth/color.4th @@ -1,6 +1,6 @@ \ Copyright (c) 2011-2013 Devin Teske <dteske@FreeBSD.org> \ All rights reserved. -\ +\ \ Redistribution and use in source and binary forms, with or without \ modification, are permitted provided that the following conditions \ are met: @@ -9,7 +9,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 @@ -21,18 +21,18 @@ \ 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 FALSE if the `loader_color' environment variable is set -\ to NO, no, or 0. Otherwise, TRUE is returned (unless booting serial). -\ +\ to NO, no, or 0. Otherwise, TRUE is returned. +\ : loader_color? ( -- N ) s" loader_color" getenv dup -1 <> if - + \ `loader_color' is set. + \ Check if it is explicitly disabled. 2dup s" NO" compare-insensitive 0= if 2drop FALSE exit @@ -44,6 +44,6 @@ marker task-color.4th drop then drop - - boot_serial? if FALSE else TRUE then + \ It is enabled. + TRUE ; diff --git a/usr/src/boot/sys/boot/forth/illumos-brand.png b/usr/src/boot/sys/boot/forth/illumos-brand.png Binary files differnew file mode 100644 index 0000000000..0679f0d050 --- /dev/null +++ b/usr/src/boot/sys/boot/forth/illumos-brand.png diff --git a/usr/src/boot/sys/boot/forth/illumos.png b/usr/src/boot/sys/boot/forth/illumos-logo.png Binary files differindex 3af7a2f360..3af7a2f360 100644 --- a/usr/src/boot/sys/boot/forth/illumos.png +++ b/usr/src/boot/sys/boot/forth/illumos-logo.png diff --git a/usr/src/boot/sys/boot/forth/logo-illumos.4th b/usr/src/boot/sys/boot/forth/logo-illumos.4th index 84948ec3ad..e64895db08 100644 --- a/usr/src/boot/sys/boot/forth/logo-illumos.4th +++ b/usr/src/boot/sys/boot/forth/logo-illumos.4th @@ -36,7 +36,16 @@ : logo ( x y -- ) \ color illumos logo - 0 0 0 0 0 s" /boot/illumos.png" fb-putimage if 2drop exit then + framebuffer? if + s" term-putimage" sfind if + >r over 0 swap ( x y 0 x ) + 12 0 22 ( x y 0 x 12 0 22 ) + s" /boot/illumos-logo.png" + r> execute if 2drop exit then + else + drop + then + then s" @[33m,@[m " logo+ s" @[33m,./% @[31m&@[m " logo+ diff --git a/usr/src/boot/sys/boot/forth/menu.4th b/usr/src/boot/sys/boot/forth/menu.4th index e60d5b8d6a..304abb4aeb 100644 --- a/usr/src/boot/sys/boot/forth/menu.4th +++ b/usr/src/boot/sys/boot/forth/menu.4th @@ -915,7 +915,7 @@ only forth definitions also menu-infrastructure then menuX ! - menu-box + ['] menu-box console-iterate at-bl ; diff --git a/usr/src/boot/sys/boot/forth/support.4th b/usr/src/boot/sys/boot/forth/support.4th index 3c291cd119..2abf48f70b 100644 --- a/usr/src/boot/sys/boot/forth/support.4th +++ b/usr/src/boot/sys/boot/forth/support.4th @@ -192,6 +192,25 @@ create last_module_option sizeof module.next allot 0 last_module_option ! 0 0 ; +: strspn { addr len addr1 len1 | paddr plen -- addr' len' } + begin + len + while + addr1 to paddr + len1 to plen + begin + plen + while + addr c@ paddr c@ = if addr len exit then + paddr 1+ to paddr + plen 1- to plen + repeat + addr 1 + to addr + len 1 - to len + repeat + 0 0 +; + : s' \ same as s", allows " in the string [char] ' parse state @ if postpone sliteral then @@ -226,10 +245,51 @@ create last_module_option sizeof module.next allot 0 last_module_option ! then ; -\ Returns TRUE if the framebuffer is active, FALSE otherwise -: framebuffer? ( -- flag ) - \ Use the screen-height variable as a proxy for framebuffer - s" screen-height" getenv? +\ execute xt for each device listed in console variable. +\ this allows us to have device specific output for logos, menu frames etc +: console-iterate { xt | caddr clen taddr tlen -- } + \ get current console and save it + s" console" getenv + ['] strdup catch if 2drop exit then + to clen to caddr + + clen to tlen + caddr to taddr + begin + tlen + while + taddr tlen s" , " strspn + \ we need to handle 3 cases for addr len pairs on stack: + \ addr len are 0 0 - there was no comma nor space + \ addr len are x 0 - the first char is either comma or space + \ addr len are x y. + 2dup + 0= if + \ there was no comma nor space. + 2drop + taddr tlen s" console" setenv + xt execute + 0 to tlen + else dup 0= if + 2drop + else + dup ( taddr' tlen' tlen' ) + tlen swap - dup + 0= if \ sequence of comma and space? + drop + else + taddr swap s" console" setenv + xt execute + then + to tlen + to taddr + then then + tlen 0> if \ step over separator + tlen 1- to tlen + taddr 1+ to taddr + then + repeat + caddr clen s" console" setenv \ restore console setup + caddr free drop ; \ Test if booted in an EFI environment @@ -285,6 +345,14 @@ create last_module_option sizeof module.next allot 0 last_module_option ! or \ previous boolean ( or ) boot_multicons ; +: framebuffer? ( -- t ) + s" console" getenv + s" text" compare 0<> if + FALSE exit + then + s" screen-width" getenv? +; + \ Private definitions vocabulary support-functions diff --git a/usr/src/common/ficl/loader.c b/usr/src/common/ficl/loader.c index c41c86c7c2..c1f5c5d0eb 100644 --- a/usr/src/common/ficl/loader.c +++ b/usr/src/common/ficl/loader.c @@ -44,6 +44,7 @@ #else #include <stand.h> #include <gfx_fb.h> +#include <sys/tem_impl.h> #include "bootstrap.h" #endif #ifdef _STANDALONE @@ -71,6 +72,54 @@ * .# ( value -- ) */ +#ifdef _STANDALONE +/* Put image using terminal coordinates. ( flags x1 y1 x2 y2 -- flag ) */ +void +ficl_term_putimage(ficlVm *pVM) +{ + char *namep, *name; + ficlUnsigned names; + ficlInteger ret = FICL_FALSE; + uint32_t x1, y1, x2, y2, f; + png_t png; + + FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 7, 1); + + names = ficlStackPopUnsigned(ficlVmGetDataStack(pVM)); + namep = (char *)ficlStackPopPointer(ficlVmGetDataStack(pVM)); + y2 = ficlStackPopUnsigned(ficlVmGetDataStack(pVM)); + x2 = ficlStackPopUnsigned(ficlVmGetDataStack(pVM)); + y1 = ficlStackPopUnsigned(ficlVmGetDataStack(pVM)); + x1 = ficlStackPopUnsigned(ficlVmGetDataStack(pVM)); + f = ficlStackPopUnsigned(ficlVmGetDataStack(pVM)); + + x1 = tems.ts_p_offset.x + x1 * tems.ts_font.vf_width; + y1 = tems.ts_p_offset.y + y1 * tems.ts_font.vf_height; + if (x2 != 0) { + x2 = tems.ts_p_offset.x + + x2 * tems.ts_font.vf_width; + } + if (y2 != 0) { + y2 = tems.ts_p_offset.y + + y2 * tems.ts_font.vf_height; + } + + name = ficlMalloc(names + 1); + if (!name) + ficlVmThrowError(pVM, "Error: out of memory"); + (void) strncpy(name, namep, names); + name[names] = '\0'; + + if (png_open(&png, name) == PNG_NO_ERROR) { + if (gfx_fb_putimage(&png, x1, y1, x2, y2, f) == 0) + ret = FICL_TRUE; /* success */ + (void) png_close(&png); + } + ficlFree(name); + ficlStackPushInteger(ficlVmGetDataStack(pVM), ret); +} +#endif + /* ( flags x1 y1 x2 y2 -- flag ) */ void ficl_fb_putimage(ficlVm *pVM) @@ -1057,6 +1106,8 @@ ficlSystemCompilePlatform(ficlSystem *pSys) (void) ficlDictionarySetPrimitive(dp, "term-drawrect", ficl_term_drawrect, FICL_WORD_DEFAULT); #ifdef _STANDALONE + (void) ficlDictionarySetPrimitive(dp, "term-putimage", + ficl_term_putimage, FICL_WORD_DEFAULT); /* Register words from linker set. */ SET_FOREACH(fnpp, Xficl_compile_set) (*fnpp)(pSys); diff --git a/usr/src/pkg/manifests/system-boot-loader.mf b/usr/src/pkg/manifests/system-boot-loader.mf index 97fdeac2d3..2073af2013 100644 --- a/usr/src/pkg/manifests/system-boot-loader.mf +++ b/usr/src/pkg/manifests/system-boot-loader.mf @@ -72,7 +72,8 @@ $(i386_ONLY)file path=boot/forth/shortcuts.4th group=sys mode=0444 $(i386_ONLY)file path=boot/forth/support.4th group=sys mode=0444 $(i386_ONLY)file path=boot/forth/version.4th group=sys mode=0444 $(i386_ONLY)file path=boot/gptzfsboot group=sys mode=0444 -$(i386_ONLY)file path=boot/illumos.png group=sys mode=0444 +$(i386_ONLY)file path=boot/illumos-brand.png group=sys mode=0444 +$(i386_ONLY)file path=boot/illumos-logo.png group=sys mode=0444 $(i386_ONLY)file path=boot/isoboot group=sys mode=0444 $(i386_ONLY)file path=boot/loader group=sys mode=0444 $(i386_ONLY)file path=boot/loader.help group=sys mode=0444 |