summaryrefslogtreecommitdiff
path: root/config/grub/config
diff options
context:
space:
mode:
Diffstat (limited to 'config/grub/config')
-rw-r--r--config/grub/config/grub.cfg171
-rw-r--r--config/grub/config/grub_memdisk.cfg2
2 files changed, 127 insertions, 46 deletions
diff --git a/config/grub/config/grub.cfg b/config/grub/config/grub.cfg
index 17576b5f..7adee869 100644
--- a/config/grub/config/grub.cfg
+++ b/config/grub/config/grub.cfg
@@ -1,3 +1,5 @@
+# SPDX-License-Identifier: GPL-3.0-or-later
+
set prefix=(memdisk)/boot/grub
insmod at_keyboard
@@ -14,24 +16,43 @@ terminal_input --append at_keyboard
terminal_input --append usb_keyboard
terminal_output --append cbmemc
-gfxpayload=keep
-terminal_output --append gfxterm
+# User interface overrides wherever "keystatus" is supported
+# Keep SHIFT key pressed before powering on to disable graphics
+if keystatus --shift; then
+ terminal_output --append vga_text
+else
+ gfxpayload=keep
+ terminal_output --append gfxterm
+
+ if [ -f (cbfsdisk)/background.png ]; then
+ insmod png
+ background_image (cbfsdisk)/background.png
+ elif [ -f (cbfsdisk)/background.jpg ]; then
+ insmod jpeg
+ background_image (cbfsdisk)/background.jpg
+ fi
+fi
+
+# Keep CTRL pressed to enable default serial terminal (COM1 or the like)
+if keystatus --ctrl; then
+ serial
+ terminal_input --append serial
+ terminal_output --append serial
+fi
-if [ -f (cbfsdisk)/background.png ]; then
- insmod png
- background_image (cbfsdisk)/background.png
-elif [ -f (cbfsdisk)/background.jpg ]; then
- insmod jpeg
- background_image (cbfsdisk)/background.jpg
+# Keep ALT pressed to enable spkmodem
+if keystatus --alt; then
+ terminal_output --append spkmodem
fi
+
set default="0"
if [ -f (cbfsdisk)/timeout.cfg ]; then
source (cbfsdisk)/timeout.cfg
else
set timeout=5
fi
-set grub_scan_disk="both"
+set grub_scan_disk="nvme ahci ata"
if [ -f (cbfsdisk)/scan.cfg ]; then
source (cbfsdisk)/scan.cfg
fi
@@ -40,34 +61,49 @@ if [ -f (cbfsdisk)/keymap.gkb ]; then
keymap (cbfsdisk)/keymap.gkb
fi
-function try_user_config {
+function really_try_user_config {
set root="${1}"
+ if [ -f /"${2}"/grub.cfg ]; then
+ unset superusers
+ configfile /"${2}"/grub.cfg
+ fi
+}
+
+function try_user_config {
# The @/... entries are for cases where the BTRFS filesystem is being used
- for dir in boot grub grub2 boot/grub boot/grub2 @/boot @/grub @/grub2 @/boot/grub @/boot/grub2; do
- for name in '' osboot_ autoboot_ libreboot_ coreboot_; do
- if [ -f /"${dir}"/"${name}"grub.cfg ]; then
- unset superusers
- configfile /"${dir}"/"${name}"grub.cfg
- fi
- done
+ for dir in grub boot/grub @/grub @/boot/grub grub2 boot/grub2 @/grub2 @/boot/grub2 boot @/boot; do
+ really_try_user_config "${1}" "${dir}"
+ done
+ for dir in ubuntu debian redhat; do
+ really_try_user_config "${1}" "EFI/${dir}"
done
}
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})"
+ for i in 0 1 2 3 4 5 6 7 8; do
+ for part in 1 2 3 4 5 6 7 8 9 10 11 12; do
+ 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
}
function try_isolinux_config {
set root="${1}"
- for dir in '' /boot /EFI /boot/EFI /@ /@/boot /@/boot/EFI /@/EFI; do
+ for dir in '' /boot /EFI /@ /@/boot; do
if [ -f "${dir}"/isolinux/isolinux.cfg ]; then
syslinux_configfile -i "${dir}"/isolinux/isolinux.cfg
elif [ -f "${dir}"/syslinux/syslinux.cfg ]; then
@@ -81,12 +117,22 @@ function try_isolinux_config {
}
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})"
+ for i in 0 1 2 3 4 5 6 7 8; do
+ for part in 1 2 3 4 5 6 7 8 9 10 11 12; do
+ 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
}
@@ -100,12 +146,9 @@ function search_bootcfg {
}
menuentry 'Load Operating System (incl. fully encrypted disks) [o]' --hotkey='o' {
- if [ "${grub_scan_disk}" != "ata" ]; then
- search_bootcfg ahci
- fi
- if [ "${grub_scan_disk}" != "ahci" ]; then
- search_bootcfg ata
- fi
+ for grub_disk in ${grub_scan_disk}; do
+ search_bootcfg ${grub_disk}
+ done
# grub device enumeration is very slow, so checks are hardcoded
@@ -122,22 +165,25 @@ menuentry 'Load Operating System (incl. fully encrypted disks) [o]' --hotkey='o
try_bootcfg "${vol}"
done
- unset ahcidev
- unset atadev
- 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
- ahcidev="(ahci${i},${part}) ${ahcidev}"
- fi
- if [ "${grub_scan_disk}" != "ahci" ]; then
- atadev="(ata${i},${part}) ${atadev}"
- fi
+ unset bootdev
+ for grub_disk in ${grub_scan_disk}; do
+ for i in 0 1 2 3 4 5 6 7 8; do
+ for part in 1 2 3 4 5 6 7 8 9 10 11 12; do
+ if [ "${grub_disk}" = "ahci" ]; then
+ bootdev="${bootdev} (ahci${i},${part})"
+ elif [ "${grub_disk}" = "ata" ]; then
+ bootdev="${bootdev} (ata${i},${part})"
+ elif [ "${grub_disk}" = "nvme" ]; then
+ # TODO: do we care about other namesapces
+ bootdev="${bootdev} (nvme${i}n1,${part})"
+ fi
+ done
done
done
set pager=0
echo -n "Attempting to unlock encrypted volumes"
- for dev in ${ahcidev} ${atadev} ${lvmvol} ${raidvol}; do
+ for dev in ${bootdev} ${lvmvol} ${raidvol}; do
if cryptomount "${dev}" ; then break ; fi
done
set pager=1
@@ -164,7 +210,10 @@ menuentry 'Search for GRUB/SYSLINUX/EXTLINUX/ISOLINUX on AHCI [a]' --hotkey='a'
search_bootcfg ahci
}
menuentry 'Search for GRUB/SYSLINUX/EXTLINUX/ISOLINUX on ATA/IDE [d]' --hotkey='d' {
- search_bootcfg ahci
+ 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' {
@@ -198,3 +247,33 @@ menuentry 'Load MemTest86+ [m]' --hotkey='m' {
chainloader /img/memtest
}
fi
+
+submenu 'Other [z]' --hotkey='z' {
+ menuentry 'Enable default serial terminal [s]' --hotkey='s' {
+ serial
+ terminal_input --append serial
+ terminal_output --append serial
+ }
+
+ menuentry 'Disable default serial terminal' {
+ terminal_input --remove serial
+ terminal_output --remove serial
+ }
+
+ menuentry 'Enable gfxterm' {
+ terminal_output --append gfxterm
+ terminal_output --remove vga_text
+ }
+ menuentry 'Disable gfxterm [g]' --hotkey='g' {
+ terminal_output --remove gfxterm
+ terminal_output --append vga_text
+ }
+
+ menuentry 'Enable spkmodem [a]' --hotkey='a' {
+ terminal_output --append spkmodem
+ }
+
+ menuentry 'Disable spkmodem [z]' --hotkey='z' {
+ terminal_output --remove spkmodem
+ }
+}
diff --git a/config/grub/config/grub_memdisk.cfg b/config/grub/config/grub_memdisk.cfg
index 0763801b..18d5d535 100644
--- a/config/grub/config/grub_memdisk.cfg
+++ b/config/grub/config/grub_memdisk.cfg
@@ -1,3 +1,5 @@
+# SPDX-License-Identifier: GPL-3.0-or-later
+
set prefix=(memdisk)/boot/grub
if [ -f (cbfsdisk)/grub.cfg ]; then