summaryrefslogtreecommitdiff
path: root/ArmPlatformPkg/Bds/Bds.c
diff options
context:
space:
mode:
authoroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>2011-06-28 11:50:32 +0000
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>2011-06-28 11:50:32 +0000
commitaa95e2f79c2d8a60c30e1aa69c7cd7077779e039 (patch)
treee5a90cf22c938a3530d1945489c1af68878d3d94 /ArmPlatformPkg/Bds/Bds.c
parent5b491514ecfefc9a4b11cac789ec3a8e5b8f13f2 (diff)
downloadedk2-platforms-aa95e2f79c2d8a60c30e1aa69c7cd7077779e039.tar.xz
ArmPlatformPkg/Bds: Check if the assumed requirements are set before to use it
There were some assumptions that some PCDs and protocols were defined. Check if these requirements are defined; either print a debug message to inform the user or skip the statements that require these PCDs or protocol. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11915 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ArmPlatformPkg/Bds/Bds.c')
-rw-r--r--ArmPlatformPkg/Bds/Bds.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/ArmPlatformPkg/Bds/Bds.c b/ArmPlatformPkg/Bds/Bds.c
index 8f6e82073f..7b49be4c11 100644
--- a/ArmPlatformPkg/Bds/Bds.c
+++ b/ArmPlatformPkg/Bds/Bds.c
@@ -198,11 +198,11 @@ DefineDefaultBootEntries (
VOID
)
{
- BDS_LOAD_OPTION *BdsLoadOption;
- UINTN Size;
- EFI_STATUS Status;
- EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *EfiDevicePathFromTextProtocol;
- EFI_DEVICE_PATH* BootDevicePath;
+ BDS_LOAD_OPTION* BdsLoadOption;
+ UINTN Size;
+ EFI_STATUS Status;
+ EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL* EfiDevicePathFromTextProtocol;
+ EFI_DEVICE_PATH* BootDevicePath;
//
// If Boot Order does not exist then create a default entry
@@ -210,8 +210,16 @@ DefineDefaultBootEntries (
Size = 0;
Status = gRT->GetVariable (L"BootOrder", &gEfiGlobalVariableGuid, NULL, &Size, NULL);
if (Status == EFI_NOT_FOUND) {
+ if ((PcdGetPtr(PcdDefaultBootDevicePath) == NULL) || (StrLen ((CHAR16*)PcdGetPtr(PcdDefaultBootDevicePath)) == 0)) {
+ return EFI_UNSUPPORTED;
+ }
+
Status = gBS->LocateProtocol (&gEfiDevicePathFromTextProtocolGuid, NULL, (VOID **)&EfiDevicePathFromTextProtocol);
- ASSERT_EFI_ERROR(Status);
+ if (EFI_ERROR(Status)) {
+ // You must provide an implementation of DevicePathFromTextProtocol in your firmware (eg: DevicePathDxe)
+ DEBUG((EFI_D_ERROR,"Error: Bds requires DevicePathFromTextProtocol\n"));
+ return Status;
+ }
BootDevicePath = EfiDevicePathFromTextProtocol->ConvertTextToDevicePath ((CHAR16*)PcdGetPtr(PcdDefaultBootDevicePath));
DEBUG_CODE_BEGIN();
@@ -238,6 +246,8 @@ DefineDefaultBootEntries (
&BdsLoadOption
);
FreePool (BdsLoadOption);
+ } else {
+ Status = EFI_UNSUPPORTED;
}
}
@@ -341,10 +351,12 @@ BdsEntry (
//
// Declare the Firmware Vendor
//
- Size = 0x100;
- gST->FirmwareVendor = AllocateRuntimePool (Size);
- ASSERT (gST->FirmwareVendor != NULL);
- UnicodeSPrint (gST->FirmwareVendor, Size, L"%a EFI %a %a", PcdGetPtr(PcdFirmwareVendor), __DATE__, __TIME__);
+ if (PcdGetPtr(PcdFirmwareVendor)) {
+ Size = 0x100;
+ gST->FirmwareVendor = AllocateRuntimePool (Size);
+ ASSERT (gST->FirmwareVendor != NULL);
+ UnicodeSPrint (gST->FirmwareVendor, Size, L"%a EFI %a %a", PcdGetPtr(PcdFirmwareVendor), __DATE__, __TIME__);
+ }
// If BootNext environment variable is defined then we just load it !
Status = BdsStartBootOption (L"BootNext");