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>

@@ -48,10 +48,11 @@
 #include <sys/param.h>
 #include <sys/machparam.h>
 #include <sys/machsystm.h>
 #include <sys/archsystm.h>
 #include <sys/boot_console.h>
+#include <sys/framebuffer.h>
 #include <sys/cmn_err.h>
 #include <sys/systm.h>
 #include <sys/promif.h>
 #include <sys/archsystm.h>
 #include <sys/x86_archext.h>

@@ -70,10 +71,11 @@
 #include <sys/kobj_lex.h>
 #include <sys/pci_cfgspace_impl.h>
 #include <sys/fastboot_impl.h>
 #include <sys/acpi/acconfig.h>
 #include <sys/acpi/acpi.h>
+#include <sys/ddipropdefs.h>    /* For DDI prop types */
 
 static int have_console = 0;    /* set once primitive console is initialized */
 static char *boot_args = "";
 
 /*

@@ -89,10 +91,13 @@
         char *cp;                               \
         for (cp = (s); *cp; ++cp)               \
                 bcons_putchar(*cp);             \
         }
 
+/* callback to boot_fb to set shadow frame buffer */
+extern void boot_fb_shadow_init(bootops_t *);
+
 bootops_t bootop;       /* simple bootops we'll pass on to kernel */
 struct bsys_mem bm;
 
 /*
  * Boot info from "glue" code in low memory. xbootp is used by:

@@ -113,11 +118,12 @@
  * stuff to store/report/manipulate boot property settings.
  */
 typedef struct bootprop {
         struct bootprop *bp_next;
         char *bp_name;
-        uint_t bp_vlen;
+        int bp_flags;                   /* DDI prop type */
+        uint_t bp_vlen;                 /* 0 for boolean */
         char *bp_value;
 } bootprop_t;
 
 static bootprop_t *bprops = NULL;
 static char *curr_page = NULL;          /* ptr to avail bprop memory */

@@ -350,11 +356,11 @@
         return (0);
 }
 
 
 static void
-bsetprop(char *name, int nlen, void *value, int vlen)
+bsetprop(int flags, char *name, int nlen, void *value, int vlen)
 {
         uint_t size;
         uint_t need_size;
         bootprop_t *b;
 

@@ -386,10 +392,15 @@
         curr_page += nlen;
         *curr_page++ = 0;
         curr_space -= nlen + 1;
 
         /*
+         * set the property type
+         */
+        b->bp_flags = flags & DDI_PROP_TYPE_MASK;
+
+        /*
          * copy in value, but no ending zero byte
          */
         b->bp_value = curr_page;
         b->bp_vlen = vlen;
         if (vlen > 0) {

@@ -408,17 +419,26 @@
 }
 
 static void
 bsetprops(char *name, char *value)
 {
-        bsetprop(name, strlen(name), value, strlen(value) + 1);
+        bsetprop(DDI_PROP_TYPE_STRING, name, strlen(name),
+            value, strlen(value) + 1);
 }
 
 static void
+bsetprop32(char *name, uint32_t value)
+{
+        bsetprop(DDI_PROP_TYPE_INT, name, strlen(name),
+            (void *)&value, sizeof (value));
+}
+
+static void
 bsetprop64(char *name, uint64_t value)
 {
-        bsetprop(name, strlen(name), (void *)&value, sizeof (value));
+        bsetprop(DDI_PROP_TYPE_INT64, name, strlen(name),
+            (void *)&value, sizeof (value));
 }
 
 static void
 bsetpropsi(char *name, int value)
 {

@@ -427,10 +447,27 @@
         (void) snprintf(prop_val, sizeof (prop_val), "%d", value);
         bsetprops(name, prop_val);
 }
 
 /*
+ * to find the type of the value associated with this name
+ */
+/*ARGSUSED*/
+int
+do_bsys_getproptype(bootops_t *bop, const char *name)
+{
+        bootprop_t *b;
+
+        for (b = bprops; b; b = b->bp_next) {
+                if (strcmp(name, b->bp_name) != 0)
+                        continue;
+                return (b->bp_flags);
+        }
+        return (-1);
+}
+
+/*
  * to find the size of the buffer to allocate
  */
 /*ARGSUSED*/
 int
 do_bsys_getproplen(bootops_t *bop, const char *name)

@@ -566,29 +603,57 @@
  */
 static void
 boot_prop_display(char *buffer)
 {
         char *name = "";
-        int i, len;
+        int i, len, flags, *buf32;
+        uint64_t *buf64;
 
         bop_printf(NULL, "\nBoot properties:\n");
 
         while ((name = do_bsys_nextprop(NULL, name)) != NULL) {
                 bop_printf(NULL, "\t0x%p %s = ", (void *)name, name);
                 (void) do_bsys_getprop(NULL, name, buffer);
                 len = do_bsys_getproplen(NULL, name);
+                flags = do_bsys_getproptype(NULL, name);
                 bop_printf(NULL, "len=%d ", len);
+
+                switch (flags) {
+                case DDI_PROP_TYPE_INT:
+                        len = len / sizeof (int);
+                        buf32 = (int *)buffer;
+                        for (i = 0; i < len; i++) {
+                                bop_printf(NULL, "%08x", buf32[i]);
+                                if (i < len - 1)
+                                        bop_printf(NULL, ".");
+                        }
+                        break;
+                case DDI_PROP_TYPE_STRING:
+                        bop_printf(NULL, buffer);
+                        break;
+                case DDI_PROP_TYPE_INT64:
+                        len = len / sizeof (uint64_t);
+                        buf64 = (uint64_t *)buffer;
+                        for (i = 0; i < len; i++) {
+                                bop_printf(NULL, "%016" PRIx64, buf64[i]);
+                                if (i < len - 1)
+                                        bop_printf(NULL, ".");
+                        }
+                        break;
+                default:
                 if (!unprintable(buffer, len)) {
                         buffer[len] = 0;
-                        bop_printf(NULL, "%s\n", buffer);
-                        continue;
+                                bop_printf(NULL, "%s", buffer);
+                                break;
                 }
                 for (i = 0; i < len; i++) {
                         bop_printf(NULL, "%02x", buffer[i] & 0xff);
                         if (i < len - 1)
                                 bop_printf(NULL, ".");
                 }
+                        break;
+                }
                 bop_printf(NULL, "\n");
         }
 }
 
 /*

@@ -712,14 +777,14 @@
 
                 /*
                  * If a property was explicitly set on the command line
                  * it will override a setting in bootenv.rc
                  */
-                if (do_bsys_getproplen(NULL, name) > 0)
+                if (do_bsys_getproplen(NULL, name) >= 0)
                         continue;
 
-                bsetprop(name, n_len, value, v_len + 1);
+                bsetprops(name, value);
         }
 done:
         if (fd >= 0)
                 (void) BRD_CLOSE(bfs_ops, fd);
 

@@ -989,11 +1054,11 @@
                 BP_SERVER_NAME, /* server hostname */
                 BP_SERVER_PATH, /* root path */
         };
         int n_prop = sizeof (prop_map) / sizeof (prop_map[0]);
 
-        bsetprop("fstype", 6, "nfs", 4);
+        bsetprops("fstype", "nfs");
 
         xen_parse_props(s, prop_map, n_prop);
 
         /*
          * If a server name wasn't specified, use a default.

@@ -1355,11 +1420,13 @@
                 for (midx = i = 0; i < xbp->bi_module_cnt; i++) {
                         if (bm[i].bm_type == BMT_ROOTFS) {
                                 rdbm = &bm[i];
                                 continue;
                         }
-                        if (bm[i].bm_type == BMT_HASH || bm[i].bm_name == NULL)
+                        if (bm[i].bm_type == BMT_HASH ||
+                            bm[i].bm_type == BMT_FONT ||
+                            bm[i].bm_name == NULL)
                                 continue;
 
                         if (bm[i].bm_type == BMT_ENV) {
                                 if (benv == NULL)
                                         benv = &bm[i];

@@ -1570,11 +1637,12 @@
                                     ISSPACE(value[value_len]))
                                         break;
                         }
 
                         if (value_len == 0) {
-                                bsetprop(name, name_len, "true", 5);
+                                bsetprop(DDI_PROP_TYPE_ANY, name, name_len,
+                                    NULL, 0);
                         } else {
                                 char *v = value;
                                 int l = value_len;
                                 if (v[0] == v[l - 1] &&
                                     (v[0] == '\'' || v[0] == '"')) {

@@ -1581,12 +1649,12 @@
                                         ++v;
                                         l -= 2;
                                 }
                                 bcopy(v, propbuf, l);
                                 propbuf[l] = '\0';
-                                bsetprop(name, name_len, propbuf,
-                                    l + 1);
+                                bsetprop(DDI_PROP_TYPE_STRING, name, name_len,
+                                    propbuf, l + 1);
                         }
                         name = value + value_len;
                         while (*name == ',')
                                 ++name;
                 }

@@ -1641,11 +1709,12 @@
                  * special pxegrub!
                  */
                 if (netboot && mbi->drives_length != 0) {
                         sip = (struct sol_netinfo *)(uintptr_t)mbi->drives_addr;
                         if (sip->sn_infotype == SN_TYPE_BOOTP)
-                                bsetprop("bootp-response",
+                                bsetprop(DDI_PROP_TYPE_BYTE,
+                                    "bootp-response",
                                     sizeof ("bootp-response"),
                                     (void *)(uintptr_t)mbi->drives_addr,
                                     mbi->drives_length);
                         else if (sip->sn_infotype == SN_TYPE_RARP)
                                 setup_rarp_props(sip);

@@ -1668,19 +1737,19 @@
                         str[1] = (boot_device & 0xf) + '0';
                         str[2] = 0;
                         bsetprops("bios-boot-device", str);
                 }
                 if (netdev != NULL) {
-                        bsetprop("bootp-response", sizeof ("bootp-response"),
+                        bsetprop(DDI_PROP_TYPE_BYTE,
+                            "bootp-response", sizeof ("bootp-response"),
                             (void *)(uintptr_t)netdev->mb_dhcpack,
                             netdev->mb_size -
                             sizeof (multiboot_tag_network_t));
                 }
         }
 
-        bsetprop("stdout", strlen("stdout"),
-            &stdout_val, sizeof (stdout_val));
+        bsetprop32("stdout", stdout_val);
 #endif /* __xpv */
 
         /*
          * more conjured up values for made up things....
          */

@@ -2027,10 +2096,12 @@
          * Install an IDT to catch early pagefaults (shouldn't have any).
          * Also needed for kmdb.
          */
         bop_idt_init();
 #endif
+        /* Set up the shadow fb for framebuffer console */
+        boot_fb_shadow_init(bops);
 
         /*
          * Start building the boot properties from the command line
          */
         DBG_MSG("Initializing boot properties:\n");

@@ -2306,11 +2377,12 @@
                 if (cfg_baap->Address != 0 && cfg_baap->PciSegment == 0) {
                         ecfginfo[0] = cfg_baap->Address;
                         ecfginfo[1] = cfg_baap->PciSegment;
                         ecfginfo[2] = cfg_baap->StartBusNumber;
                         ecfginfo[3] = cfg_baap->EndBusNumber;
-                        bsetprop(MCFG_PROPNAME, strlen(MCFG_PROPNAME),
+                        bsetprop(DDI_PROP_TYPE_INT64,
+                            MCFG_PROPNAME, strlen(MCFG_PROPNAME),
                             ecfginfo, sizeof (ecfginfo));
                         break;
                 }
                 cfg_baap++;
         }

@@ -2394,11 +2466,12 @@
 
                 /*
                  * Make boot property for array of "final" APIC IDs for each
                  * CPU
                  */
-                bsetprop(BP_CPU_APICID_ARRAY, strlen(BP_CPU_APICID_ARRAY),
+                bsetprop(DDI_PROP_TYPE_INT,
+                    BP_CPU_APICID_ARRAY, strlen(BP_CPU_APICID_ARRAY),
                     cpu_apicid_array, cpu_count * sizeof (*cpu_apicid_array));
         }
 
         /*
          * Check whether property plat-max-ncpus is already set.

@@ -2487,11 +2560,12 @@
                                     cpu->ProximityDomainHi[i] << ((i + 1) * 8);
                         processor.apic_id = cpu->ApicId;
                         processor.sapic_id = cpu->LocalSapicEid;
                         (void) snprintf(prop_name, 30, "acpi-srat-processor-%d",
                             proc_num);
-                        bsetprop(prop_name, strlen(prop_name), &processor,
+                        bsetprop(DDI_PROP_TYPE_INT,
+                            prop_name, strlen(prop_name), &processor,
                             sizeof (processor));
                         proc_num++;
                         break;
                 }
                 case ACPI_SRAT_TYPE_MEMORY_AFFINITY: {

@@ -2504,11 +2578,12 @@
                         memory.addr = mem->BaseAddress;
                         memory.length = mem->Length;
                         memory.flags = mem->Flags;
                         (void) snprintf(prop_name, 30, "acpi-srat-memory-%d",
                             mem_num);
-                        bsetprop(prop_name, strlen(prop_name), &memory,
+                        bsetprop(DDI_PROP_TYPE_INT,
+                            prop_name, strlen(prop_name), &memory,
                             sizeof (memory));
                         if ((mem->Flags & ACPI_SRAT_MEM_HOT_PLUGGABLE) &&
                             (memory.addr + memory.length > maxmem)) {
                                 maxmem = memory.addr + memory.length;
                         }

@@ -2523,11 +2598,12 @@
                                 break;
                         x2apic.domain = x2cpu->ProximityDomain;
                         x2apic.x2apic_id = x2cpu->ApicId;
                         (void) snprintf(prop_name, 30, "acpi-srat-processor-%d",
                             proc_num);
-                        bsetprop(prop_name, strlen(prop_name), &x2apic,
+                        bsetprop(DDI_PROP_TYPE_INT,
+                            prop_name, strlen(prop_name), &x2apic,
                             sizeof (x2apic));
                         proc_num++;
                         break;
                 }
                 default:

@@ -2564,13 +2640,13 @@
          * passed to bsetprop() below.
          */
         if (tp->LocalityCount >= SLIT_LOCALITIES_MAX)
                 return;
 
-        bsetprop(SLIT_NUM_PROPNAME, strlen(SLIT_NUM_PROPNAME),
-            &tp->LocalityCount, sizeof (tp->LocalityCount));
-        bsetprop(SLIT_PROPNAME, strlen(SLIT_PROPNAME), &tp->Entry,
+        bsetprop64(SLIT_NUM_PROPNAME, tp->LocalityCount);
+        bsetprop(DDI_PROP_TYPE_BYTE,
+            SLIT_PROPNAME, strlen(SLIT_PROPNAME), &tp->Entry,
             tp->LocalityCount * tp->LocalityCount);
 }
 
 static ACPI_TABLE_MSCT *
 process_msct(ACPI_TABLE_MSCT *tp)

@@ -2758,12 +2834,11 @@
 {
         static char *p = NULL;
 
         p = do_bsys_alloc(NULL, NULL, size, MMU_PAGESIZE);
         *p = 0;
-        bsetprop("deferred-console-buf", strlen("deferred-console-buf") + 1,
-            &p, sizeof (p));
+        bsetprop32("deferred-console-buf", (uint32_t)((uintptr_t)&p));
         return (p);
 }
 
 /*ARGSUSED*/
 int