Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/stand/efiboot efiboot: add "setup" command



details:   https://anonhg.NetBSD.org/src/rev/ce5857d65b0c
branches:  trunk
changeset: 989004:ce5857d65b0c
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sat Oct 09 13:09:17 2021 +0000

description:
efiboot: add "setup" command

The "setup" command sets the 64-bit "OsIndications" variable to the value of
EFI_OS_INDICATIONS_BOOT_TO_FW_UI and requests a reboot. On firmware that
supports this, after reboot the user will be presented with the firmware
setup menu.

diffstat:

 sys/stand/efiboot/boot.c |  33 ++++++++++++++++++++++++++++++++-
 1 files changed, 32 insertions(+), 1 deletions(-)

diffs (75 lines):

diff -r 1645d131b489 -r ce5857d65b0c sys/stand/efiboot/boot.c
--- a/sys/stand/efiboot/boot.c  Sat Oct 09 11:13:25 2021 +0000
+++ b/sys/stand/efiboot/boot.c  Sat Oct 09 13:09:17 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: boot.c,v 1.38 2021/10/06 10:13:19 jmcneill Exp $       */
+/*     $NetBSD: boot.c,v 1.39 2021/10/09 13:09:17 jmcneill Exp $       */
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka <nonaka%netbsd.org@localhost>
@@ -111,6 +111,7 @@
 void   command_mem(char *);
 void   command_menu(char *);
 void   command_reset(char *);
+void   command_setup(char *);
 void   command_version(char *);
 void   command_quit(char *);
 
@@ -134,6 +135,7 @@
        { "menu",       command_menu,           "menu" },
        { "reboot",     command_reset,          "reboot|reset" },
        { "reset",      command_reset,          NULL },
+       { "setup",      command_setup,          "setup" },
        { "version",    command_version,        "version" },
        { "ver",        command_version,        NULL },
        { "help",       command_help,           "help|?" },
@@ -355,6 +357,7 @@
 {
        char pathbuf[80];
        char *ufirmware;
+       const UINT64 *osindsup;
        int rv;
 
        printf("Version: %s (%s)\n", bootprog_rev, bootprog_kernrev);
@@ -371,6 +374,11 @@
                printf("Config path: %s\n", pathbuf);
        }
 
+       osindsup = LibGetVariable(L"OsIndicationsSupported", &EfiGlobalVariable);
+       if (osindsup != NULL) {
+               printf("UEFI OS indications supported: 0x%" PRIx64 "\n", *osindsup);
+       }
+
 #ifdef EFIBOOT_FDT
        efi_fdt_show();
 #endif
@@ -394,6 +402,29 @@
        efi_reboot();
 }
 
+void
+command_setup(char *arg)
+{
+       EFI_STATUS status;
+       const UINT64 *osindsup;
+       UINT64 osind;
+
+       osindsup = LibGetVariable(L"OsIndicationsSupported", &EfiGlobalVariable);
+       if (osindsup == NULL || (*osindsup & EFI_OS_INDICATIONS_BOOT_TO_FW_UI) == 0) {
+               printf("Not supported by firmware\n");
+               return;
+       }
+
+       osind = EFI_OS_INDICATIONS_BOOT_TO_FW_UI;
+       status = LibSetNVVariable(L"OsIndications", &EfiGlobalVariable, sizeof(osind), &osind);
+       if (EFI_ERROR(status)) {
+               printf("Failed to set OsIndications variable: %lu\n", (u_long)status);
+               return;
+       }
+
+       efi_reboot();
+}
+
 int
 set_default_device(const char *arg)
 {



Home | Main Index | Thread Index | Old Index