build/roms: re-add SeaGRUB build support

it didn't work in the past, but it does work nowadays;
specifically, it only worked with libgfxinit in the past,
but not on VGA ROMs.

now it does work on VGA ROMs, tested on e6400 and t1650 so
it was enabled there.

in this setup, a special image is provided where SeaBIOS is
the main payload, but it only loads GRUB; nothing else, every.

this is called SeaGRUB. this setup is useful in cases where
the user only has a GPU that lacks libgfxinit support.

Signed-off-by: Leah Rowe <leah@libreboot.org>
btrfsvols
Leah Rowe 2023-11-01 09:12:56 +00:00
parent 971f651775
commit 82bd87fa16
3 changed files with 32 additions and 3 deletions

View File

@ -6,5 +6,6 @@ payload_grub_withseabios="n"
payload_seabios="y"
payload_memtest="y"
payload_seabios_withgrub="y"
payload_seabios_grubonly="y"
grub_scan_disk="ahci"
microcode_required="n"

View File

@ -3,5 +3,6 @@ romtype="normal"
arch="x86_64"
payload_seabios="y"
payload_seabios_withgrub="y"
payload_seabios_grubonly="y"
payload_memtest="y"
grub_scan_disk="ahci"

View File

@ -21,7 +21,7 @@ kmapdir="config/grub/keymap"
# Disable all payloads by default.
# target.cfg files have to specifically enable [a] payload(s)
pv="payload_grub payload_grub_withseabios payload_seabios payload_memtest"
pv="${pv} payload_seabios_withgrub payload_uboot memtest_bin"
pv="${pv} payload_seabios_withgrub payload_seabios_grubonly payload_uboot memtest_bin"
v="romdir cbrom initmode displaymode cbcfg targetdir tree arch"
v="${v} grub_timeout ubdir vendorfiles board grub_scan_disk uboot_config"
eval "$(setvars "n" ${pv})"
@ -93,6 +93,10 @@ check_target()
eval "$(setvars "y" payload_seabios payload_seabios_withgrub)"
[ "${payload_seabios_withgrub}" = "y" ] && \
payload_seabios="y"
if [ "${payload_seabios_grubonly}" = "y" ]; then
payload_seabios="y"
payload_seabios_withgrub="y"
fi
# The reverse logic must not be applied. If SeaBIOS-with-GRUB works,
# that doesn't mean GRUB-withSeaBIOS will. For example, the board
@ -115,7 +119,8 @@ check_target()
[ -z "${_payload}" ] && return 0
printf "setting payload to: %s\n" "${_payload}"
eval "$(setvars "n" payload_grub payload_memtest payload_seabios \
payload_seabios_withgrub payload_uboot payload_grub_withseabios)"
payload_seabios_withgrub payload_uboot payload_grub_withseabios \
payload_seabios_grubonly)"
eval "payload_${_payload}=y"
}
@ -157,7 +162,8 @@ build_dependency_seabios()
build_dependency_grub()
{
[ "${payload_grub}" != "y" ] && \
[ "${payload_seabios_withgrub}" != "y" ] && return 0
[ "${payload_seabios_withgrub}" != "y" ] && \
[ "${payload_seabios_grubonly}" != "y" ] && return 0
rebuild_grub="n"
[ -f "${grubelf}" ] || rebuild_grub="y"
@ -308,6 +314,8 @@ build_grub_roms()
newrom="${romdir}/${payload1}_${board}_" && \
newrom="${newrom}${initmode}_${keymap}.rom"
x_ moverom "${tmpgrubrom}" "${newrom}"
[ "${payload_seabios_grubonly}" = "y" ] && \
mkSeabiosGrubonlyRom "${tmpgrubrom}" "${newrom}"
x_ rm -f "${tmpgrubrom}"
done
}
@ -349,6 +357,25 @@ mkSeabiosRom() {
printf "%s\n" "${tmprom}"
}
# SeaGRUB configuration
mkSeabiosGrubonlyRom()
{
_grubrom="${1}"
_newrom="${2}"
tmpbootorder=$(mktemp -t coreboot_rom.XXXXXXXXXX)
# only load grub, by inserting a custom bootorder file
printf "/rom@img/grub2\n" > "${tmpbootorder}" || err "printf bootorder"
x_ "${cbfstool}" "${_grubrom}" \
add -f "${tmpbootorder}" -n bootorder -t raw
x_ rm -f "${tmpbootorder}"
x_ "${cbfstool}" "${_grubrom}" add-int -i 0 -n etc/show-boot-menu
x_ moverom "${_grubrom}" "${_newrom%.rom}_grubonly.rom"
}
build_uboot_roms()
{
tmprom="$(mkUbootRom "${cbrom}" "fallback/payload")"