summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>2011-11-01 23:43:37 +0000
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>2011-11-01 23:43:37 +0000
commit22a262c8eeace5e5e7e3e812a0b30ac49ea5b811 (patch)
tree0bd4920df4ca357252b636cac5044777ae1a9cdb
parent483bc3d3308c640316f61e3b97ce7ea21dfd61a3 (diff)
downloadedk2-platforms-22a262c8eeace5e5e7e3e812a0b30ac49ea5b811.tar.xz
ArmPlatformPkg/Bds: Fixed and Improved initrd support in the ArmPlatformPkg Boot Manager
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12641 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r--ArmPlatformPkg/Bds/BdsInternal.h10
-rw-r--r--ArmPlatformPkg/Bds/BootMenu.c86
-rw-r--r--ArmPlatformPkg/Bds/BootOptionSupport.c211
3 files changed, 187 insertions, 120 deletions
diff --git a/ArmPlatformPkg/Bds/BdsInternal.h b/ArmPlatformPkg/Bds/BdsInternal.h
index e7a83e6926..5ef85631f3 100644
--- a/ArmPlatformPkg/Bds/BdsInternal.h
+++ b/ArmPlatformPkg/Bds/BdsInternal.h
@@ -99,9 +99,9 @@ typedef struct {
typedef struct _BDS_LOAD_OPTION_SUPPORT {
BDS_SUPPORTED_DEVICE_TYPE Type;
EFI_STATUS (*ListDevices)(IN OUT LIST_ENTRY* BdsLoadOptionList);
- BOOLEAN (*IsSupported)(IN BDS_LOAD_OPTION* BdsLoadOption);
- EFI_STATUS (*CreateDevicePathNode)(IN BDS_SUPPORTED_DEVICE* BdsLoadOption, OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode, OUT ARM_BDS_LOADER_TYPE *BootType, OUT UINT32 *Attributes);
- EFI_STATUS (*UpdateDevicePathNode)(IN EFI_DEVICE_PATH *OldDevicePath, OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath, OUT ARM_BDS_LOADER_TYPE *BootType, OUT UINT32 *Attributes);
+ BOOLEAN (*IsSupported)(IN EFI_DEVICE_PATH *DevicePath);
+ EFI_STATUS (*CreateDevicePathNode)(IN CHAR16* FileName, OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode, OUT ARM_BDS_LOADER_TYPE *BootType, OUT UINT32 *Attributes);
+ EFI_STATUS (*UpdateDevicePathNode)(IN EFI_DEVICE_PATH *OldDevicePath, IN CHAR16* FileName, OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath, OUT ARM_BDS_LOADER_TYPE *BootType, OUT UINT32 *Attributes);
} BDS_LOAD_OPTION_SUPPORT;
#define LOAD_OPTION_ENTRY_FROM_LINK(a) BASE_CR(a, BDS_LOAD_OPTION_ENTRY, Link)
@@ -128,8 +128,8 @@ BootDeviceListSupportedFree (
EFI_STATUS
BootDeviceGetDeviceSupport (
- IN BDS_LOAD_OPTION *BootOption,
- OUT BDS_LOAD_OPTION_SUPPORT** DeviceSupport
+ IN EFI_DEVICE_PATH *DevicePath,
+ OUT BDS_LOAD_OPTION_SUPPORT **DeviceSupport
);
EFI_STATUS
diff --git a/ArmPlatformPkg/Bds/BootMenu.c b/ArmPlatformPkg/Bds/BootMenu.c
index 7d1010bac2..315fc953f5 100644
--- a/ArmPlatformPkg/Bds/BootMenu.c
+++ b/ArmPlatformPkg/Bds/BootMenu.c
@@ -126,6 +126,7 @@ BootMenuAddBootOption (
EFI_DEVICE_PATH_PROTOCOL *InitrdPathNode;
EFI_DEVICE_PATH_PROTOCOL *InitrdPath;
UINTN CmdLineSize;
+ BOOLEAN InitrdSupport;
UINTN InitrdSize;
Attributes = 0;
@@ -139,8 +140,7 @@ BootMenuAddBootOption (
}
// Create the specific device path node
- Print(L"File path of the EFI Application or the kernel: ");
- Status = SupportedBootDevice->Support->CreateDevicePathNode (SupportedBootDevice, &DevicePathNode, &BootType, &Attributes);
+ Status = SupportedBootDevice->Support->CreateDevicePathNode (L"EFI Application or the kernel", &DevicePathNode, &BootType, &Attributes);
if (EFI_ERROR(Status)) {
Status = EFI_ABORTED;
goto EXIT;
@@ -149,17 +149,27 @@ BootMenuAddBootOption (
DevicePath = AppendDevicePathNode (SupportedBootDevice->DevicePathProtocol, (CONST EFI_DEVICE_PATH_PROTOCOL *)DevicePathNode);
if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_FDT)) {
- // Create the specific device path node
- Print(L"File path of the initrd: ");
- Status = SupportedBootDevice->Support->CreateDevicePathNode (SupportedBootDevice, &InitrdPathNode, NULL, NULL);
- if (EFI_ERROR(Status) && Status != EFI_NOT_FOUND) { // EFI_NOT_FOUND is returned on empty input string, but we can boot without an initrd
+ Print(L"Add an initrd: ");
+ Status = GetHIInputBoolean (&InitrdSupport);
+ if (EFI_ERROR(Status)) {
Status = EFI_ABORTED;
goto EXIT;
}
- if (InitrdPathNode != NULL) {
- // Append the Device Path node to the select device path
- InitrdPath = AppendDevicePathNode (SupportedBootDevice->DevicePathProtocol, (CONST EFI_DEVICE_PATH_PROTOCOL *)InitrdPathNode);
+ if (InitrdSupport) {
+ // Create the specific device path node
+ Status = SupportedBootDevice->Support->CreateDevicePathNode (L"initrd", &InitrdPathNode, NULL, NULL);
+ if (EFI_ERROR(Status) && Status != EFI_NOT_FOUND) { // EFI_NOT_FOUND is returned on empty input string, but we can boot without an initrd
+ Status = EFI_ABORTED;
+ goto EXIT;
+ }
+
+ if (InitrdPathNode != NULL) {
+ // Append the Device Path node to the select device path
+ InitrdPath = AppendDevicePathNode (SupportedBootDevice->DevicePathProtocol, (CONST EFI_DEVICE_PATH_PROTOCOL *)InitrdPathNode);
+ } else {
+ InitrdPath = NULL;
+ }
} else {
InitrdPath = NULL;
}
@@ -348,9 +358,11 @@ BootMenuUpdateBootOption (
ARM_BDS_LOADER_TYPE BootType;
ARM_BDS_LOADER_OPTIONAL_DATA* OptionalData;
ARM_BDS_LINUX_ARGUMENTS* LinuxArguments;
- EFI_DEVICE_PATH* InitrdPathList;
+ EFI_DEVICE_PATH *InitrdPathNode;
+ EFI_DEVICE_PATH *InitrdPath;
UINTN InitrdSize;
UINTN CmdLineSize;
+ BOOLEAN InitrdSupport;
Status = BootMenuSelectBootOption (BootOptionsList, UPDATE_BOOT_ENTRY, TRUE, &BootOptionEntry);
if (EFI_ERROR(Status)) {
@@ -359,14 +371,13 @@ BootMenuUpdateBootOption (
BootOption = BootOptionEntry->BdsLoadOption;
// Get the device support for this Boot Option
- Status = BootDeviceGetDeviceSupport (BootOption, &DeviceSupport);
+ Status = BootDeviceGetDeviceSupport (BootOption->FilePathList, &DeviceSupport);
if (EFI_ERROR(Status)) {
Print(L"Not possible to retrieve the supported device for the update\n");
return EFI_UNSUPPORTED;
}
- Print(L"File path of the EFI Application or the kernel: ");
- Status = DeviceSupport->UpdateDevicePathNode (BootOption->FilePathList, &DevicePath, NULL, NULL);
+ Status = DeviceSupport->UpdateDevicePathNode (BootOption->FilePathList, L"EFI Application or the kernel", &DevicePath, NULL, NULL);
if (EFI_ERROR(Status)) {
Status = EFI_ABORTED;
goto EXIT;
@@ -375,7 +386,6 @@ BootMenuUpdateBootOption (
OptionalData = BootOption->OptionalData;
BootType = (ARM_BDS_LOADER_TYPE)ReadUnaligned32 ((UINT32 *)(&OptionalData->Header.LoaderType));
- // TODO: Allow adding an initrd to a boot entry without one
if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_FDT)) {
LinuxArguments = &OptionalData->Arguments.LinuxArguments;
@@ -383,13 +393,47 @@ BootMenuUpdateBootOption (
InitrdSize = ReadUnaligned16 ((CONST UINT16*)&LinuxArguments->InitrdSize);
if (InitrdSize > 0) {
- Print(L"File path of the initrd: ");
- Status = DeviceSupport->UpdateDevicePathNode ((EFI_DEVICE_PATH*)((LinuxArguments + 1) + CmdLineSize), &InitrdPathList, NULL, NULL);
- if (EFI_ERROR(Status) && Status != EFI_NOT_FOUND) {// EFI_NOT_FOUND is returned on empty input string, but we can boot without an initrd
- Status = EFI_ABORTED;
- goto EXIT;
+ Print(L"Keep the initrd: ");
+ } else {
+ Print(L"Add an initrd: ");
+ }
+ Status = GetHIInputBoolean (&InitrdSupport);
+ if (EFI_ERROR(Status)) {
+ Status = EFI_ABORTED;
+ goto EXIT;
+ }
+
+ if (InitrdSupport) {
+ if (InitrdSize > 0) {
+ // Case we update the initrd device path
+ Status = DeviceSupport->UpdateDevicePathNode ((EFI_DEVICE_PATH*)((LinuxArguments + 1) + CmdLineSize), L"initrd", &InitrdPath, NULL, NULL);
+ if (EFI_ERROR(Status) && Status != EFI_NOT_FOUND) {// EFI_NOT_FOUND is returned on empty input string, but we can boot without an initrd
+ Status = EFI_ABORTED;
+ goto EXIT;
+ }
+ InitrdSize = GetDevicePathSize (InitrdPath);
+ } else {
+ // Case we create the initrd device path
+
+ Status = DeviceSupport->CreateDevicePathNode (L"initrd", &InitrdPathNode, NULL, NULL);
+ if (EFI_ERROR(Status) && Status != EFI_NOT_FOUND) { // EFI_NOT_FOUND is returned on empty input string, but we can boot without an initrd
+ Status = EFI_ABORTED;
+ goto EXIT;
+ }
+
+ if (InitrdPathNode != NULL) {
+ // Duplicate Linux kernel Device Path
+ DevicePath = DuplicateDevicePath (BootOption->FilePathList);
+ // Replace Linux kernel Node by EndNode
+ SetDevicePathEndNode (GetLastDevicePathNode (DevicePath));
+ // Append the Device Path node to the select device path
+ InitrdPath = AppendDevicePathNode (DevicePath, (CONST EFI_DEVICE_PATH_PROTOCOL *)InitrdPathNode);
+ } else {
+ InitrdPath = NULL;
+ }
}
- InitrdSize = GetDevicePathSize (InitrdPathList);
+ } else {
+ InitrdSize = 0;
}
Print(L"Arguments to pass to the binary: ");
@@ -410,7 +454,7 @@ BootMenuUpdateBootOption (
BootArguments->LinuxArguments.CmdLineSize = CmdLineSize;
BootArguments->LinuxArguments.InitrdSize = InitrdSize;
CopyMem (&BootArguments->LinuxArguments + 1, CmdLine, CmdLineSize);
- CopyMem ((UINTN)(&BootArguments->LinuxArguments + 1) + CmdLine, InitrdPathList, InitrdSize);
+ CopyMem ((UINTN)(&BootArguments->LinuxArguments + 1) + CmdLine, InitrdPath, InitrdSize);
} else {
BootArguments = NULL;
}
diff --git a/ArmPlatformPkg/Bds/BootOptionSupport.c b/ArmPlatformPkg/Bds/BootOptionSupport.c
index fb383b6f24..f16de7c82d 100644
--- a/ArmPlatformPkg/Bds/BootOptionSupport.c
+++ b/ArmPlatformPkg/Bds/BootOptionSupport.c
@@ -33,23 +33,24 @@ BdsLoadOptionFileSystemList (
EFI_STATUS
BdsLoadOptionFileSystemCreateDevicePath (
- IN BDS_SUPPORTED_DEVICE* BdsLoadOption,
- OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,
- OUT ARM_BDS_LOADER_TYPE *BootType,
- OUT UINT32 *Attributes
+ IN CHAR16* FileName,
+ OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,
+ OUT ARM_BDS_LOADER_TYPE *BootType,
+ OUT UINT32 *Attributes
);
EFI_STATUS
BdsLoadOptionFileSystemUpdateDevicePath (
- IN EFI_DEVICE_PATH *OldDevicePath,
- OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,
- OUT ARM_BDS_LOADER_TYPE *BootType,
- OUT UINT32 *Attributes
+ IN EFI_DEVICE_PATH *OldDevicePath,
+ IN CHAR16* FileName,
+ OUT EFI_DEVICE_PATH_PROTOCOL **NewDevicePath,
+ OUT ARM_BDS_LOADER_TYPE *BootType,
+ OUT UINT32 *Attributes
);
BOOLEAN
BdsLoadOptionFileSystemIsSupported (
- IN BDS_LOAD_OPTION* BdsLoadOption
+ IN EFI_DEVICE_PATH *DevicePath
);
EFI_STATUS
@@ -59,23 +60,24 @@ BdsLoadOptionMemMapList (
EFI_STATUS
BdsLoadOptionMemMapCreateDevicePath (
- IN BDS_SUPPORTED_DEVICE* BdsLoadOption,
- OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,
- OUT ARM_BDS_LOADER_TYPE *BootType,
- OUT UINT32 *Attributes
+ IN CHAR16* FileName,
+ OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,
+ OUT ARM_BDS_LOADER_TYPE *BootType,
+ OUT UINT32 *Attributes
);
EFI_STATUS
BdsLoadOptionMemMapUpdateDevicePath (
- IN EFI_DEVICE_PATH *OldDevicePath,
- OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,
- OUT ARM_BDS_LOADER_TYPE *BootType,
- OUT UINT32 *Attributes
+ IN EFI_DEVICE_PATH *OldDevicePath,
+ IN CHAR16* FileName,
+ OUT EFI_DEVICE_PATH_PROTOCOL **NewDevicePath,
+ OUT ARM_BDS_LOADER_TYPE *BootType,
+ OUT UINT32 *Attributes
);
BOOLEAN
BdsLoadOptionMemMapIsSupported (
- IN BDS_LOAD_OPTION* BdsLoadOption
+ IN EFI_DEVICE_PATH *DevicePath
);
EFI_STATUS
@@ -85,23 +87,24 @@ BdsLoadOptionPxeList (
EFI_STATUS
BdsLoadOptionPxeCreateDevicePath (
- IN BDS_SUPPORTED_DEVICE* BdsLoadOption,
- OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,
- OUT ARM_BDS_LOADER_TYPE *BootType,
- OUT UINT32 *Attributes
+ IN CHAR16* FileName,
+ OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,
+ OUT ARM_BDS_LOADER_TYPE *BootType,
+ OUT UINT32 *Attributes
);
EFI_STATUS
BdsLoadOptionPxeUpdateDevicePath (
- IN EFI_DEVICE_PATH *OldDevicePath,
- OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,
- OUT ARM_BDS_LOADER_TYPE *BootType,
- OUT UINT32 *Attributes
+ IN EFI_DEVICE_PATH *OldDevicePath,
+ IN CHAR16* FileName,
+ OUT EFI_DEVICE_PATH_PROTOCOL **NewDevicePath,
+ OUT ARM_BDS_LOADER_TYPE *BootType,
+ OUT UINT32 *Attributes
);
BOOLEAN
BdsLoadOptionPxeIsSupported (
- IN BDS_LOAD_OPTION* BdsLoadOption
+ IN EFI_DEVICE_PATH *DevicePath
);
EFI_STATUS
@@ -111,23 +114,24 @@ BdsLoadOptionTftpList (
EFI_STATUS
BdsLoadOptionTftpCreateDevicePath (
- IN BDS_SUPPORTED_DEVICE* BdsLoadOption,
- OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,
- OUT ARM_BDS_LOADER_TYPE *BootType,
- OUT UINT32 *Attributes
+ IN CHAR16* FileName,
+ OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,
+ OUT ARM_BDS_LOADER_TYPE *BootType,
+ OUT UINT32 *Attributes
);
EFI_STATUS
BdsLoadOptionTftpUpdateDevicePath (
- IN EFI_DEVICE_PATH *OldDevicePath,
- OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,
- OUT ARM_BDS_LOADER_TYPE *BootType,
- OUT UINT32 *Attributes
+ IN EFI_DEVICE_PATH *OldDevicePath,
+ IN CHAR16* FileName,
+ OUT EFI_DEVICE_PATH_PROTOCOL **NewDevicePath,
+ OUT ARM_BDS_LOADER_TYPE *BootType,
+ OUT UINT32 *Attributes
);
BOOLEAN
BdsLoadOptionTftpIsSupported (
- IN BDS_LOAD_OPTION* BdsLoadOption
+ IN EFI_DEVICE_PATH *DevicePath
);
BDS_LOAD_OPTION_SUPPORT BdsLoadOptionSupportList[] = {
@@ -201,15 +205,15 @@ BootDeviceListSupportedFree (
EFI_STATUS
BootDeviceGetDeviceSupport (
- IN BDS_LOAD_OPTION *BootOption,
- OUT BDS_LOAD_OPTION_SUPPORT** DeviceSupport
+ IN EFI_DEVICE_PATH *DevicePath,
+ OUT BDS_LOAD_OPTION_SUPPORT **DeviceSupport
)
{
UINTN Index;
// Find which supported device is the most appropriate
for (Index = 0; Index < BDS_DEVICE_MAX; Index++) {
- if (BdsLoadOptionSupportList[Index].IsSupported (BootOption)) {
+ if (BdsLoadOptionSupportList[Index].IsSupported (DevicePath)) {
*DeviceSupport = &BdsLoadOptionSupportList[Index];
return EFI_SUCCESS;
}
@@ -327,10 +331,10 @@ BdsLoadOptionFileSystemList (
EFI_STATUS
BdsLoadOptionFileSystemCreateDevicePath (
- IN BDS_SUPPORTED_DEVICE* BdsLoadOption,
- OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,
- OUT ARM_BDS_LOADER_TYPE *BootType,
- OUT UINT32 *Attributes
+ IN CHAR16* FileName,
+ OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,
+ OUT ARM_BDS_LOADER_TYPE *BootType,
+ OUT UINT32 *Attributes
)
{
EFI_STATUS Status;
@@ -338,6 +342,7 @@ BdsLoadOptionFileSystemCreateDevicePath (
CHAR16 BootFilePath[BOOT_DEVICE_FILEPATH_MAX];
UINTN BootFilePathSize;
+ Print(L"File path of the %s: ", FileName);
Status = GetHIInputStr (BootFilePath, BOOT_DEVICE_FILEPATH_MAX);
if (EFI_ERROR(Status)) {
return EFI_ABORTED;
@@ -371,10 +376,11 @@ BdsLoadOptionFileSystemCreateDevicePath (
EFI_STATUS
BdsLoadOptionFileSystemUpdateDevicePath (
- IN EFI_DEVICE_PATH *OldDevicePath,
- OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,
- OUT ARM_BDS_LOADER_TYPE *BootType,
- OUT UINT32 *Attributes
+ IN EFI_DEVICE_PATH *OldDevicePath,
+ IN CHAR16* FileName,
+ OUT EFI_DEVICE_PATH_PROTOCOL **NewDevicePath,
+ OUT ARM_BDS_LOADER_TYPE *BootType,
+ OUT UINT32 *Attributes
)
{
EFI_STATUS Status;
@@ -388,6 +394,7 @@ BdsLoadOptionFileSystemUpdateDevicePath (
EndingDevicePath = (FILEPATH_DEVICE_PATH*)GetLastDevicePathNode (DevicePath);
+ Print(L"File path of the %s: ", FileName);
StrnCpy (BootFilePath, EndingDevicePath->PathName, BOOT_DEVICE_FILEPATH_MAX);
Status = EditHIInputStr (BootFilePath, BOOT_DEVICE_FILEPATH_MAX);
if (EFI_ERROR(Status)) {
@@ -421,12 +428,12 @@ BdsLoadOptionFileSystemUpdateDevicePath (
BOOLEAN
BdsLoadOptionFileSystemIsSupported (
- IN BDS_LOAD_OPTION* BdsLoadOption
+ IN EFI_DEVICE_PATH *DevicePath
)
{
EFI_DEVICE_PATH* DevicePathNode;
- DevicePathNode = GetLastDevicePathNode (BdsLoadOption->FilePathList);
+ DevicePathNode = GetLastDevicePathNode (DevicePath);
return IS_DEVICE_PATH_NODE(DevicePathNode,MEDIA_DEVICE_PATH,MEDIA_FILEPATH_DP);
}
@@ -525,38 +532,45 @@ BdsLoadOptionMemMapList (
EFI_STATUS
BdsLoadOptionMemMapCreateDevicePath (
- IN BDS_SUPPORTED_DEVICE* BdsLoadOption,
- OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,
- OUT ARM_BDS_LOADER_TYPE *BootType,
- OUT UINT32 *Attributes
+ IN CHAR16* FileName,
+ OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,
+ OUT ARM_BDS_LOADER_TYPE *BootType,
+ OUT UINT32 *Attributes
)
{
- EFI_STATUS Status;
- MEMMAP_DEVICE_PATH* MemMapDevicePath;
- CHAR16 StrStartingAddress[BOOT_DEVICE_ADDRESS_MAX];
- CHAR16 StrEndingAddress[BOOT_DEVICE_ADDRESS_MAX];
+ EFI_STATUS Status;
+ MEMMAP_DEVICE_PATH *MemMapDevicePath;
+ CHAR16 StrStartingAddress[BOOT_DEVICE_ADDRESS_MAX];
+ CHAR16 StrEndingAddress[BOOT_DEVICE_ADDRESS_MAX];
- Print(L"Starting Address of the binary: ");
- Status = GetHIInputStr (StrStartingAddress,BOOT_DEVICE_ADDRESS_MAX);
+ Print(L"Starting Address of the %s: ", FileName);
+ Status = GetHIInputStr (StrStartingAddress, BOOT_DEVICE_ADDRESS_MAX);
if (EFI_ERROR(Status)) {
return EFI_ABORTED;
}
- Print(L"Ending Address of the binary: ");
- Status = GetHIInputStr (StrEndingAddress,BOOT_DEVICE_ADDRESS_MAX);
+ Print(L"Ending Address of the %s: ", FileName);
+ Status = GetHIInputStr (StrEndingAddress, BOOT_DEVICE_ADDRESS_MAX);
if (EFI_ERROR(Status)) {
return EFI_ABORTED;
}
// Create the MemMap Device Path Node
- MemMapDevicePath = (MEMMAP_DEVICE_PATH*)AllocatePool (sizeof(MEMMAP_DEVICE_PATH));
+ MemMapDevicePath = (MEMMAP_DEVICE_PATH*)AllocatePool (sizeof(MEMMAP_DEVICE_PATH) + END_DEVICE_PATH_LENGTH);
MemMapDevicePath->Header.Type = HARDWARE_DEVICE_PATH;
MemMapDevicePath->Header.SubType = HW_MEMMAP_DP;
+ SetDevicePathNodeLength (MemMapDevicePath, sizeof(MEMMAP_DEVICE_PATH));
MemMapDevicePath->MemoryType = EfiBootServicesData;
MemMapDevicePath->StartingAddress = StrHexToUint64 (StrStartingAddress);
MemMapDevicePath->EndingAddress = StrHexToUint64 (StrEndingAddress);
- Status = BootDeviceGetType (NULL, BootType, Attributes);
+ // Set a Device Path End Node after the Memory Map Device Path Node
+ SetDevicePathEndNode (MemMapDevicePath + 1);
+
+ if (BootType != NULL || Attributes != NULL) {
+ Status = BootDeviceGetType (NULL, BootType, Attributes);
+ }
+
if (EFI_ERROR(Status)) {
FreePool (MemMapDevicePath);
} else {
@@ -568,10 +582,11 @@ BdsLoadOptionMemMapCreateDevicePath (
EFI_STATUS
BdsLoadOptionMemMapUpdateDevicePath (
- IN EFI_DEVICE_PATH *OldDevicePath,
- OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,
- OUT ARM_BDS_LOADER_TYPE *BootType,
- OUT UINT32 *Attributes
+ IN EFI_DEVICE_PATH *OldDevicePath,
+ IN CHAR16* FileName,
+ OUT EFI_DEVICE_PATH_PROTOCOL **NewDevicePath,
+ OUT ARM_BDS_LOADER_TYPE *BootType,
+ OUT UINT32 *Attributes
)
{
EFI_STATUS Status;
@@ -583,14 +598,14 @@ BdsLoadOptionMemMapUpdateDevicePath (
DevicePath = DuplicateDevicePath (OldDevicePath);
EndingDevicePath = (MEMMAP_DEVICE_PATH*)GetLastDevicePathNode (DevicePath);
- Print(L"Starting Address of the binary: ");
+ Print(L"Starting Address of the %s: ", FileName);
UnicodeSPrint (StrStartingAddress, BOOT_DEVICE_ADDRESS_MAX, L"0x%X", (UINTN)EndingDevicePath->StartingAddress);
Status = EditHIInputStr (StrStartingAddress, BOOT_DEVICE_ADDRESS_MAX);
if (EFI_ERROR(Status)) {
return EFI_ABORTED;
}
- Print(L"Ending Address of the binary: ");
+ Print(L"Ending Address of the %s: ", FileName);
UnicodeSPrint (StrEndingAddress, BOOT_DEVICE_ADDRESS_MAX, L"0x%X", (UINTN)EndingDevicePath->EndingAddress);
Status = EditHIInputStr (StrEndingAddress, BOOT_DEVICE_ADDRESS_MAX);
if (EFI_ERROR(Status)) {
@@ -600,7 +615,10 @@ BdsLoadOptionMemMapUpdateDevicePath (
EndingDevicePath->StartingAddress = StrHexToUint64 (StrStartingAddress);
EndingDevicePath->EndingAddress = StrHexToUint64 (StrEndingAddress);
- Status = BootDeviceGetType (NULL, BootType, Attributes);
+ if (BootType != NULL || Attributes != NULL) {
+ Status = BootDeviceGetType (NULL, BootType, Attributes);
+ }
+
if (EFI_ERROR(Status)) {
FreePool(DevicePath);
} else {
@@ -612,12 +630,12 @@ BdsLoadOptionMemMapUpdateDevicePath (
BOOLEAN
BdsLoadOptionMemMapIsSupported (
- IN BDS_LOAD_OPTION* BdsLoadOption
+ IN EFI_DEVICE_PATH *DevicePath
)
{
EFI_DEVICE_PATH* DevicePathNode;
- DevicePathNode = GetLastDevicePathNode (BdsLoadOption->FilePathList);
+ DevicePathNode = GetLastDevicePathNode (DevicePath);
return IS_DEVICE_PATH_NODE(DevicePathNode,HARDWARE_DEVICE_PATH,HW_MEMMAP_DP);
}
@@ -672,10 +690,10 @@ BdsLoadOptionPxeList (
EFI_STATUS
BdsLoadOptionPxeCreateDevicePath (
- IN BDS_SUPPORTED_DEVICE* BdsLoadOption,
- OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,
- OUT ARM_BDS_LOADER_TYPE *BootType,
- OUT UINT32 *Attributes
+ IN CHAR16* FileName,
+ OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,
+ OUT ARM_BDS_LOADER_TYPE *BootType,
+ OUT UINT32 *Attributes
)
{
*DevicePathNode = (EFI_DEVICE_PATH_PROTOCOL *) AllocatePool (END_DEVICE_PATH_LENGTH);
@@ -686,10 +704,11 @@ BdsLoadOptionPxeCreateDevicePath (
EFI_STATUS
BdsLoadOptionPxeUpdateDevicePath (
- IN EFI_DEVICE_PATH *OldDevicePath,
- OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,
- OUT ARM_BDS_LOADER_TYPE *BootType,
- OUT UINT32 *Attributes
+ IN EFI_DEVICE_PATH *OldDevicePath,
+ IN CHAR16* FileName,
+ OUT EFI_DEVICE_PATH_PROTOCOL **NewDevicePath,
+ OUT ARM_BDS_LOADER_TYPE *BootType,
+ OUT UINT32 *Attributes
)
{
ASSERT (0);
@@ -698,7 +717,7 @@ BdsLoadOptionPxeUpdateDevicePath (
BOOLEAN
BdsLoadOptionPxeIsSupported (
- IN BDS_LOAD_OPTION* BdsLoadOption
+ IN EFI_DEVICE_PATH *DevicePath
)
{
EFI_STATUS Status;
@@ -706,7 +725,7 @@ BdsLoadOptionPxeIsSupported (
EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath;
EFI_PXE_BASE_CODE_PROTOCOL *PxeBcProtocol;
- Status = BdsConnectDevicePath (BdsLoadOption->FilePathList, &Handle, &RemainingDevicePath);
+ Status = BdsConnectDevicePath (DevicePath, &Handle, &RemainingDevicePath);
if (EFI_ERROR(Status)) {
return FALSE;
}
@@ -773,10 +792,10 @@ BdsLoadOptionTftpList (
EFI_STATUS
BdsLoadOptionTftpCreateDevicePath (
- IN BDS_SUPPORTED_DEVICE* BdsLoadOption,
- OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,
- OUT ARM_BDS_LOADER_TYPE *BootType,
- OUT UINT32 *Attributes
+ IN CHAR16* FileName,
+ OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,
+ OUT ARM_BDS_LOADER_TYPE *BootType,
+ OUT UINT32 *Attributes
)
{
EFI_STATUS Status;
@@ -808,7 +827,7 @@ BdsLoadOptionTftpCreateDevicePath (
return EFI_ABORTED;
}
- Print(L"File path of the EFI Application or the kernel : ");
+ Print(L"File path of the %s : ", FileName);
Status = GetHIInputStr (BootFilePath, BOOT_DEVICE_FILEPATH_MAX);
if (EFI_ERROR(Status)) {
return EFI_ABORTED;
@@ -840,7 +859,10 @@ BdsLoadOptionTftpCreateDevicePath (
SetDevicePathNodeLength (FilePathDevicePath, SIZE_OF_FILEPATH_DEVICE_PATH + BootFilePathSize);
CopyMem (FilePathDevicePath->PathName, BootFilePath, BootFilePathSize);
- Status = BootDeviceGetType (NULL, BootType, Attributes);
+ if (BootType != NULL || Attributes != NULL) {
+ Status = BootDeviceGetType (NULL, BootType, Attributes);
+ }
+
if (EFI_ERROR(Status)) {
FreePool (IPv4DevicePathNode);
} else {
@@ -852,10 +874,11 @@ BdsLoadOptionTftpCreateDevicePath (
EFI_STATUS
BdsLoadOptionTftpUpdateDevicePath (
- IN EFI_DEVICE_PATH *OldDevicePath,
- OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,
- OUT ARM_BDS_LOADER_TYPE *BootType,
- OUT UINT32 *Attributes
+ IN EFI_DEVICE_PATH *OldDevicePath,
+ IN CHAR16* FileName,
+ OUT EFI_DEVICE_PATH_PROTOCOL **NewDevicePath,
+ OUT ARM_BDS_LOADER_TYPE *BootType,
+ OUT UINT32 *Attributes
)
{
ASSERT (0);
@@ -864,7 +887,7 @@ BdsLoadOptionTftpUpdateDevicePath (
BOOLEAN
BdsLoadOptionTftpIsSupported (
- IN BDS_LOAD_OPTION* BdsLoadOption
+ IN EFI_DEVICE_PATH *DevicePath
)
{
EFI_STATUS Status;
@@ -873,7 +896,7 @@ BdsLoadOptionTftpIsSupported (
EFI_DEVICE_PATH *NextDevicePath;
EFI_PXE_BASE_CODE_PROTOCOL *PxeBcProtocol;
- Status = BdsConnectDevicePath (BdsLoadOption->FilePathList, &Handle, &RemainingDevicePath);
+ Status = BdsConnectDevicePath (DevicePath, &Handle, &RemainingDevicePath);
if (EFI_ERROR(Status)) {
return FALSE;
}