Print this page
NEX-16819 loader UEFI support
Includes work by Toomas Soome <tsoome@me.com>
Upstream commits:
    loader: pxe receive cleanup
    9475 libefi: Do not return only if ReceiveFilter
    installboot: should support efi system partition
    8931 boot1.efi: scan all display modes rather than
    loader: spinconsole updates
    loader: gfx experiment to try GOP Blt() function.
    sha1 build test
    loader: add sha1 hash calculation
    common/sha1: update for loader build
    loader: biosdisk rework
    uts: 32-bit kernel FB needs mapping in low memory
    uts: add diag-device
    uts: boot console mirror with diag-device
    uts: enable very early console on ttya
    kmdb: add diag-device as input/output device
    uts: test VGA memory exclusion from mapping
    uts: clear boot mapping and protect boot pages test
    uts: add dboot map debug printf
    uts: need to release FB pages in release_bootstrap()
    uts: add screenmap ioctl
    uts: update sys/queue.h
    loader: add illumos uts/common to include path
    loader: tem/gfx font cleanup
    loader: vbe checks
    uts: gfx_private set KD_TEXT when KD_RESETTEXT is
    uts: gfx 8-bit update
    loader: gfx 8-bit fix
    loader: always set media size from partition.
    uts: MB2 support for 32-bit kernel
    loader: x86 should have tem 80x25
    uts: x86 should have tem 80x25
    uts: font update
    loader: font update
    uts: tem attributes
    loader: tem.c comment added
    uts: use font module
    loader: add font module
    loader: build rules for new font setup
    uts: gfx_private update for new font structure
    uts: early boot update for new font structure
    uts: font update
    uts: font build rules update for new fonts
    uts: tem update to new font structure
    loader: module.c needs to include tem_impl.h
    uts: gfx_private 8x16 font rework
    uts: make font_lookup public
    loader: font rework
    uts: font rework
    9259 libefi: efi_alloc_and_read should check for PMBR
    uts: tem utf-8 support
    loader: implement tem utf-8 support
    loader: tem should be able to display UTF-8
    7784 uts: console input should support utf-8
    7796 uts: ldterm default to utf-8
    uts: do not reset serial console
    uts: set up colors even if tem is not console
    uts: add type for early boot properties
    uts: gfx_private experiment with drm and vga
    uts: gfx_private should use setmode drm callback.
    uts: identify FB types and set up gfx_private based
    loader: replace gop and vesa with framebuffer
    uts: boot needs simple tem to support mdb
    uts: boot_keyboard should emit esc sequences for
    uts: gfx_private FB showuld be written by line
    kmdb: set terminal window size
    uts: gfx_private needs to keep track of early boot FB
    pnglite: move pnglite to usr/src/common
    loader: gfx_fb
    ficl-sys: add gfx primitives
    loader: add illumos.png logo
    ficl: add fb-putimage
    loader: add png support
    loader: add alpha blending for gfx_fb
    loader: use term-drawrect for menu frame
    ficl: add simple gfx words
    uts: provide fb_info via fbgattr dev_specific array.
    uts: gfx_private add alpha blending
    uts: update sys/ascii.h
    uts: tem OSC support (incomplete)
    uts: implement env module support and use data from
    uts: tem get colors from early boot data
    loader: use crc32 from libstand (libz)
    loader: optimize for size
    loader: pass tem info to the environment
    loader: import tem for loader console
    loader: UEFI loader needs to set ISADIR based on
    loader: need UEFI32 support
    8918 loader.efi: add vesa edid support
    uts: tem_safe_pix_clear_prom_output() should only
    uts: tem_safe_pix_clear_entire_screen() should use
    uts: tem_safe_check_first_time() should query cursor
    uts: tem implement cls callback & visual_io v4
    uts: gfx_vgatext use block cursor for vgatext
    uts: gfx_private implement cls callback & visual_io
    uts: gfx_private bitmap framebuffer implementation
    uts: early start frame buffer console support
    uts: font functions should check the input char
    uts: font rendering should support 16/24/32bit depths
    uts: use smallest font as fallback default.
    uts: update terminal dimensions based on selected
    7834 uts: vgatext should use gfx_private
    uts: add spacing property to 8859-1.bdf
    terminfo: add underline for sun-color
    terminfo: sun-color has 16 colors
    uts: add font load callback type
    loader: do not repeat int13 calls with error 0x20 and
    8905 loader: add skein/edonr support
    8904 common/crypto: make skein and edonr loader
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Revert "NEX-16819 loader UEFI support"
This reverts commit ec06b9fc617b99234e538bf2e7e4d02a24993e0c.
Reverting due to failures in the zfs-tests and the sharefs-tests
NEX-16819 loader UEFI support
Includes work by Toomas Soome <tsoome@me.com>
Upstream commits:
    loader: pxe receive cleanup
    9475 libefi: Do not return only if ReceiveFilter
    installboot: should support efi system partition
    8931 boot1.efi: scan all display modes rather than
    loader: spinconsole updates
    loader: gfx experiment to try GOP Blt() function.
    sha1 build test
    loader: add sha1 hash calculation
    common/sha1: update for loader build
    loader: biosdisk rework
    uts: 32-bit kernel FB needs mapping in low memory
    uts: add diag-device
    uts: boot console mirror with diag-device
    uts: enable very early console on ttya
    kmdb: add diag-device as input/output device
    uts: test VGA memory exclusion from mapping
    uts: clear boot mapping and protect boot pages test
    uts: add dboot map debug printf
    uts: need to release FB pages in release_bootstrap()
    uts: add screenmap ioctl
    uts: update sys/queue.h
    loader: add illumos uts/common to include path
    loader: tem/gfx font cleanup
    loader: vbe checks
    uts: gfx_private set KD_TEXT when KD_RESETTEXT is
    uts: gfx 8-bit update
    loader: gfx 8-bit fix
    loader: always set media size from partition.
    uts: MB2 support for 32-bit kernel
    loader: x86 should have tem 80x25
    uts: x86 should have tem 80x25
    uts: font update
    loader: font update
    uts: tem attributes
    loader: tem.c comment added
    uts: use font module
    loader: add font module
    loader: build rules for new font setup
    uts: gfx_private update for new font structure
    uts: early boot update for new font structure
    uts: font update
    uts: font build rules update for new fonts
    uts: tem update to new font structure
    loader: module.c needs to include tem_impl.h
    uts: gfx_private 8x16 font rework
    uts: make font_lookup public
    loader: font rework
    uts: font rework
    libefi: efi_alloc_and_read should check for PMBR
    uts: tem utf-8 support
    loader: implement tem utf-8 support
    loader: tem should be able to display UTF-8
    7784 uts: console input should support utf-8
    7796 uts: ldterm default to utf-8
    uts: do not reset serial console
    uts: set up colors even if tem is not console
    uts: add type for early boot properties
    uts: gfx_private experiment with drm and vga
    uts: gfx_private should use setmode drm callback.
    uts: identify FB types and set up gfx_private based
    loader: replace gop and vesa with framebuffer
    uts: boot needs simple tem to support mdb
    uts: boot_keyboard should emit esc sequences for
    uts: gfx_private FB showuld be written by line
    kmdb: set terminal window size
    uts: gfx_private needs to keep track of early boot FB
    pnglite: move pnglite to usr/src/common
    loader: gfx_fb
    ficl-sys: add gfx primitives
    loader: add illumos.png logo
    ficl: add fb-putimage
    loader: add png support
    loader: add alpha blending for gfx_fb
    loader: use term-drawrect for menu frame
    ficl: add simple gfx words
    uts: provide fb_info via fbgattr dev_specific array.
    uts: gfx_private add alpha blending
    uts: update sys/ascii.h
    uts: tem OSC support (incomplete)
    uts: implement env module support and use data from
    uts: tem get colors from early boot data
    loader: use crc32 from libstand (libz)
    loader: optimize for size
    loader: pass tem info to the environment
    loader: import tem for loader console
    loader: UEFI loader needs to set ISADIR based on
    loader: need UEFI32 support
    8918 loader.efi: add vesa edid support
    uts: tem_safe_pix_clear_prom_output() should only
    uts: tem_safe_pix_clear_entire_screen() should use
    uts: tem_safe_check_first_time() should query cursor
    uts: tem implement cls callback & visual_io v4
    uts: gfx_vgatext use block cursor for vgatext
    uts: gfx_private implement cls callback & visual_io
    uts: gfx_private bitmap framebuffer implementation
    uts: early start frame buffer console support
    uts: font functions should check the input char
    uts: font rendering should support 16/24/32bit depths
    uts: use smallest font as fallback default.
    uts: update terminal dimensions based on selected
    7834 uts: vgatext should use gfx_private
    uts: add spacing property to 8859-1.bdf
    terminfo: add underline for sun-color
    terminfo: sun-color has 16 colors
    uts: add font load callback type
    loader: do not repeat int13 calls with error 0x20 and
    8905 loader: add skein/edonr support
    8904 common/crypto: make skein and edonr loader
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>


  34 #ifndef _STANDALONE
  35 #include <sys/types.h>
  36 #include <sys/stat.h>
  37 #include <dirent.h>
  38 #include <fcntl.h>
  39 #include <stdio.h>
  40 #include <stdlib.h>
  41 #include <unistd.h>
  42 #include <strings.h>
  43 #include <termios.h>
  44 #else
  45 #include <stand.h>
  46 #include "bootstrap.h"
  47 #endif
  48 #ifdef _STANDALONE
  49 #include <uuid.h>
  50 #else
  51 #include <uuid/uuid.h>
  52 #endif
  53 #include <string.h>

  54 #include "ficl.h"
  55 
  56 /*
  57  *              FreeBSD's loader interaction words and extras
  58  *
  59  *              setenv      ( value n name n' -- )
  60  *              setenv?     ( value n name n' flag -- )
  61  *              getenv      ( addr n -- addr' n' | -1 )
  62  *              unsetenv    ( addr n -- )
  63  *              copyin      ( addr addr' len -- )
  64  *              copyout     ( addr addr' len -- )
  65  *              findfile    ( name len type len' -- addr )
  66  *              ccall       ( [[...[p10] p9] ... p1] n addr -- result )
  67  *              uuid-from-string ( addr n -- addr' )
  68  *              uuid-to-string ( addr' -- addr n | -1 )
  69  *              .#          ( value -- )
  70  */
  71 
  72 void









































































































  73 ficlSetenv(ficlVm *pVM)
  74 {
  75         char *name, *value;
  76         char *namep, *valuep;
  77         int names, values;
  78 
  79         FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 4, 0);
  80 
  81         names = ficlStackPopInteger(ficlVmGetDataStack(pVM));
  82         namep = (char *)ficlStackPopPointer(ficlVmGetDataStack(pVM));
  83         values = ficlStackPopInteger(ficlVmGetDataStack(pVM));
  84         valuep = (char *)ficlStackPopPointer(ficlVmGetDataStack(pVM));
  85 
  86         name = (char *)ficlMalloc(names+1);
  87         if (!name)
  88                 ficlVmThrowError(pVM, "Error: out of memory");
  89         strncpy(name, namep, names);
  90         name[names] = '\0';
  91         value = (char *)ficlMalloc(values+1);
  92         if (!value)


 897         ficlDictionarySetPrimitive(dp, "ms", ms, FICL_WORD_DEFAULT);
 898         ficlDictionarySetPrimitive(dp, "seconds", pseconds, FICL_WORD_DEFAULT);
 899         ficlDictionarySetPrimitive(dp, "heap?", freeHeap, FICL_WORD_DEFAULT);
 900 
 901         ficlDictionarySetPrimitive(dp, "setenv", ficlSetenv, FICL_WORD_DEFAULT);
 902         ficlDictionarySetPrimitive(dp, "setenv?", ficlSetenvq,
 903             FICL_WORD_DEFAULT);
 904         ficlDictionarySetPrimitive(dp, "getenv", ficlGetenv, FICL_WORD_DEFAULT);
 905         ficlDictionarySetPrimitive(dp, "unsetenv", ficlUnsetenv,
 906             FICL_WORD_DEFAULT);
 907         ficlDictionarySetPrimitive(dp, "copyin", ficlCopyin, FICL_WORD_DEFAULT);
 908         ficlDictionarySetPrimitive(dp, "copyout", ficlCopyout,
 909             FICL_WORD_DEFAULT);
 910         ficlDictionarySetPrimitive(dp, "findfile", ficlFindfile,
 911             FICL_WORD_DEFAULT);
 912         ficlDictionarySetPrimitive(dp, "ccall", ficlCcall, FICL_WORD_DEFAULT);
 913         ficlDictionarySetPrimitive(dp, "uuid-from-string", ficlUuidFromString,
 914             FICL_WORD_DEFAULT);
 915         ficlDictionarySetPrimitive(dp, "uuid-to-string", ficlUuidToString,
 916             FICL_WORD_DEFAULT);












 917 #ifdef _STANDALONE
 918         /* Register words from linker set. */
 919         SET_FOREACH(fnpp, Xficl_compile_set)
 920                 (*fnpp)(pSys);
 921 #endif
 922 
 923 #if defined(__i386__) || defined(__amd64__)
 924         ficlDictionarySetConstant(env, "arch-i386", FICL_TRUE);
 925         ficlDictionarySetConstant(env, "arch-sparc", FICL_FALSE);
 926 #endif
 927 #ifdef __sparc
 928         ficlDictionarySetConstant(env, "arch-i386", FICL_FALSE);
 929         ficlDictionarySetConstant(env, "arch-sparc", FICL_TRUE);
 930 #endif
 931 }


  34 #ifndef _STANDALONE
  35 #include <sys/types.h>
  36 #include <sys/stat.h>
  37 #include <dirent.h>
  38 #include <fcntl.h>
  39 #include <stdio.h>
  40 #include <stdlib.h>
  41 #include <unistd.h>
  42 #include <strings.h>
  43 #include <termios.h>
  44 #else
  45 #include <stand.h>
  46 #include "bootstrap.h"
  47 #endif
  48 #ifdef _STANDALONE
  49 #include <uuid.h>
  50 #else
  51 #include <uuid/uuid.h>
  52 #endif
  53 #include <string.h>
  54 #include <gfx_fb.h>
  55 #include "ficl.h"
  56 
  57 /*
  58  *              FreeBSD's loader interaction words and extras
  59  *
  60  *              setenv      ( value n name n' -- )
  61  *              setenv?     ( value n name n' flag -- )
  62  *              getenv      ( addr n -- addr' n' | -1 )
  63  *              unsetenv    ( addr n -- )
  64  *              copyin      ( addr addr' len -- )
  65  *              copyout     ( addr addr' len -- )
  66  *              findfile    ( name len type len' -- addr )
  67  *              ccall       ( [[...[p10] p9] ... p1] n addr -- result )
  68  *              uuid-from-string ( addr n -- addr' )
  69  *              uuid-to-string ( addr' -- addr n | -1 )
  70  *              .#          ( value -- )
  71  */
  72 
  73 void
  74 ficl_fb_putimage(ficlVm *pVM)
  75 {
  76         char *namep, *name;
  77         int names, ret = 0;
  78         png_t png;
  79 
  80         FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 2, 1);
  81 
  82         names = ficlStackPopInteger(ficlVmGetDataStack(pVM));
  83         namep = (char *)ficlStackPopPointer(ficlVmGetDataStack(pVM));
  84 
  85         name = ficlMalloc(names+1);
  86         if (!name)
  87                 ficlVmThrowError(pVM, "Error: out of memory");
  88         strncpy(name, namep, names);
  89         name[names] = '\0';
  90 
  91         if ((ret = png_open(&png, name)) != PNG_NO_ERROR) {
  92                 ret = 0;
  93                 ficlFree(name);
  94                 ficlStackPushInteger(ficlVmGetDataStack(pVM), ret);
  95                 return;
  96         }
  97 
  98         if (gfx_fb_putimage(&png) == 0)
  99                 ret = -1;       /* success */
 100         png_close(&png);
 101         ficlFree(name);
 102         ficlStackPushInteger(ficlVmGetDataStack(pVM), ret);
 103 }
 104 
 105 void
 106 ficl_fb_setpixel(ficlVm *pVM)
 107 {
 108         uint32_t x, y;
 109 
 110         FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 2, 0);
 111 
 112         y = ficlStackPopInteger(ficlVmGetDataStack(pVM));
 113         x = ficlStackPopInteger(ficlVmGetDataStack(pVM));
 114         gfx_fb_setpixel(x, y);
 115 }
 116 
 117 void
 118 ficl_fb_line(ficlVm *pVM)
 119 {
 120         uint32_t x0, y0, x1, y1, wd;
 121 
 122         FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 5, 0);
 123 
 124         wd = ficlStackPopInteger(ficlVmGetDataStack(pVM));
 125         y1 = ficlStackPopInteger(ficlVmGetDataStack(pVM));
 126         x1 = ficlStackPopInteger(ficlVmGetDataStack(pVM));
 127         y0 = ficlStackPopInteger(ficlVmGetDataStack(pVM));
 128         x0 = ficlStackPopInteger(ficlVmGetDataStack(pVM));
 129         gfx_fb_line(x0, y0, x1, y1, wd);
 130 }
 131 
 132 void
 133 ficl_fb_bezier(ficlVm *pVM)
 134 {
 135         uint32_t x0, y0, x1, y1, x2, y2, width;
 136 
 137         FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 7, 0);
 138 
 139         width = ficlStackPopInteger(ficlVmGetDataStack(pVM));
 140         y2 = ficlStackPopInteger(ficlVmGetDataStack(pVM));
 141         x2 = ficlStackPopInteger(ficlVmGetDataStack(pVM));
 142         y1 = ficlStackPopInteger(ficlVmGetDataStack(pVM));
 143         x1 = ficlStackPopInteger(ficlVmGetDataStack(pVM));
 144         y0 = ficlStackPopInteger(ficlVmGetDataStack(pVM));
 145         x0 = ficlStackPopInteger(ficlVmGetDataStack(pVM));
 146         gfx_fb_bezier(x0, y0, x1, y1, x2, y2, width);
 147 }
 148 
 149 void
 150 ficl_fb_drawrect(ficlVm *pVM)
 151 {
 152         uint32_t x1, x2, y1, y2, fill;
 153 
 154         FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 5, 0);
 155 
 156         fill = ficlStackPopInteger(ficlVmGetDataStack(pVM));
 157         y2 = ficlStackPopInteger(ficlVmGetDataStack(pVM));
 158         x2 = ficlStackPopInteger(ficlVmGetDataStack(pVM));
 159         y1 = ficlStackPopInteger(ficlVmGetDataStack(pVM));
 160         x1 = ficlStackPopInteger(ficlVmGetDataStack(pVM));
 161         gfx_fb_drawrect(x1, y1, x2, y2, fill);
 162 }
 163 
 164 void
 165 ficl_term_drawrect(ficlVm *pVM)
 166 {
 167         uint32_t x1, x2, y1, y2;
 168 
 169         FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 4, 0);
 170 
 171         y2 = ficlStackPopInteger(ficlVmGetDataStack(pVM));
 172         x2 = ficlStackPopInteger(ficlVmGetDataStack(pVM));
 173         y1 = ficlStackPopInteger(ficlVmGetDataStack(pVM));
 174         x1 = ficlStackPopInteger(ficlVmGetDataStack(pVM));
 175         gfx_term_drawrect(x1, y1, x2, y2);
 176 }
 177 
 178 void
 179 ficlSetenv(ficlVm *pVM)
 180 {
 181         char *name, *value;
 182         char *namep, *valuep;
 183         int names, values;
 184 
 185         FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 4, 0);
 186 
 187         names = ficlStackPopInteger(ficlVmGetDataStack(pVM));
 188         namep = (char *)ficlStackPopPointer(ficlVmGetDataStack(pVM));
 189         values = ficlStackPopInteger(ficlVmGetDataStack(pVM));
 190         valuep = (char *)ficlStackPopPointer(ficlVmGetDataStack(pVM));
 191 
 192         name = (char *)ficlMalloc(names+1);
 193         if (!name)
 194                 ficlVmThrowError(pVM, "Error: out of memory");
 195         strncpy(name, namep, names);
 196         name[names] = '\0';
 197         value = (char *)ficlMalloc(values+1);
 198         if (!value)


1003         ficlDictionarySetPrimitive(dp, "ms", ms, FICL_WORD_DEFAULT);
1004         ficlDictionarySetPrimitive(dp, "seconds", pseconds, FICL_WORD_DEFAULT);
1005         ficlDictionarySetPrimitive(dp, "heap?", freeHeap, FICL_WORD_DEFAULT);
1006 
1007         ficlDictionarySetPrimitive(dp, "setenv", ficlSetenv, FICL_WORD_DEFAULT);
1008         ficlDictionarySetPrimitive(dp, "setenv?", ficlSetenvq,
1009             FICL_WORD_DEFAULT);
1010         ficlDictionarySetPrimitive(dp, "getenv", ficlGetenv, FICL_WORD_DEFAULT);
1011         ficlDictionarySetPrimitive(dp, "unsetenv", ficlUnsetenv,
1012             FICL_WORD_DEFAULT);
1013         ficlDictionarySetPrimitive(dp, "copyin", ficlCopyin, FICL_WORD_DEFAULT);
1014         ficlDictionarySetPrimitive(dp, "copyout", ficlCopyout,
1015             FICL_WORD_DEFAULT);
1016         ficlDictionarySetPrimitive(dp, "findfile", ficlFindfile,
1017             FICL_WORD_DEFAULT);
1018         ficlDictionarySetPrimitive(dp, "ccall", ficlCcall, FICL_WORD_DEFAULT);
1019         ficlDictionarySetPrimitive(dp, "uuid-from-string", ficlUuidFromString,
1020             FICL_WORD_DEFAULT);
1021         ficlDictionarySetPrimitive(dp, "uuid-to-string", ficlUuidToString,
1022             FICL_WORD_DEFAULT);
1023         ficlDictionarySetPrimitive(dp, "fb-setpixel", ficl_fb_setpixel,
1024             FICL_WORD_DEFAULT);
1025         ficlDictionarySetPrimitive(dp, "fb-line", ficl_fb_line,
1026             FICL_WORD_DEFAULT);
1027         ficlDictionarySetPrimitive(dp, "fb-bezier", ficl_fb_bezier,
1028             FICL_WORD_DEFAULT);
1029         ficlDictionarySetPrimitive(dp, "fb-drawrect", ficl_fb_drawrect,
1030             FICL_WORD_DEFAULT);
1031         ficlDictionarySetPrimitive(dp, "fb-putimage", ficl_fb_putimage,
1032             FICL_WORD_DEFAULT);
1033         ficlDictionarySetPrimitive(dp, "term-drawrect", ficl_term_drawrect,
1034             FICL_WORD_DEFAULT);
1035 #ifdef _STANDALONE
1036         /* Register words from linker set. */
1037         SET_FOREACH(fnpp, Xficl_compile_set)
1038                 (*fnpp)(pSys);
1039 #endif
1040 
1041 #if defined(__i386__) || defined(__amd64__)
1042         ficlDictionarySetConstant(env, "arch-i386", FICL_TRUE);
1043         ficlDictionarySetConstant(env, "arch-sparc", FICL_FALSE);
1044 #endif
1045 #ifdef __sparc
1046         ficlDictionarySetConstant(env, "arch-i386", FICL_FALSE);
1047         ficlDictionarySetConstant(env, "arch-sparc", FICL_TRUE);
1048 #endif
1049 }