diff options
-rw-r--r-- | ArmPkg/Include/Library/BdsLib.h | 19 | ||||
-rw-r--r-- | ArmPlatformPkg/Bds/BdsInternal.h | 25 | ||||
-rw-r--r-- | ArmPlatformPkg/Bds/BootMenu.c | 71 | ||||
-rw-r--r-- | ArmPlatformPkg/Bds/BootOption.c | 56 |
4 files changed, 102 insertions, 69 deletions
diff --git a/ArmPkg/Include/Library/BdsLib.h b/ArmPkg/Include/Library/BdsLib.h index b7aa724925..91c67e726e 100644 --- a/ArmPkg/Include/Library/BdsLib.h +++ b/ArmPkg/Include/Library/BdsLib.h @@ -15,6 +15,25 @@ #ifndef __BDS_ENTRY_H__
#define __BDS_ENTRY_H__
+typedef UINT8* EFI_LOAD_OPTION;
+
+/**
+ This is defined by the UEFI specs, don't change it
+**/
+typedef struct {
+ UINT16 LoadOptionIndex;
+ EFI_LOAD_OPTION LoadOption;
+ UINTN LoadOptionSize;
+
+ UINT32 Attributes;
+ UINT16 FilePathListLength;
+ CHAR16 *Description;
+ EFI_DEVICE_PATH_PROTOCOL *FilePathList;
+
+ VOID* OptionalData;
+ UINTN OptionalDataSize;
+} BDS_LOAD_OPTION;
+
/**
Connect a Device Path and return the handle of the driver that support this DevicePath
diff --git a/ArmPlatformPkg/Bds/BdsInternal.h b/ArmPlatformPkg/Bds/BdsInternal.h index d4c438b010..3f2d1a63d2 100644 --- a/ArmPlatformPkg/Bds/BdsInternal.h +++ b/ArmPlatformPkg/Bds/BdsInternal.h @@ -71,6 +71,11 @@ typedef struct { ARM_BDS_LOADER_ARGUMENTS Arguments;
} ARM_BDS_LOADER_OPTIONAL_DATA;
+typedef struct {
+ LIST_ENTRY Link;
+ BDS_LOAD_OPTION* BdsLoadOption;
+} BDS_LOAD_OPTION_ENTRY;
+
typedef enum {
BDS_DEVICE_FILESYSTEM = 0,
BDS_DEVICE_MEMMAP,
@@ -88,23 +93,6 @@ typedef struct { #define SUPPORTED_BOOT_DEVICE_FROM_LINK(a) BASE_CR(a, BDS_SUPPORTED_DEVICE, Link)
-typedef UINT8* EFI_LOAD_OPTION;
-
-/* This is defined by the UEFI specs, don't change it */
-typedef struct {
- LIST_ENTRY Link;
-
- UINT16 LoadOptionIndex;
- EFI_LOAD_OPTION LoadOption;
- UINTN LoadOptionSize;
-
- UINT32 Attributes;
- UINT16 FilePathListLength;
- CHAR16 *Description;
- EFI_DEVICE_PATH_PROTOCOL *FilePathList;
- BDS_LOADER_OPTIONAL_DATA *OptionalData;
-} BDS_LOAD_OPTION;
-
typedef struct _BDS_LOAD_OPTION_SUPPORT {
BDS_SUPPORTED_DEVICE_TYPE Type;
EFI_STATUS (*ListDevices)(IN OUT LIST_ENTRY* BdsLoadOptionList);
@@ -113,7 +101,8 @@ typedef struct _BDS_LOAD_OPTION_SUPPORT { EFI_STATUS (*UpdateDevicePathNode)(IN EFI_DEVICE_PATH *OldDevicePath, OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath, OUT ARM_BDS_LOADER_TYPE *BootType, OUT UINT32 *Attributes);
} BDS_LOAD_OPTION_SUPPORT;
-#define LOAD_OPTION_FROM_LINK(a) BASE_CR(a, BDS_LOAD_OPTION, Link)
+#define LOAD_OPTION_ENTRY_FROM_LINK(a) BASE_CR(a, BDS_LOAD_OPTION_ENTRY, Link)
+#define LOAD_OPTION_FROM_LINK(a) ((BDS_LOAD_OPTION_ENTRY*)BASE_CR(a, BDS_LOAD_OPTION_ENTRY, Link))->BdsLoadOption
EFI_STATUS
GetEnvironmentVariable (
diff --git a/ArmPlatformPkg/Bds/BootMenu.c b/ArmPlatformPkg/Bds/BootMenu.c index 8aa09596fd..d583c02256 100644 --- a/ArmPlatformPkg/Bds/BootMenu.c +++ b/ArmPlatformPkg/Bds/BootMenu.c @@ -120,7 +120,7 @@ BootMenuAddBootOption ( CHAR8 CmdLine[BOOT_DEVICE_OPTION_MAX];
UINT32 Attributes;
ARM_BDS_LOADER_TYPE BootType;
- BDS_LOAD_OPTION *BdsLoadOption;
+ BDS_LOAD_OPTION_ENTRY *BdsLoadOptionEntry;
EFI_DEVICE_PATH *DevicePath;
EFI_DEVICE_PATH_PROTOCOL *DevicePathNode;
EFI_DEVICE_PATH_PROTOCOL *InitrdPathNode;
@@ -192,9 +192,10 @@ BootMenuAddBootOption ( }
// Create new entry
- Status = BootOptionCreate (Attributes, BootDescription, DevicePath, BootType, &BootArguments, &BdsLoadOption);
+ BdsLoadOptionEntry = (BDS_LOAD_OPTION_ENTRY*)AllocatePool (sizeof(BDS_LOAD_OPTION_ENTRY));
+ Status = BootOptionCreate (Attributes, BootDescription, DevicePath, BootType, BootArguments, &BdsLoadOptionEntry->BdsLoadOption);
if (!EFI_ERROR(Status)) {
- InsertTailList (BootOptionsList,&BdsLoadOption->Link);
+ InsertTailList (BootOptionsList, &BdsLoadOptionEntry->Link);
}
FREE_DEVICE_PATH:
@@ -212,36 +213,43 @@ EXIT: STATIC
EFI_STATUS
BootMenuSelectBootOption (
- IN LIST_ENTRY *BootOptionsList,
- IN CONST CHAR16* InputStatement,
- OUT BDS_LOAD_OPTION **BdsLoadOption
+ IN LIST_ENTRY* BootOptionsList,
+ IN CONST CHAR16* InputStatement,
+ IN BOOLEAN OnlyArmBdsBootEntry,
+ OUT BDS_LOAD_OPTION_ENTRY** BdsLoadOptionEntry
)
{
- EFI_STATUS Status;
- LIST_ENTRY* Entry;
- BDS_LOAD_OPTION *BootOption;
- UINTN BootOptionSelected;
- UINTN BootOptionCount;
- UINTN Index;
+ EFI_STATUS Status;
+ LIST_ENTRY* Entry;
+ BDS_LOAD_OPTION* BdsLoadOption;
+ UINTN BootOptionSelected;
+ UINTN BootOptionCount;
+ UINTN Index;
// Display the list of supported boot devices
BootOptionCount = 1;
for (Entry = GetFirstNode (BootOptionsList);
!IsNull (BootOptionsList,Entry);
- Entry = GetNextNode (BootOptionsList,Entry)
+ Entry = GetNextNode (BootOptionsList, Entry)
)
{
- BootOption = LOAD_OPTION_FROM_LINK(Entry);
- Print(L"[%d] %s\n",BootOptionCount,BootOption->Description);
+ BdsLoadOption = LOAD_OPTION_FROM_LINK(Entry);
+
+ if (OnlyArmBdsBootEntry && !IS_ARM_BDS_BOOTENTRY (BdsLoadOption)) {
+ continue;
+ }
+
+ Print (L"[%d] %s\n", BootOptionCount, BdsLoadOption->Description);
DEBUG_CODE_BEGIN();
CHAR16* DevicePathTxt;
EFI_DEVICE_PATH_TO_TEXT_PROTOCOL* DevicePathToTextProtocol;
ARM_BDS_LOADER_TYPE LoaderType;
+ ARM_BDS_LOADER_OPTIONAL_DATA* OptionalData;
Status = gBS->LocateProtocol(&gEfiDevicePathToTextProtocolGuid, NULL, (VOID **)&DevicePathToTextProtocol);
ASSERT_EFI_ERROR(Status);
- DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText(BootOption->FilePathList,TRUE,TRUE);
+ DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText(BdsLoadOption->FilePathList,TRUE,TRUE);
Print(L"\t- %s\n",DevicePathTxt);
OptionalData = BdsLoadOption->OptionalData;
@@ -256,6 +264,11 @@ BootMenuSelectBootOption ( BootOptionCount++;
}
+ if (BootOptionCount == 0) {
+ Print (L"No supported Boot Entry.\n");
+ return EFI_NOT_FOUND;
+ }
+
// Get the index of the boot device to delete
BootOptionSelected = 0;
while (BootOptionSelected == 0) {
@@ -277,7 +290,7 @@ BootMenuSelectBootOption ( )
{
if (Index == BootOptionSelected) {
- *BdsLoadOption = LOAD_OPTION_FROM_LINK(Entry);
+ *BdsLoadOptionEntry = LOAD_OPTION_ENTRY_FROM_LINK(Entry);
break;
}
Index++;
@@ -291,16 +304,22 @@ BootMenuRemoveBootOption ( IN LIST_ENTRY *BootOptionsList
)
{
- EFI_STATUS Status;
- BDS_LOAD_OPTION *BootOption;
+ EFI_STATUS Status;
+ BDS_LOAD_OPTION_ENTRY* BootOptionEntry;
- Status = BootMenuSelectBootOption (BootOptionsList,L"Delete entry: ",&BootOption);
+ Status = BootMenuSelectBootOption (BootOptionsList, L"Delete entry: ", FALSE, &BootOptionEntry);
if (EFI_ERROR(Status)) {
return Status;
}
+ // If the Boot Option was attached to a list remove it
+ if (!IsListEmpty (&BootOptionEntry->Link)) {
+ // Remove the entry from the list
+ RemoveEntryList (&BootOptionEntry->Link);
+ }
+
// Delete the BDS Load option structures
- BootOptionDelete (BootOption);
+ BootOptionDelete (BootOptionEntry->BdsLoadOption);
return EFI_SUCCESS;
}
@@ -311,6 +330,7 @@ BootMenuUpdateBootOption ( )
{
EFI_STATUS Status;
+ BDS_LOAD_OPTION_ENTRY *BootOptionEntry;
BDS_LOAD_OPTION *BootOption;
BDS_LOAD_OPTION_SUPPORT* DeviceSupport;
ARM_BDS_LOADER_ARGUMENTS* BootArguments;
@@ -324,10 +344,11 @@ BootMenuUpdateBootOption ( UINTN InitrdSize;
UINTN CmdLineSize;
- Status = BootMenuSelectBootOption (BootOptionsList,L"Update entry: ",&BootOption);
+ Status = BootMenuSelectBootOption (BootOptionsList, L"Update entry: ", TRUE, &BootOptionEntry);
if (EFI_ERROR(Status)) {
return Status;
}
+ BootOption = BootOptionEntry->BdsLoadOption;
// Get the device support for this Boot Option
Status = BootDeviceGetDeviceSupport (BootOption,&DeviceSupport);
@@ -494,10 +515,10 @@ BootMenuMain ( BootOption = NULL;
BootMainEntryCount = sizeof(BootMainEntries) / sizeof(struct BOOT_MAIN_ENTRY);
- // Get Boot#### list
- BootOptionList (&BootOptionsList);
-
while (TRUE) {
+ // Get Boot#### list
+ BootOptionList (&BootOptionsList);
+
OptionCount = 1;
// Display the Boot options
diff --git a/ArmPlatformPkg/Bds/BootOption.c b/ArmPlatformPkg/Bds/BootOption.c index f6090d266d..6a5f010abe 100644 --- a/ArmPlatformPkg/Bds/BootOption.c +++ b/ArmPlatformPkg/Bds/BootOption.c @@ -22,7 +22,6 @@ BootOptionStart ( )
{
EFI_STATUS Status;
- EFI_DEVICE_PATH* FdtDevicePath;
EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL* EfiDevicePathFromTextProtocol;
UINT32 LoaderType;
ARM_BDS_LOADER_OPTIONAL_DATA* OptionalData;
@@ -34,6 +33,7 @@ BootOptionStart ( UINTN InitrdSize;
EFI_DEVICE_PATH* Initrd;
+ if (IS_ARM_BDS_BOOTENTRY (BootOption)) {
Status = EFI_UNSUPPORTED;
OptionalData = BootOption->OptionalData;
LoaderType = ReadUnaligned32 ((CONST UINT32*)&OptionalData->Header.LoaderType);
@@ -83,6 +83,10 @@ BootOptionStart ( Initrd, // Initrd
(CHAR8*)(LinuxArguments + 1),
FdtDevicePath);
+ }
+ } else {
+ Status = BdsStartEfiApplication (mImageHandle, BootOption->FilePathList);
+ }
return Status;
}
@@ -159,11 +163,12 @@ BootOptionList ( IN OUT LIST_ENTRY *BootOptionList
)
{
- EFI_STATUS Status;
- UINTN Index;
- UINT16 *BootOrder;
- UINTN BootOrderSize;
- BDS_LOAD_OPTION *BdsLoadOption;
+ EFI_STATUS Status;
+ UINTN Index;
+ UINT16* BootOrder;
+ UINTN BootOrderSize;
+ BDS_LOAD_OPTION* BdsLoadOption;
+ BDS_LOAD_OPTION_ENTRY* BdsLoadOptionEntry;
InitializeListHead (BootOptionList);
@@ -176,7 +181,9 @@ BootOptionList ( for (Index = 0; Index < BootOrderSize / sizeof (UINT16); Index++) {
Status = BootOptionFromLoadOptionVariable (BootOrder[Index],&BdsLoadOption);
if (!EFI_ERROR(Status)) {
- InsertTailList (BootOptionList,&BdsLoadOption->Link);
+ BdsLoadOptionEntry = (BDS_LOAD_OPTION_ENTRY*)AllocatePool(sizeof(BDS_LOAD_OPTION_ENTRY));
+ BdsLoadOptionEntry->BdsLoadOption = BdsLoadOption;
+ InsertTailList (BootOptionList,&BdsLoadOptionEntry->Link);
}
}
@@ -327,21 +334,24 @@ BootOptionCreate ( IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,
IN ARM_BDS_LOADER_TYPE BootType,
IN ARM_BDS_LOADER_ARGUMENTS* BootArguments,
- OUT BDS_LOAD_OPTION **BdsLoadOption
+ OUT BDS_LOAD_OPTION** BdsLoadOption
)
{
- EFI_STATUS Status;
- BDS_LOAD_OPTION *BootOption;
- CHAR16 BootVariableName[9];
- UINT16 *BootOrder;
- UINTN BootOrderSize;
+ EFI_STATUS Status;
+ BDS_LOAD_OPTION_ENTRY* BootOptionEntry;
+ BDS_LOAD_OPTION* BootOption;
+ CHAR16 BootVariableName[9];
+ UINT16* BootOrder;
+ UINTN BootOrderSize;
//
// Allocate and fill the memory for the BDS Load Option structure
//
- BootOption = (BDS_LOAD_OPTION*)AllocateZeroPool(sizeof(BDS_LOAD_OPTION));
+ BootOptionEntry = (BDS_LOAD_OPTION_ENTRY*)AllocatePool (sizeof (BDS_LOAD_OPTION_ENTRY));
+ InitializeListHead (&BootOptionEntry->Link);
+ BootOptionEntry->BdsLoadOption = (BDS_LOAD_OPTION*)AllocateZeroPool (sizeof(BDS_LOAD_OPTION));
- InitializeListHead (&BootOption->Link);
+ BootOption = BootOptionEntry->BdsLoadOption;
BootOptionSetFields (BootOption, Attributes, BootDescription, DevicePath, BootType, BootArguments);
//
@@ -419,17 +429,11 @@ BootOptionDelete ( IN BDS_LOAD_OPTION *BootOption
)
{
- UINTN Index;
- UINTN BootOrderSize;
- UINT16* BootOrder;
- UINTN BootOrderCount;
- EFI_STATUS Status;
-
- // If the Boot Optiono was attached to a list remove it
- if (!IsListEmpty (&BootOption->Link)) {
- // Remove the entry from the list
- RemoveEntryList (&BootOption->Link);
- }
+ UINTN Index;
+ UINTN BootOrderSize;
+ UINT16* BootOrder;
+ UINTN BootOrderCount;
+ EFI_STATUS Status;
// Remove the entry from the BootOrder environment variable
Status = GetEnvironmentVariable (L"BootOrder", NULL, &BootOrderSize, (VOID**)&BootOrder);
|