Page MenuHomeFreeBSD

D61996.1795633393.diff
No OneTemporary

Authored By
Unknown
Size
4 KB
Referenced Files
None
Subscribers
None

D61996.1795633393.diff

diff --git a/stand/efi/loader/main.c b/stand/efi/loader/main.c
--- a/stand/efi/loader/main.c
+++ b/stand/efi/loader/main.c
@@ -53,6 +53,7 @@
#include <Guid/DebugImageInfoTable.h>
#include <Guid/DxeServices.h>
+#include <Guid/GlobalVariable.h>
#include <Guid/Mps.h>
#include <Guid/SmBios.h>
#include <Protocol/Rng.h>
@@ -108,6 +109,7 @@
{ 0xb1b621d5, 0xf19c, 0x41a5, {0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0} }
EFI_GUID devid = DEVICE_PATH_PROTOCOL;
+EFI_GUID globalvar = EFI_GLOBAL_VARIABLE;
EFI_GUID imgid = LOADED_IMAGE_PROTOCOL;
EFI_GUID mps = MPS_TABLE_GUID;
EFI_GUID netid = EFI_SIMPLE_NETWORK_PROTOCOL_GUID;
@@ -1294,6 +1296,21 @@
return (efi_devpath_get_mac(devpath, mac));
}
+static bool
+fwsetup_supported(void)
+{
+ UINT64 osind;
+ size_t sz;
+
+ /* Older firmware provides UINT32, newer UINT64. */
+ osind = 0;
+ sz = sizeof(osind);
+ if (efi_global_getenv("OsIndicationsSupported", &osind, &sz) !=
+ EFI_SUCCESS)
+ return (false);
+ return ((osind & EFI_OS_INDICATIONS_BOOT_TO_FW_UI) != 0);
+}
+
EFI_STATUS
main(int argc, CHAR16 *argv[])
{
@@ -1319,6 +1336,9 @@
/* Report the RSDP early. */
acpi_detect();
+ if (fwsetup_supported())
+ feature_enable(FEATURE_FW_SETUP);
+
#ifdef LOADER_VERIEXEC
/* tell boot_setenv to be careful */
set_check_restricted(true);
@@ -1715,6 +1735,49 @@
return (CMD_ERROR);
}
+COMMAND_SET(fwsetup, "fwsetup", "reboot into the firmware setup UI",
+ command_fwsetup);
+
+static int
+command_fwsetup(int argc __unused, char *argv[] __unused)
+{
+ UINT64 osind;
+ size_t sz;
+ EFI_STATUS status;
+ int i;
+
+ if (!fwsetup_supported()) {
+ command_errmsg =
+ "firmware does not support booting into its setup UI";
+ return (CMD_ERROR);
+ }
+
+ /* Preserve any other indications already pending. */
+ osind = 0;
+ sz = sizeof(osind);
+ if (efi_global_getenv("OsIndications", &osind, &sz) != EFI_SUCCESS)
+ osind = 0;
+ osind |= EFI_OS_INDICATIONS_BOOT_TO_FW_UI;
+ status = efi_setenv(&globalvar, "OsIndications",
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS |
+ EFI_VARIABLE_RUNTIME_ACCESS, &osind, sizeof(osind));
+ if (EFI_ERROR(status)) {
+ snprintf(command_errbuf, sizeof(command_errbuf),
+ "failed to set OsIndications: error %lu",
+ DECODE_ERROR(status));
+ return (CMD_ERROR);
+ }
+
+ for (i = 0; devsw[i] != NULL; ++i)
+ if (devsw[i]->dv_cleanup != NULL)
+ (devsw[i]->dv_cleanup)();
+
+ RS->ResetSystem(EfiResetCold, EFI_SUCCESS, 0, NULL);
+
+ /* NOTREACHED */
+ return (CMD_ERROR);
+}
+
COMMAND_SET(memmap, "memmap", "print memory map", command_memmap);
static int
diff --git a/stand/libsa/features.c b/stand/libsa/features.c
--- a/stand/libsa/features.c
+++ b/stand/libsa/features.c
@@ -18,6 +18,7 @@
const char *desc;
} feature_map[] = {
FEATURE_ENTRY(EARLY_ACPI, "Loader probes ACPI in early startup"),
+ FEATURE_ENTRY(FW_SETUP, "Loader can reboot into firmware setup"),
};
void
diff --git a/stand/libsa/stand.h b/stand/libsa/stand.h
--- a/stand/libsa/stand.h
+++ b/stand/libsa/stand.h
@@ -532,6 +532,7 @@
* features table, just to simplify reasoning about these.
*/
#define FEATURE_EARLY_ACPI 0x0001
+#define FEATURE_FW_SETUP 0x0002
/* hexdump.c */
void hexdump(caddr_t region, size_t len);
diff --git a/stand/lua/menu.lua b/stand/lua/menu.lua
--- a/stand/lua/menu.lua
+++ b/stand/lua/menu.lua
@@ -244,6 +244,7 @@
boot_entry_2,
menu_entries.prompt,
menu_entries.reboot,
+ menu_entries.fwsetup,
menu_entries.console,
{
entry_type = core.MENU_SEPARATOR,
@@ -328,6 +329,18 @@
end,
alias = {"r", "R"},
},
+ fwsetup = {
+ entry_type = core.MENU_ENTRY,
+ name = "Reboot to " .. color.highlight("F") ..
+ "irmware Setup",
+ func = function()
+ loader.perform("fwsetup")
+ end,
+ visible = function()
+ return core.hasFeature("FW_SETUP")
+ end,
+ alias = {"f", "F"},
+ },
kernel_options = {
entry_type = core.MENU_CAROUSEL_ENTRY,
carousel_id = "kernel",
diff --git a/stand/man/loader.efi.8 b/stand/man/loader.efi.8
--- a/stand/man/loader.efi.8
+++ b/stand/man/loader.efi.8
@@ -30,7 +30,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd June 14, 2026
+.Dd November 25, 2026
.Dt LOADER.EFI 8
.Os
.Sh NAME
@@ -372,6 +372,26 @@
environment for testing purposes, by executing the
.Ic ud2
processor instruction.
+.Ss Firmware Setup
+The
+.Ic fwsetup
+command asks the firmware to stop in its setup user interface on the
+next boot, by setting the
+.Dv EFI_OS_INDICATIONS_BOOT_TO_FW_UI
+bit in the
+.Va OsIndications
+UEFI variable, and then reboots the system.
+It is only available when the firmware advertises support for this
+in the
+.Va OsIndicationsSupported
+UEFI variable.
+When it is, the boot menu also offers a
+.Dq Reboot to Firmware Setup
+entry.
+.Xr efibootmgr 8
+provides the same function from a running system with its
+.Fl f
+option.
.Ss i386 firmware on amd64 machines
Some devices have 64-bit (long mode) capable CPUs, but come with a
32-bit (protected mode) UEFI implementation.

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 25, 7:03 PM (21 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41995953
Default Alt Text
D61996.1795633393.diff (4 KB)

Event Timeline