Add NVMe support to GRUB2 payload

Tested on OptiPlex 3050 (via injecting grub2.elf into WIP coreboot
port).
audit2-merge1
Mate Kukri 2024-05-20 20:48:44 +01:00 committed by Leah Rowe
parent b892036edf
commit f58b01c300
3 changed files with 1112 additions and 6 deletions

View File

@ -76,10 +76,20 @@ function search_grub {
echo -n "Attempting to load grub.cfg from '${1}' devices"
for i in 0 1 2 3 4 5 6 7 8 9 10 11; do
for part in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do
try_user_config "(${1}${i},${part})"
if [ "${1}" != "nvme" ]; then
try_user_config "(${1}${i},${part})"
else
# TODO: do we care about other namesapces
try_user_config "(nvme${i}n1,${part})"
fi
done
# raw devices e.g. (ahci0) instead of (ahci0,1)
try_user_config "(${1}${i})"
if [ "${1}" != "nvme" ]; then
# raw devices e.g. (ahci0) instead of (ahci0,1)
try_user_config "(${1}${i})"
else
# TODO: do we care about other namesapces
try_user_config "(nvme${i}n1)"
fi
done
echo # Insert newline
}
@ -102,10 +112,20 @@ function search_isolinux {
echo "\nAttempting to parse iso/sys/extlinux config from '${1}' devices"
for i in 0 1 2 3 4 5 6 7 8 9 10 11; do
for part in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do
try_isolinux_config "(${1}${i},${part})"
if [ "${1}" != "nvme" ]; then
try_isolinux_config "(${1}${i},${part})"
else
# TODO: see above
try_isolinux_config "(nvme${i}n1,${part})"
fi
done
# raw devices e.g. (usb0) instead of (usb0,1)
try_isolinux_config "(${1}${i})"
if [ "${1}" != "nvme" ]; then
# raw devices e.g. (usb0) instead of (usb0,1)
try_isolinux_config "(${1}${i})"
else
# TODO: do we care about other namesapces
try_isolinux_config "(nvme${i}n1)"
fi
done
echo # Insert newline
}
@ -125,6 +145,9 @@ menuentry 'Load Operating System (incl. fully encrypted disks) [o]' --hotkey='o
if [ "${grub_scan_disk}" != "ahci" ]; then
search_bootcfg ata
fi
if [ "${grub_scan_disk}" != "nvme" ]; then
search_bootcfg nvme
fi
# grub device enumeration is very slow, so checks are hardcoded
@ -143,6 +166,7 @@ menuentry 'Load Operating System (incl. fully encrypted disks) [o]' --hotkey='o
unset ahcidev
unset atadev
unset nvmedev
for i in 11 10 9 8 7 6 5 4 3 2 1 0; do
for part in 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1; do
if [ "${grub_scan_disk}" != "ata" ]; then
@ -151,6 +175,10 @@ menuentry 'Load Operating System (incl. fully encrypted disks) [o]' --hotkey='o
if [ "${grub_scan_disk}" != "ahci" ]; then
atadev="(ata${i},${part}) ${atadev}"
fi
if [ "${grub_scan_disk}" != "nvme" ]; then
# TODO: do we care about other namesapces
nvmedev="(nvme${i}n1,${part}) ${nvmedev}"
fi
done
done
@ -185,6 +213,9 @@ menuentry 'Search for GRUB/SYSLINUX/EXTLINUX/ISOLINUX on AHCI [a]' --hotkey='a'
menuentry 'Search for GRUB/SYSLINUX/EXTLINUX/ISOLINUX on ATA/IDE [d]' --hotkey='d' {
search_bootcfg ata
}
menuentry 'Search for GRUB/SYSLINUX/EXTLINUX/ISOLINUX on NVMe [e]' --hotkey='e' {
search_bootcfg nvme
}
if [ -f (cbfsdisk)/grubtest.cfg ]; then
menuentry 'Load test configuration (grubtest.cfg) inside of CBFS [t]' --hotkey='t' {
set root='(cbfsdisk)'

View File

@ -105,6 +105,7 @@ multiboot2 \
nativedisk \
normal \
ntfs \
nvme \
ohci \
part_bsd \
part_dfly \

File diff suppressed because it is too large Load Diff