summaryrefslogtreecommitdiff
path: root/usr/src/boot
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/boot')
-rw-r--r--usr/src/boot/common/console.c13
-rw-r--r--usr/src/boot/efi/loader/Makefile.com10
-rw-r--r--usr/src/boot/efi/loader/conf.c8
-rw-r--r--usr/src/boot/forth/Makefile11
-rw-r--r--usr/src/boot/forth/brand-smartos.4th38
-rw-r--r--usr/src/boot/forth/loader.4th18
-rw-r--r--usr/src/boot/forth/loader.rc10
-rw-r--r--usr/src/boot/forth/logo-smartos.4th41
-rw-r--r--usr/src/boot/forth/menu-commands.4th114
-rw-r--r--usr/src/boot/forth/menu.4th44
-rw-r--r--usr/src/boot/forth/support.4th15
-rw-r--r--usr/src/boot/forth/triton-logo.pngbin0 -> 13720 bytes
-rw-r--r--usr/src/boot/forth/triton.menu.rc109
-rw-r--r--usr/src/boot/forth/triton.pngbin0 -> 2561 bytes
-rw-r--r--usr/src/boot/i386/libi386/i386_copy.c20
-rw-r--r--usr/src/boot/i386/pmbr/pmbr.s4
16 files changed, 438 insertions, 17 deletions
diff --git a/usr/src/boot/common/console.c b/usr/src/boot/common/console.c
index 4b0b5c5eb3..3f65566d6c 100644
--- a/usr/src/boot/common/console.c
+++ b/usr/src/boot/common/console.c
@@ -23,7 +23,9 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-
+/*
+ * Copyright (c) 2019, Joyent, Inc.
+ */
#include <sys/cdefs.h>
#include <stand.h>
@@ -321,15 +323,6 @@ cons_change(const char *string, char **list)
*list = cons_add_list(*list, curpos);
continue;
}
-
- if (active != 0) {
- /*
- * If no consoles have initialised we wouldn't
- * see this.
- */
- printf("console %s failed to initialize\n",
- consoles[cons]->c_name);
- }
}
}
diff --git a/usr/src/boot/efi/loader/Makefile.com b/usr/src/boot/efi/loader/Makefile.com
index 576f60eaf0..963ea246e6 100644
--- a/usr/src/boot/efi/loader/Makefile.com
+++ b/usr/src/boot/efi/loader/Makefile.com
@@ -12,6 +12,8 @@
#
# Copyright 2016 Toomas Soome <tsoome@me.com>
#
+# Copyright 2022 Joyent, Inc.
+#
include $(SRC)/boot/Makefile.version
include $(SRC)/boot/Makefile.inc
@@ -77,6 +79,14 @@ CPPFLAGS += -I$(SRC)/uts/intel/sys/acpi
CPPFLAGS += -I$(PNGLITE)
CPPFLAGS += -DNO_PCI -DEFI
+#
+# Using SNP from loader causes issues when chain-loading iPXE, as described in
+# TRITON-1191. While the exact problem is not known, we have no use for SNP, so
+# we'll just disable it.
+#
+CPPFLAGS += -DLOADER_DISABLE_SNP
+
+
DPLIBSA= ../../../libsa/$(MACHINE)/libsa_pics.a
LIBSA= -L../../../libsa/$(MACHINE) -lsa_pics
diff --git a/usr/src/boot/efi/loader/conf.c b/usr/src/boot/efi/loader/conf.c
index d29cbca573..e493d7cb03 100644
--- a/usr/src/boot/efi/loader/conf.c
+++ b/usr/src/boot/efi/loader/conf.c
@@ -24,6 +24,10 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+/*
+ * Copyright (c) 2019, Joyent, Inc.
+ */
+
#include <sys/cdefs.h>
#include <stand.h>
@@ -38,7 +42,9 @@ struct devsw *devsw[] = {
&efipart_fddev,
&efipart_cddev,
&efipart_hddev,
+#ifndef LOADER_DISABLE_SNP
&efinet_dev,
+#endif
&vdisk_dev,
&zfs_dev,
NULL
@@ -60,7 +66,9 @@ struct fs_ops *file_system[] = {
};
struct netif_driver *netif_drivers[] = {
+#ifndef LOADER_DISABLE_SNP
&efinetif,
+#endif
NULL
};
diff --git a/usr/src/boot/forth/Makefile b/usr/src/boot/forth/Makefile
index 5de1fc3878..5d43a4e9ad 100644
--- a/usr/src/boot/forth/Makefile
+++ b/usr/src/boot/forth/Makefile
@@ -11,6 +11,8 @@
#
# Copyright 2022 Toomas Soome <tsoome@me.com>
+# Copyright 2022 Joyent, Inc.
+# Copyright 2022 MNX Cloud, Inc.
#
include $(SRC)/Makefile.master
@@ -27,6 +29,7 @@ FORTH = beastie.4th
FORTH += beadm.4th
FORTH += brand.4th
FORTH += brand-illumos.4th
+FORTH += brand-smartos.4th
FORTH += check-password.4th
FORTH += color.4th
FORTH += delay.4th
@@ -40,6 +43,7 @@ FORTH += logo-fbsdbw.4th
FORTH += logo-illumos.4th
FORTH += logo-orb.4th
FORTH += logo-orbbw.4th
+FORTH += logo-smartos.4th
FORTH += menu.4th
FORTH += menu.rc
FORTH += menu-commands.4th
@@ -51,6 +55,8 @@ FORTH += support.4th
FORTH += version.4th
FILES += illumos-logo.png
FILES += illumos-brand.png
+FILES += triton-logo.png
+FILES += triton.png
FILES += loader.rc
all clean clobber:
@@ -64,6 +70,11 @@ $(ROOT_BOOT)/%: % $(ROOT_BOOT)
$(ROOT_BOOT_DEFAULTS)/%: % $(ROOT_BOOT_DEFAULTS)
$(INS.file)
+$(ROOT_BOOT_FORTH)/menu.rc: triton.menu.rc $(ROOT_BOOT_FORTH)
+ $(RM) $@; \
+ $(INS) -s -m $(FILEMODE) -f $(@D) triton.menu.rc; \
+ $(MV) $(@D)/triton.menu.rc $@
+
$(ROOT_BOOT_FORTH)/%: % $(ROOT_BOOT_FORTH)
$(INS.file)
diff --git a/usr/src/boot/forth/brand-smartos.4th b/usr/src/boot/forth/brand-smartos.4th
new file mode 100644
index 0000000000..acdbcf13af
--- /dev/null
+++ b/usr/src/boot/forth/brand-smartos.4th
@@ -0,0 +1,38 @@
+\
+\ This file and its contents are supplied under the terms of the
+\ Common Development and Distribution License ("CDDL"), version 1.0.
+\ You may only use this file in accordance with the terms of version
+\ 1.0 of the CDDL.
+\
+\ A full copy of the text of the CDDL should have accompanied this
+\ source. A copy of the CDDL is also available via the Internet at
+\ http://www.illumos.org/license/CDDL.
+\
+
+\
+\ Copyright 2019 Joyent, Inc.
+\ Copyright 2022 MNX Cloud, Inc.
+\
+
+2 brandX ! 1 brandY ! \ Initialize brand placement defaults
+
+: brand+ ( x y c-addr/u -- x y' )
+ 2swap 2dup at-xy 2swap \ position the cursor
+ type \ print to the screen
+ 1+ \ increase y for next time we're called
+;
+
+: brand ( x y -- ) \ "triton" [wide] logo in B/W (7 rows x 42 columns)
+
+ 0 1 1 0 0 s" /boot/triton-logo.png" fb-putimage if 2drop exit then
+
+ s" " brand+
+ s" ##### #### # ##### ### # # " brand+
+ s" # # # # # # # ## # " brand+
+ s" # #### # # # # # # # " brand+
+ s" # # # # # # # # ## " brand+
+ s" # # # # # # # # ## " brand+
+ s" # # # # # ### # # TM " brand+
+
+ 2drop
+;
diff --git a/usr/src/boot/forth/loader.4th b/usr/src/boot/forth/loader.4th
index d010b72a33..9bd01644e0 100644
--- a/usr/src/boot/forth/loader.4th
+++ b/usr/src/boot/forth/loader.4th
@@ -606,6 +606,24 @@ only forth definitions also support-functions
then
;
+create pathname 1024 chars allot
+
+: set-platform ( c-addr u -- )
+ 2dup
+ pathname place
+ s" /platform/i86pc/kernel/amd64/unix" pathname append
+ pathname count s" bootfile" setenv
+ pathname count erase
+ 2dup
+ pathname place
+ s" /platform/i86pc/amd64/boot_archive" pathname append
+ pathname count s" boot_archive" set-module-path
+ pathname count erase
+ pathname place
+ s" /platform/i86pc/amd64/boot_archive.hash" pathname append
+ pathname count s" boot_archive.hash" set-module-path
+;
+
\ Words to be used inside configuration files
: retry false ; \ For use in load error commands
diff --git a/usr/src/boot/forth/loader.rc b/usr/src/boot/forth/loader.rc
index 32f6bf8043..989a014da4 100644
--- a/usr/src/boot/forth/loader.rc
+++ b/usr/src/boot/forth/loader.rc
@@ -2,6 +2,16 @@
\
\ Includes additional commands
include /boot/forth/loader.4th
+
+\ For SmartOS, override the default color scheme back to the more traditional
+\ black background and white foreground.
+set tem.fg_color=white
+set tem.bg_color=black
+
+\ As another SmartOS customization, work around OS-8160 by limiting the size of
+\ the framebuffer.
+framebuffer set 1024x768
+
try-include /boot/loader.rc.local
\ Reads and processes loader.conf variables
diff --git a/usr/src/boot/forth/logo-smartos.4th b/usr/src/boot/forth/logo-smartos.4th
new file mode 100644
index 0000000000..f897c45165
--- /dev/null
+++ b/usr/src/boot/forth/logo-smartos.4th
@@ -0,0 +1,41 @@
+\
+\ This file and its contents are supplied under the terms of the
+\ Common Development and Distribution License ("CDDL"), version 1.0.
+\ You may only use this file in accordance with the terms of version
+\ 1.0 of the CDDL.
+\
+\ A full copy of the text of the CDDL should have accompanied this
+\ source. A copy of the CDDL is also available via the Internet at
+\ http://www.illumos.org/license/CDDL.
+\
+
+\
+\ Copyright 2019 Joyent, Inc.
+\
+
+52 logoX ! 11 logoY ! \ Initialize logo placement defaults
+
+: logo+ ( x y c-addr/u -- x y' )
+ 2swap 2dup at-xy 2swap \ position the cursor
+ [char] @ escc! \ replace @ with Esc
+ type \ print to the screen
+ 1+ \ increase y for next time we're called
+;
+
+: logo ( x y -- ) \ color Illumos logo
+
+ 0 0 0 0 0 s" /boot/triton.png" fb-putimage if 2drop exit then
+
+ s" @[31m--@[0;31m+--@[1;31m*@[0;33m--@[1;33m*" logo+
+ s" @[31m|@[1m\@[0m @[31m|\ |@[33m\ @[1m|\" logo+
+ s" @[31m| @[1m\@[0;31m|@[37m @[31m\| @[33m\@[1m| \" logo+
+ s" @[31m+--@[1;31m*@[31m--+@[0;33m--@[1;33m*@[33m--@[33m*" logo+
+ s" |@[31m\ |\ |\ @[33m|@[1m\ |" logo+
+ s" | @[31m\| \| \@[33m| @[1m\|" logo+
+ s" @[1m*@[0m--+@[31m--+@[33m--+@[1m--+" logo+
+ s" @[1m \ |@[0;34m\ |\ |@[1m\ |" logo+
+ s" @[1m \| @[0;34m\| \| @[1m\|" logo+
+ s" @[1m *--+@[0;34m--@[1;34m*@[34m--@[34m*" logo+
+
+ 2drop
+;
diff --git a/usr/src/boot/forth/menu-commands.4th b/usr/src/boot/forth/menu-commands.4th
index 5fe6c8c62f..4938608fb5 100644
--- a/usr/src/boot/forth/menu-commands.4th
+++ b/usr/src/boot/forth/menu-commands.4th
@@ -41,6 +41,43 @@ variable kmdb_state
also menu-namespace also menu-command-helpers
+\ PATH_MAX + 6
+create chaincmd 1030 chars allot
+
+\
+\ Rollback to previous platform image.
+\ Used by Joyent Triton
+\
+: rollback_boot ( N -- NOTREACHED )
+ dup
+ s" prev-platform" getenv s" bootfile" setenv
+ s" prev-archive" getenv s" boot_archive" set-module-path
+ s" prev-hash" getenv s" boot_archive.hash" set-module-path
+ 0 boot ( state -- )
+;
+
+\
+\ Boot from ipxe kernel
+\ Used by Joyent Triton when booted in BIOS/CSM mode
+\
+: ipxe_boot ( N -- NOTREACHED )
+ dup
+ s" ipxe-bootfile" getenv s" bootfile" setenv
+ s" ipxe-archive" getenv s" boot_archive" set-module-path
+ s" boot_archive.hash" disable-module
+ 0 boot ( state -- )
+;
+
+\
+\ Chainload the ipxe EFI binary
+\ Used by Joyent Triton when booted in UEFI mode
+\
+: ipxe_chainload ( N -- NOTREACHED )
+ s" chain " chaincmd place
+ s" ipxe-efi" getenv chaincmd append
+ chaincmd count evaluate
+;
+
\
\ Boot
\
@@ -102,6 +139,25 @@ also menu-namespace also menu-command-helpers
;
\
+\ Platform-image selection for standalone SmartOS is mostly in pi.rc.
+\ We will also steal a boot environment routine in pi_draw_screen (way below).
+
+: init_pi ( -- )
+ s" bootpi" getenv? 0= if
+ s" default" s" bootpi" setenv
+ then
+
+ \ Reset the "options" text to show current bootpi selected.
+ s" set menu_optionstext=${pitext}${bootpi}" evaluate
+ s" set pimenu_optionstext=${pitext}${bootpi}" evaluate
+;
+
+\ Shorter than inlining this in pi.rc.
+: pi_unload ( -- )
+ s" unload" evaluate
+;
+
+\
\ Single User Mode
\
@@ -246,6 +302,53 @@ also menu-namespace also menu-command-helpers
;
\
+\ Disaster Recovery boot
+\
+
+: rescue_enabled? ( -- flag )
+ s" noimport" getenv -1 <> dup if
+ swap drop ( c-addr flag -- flag )
+ then
+;
+
+: rescue_enable ( -- )
+ s" set noimport=true" evaluate
+ s" smartos" getenv? if
+ s" set standalone=true" evaluate
+ s" set smartos=false" evaluate
+ then
+;
+
+: rescue_disable ( -- )
+ s" noimport" unsetenv
+ s" standalone" unsetenv
+ s" smartos" getenv? if
+ s" set smartos=true" evaluate
+ then
+;
+
+: init_rescue ( N -- N )
+ rescue_enabled? if
+ toggle_menuitem ( n -- n )
+ then
+;
+
+: toggle_rescue ( N -- N TRUE )
+ toggle_menuitem
+ menu-redraw
+
+ \ Now we're going to make the change effective
+
+ dup toggle_stateN @ 0= if
+ rescue_disable
+ else
+ rescue_enable
+ then
+
+ TRUE \ loop menu again
+;
+
+\
\ Escape to Prompt
\
@@ -505,6 +608,17 @@ also menu-namespace also menu-command-helpers
menu-init \ Initialize menu and draw bounding box (in menu.4th)
;
+\ PI reuse of be_draw_screen, plus some other things to be used by pi.rc.
+
+: pi_draw_screen ( -- TRUE )
+ \ So we can make SURE we have the current boot PI on display.
+ init_pi
+
+ be_draw_screen
+ menu-redraw
+ TRUE
+;
+
\
\ Select a boot environment
\
diff --git a/usr/src/boot/forth/menu.4th b/usr/src/boot/forth/menu.4th
index 1fd20811c6..fee6ec3806 100644
--- a/usr/src/boot/forth/menu.4th
+++ b/usr/src/boot/forth/menu.4th
@@ -3,6 +3,7 @@
\ Copyright (c) 2006-2015 Devin Teske <dteske@FreeBSD.org>
\ Copyright 2020 OmniOS Community Edition (OmniOSce) Association.
\ All rights reserved.
+\ Copyright 2019 Joyent, Inc.
\
\ Redistribution and use in source and binary forms, with or without
\ modification, are permitted provided that the following conditions
@@ -332,7 +333,7 @@ also menu-infrastructure definitions
\ Print the frame caption at (x,y)
s" loader_menu_title" getenv dup -1 = if
- drop s" Welcome to illumos"
+ drop s" Welcome to SmartOS"
then
TRUE ( use default alignment )
s" loader_menu_title_align" getenv dup -1 <> if
@@ -549,14 +550,39 @@ also menu-infrastructure definitions
then
;
-\ Takes an integer on the stack and updates the timeout display.
+: do_ipxe ( -- bool)
+ \ getenv? leaves -1 on stack if the env var exists. Thus if both
+ \ headnode and ipxe exist then the sum of what will be left on the
+ \ stack should be -2.
+ s" headnode" getenv? s" ipxe" getenv? + -2 = if
+ s" ipxe" getenv s" true" compare 0= if
+ true
+ else
+ false
+ then
+ else
+ false
+ 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 -- )
\ Enforce minimum
dup 0 < if drop 0 then
- menu_timeout_x @ menu_timeout_y @ at-xy \ position cursor
+ s" headnode" getenv? if
+ do_ipxe if
+ s" Autoboot in N seconds from PXE. [Space] to pause" ( n -- n c-addr/u )
+ else
+ s" Autoboot in N seconds from the USB Key. [Space] to pause" ( n -- n c-addr/u )
+ then
+ else
+ s" Autoboot in N seconds. [Space] to pause" ( n -- n c-addr/u )
+ then
dup 0> if
s" Autoboot in " type
@@ -1012,8 +1038,16 @@ also menu-namespace
dup over 13 = swap 10 = or if
drop ( no longer needed )
cursor-normal cursor-set
- s" boot" evaluate
- exit ( pedantic; never reached )
+ do_ipxe if
+ s" efi-version" getenv? if
+ s" ipxe_chainload" evaluate
+ else
+ s" ipxe_boot" evaluate
+ then
+ else
+ s" boot" evaluate
+ exit ( pedantic; never reached )
+ then
then
dup menureboot @ = if 0 reboot then
diff --git a/usr/src/boot/forth/support.4th b/usr/src/boot/forth/support.4th
index 2abf48f70b..961d3b528a 100644
--- a/usr/src/boot/forth/support.4th
+++ b/usr/src/boot/forth/support.4th
@@ -245,6 +245,21 @@ create last_module_option sizeof module.next allot 0 last_module_option !
then
;
+\ Place string into an allocated buffer
+\
+\ e.g
+\ create mystring 32 chars allot
+\ s" Burning down " mystring place
+\
+: place over over >r >r char+ swap chars move r> r> c! ;
+
+\ Append string
+\
+\ e.g.
+\ s" the house!" mystring append
+\
+: append over over >r >r count chars + swap chars move r> r> dup >r c@ + r> c! ;
+
\ 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 -- }
diff --git a/usr/src/boot/forth/triton-logo.png b/usr/src/boot/forth/triton-logo.png
new file mode 100644
index 0000000000..79e917b1e8
--- /dev/null
+++ b/usr/src/boot/forth/triton-logo.png
Binary files differ
diff --git a/usr/src/boot/forth/triton.menu.rc b/usr/src/boot/forth/triton.menu.rc
new file mode 100644
index 0000000000..3dddb7ffe7
--- /dev/null
+++ b/usr/src/boot/forth/triton.menu.rc
@@ -0,0 +1,109 @@
+\ Menu.rc
+\
+\ Load required Forth modules
+include /boot/forth/version.4th
+include /boot/forth/brand.4th
+include /boot/forth/menu.4th
+include /boot/forth/menu-commands.4th
+include /boot/forth/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 `non-ansi' variants, add `loader_color=0' to loader.conf(5)
+\ NOTE: ANSI variants can use `^' in place of literal `Esc' (ASCII 27)
+
+\
+\ MAIN MENU
+\
+
+set menuset_name1="main"
+
+set mainmenu_init[1]="init_boot"
+
+set mainmenu_caption[1]="Boot SmartOS [Enter]"
+set mainansi_caption[1]="^[1mB^[moot SmartOS ^[1m[Enter]^[m"
+set mainmenu_command[1]="boot"
+\ keycode set by init_boot
+
+set mainmenu_caption[2]="[Esc]ape to loader prompt"
+set mainmenu_command[2]="goto_prompt"
+set mainmenu_keycode[2]=27
+set mainansi_caption[2]="^[1mEsc^[mape to loader prompt"
+
+\ Enable built-in "Reboot" trailing menuitem
+\ NOTE: appears before menu_options if configured
+\
+set mainmenu_reboot
+
+\ Enable "Options:" separator. When set to a numerical value (1-8), a visual
+\ separator is inserted before that menuitem number.
+\
+set mainmenu_options=4
+
+set mainmenu_caption[4]="Configure Boot [O]ptions..."
+set mainmenu_command[4]="2 goto_menu"
+set mainmenu_keycode[4]=111
+set mainansi_caption[4]="Configure Boot ^[1mO^[mptions..."
+
+\
+\ If available, load the "Platform Image Selection" option.
+\
+try-include /os/pi.rc
+
+\
+\ BOOT OPTIONS MENU
+\
+
+set menuset_name2="options"
+
+set optionsmenu_caption[1]="Back to Main Menu [Backspace]"
+set optionsmenu_command[1]="1 goto_menu"
+set optionsmenu_keycode[1]=8
+set optionsansi_caption[1]="Back to Main Menu ^[1m[Backspace]^[m"
+
+set optionsmenu_options=2
+set optionsmenu_optionstext="Boot Options:"
+
+set optionsmenu_osconsole=2
+set optionsmenu_command[2]="cycle_osconsole"
+set optionsmenu_keycode[2]=99
+
+set optionsmenu_init[3]="init_verbose"
+set optionsmenu_caption[3]="[V]erbose............. Off"
+set optionstoggled_text[3]="[V]erbose............. On"
+set optionsmenu_command[3]="toggle_verbose"
+set optionsmenu_keycode[3]=118
+set optionsansi_caption[3]="^[1mV^[merbose............... ^[34;1mOff^[m"
+set optionstoggled_ansi[3]="^[1mV^[merbose............... ^[32;7mOn^[m"
+
+set optionsmenu_kmdb=4
+set optionsmenu_command[4]="cycle_kmdb"
+set optionsmenu_keycode[4]=107
+
+set optionsmenu_init[5]="init_rescue"
+set optionsmenu_caption[5]="[R]escue Mode......... Off"
+set optionstoggled_text[5]="[R]escue Mode......... On"
+set optionsmenu_command[5]="toggle_rescue"
+set optionsmenu_keycode[5]=114
+set optionsansi_caption[5]="^[1mR^[mescue Mode........... ^[34;1mOff^[m"
+set optionstoggled_ansi[5]="^[1mR^[mescue Mode........... ^[32;7mOn^[m"
+
+\ Enable automatic booting (add ``autoboot_delay=N'' to loader.conf(5) to
+\ customize the timeout; default is 10-seconds)
+\
+set menu_timeout_command="boot"
+
+\ Include optional elements defined in a local file
+\
+try-include /boot/menu.rc.local
+
+\ Display the main menu (see `menu.4th')
+set menuset_initial=1
+menuset-loadinitial
+menu-display
diff --git a/usr/src/boot/forth/triton.png b/usr/src/boot/forth/triton.png
new file mode 100644
index 0000000000..9b7e9a94b6
--- /dev/null
+++ b/usr/src/boot/forth/triton.png
Binary files differ
diff --git a/usr/src/boot/i386/libi386/i386_copy.c b/usr/src/boot/i386/libi386/i386_copy.c
index bcfd475c37..e34eddd5b0 100644
--- a/usr/src/boot/i386/libi386/i386_copy.c
+++ b/usr/src/boot/i386/libi386/i386_copy.c
@@ -24,6 +24,10 @@
* SUCH DAMAGE.
*/
+/*
+ * Copyright (c) 2019, Joyent, Inc.
+ */
+
#include <sys/cdefs.h>
/*
@@ -96,6 +100,8 @@ smap_find(struct bios_smap *smap, int smaplen, vm_offset_t addr, size_t size)
return (0);
}
+#define SAFE_LOAD_BASE 0xc800000
+
/*
* Find usable address for loading. The address for the kernel is fixed, as
* it is determined by kernel linker map (dboot PT_LOAD address).
@@ -119,8 +125,13 @@ i386_loadaddr(uint_t type, void *data, vm_offset_t addr)
if (type == LOAD_KERN)
return (addr);
+ /*
+ * Nothing is yet loaded. We shouldn't get to a module with a load
+ * address of zero still, and the kernel loads at its own multiboot
+ * address, so we don't need to make any adjustments here.
+ */
if (addr == 0)
- return (addr); /* nothing to do */
+ return (0);
if (type == LOAD_ELF)
return (0); /* not supported */
@@ -149,12 +160,19 @@ i386_loadaddr(uint_t type, void *data, vm_offset_t addr)
/* Start from the end of the kernel. */
mfp = fp;
do {
+
+
if (mfp == NULL) {
off = roundup2(addr + 1, MULTIBOOT_MOD_ALIGN);
} else {
off = roundup2(mfp->f_addr + mfp->f_size + 1,
MULTIBOOT_MOD_ALIGN);
}
+
+ /* RICHMOND-16 work around. */
+ if (off < SAFE_LOAD_BASE)
+ off = SAFE_LOAD_BASE;
+
/* Avoid possible framebuffer memory */
if (plat_stdout_is_framebuffer()) {
vm_offset_t fb_addr;
diff --git a/usr/src/boot/i386/pmbr/pmbr.s b/usr/src/boot/i386/pmbr/pmbr.s
index 46088cc78c..e5f059e88b 100644
--- a/usr/src/boot/i386/pmbr/pmbr.s
+++ b/usr/src/boot/i386/pmbr/pmbr.s
@@ -31,10 +31,12 @@
#
# Partly from: src/sys/boot/i386/mbr/mbr.s 1.7
+# Copyright (c) 2019, Joyent, Inc.
+
# A 512 byte PMBR boot manager to read a boot program and run it.
# The embedded MBR is set up for PMBR and default bootblock sector
# is hardcoded to 256 and size 1. The actual values are supposed to be
-# updated by installboot.
+# updated by installboot (and smartos-live's format_image).
.set LOAD,0x7c00 # Load address
.set EXEC,0x600 # Execution address