Implement BlEnterFirmwareSetup() routine

This commit is contained in:
2024-03-19 16:50:04 +01:00
parent 7b2a2565c5
commit 94e6ca7aec
3 changed files with 52 additions and 0 deletions

View File

@@ -9,6 +9,51 @@
#include <xtldr.h>
/**
* Reboots into UEFI firmware setup interface.
*
* @return This routine returns a status code.
*
* @since XT 1.0
*/
XTCDECL
EFI_STATUS
BlEnterFirmwareSetup()
{
EFI_GUID Guid = EFI_GLOBAL_VARIABLE_GUID;
PULONGLONG SetupSupport;
ULONGLONG Indications;
EFI_STATUS Status;
/* Check if booting into firmware interface is supported */
Status = BlGetEfiVariable(&Guid, L"OsIndicationsSupported", (PVOID*)&SetupSupport);
if(Status != STATUS_EFI_SUCCESS || !(*SetupSupport & EFI_OS_INDICATIONS_BOOT_TO_FW_UI))
{
/* Reboot into firmware setup is not supported */
BlDebugPrint(L"WARNING: Reboot into firmware setup interface not supported\n");
return STATUS_EFI_UNSUPPORTED;
}
/* Get the value of OsIndications variable */
Indications = 0;
Status = BlGetEfiVariable(&Guid, L"OsIndications", (PVOID)&Indications);
/* Enable FW setup on next boot */
Indications |= EFI_OS_INDICATIONS_BOOT_TO_FW_UI;
Status = BlSetEfiVariable(&Guid, L"OsIndications", (PVOID)&Indications, sizeof(Indications));
if(Status != STATUS_EFI_SUCCESS)
{
/* Failed to update OsIndications variable */
return Status;
}
/* Reboot into firmware setup */
BlRebootSystem();
/* Must not reach this point, just make the compiler happy */
return STATUS_EFI_SUCCESS;
}
/**
* Exits EFI boot services.
*

View File

@@ -95,6 +95,10 @@ XTCDECL
VOID
BlEnableConsoleCursor();
XTCDECL
EFI_STATUS
BlEnterFirmwareSetup();
XTCDECL
EFI_STATUS
BlEnumerateBlockDevices();