Add NVMe support to GRUB2 payload

Tested on OptiPlex 3050 (via injecting grub2.elf into WIP coreboot
port).
20240612_branch
Mate Kukri 2024-05-20 20:48:44 +01:00
parent 1e54db2989
commit abe6717c33
3 changed files with 1113 additions and 7 deletions

View File

@ -76,10 +76,20 @@ function search_grub {
echo -n "Attempting to load grub.cfg from '${1}' devices" 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 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 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 done
# raw devices e.g. (ahci0) instead of (ahci0,1) if [ "${1}" != "nvme" ]; then
try_user_config "(${1}${i})" # 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 done
echo # Insert newline echo # Insert newline
} }
@ -102,10 +112,20 @@ function search_isolinux {
echo "\nAttempting to parse iso/sys/extlinux config from '${1}' devices" 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 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 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 done
# raw devices e.g. (usb0) instead of (usb0,1) if [ "${1}" != "nvme" ]; then
try_isolinux_config "(${1}${i})" # 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 done
echo # Insert newline echo # Insert newline
} }
@ -125,6 +145,9 @@ menuentry 'Load Operating System (incl. fully encrypted disks) [o]' --hotkey='o
if [ "${grub_scan_disk}" != "ahci" ]; then if [ "${grub_scan_disk}" != "ahci" ]; then
search_bootcfg ata search_bootcfg ata
fi fi
if [ "${grub_scan_disk}" != "nvme" ]; then
search_bootcfg nvme
fi
# grub device enumeration is very slow, so checks are hardcoded # 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 ahcidev
unset atadev unset atadev
unset nvmedev
for i in 11 10 9 8 7 6 5 4 3 2 1 0; do 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 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 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 if [ "${grub_scan_disk}" != "ahci" ]; then
atadev="(ata${i},${part}) ${atadev}" atadev="(ata${i},${part}) ${atadev}"
fi fi
if [ "${grub_scan_disk}" != "nvme" ]; then
# TODO: do we care about other namesapces
nvmedev="(nvme${i}n1,${part}) ${nvmedev}"
fi
done done
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' { menuentry 'Search for GRUB/SYSLINUX/EXTLINUX/ISOLINUX on ATA/IDE [d]' --hotkey='d' {
search_bootcfg ata search_bootcfg ata
} }
menuentry 'Search for GRUB/SYSLINUX/EXTLINUX/ISOLINUX on NVMe [e]' --hotkey='e' {
search_bootcfg nvme
}
if [ -f (cbfsdisk)/grubtest.cfg ]; then if [ -f (cbfsdisk)/grubtest.cfg ]; then
menuentry 'Load test configuration (grubtest.cfg) inside of CBFS [t]' --hotkey='t' { menuentry 'Load test configuration (grubtest.cfg) inside of CBFS [t]' --hotkey='t' {
set root='(cbfsdisk)' set root='(cbfsdisk)'
@ -246,4 +277,4 @@ submenu 'Other [z]' --hotkey='z' {
menuentry 'Disable spkmodem [z]' --hotkey='z' { menuentry 'Disable spkmodem [z]' --hotkey='z' {
terminal_output --remove spkmodem terminal_output --remove spkmodem
} }
} }

View File

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

File diff suppressed because it is too large Load Diff