Implement BlEfiGetSecureBootStatus() to get SecureBoot status
All checks were successful
ci/woodpecker/push/build Pipeline was successful
All checks were successful
ci/woodpecker/push/build Pipeline was successful
This commit is contained in:
parent
da37ceaa0f
commit
09e58d0b67
@ -162,6 +162,38 @@ BlDbgPrint(IN PUINT16 Format,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This routine checks whether SecureBoot is enabled or not.
|
||||
*
|
||||
* @return Numeric representation of SecureBoot status (0 = Disabled, >0 = Enabled, <0 SetupMode).
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
INT_PTR
|
||||
BlEfiGetSecureBootStatus()
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* This routine allocates a pool memory.
|
||||
*
|
||||
|
@ -19,6 +19,9 @@ EXTERN EFI_HANDLE EfiImageHandle;
|
||||
/* EFI System Table */
|
||||
EXTERN PEFI_SYSTEM_TABLE EfiSystemTable;
|
||||
|
||||
/* EFI Secure Boot status */
|
||||
EXTERN INT_PTR EfiSecureBoot;
|
||||
|
||||
/* Serial port configuration */
|
||||
EXTERN CPPORT EfiSerialPort;
|
||||
|
||||
@ -44,6 +47,9 @@ VOID
|
||||
BlDbgPrint(IN PUINT16 Format,
|
||||
IN ...);
|
||||
|
||||
INT_PTR
|
||||
BlEfiGetSecureBootStatus();
|
||||
|
||||
EFI_STATUS
|
||||
BlEfiMemoryAllocatePool(IN UINT_PTR Size,
|
||||
OUT PVOID *Memory);
|
||||
|
@ -308,6 +308,10 @@ BlStartXtLoader(IN EFI_HANDLE ImageHandle,
|
||||
BlDbgPrint(L"WARNING: Failed to disable watchdog timer\n");
|
||||
}
|
||||
|
||||
/* Check SecureBoot status */
|
||||
EfiSecureBoot = BlEfiGetSecureBootStatus();
|
||||
BlDbgPrint(L"SecureBoot status: %S\n", EfiSecureBoot == 0 ? L"DISABLED" : EfiSecureBoot > 0 ? L"ENABLED" : L"SETUP");
|
||||
|
||||
/* Register loader protocol */
|
||||
Status = BlRegisterXtLoaderProtocol();
|
||||
if(Status != STATUS_EFI_SUCCESS)
|
||||
|
Loading…
Reference in New Issue
Block a user