diff --git a/boards/librem_mini/initrd/bin/board-init.sh b/boards/librem_mini/initrd/bin/board-init.sh new file mode 100755 index 00000000..7fb09be2 --- /dev/null +++ b/boards/librem_mini/initrd/bin/board-init.sh @@ -0,0 +1,22 @@ +#!/bin/ash +set -o pipefail + +. /tmp/config + +# Set the Mini v2 EC's automatic power-on setting. +# CONFIG_AUTOMATIC_POWERON is three-valued: +# y - enable automatic power on in EC +# n - disable automatic power on in EC +# - don't configure EC, could be configured from OS + +# EC BRAM bank 1 +BRAMADDR=0x360 +BRAMDATA=0x361 + +if [ "$CONFIG_AUTOMATIC_POWERON" = "y" ]; then + outb "$BRAMADDR" 0x29 # Select byte at offset 29h + outb "$BRAMDATA" 0x00 # 0 -> automatic power on +elif [ "$CONFIG_AUTOMATIC_POWERON" = "n" ]; then + outb "$BRAMADDR" 0x29 # Select byte at offset 29h + outb "$BRAMDATA" 0x01 # 1 -> stay off +fi diff --git a/boards/librem_mini/librem_mini.config b/boards/librem_mini/librem_mini.config index bb5035f3..3c6761a2 100644 --- a/boards/librem_mini/librem_mini.config +++ b/boards/librem_mini/librem_mini.config @@ -11,6 +11,7 @@ CONFIG_CRYPTSETUP2=y CONFIG_FLASHROM=y CONFIG_FLASHTOOLS=y CONFIG_GPG2=y +CONFIG_IOPORT=y CONFIG_KEXEC=y CONFIG_UTIL_LINUX=y CONFIG_LVM2=y @@ -42,3 +43,4 @@ export CONFIG_AUTO_BOOT_TIMEOUT=5 export CONFIG_ROOT_DEV="/dev/nvme0n1p2" export CONFIG_ROOT_DIRLIST="bin boot lib sbin usr" export CONFIG_ROOT_CHECK_AT_BOOT="n" +export CONFIG_SUPPORT_AUTOMATIC_POWERON=y diff --git a/boards/librem_mini_v2/initrd/bin/board-init.sh b/boards/librem_mini_v2/initrd/bin/board-init.sh new file mode 100755 index 00000000..7fb09be2 --- /dev/null +++ b/boards/librem_mini_v2/initrd/bin/board-init.sh @@ -0,0 +1,22 @@ +#!/bin/ash +set -o pipefail + +. /tmp/config + +# Set the Mini v2 EC's automatic power-on setting. +# CONFIG_AUTOMATIC_POWERON is three-valued: +# y - enable automatic power on in EC +# n - disable automatic power on in EC +# - don't configure EC, could be configured from OS + +# EC BRAM bank 1 +BRAMADDR=0x360 +BRAMDATA=0x361 + +if [ "$CONFIG_AUTOMATIC_POWERON" = "y" ]; then + outb "$BRAMADDR" 0x29 # Select byte at offset 29h + outb "$BRAMDATA" 0x00 # 0 -> automatic power on +elif [ "$CONFIG_AUTOMATIC_POWERON" = "n" ]; then + outb "$BRAMADDR" 0x29 # Select byte at offset 29h + outb "$BRAMDATA" 0x01 # 1 -> stay off +fi diff --git a/boards/librem_mini_v2/librem_mini_v2.config b/boards/librem_mini_v2/librem_mini_v2.config index 744b0655..9f8afde8 100644 --- a/boards/librem_mini_v2/librem_mini_v2.config +++ b/boards/librem_mini_v2/librem_mini_v2.config @@ -43,3 +43,4 @@ export CONFIG_AUTO_BOOT_TIMEOUT=5 export CONFIG_ROOT_DEV="/dev/nvme0n1p2" export CONFIG_ROOT_DIRLIST="bin boot lib sbin usr" export CONFIG_ROOT_CHECK_AT_BOOT="n" +export CONFIG_SUPPORT_AUTOMATIC_POWERON=y diff --git a/initrd/bin/config-gui.sh b/initrd/bin/config-gui.sh index e00f13de..33f3e479 100755 --- a/initrd/bin/config-gui.sh +++ b/initrd/bin/config-gui.sh @@ -33,6 +33,7 @@ while true; do RESTRICTED_BOOT="$(load_config_value CONFIG_RESTRICTED_BOOT)" BASIC_NO_AUTOMATIC_DEFAULT="$(load_config_value CONFIG_BASIC_NO_AUTOMATIC_DEFAULT)" BASIC_USB_AUTOBOOT="$(load_config_value CONFIG_BASIC_USB_AUTOBOOT)" + AUTOMATIC_POWERON="$(load_config_value CONFIG_AUTOMATIC_POWERON)" dynamic_config_options=() @@ -53,6 +54,12 @@ while true; do ) fi + if [ "$CONFIG_SUPPORT_AUTOMATIC_POWERON" = "y" ]; then + dynamic_config_options+=( \ + 'N' " $(get_config_display_action "$AUTOMATIC_POWERON") Automatic Power-On" \ + ) + fi + unset menu_choice whiptail $BG_COLOR_MAIN_MENU --title "Config Management Menu" \ --menu "This menu lets you change settings for the current BIOS session.\n\nAll changes will revert after a reboot,\n\nunless you also save them to the running BIOS." 0 80 10 \ @@ -390,6 +397,31 @@ while true; do fi fi ;; + "N" ) + if [ "$AUTOMATIC_POWERON" = "n" ]; then + if (whiptail --title 'Enable automatic power-on?' \ + --yesno "The system will boot automatically when power is applied. + \n\nDo you want to proceed?" 0 80) then + + toggle_config /etc/config.user "CONFIG_AUTOMATIC_POWERON" + combine_configs + + whiptail --title 'Config change successful' \ + --msgbox "Automatic power-on enabled;\nsave the config change and reboot for it to go into effect." 0 80 + fi + else + if (whiptail --title 'Disable automatic power-on?' \ + --yesno "The system will stay off when power is applied. + \n\nDo you want to proceed?" 0 80) then + + toggle_config /etc/config.user "CONFIG_AUTOMATIC_POWERON" + combine_configs + + whiptail --title 'Config change successful' \ + --msgbox "Automatic power-on disabled;\nsave the config change and reboot for it to go into effect." 0 80 + fi + fi + ;; esac done