Implement BlGetSecureBootStatus() and do some refactoring
This commit is contained in:
@@ -26,11 +26,11 @@ BlExitBootServices(IN UINT_PTR MapKey)
|
||||
EFI_STATUS Status;
|
||||
|
||||
/* Attempt to exit boot services */
|
||||
Status = EfiSystemTable->BootServices->ExitBootServices(BlpStatus.ImageHandle, MapKey);
|
||||
Status = EfiSystemTable->BootServices->ExitBootServices(EfiImageHandle, MapKey);
|
||||
if(Status != STATUS_EFI_SUCCESS)
|
||||
{
|
||||
/* Retry as UEFI spec says to do it twice */
|
||||
Status = EfiSystemTable->BootServices->ExitBootServices(BlpStatus.ImageHandle, MapKey);
|
||||
Status = EfiSystemTable->BootServices->ExitBootServices(EfiImageHandle, MapKey);
|
||||
}
|
||||
|
||||
/* Make sure boot services were successfully exited */
|
||||
@@ -44,6 +44,39 @@ BlExitBootServices(IN UINT_PTR MapKey)
|
||||
return Status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether SecureBoot is enabled or not.
|
||||
*
|
||||
* @return Numeric representation of SecureBoot status (0 = Disabled, >0 = Enabled, <0 SetupMode).
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTCDECL
|
||||
INT_PTR
|
||||
BlGetSecureBootStatus()
|
||||
{
|
||||
EFI_GUID VarGuid = EFI_GLOBAL_VARIABLE_GUID;
|
||||
INT_PTR SecureBootStatus = 0;
|
||||
UCHAR VarValue = 0;
|
||||
UINT_PTR Size;
|
||||
|
||||
Size = sizeof(VarValue);
|
||||
if(EfiSystemTable->RuntimeServices->GetVariable(L"SecureBoot", &VarGuid,
|
||||
NULL, &Size, &VarValue) == STATUS_EFI_SUCCESS)
|
||||
{
|
||||
SecureBootStatus = (INT_PTR)VarValue;
|
||||
|
||||
if((EfiSystemTable->RuntimeServices->GetVariable(L"SetupMode", &VarGuid,
|
||||
NULL, &Size, &VarValue) == STATUS_EFI_SUCCESS) && VarValue != 0)
|
||||
{
|
||||
SecureBootStatus = -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Return SecureBoot status */
|
||||
return SecureBootStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts the system to sleep for the specified number of milliseconds.
|
||||
*
|
||||
@@ -74,8 +107,6 @@ BlpInitializeEfiBootLoader()
|
||||
{
|
||||
/* Set current XTLDR status */
|
||||
BlpStatus.BootServices = TRUE;
|
||||
BlpStatus.ImageHandle = EfiImageHandle;
|
||||
BlpStatus.SystemTable = EfiSystemTable;
|
||||
|
||||
/* Initialize console */
|
||||
BlpInitializeConsole();
|
||||
|
||||
Reference in New Issue
Block a user