diff options
author | Olivier Martin <olivier.martin@arm.com> | 2014-04-11 10:56:02 +0000 |
---|---|---|
committer | oliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524> | 2014-04-11 10:56:02 +0000 |
commit | 90a44ec4d85a03cf8feb4a95183aa3acfe246d13 (patch) | |
tree | 38c80b833e8b432a7e407b6e10187a0b17b3fb8c /ArmPlatformPkg/Bds | |
parent | 9fc9aa46ccf2d942b98d921bb22987fd232f6248 (diff) | |
download | edk2-platforms-90a44ec4d85a03cf8feb4a95183aa3acfe246d13.tar.xz |
ArmPlatformPkg/Bds: Decoupled OptionalData for the EFI application boot entry from the Linux loader
OptionalData for EFI Application does not contain any more specific information about the ArmPlatformPkg/Bds.
OptionalData now only contains the data pass to the EFI application.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <olivier.martin@arm.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15451 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ArmPlatformPkg/Bds')
-rw-r--r-- | ArmPlatformPkg/Bds/Bds.c | 13 | ||||
-rw-r--r-- | ArmPlatformPkg/Bds/BdsInternal.h | 6 | ||||
-rw-r--r-- | ArmPlatformPkg/Bds/BootMenu.c | 32 | ||||
-rw-r--r-- | ArmPlatformPkg/Bds/BootOption.c | 38 |
4 files changed, 57 insertions, 32 deletions
diff --git a/ArmPlatformPkg/Bds/Bds.c b/ArmPlatformPkg/Bds/Bds.c index 76dd5465a2..2888843058 100644 --- a/ArmPlatformPkg/Bds/Bds.c +++ b/ArmPlatformPkg/Bds/Bds.c @@ -220,6 +220,8 @@ DefineDefaultBootEntries ( EFI_STATUS Status;
EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL* EfiDevicePathFromTextProtocol;
EFI_DEVICE_PATH* BootDevicePath;
+ UINT8* OptionalData;
+ UINTN OptionalDataSize;
ARM_BDS_LOADER_ARGUMENTS* BootArguments;
ARM_BDS_LOADER_TYPE BootType;
EFI_DEVICE_PATH* InitrdPath;
@@ -306,7 +308,8 @@ DefineDefaultBootEntries ( InitrdPath = EfiDevicePathFromTextProtocol->ConvertTextToDevicePath ((CHAR16*)PcdGetPtr(PcdDefaultBootInitrdPath));
InitrdSize = GetDevicePathSize (InitrdPath);
- BootArguments = (ARM_BDS_LOADER_ARGUMENTS*)AllocatePool (sizeof(ARM_BDS_LOADER_ARGUMENTS) + CmdLineAsciiSize + InitrdSize);
+ OptionalDataSize = sizeof(ARM_BDS_LOADER_ARGUMENTS) + CmdLineAsciiSize + InitrdSize;
+ BootArguments = (ARM_BDS_LOADER_ARGUMENTS*)AllocatePool (OptionalDataSize);
if (BootArguments == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -315,15 +318,19 @@ DefineDefaultBootEntries ( CopyMem ((VOID*)(BootArguments + 1), AsciiDefaultBootArgument, CmdLineAsciiSize);
CopyMem ((VOID*)((UINTN)(BootArguments + 1) + CmdLineAsciiSize), InitrdPath, InitrdSize);
+
+ OptionalData = (UINT8*)BootArguments;
} else {
- BootArguments = NULL;
+ OptionalData = NULL;
+ OptionalDataSize = 0;
}
BootOptionCreate (LOAD_OPTION_ACTIVE | LOAD_OPTION_CATEGORY_BOOT,
(CHAR16*)PcdGetPtr(PcdDefaultBootDescription),
BootDevicePath,
BootType,
- BootArguments,
+ OptionalData,
+ OptionalDataSize,
&BdsLoadOption
);
FreePool (BdsLoadOption);
diff --git a/ArmPlatformPkg/Bds/BdsInternal.h b/ArmPlatformPkg/Bds/BdsInternal.h index d2c1655114..085a5a49ef 100644 --- a/ArmPlatformPkg/Bds/BdsInternal.h +++ b/ArmPlatformPkg/Bds/BdsInternal.h @@ -219,7 +219,8 @@ BootOptionCreate ( IN CHAR16* BootDescription,
IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,
IN ARM_BDS_LOADER_TYPE BootType,
- IN ARM_BDS_LOADER_ARGUMENTS* BootArguments,
+ IN UINT8* OptionalData,
+ IN UINTN OptionalDataSize,
OUT BDS_LOAD_OPTION** BdsLoadOption
);
@@ -230,7 +231,8 @@ BootOptionUpdate ( IN CHAR16* BootDescription,
IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,
IN ARM_BDS_LOADER_TYPE BootType,
- IN ARM_BDS_LOADER_ARGUMENTS* BootArguments
+ IN UINT8* OptionalData,
+ IN UINTN OptionalDataSize
);
EFI_STATUS
diff --git a/ArmPlatformPkg/Bds/BootMenu.c b/ArmPlatformPkg/Bds/BootMenu.c index 1b101d45c1..b04ebd35a2 100644 --- a/ArmPlatformPkg/Bds/BootMenu.c +++ b/ArmPlatformPkg/Bds/BootMenu.c @@ -131,6 +131,8 @@ BootMenuAddBootOption ( UINTN CmdLineSize;
BOOLEAN InitrdSupport;
UINTN InitrdSize;
+ UINT8* OptionalData;
+ UINTN OptionalDataSize;
Attributes = 0;
SupportedBootDevice = NULL;
@@ -195,14 +197,18 @@ BootMenuAddBootOption ( CmdLineSize = AsciiStrSize (CmdLine);
InitrdSize = GetDevicePathSize (InitrdPath);
- BootArguments = (ARM_BDS_LOADER_ARGUMENTS*)AllocatePool (sizeof(ARM_BDS_LOADER_ARGUMENTS) + CmdLineSize + InitrdSize);
+ OptionalDataSize = sizeof(ARM_BDS_LOADER_ARGUMENTS) + CmdLineSize + InitrdSize;
+ BootArguments = (ARM_BDS_LOADER_ARGUMENTS*)AllocatePool (OptionalDataSize);
BootArguments->LinuxArguments.CmdLineSize = CmdLineSize;
BootArguments->LinuxArguments.InitrdSize = InitrdSize;
CopyMem ((VOID*)(&BootArguments->LinuxArguments + 1), CmdLine, CmdLineSize);
CopyMem ((VOID*)((UINTN)(&BootArguments->LinuxArguments + 1) + CmdLineSize), InitrdPath, InitrdSize);
+
+ OptionalData = (UINT8*)BootArguments;
} else {
- BootArguments = NULL;
+ OptionalData = NULL;
+ OptionalDataSize = 0;
}
Print(L"Description for this new Entry: ");
@@ -214,7 +220,7 @@ BootMenuAddBootOption ( // Create new entry
BdsLoadOptionEntry = (BDS_LOAD_OPTION_ENTRY*)AllocatePool (sizeof(BDS_LOAD_OPTION_ENTRY));
- Status = BootOptionCreate (Attributes, BootDescription, DevicePath, BootType, BootArguments, &BdsLoadOptionEntry->BdsLoadOption);
+ Status = BootOptionCreate (Attributes, BootDescription, DevicePath, BootType, OptionalData, OptionalDataSize, &BdsLoadOptionEntry->BdsLoadOption);
if (!EFI_ERROR(Status)) {
InsertTailList (BootOptionsList, &BdsLoadOptionEntry->Link);
}
@@ -367,13 +373,15 @@ BootMenuUpdateBootOption ( EFI_DEVICE_PATH *DevicePath;
EFI_DEVICE_PATH *TempInitrdPath;
ARM_BDS_LOADER_TYPE BootType;
- ARM_BDS_LOADER_OPTIONAL_DATA* OptionalData;
+ ARM_BDS_LOADER_OPTIONAL_DATA* LoaderOptionalData;
ARM_BDS_LINUX_ARGUMENTS* LinuxArguments;
EFI_DEVICE_PATH *InitrdPathNodes;
EFI_DEVICE_PATH *InitrdPath;
UINTN InitrdSize;
UINTN CmdLineSize;
BOOLEAN InitrdSupport;
+ UINT8* OptionalData;
+ UINTN OptionalDataSize;
Status = BootMenuSelectBootOption (BootOptionsList, UPDATE_BOOT_ENTRY, TRUE, &BootOptionEntry);
if (EFI_ERROR(Status)) {
@@ -394,11 +402,11 @@ BootMenuUpdateBootOption ( goto EXIT;
}
- OptionalData = BootOption->OptionalData;
- BootType = (ARM_BDS_LOADER_TYPE)ReadUnaligned32 ((UINT32 *)(&OptionalData->Header.LoaderType));
+ LoaderOptionalData = BootOption->OptionalData;
+ BootType = (ARM_BDS_LOADER_TYPE)ReadUnaligned32 ((UINT32 *)(&LoaderOptionalData->Header.LoaderType));
if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_FDT)) {
- LinuxArguments = &OptionalData->Arguments.LinuxArguments;
+ LinuxArguments = &LoaderOptionalData->Arguments.LinuxArguments;
CmdLineSize = ReadUnaligned16 ((CONST UINT16*)&LinuxArguments->CmdLineSize);
@@ -467,13 +475,17 @@ BootMenuUpdateBootOption ( CmdLineSize = AsciiStrSize (CmdLine);
- BootArguments = (ARM_BDS_LOADER_ARGUMENTS*)AllocatePool(sizeof(ARM_BDS_LOADER_ARGUMENTS) + CmdLineSize + InitrdSize);
+ OptionalDataSize = sizeof(ARM_BDS_LOADER_ARGUMENTS) + CmdLineSize + InitrdSize;
+ BootArguments = (ARM_BDS_LOADER_ARGUMENTS*)AllocatePool (OptionalDataSize);
BootArguments->LinuxArguments.CmdLineSize = CmdLineSize;
BootArguments->LinuxArguments.InitrdSize = InitrdSize;
CopyMem (&BootArguments->LinuxArguments + 1, CmdLine, CmdLineSize);
CopyMem ((VOID*)((UINTN)(&BootArguments->LinuxArguments + 1) + CmdLineSize), InitrdPath, InitrdSize);
+
+ OptionalData = (UINT8*)BootArguments;
} else {
- BootArguments = NULL;
+ OptionalData = NULL;
+ OptionalDataSize = 0;
}
Print(L"Description for this new Entry: ");
@@ -485,7 +497,7 @@ BootMenuUpdateBootOption ( }
// Update the entry
- Status = BootOptionUpdate (BootOption, BootOption->Attributes, BootDescription, DevicePath, BootType, BootArguments);
+ Status = BootOptionUpdate (BootOption, BootOption->Attributes, BootDescription, DevicePath, BootType, OptionalData, OptionalDataSize);
FREE_DEVICE_PATH:
FreePool (DevicePath);
diff --git a/ArmPlatformPkg/Bds/BootOption.c b/ArmPlatformPkg/Bds/BootOption.c index 8993cb14a2..6f84ed9b63 100644 --- a/ArmPlatformPkg/Bds/BootOption.c +++ b/ArmPlatformPkg/Bds/BootOption.c @@ -150,36 +150,37 @@ BootOptionSetFields ( IN CHAR16* BootDescription,
IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,
IN ARM_BDS_LOADER_TYPE BootType,
- IN ARM_BDS_LOADER_ARGUMENTS* BootArguments
+ IN UINT8* OptionalData,
+ IN UINTN OptionalDataSize
)
{
EFI_LOAD_OPTION EfiLoadOption;
UINTN EfiLoadOptionSize;
UINTN BootDescriptionSize;
- UINTN BootOptionalDataSize;
UINT16 FilePathListLength;
UINT8* EfiLoadOptionPtr;
UINT8* InitrdPathListPtr;
- UINTN OptionalDataSize;
ARM_BDS_LINUX_ARGUMENTS* DestLinuxArguments;
ARM_BDS_LINUX_ARGUMENTS* SrcLinuxArguments;
+ ARM_BDS_LOADER_ARGUMENTS* BootArguments;
// If we are overwriting an existent Boot Option then we have to free previously allocated memory
if (BootOption->LoadOption) {
- FreePool(BootOption->LoadOption);
+ FreePool (BootOption->LoadOption);
}
BootDescriptionSize = StrSize (BootDescription);
- BootOptionalDataSize = sizeof(ARM_BDS_LOADER_OPTIONAL_DATA_HEADER);
+
+ // Fixup the size in case of entry specific to ArmPlatformPkg/Bds
if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_FDT)) {
- BootOptionalDataSize += sizeof(ARM_BDS_LINUX_ARGUMENTS) + BootArguments->LinuxArguments.CmdLineSize + BootArguments->LinuxArguments.InitrdSize;
+ OptionalDataSize += sizeof(ARM_BDS_LOADER_OPTIONAL_DATA_HEADER);
}
// Compute the size of the FilePath list
FilePathListLength = GetUnalignedDevicePathSize (DevicePath);
// Allocate the memory for the EFI Load Option
- EfiLoadOptionSize = sizeof(UINT32) + sizeof(UINT16) + BootDescriptionSize + FilePathListLength + BootOptionalDataSize;
+ EfiLoadOptionSize = sizeof(UINT32) + sizeof(UINT16) + BootDescriptionSize + FilePathListLength + OptionalDataSize;
EfiLoadOption = (EFI_LOAD_OPTION)AllocatePool(EfiLoadOptionSize);
EfiLoadOptionPtr = EfiLoadOption;
@@ -209,28 +210,29 @@ BootOptionSetFields ( // Optional Data fields, Do unaligned writes
BootOption->OptionalData = EfiLoadOptionPtr;
- WriteUnaligned32 ((UINT32 *)EfiLoadOptionPtr, ARM_BDS_OPTIONAL_DATA_SIGNATURE);
- WriteUnaligned32 ((UINT32 *)(EfiLoadOptionPtr + 4), BootType);
-
- OptionalDataSize = sizeof(ARM_BDS_LOADER_OPTIONAL_DATA_HEADER);
if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_FDT)) {
+ // Write the header
+ WriteUnaligned32 ((UINT32 *)EfiLoadOptionPtr, ARM_BDS_OPTIONAL_DATA_SIGNATURE);
+ WriteUnaligned32 ((UINT32 *)(EfiLoadOptionPtr + 4), BootType);
+
+ BootArguments = (ARM_BDS_LOADER_ARGUMENTS*)OptionalData;
SrcLinuxArguments = &(BootArguments->LinuxArguments);
DestLinuxArguments = &((ARM_BDS_LOADER_OPTIONAL_DATA*)EfiLoadOptionPtr)->Arguments.LinuxArguments;
WriteUnaligned16 ((UINT16 *)&(DestLinuxArguments->CmdLineSize), SrcLinuxArguments->CmdLineSize);
WriteUnaligned16 ((UINT16 *)&(DestLinuxArguments->InitrdSize), SrcLinuxArguments->InitrdSize);
- OptionalDataSize += sizeof (ARM_BDS_LINUX_ARGUMENTS);
if (SrcLinuxArguments->CmdLineSize > 0) {
CopyMem ((VOID*)(DestLinuxArguments + 1), (VOID*)(SrcLinuxArguments + 1), SrcLinuxArguments->CmdLineSize);
- OptionalDataSize += SrcLinuxArguments->CmdLineSize;
}
if (SrcLinuxArguments->InitrdSize > 0) {
InitrdPathListPtr = (UINT8*)((UINTN)(DestLinuxArguments + 1) + SrcLinuxArguments->CmdLineSize);
CopyMem (InitrdPathListPtr, (VOID*)((UINTN)(SrcLinuxArguments + 1) + SrcLinuxArguments->CmdLineSize), SrcLinuxArguments->InitrdSize);
}
+ } else {
+ CopyMem (BootOption->OptionalData, OptionalData, OptionalDataSize);
}
BootOption->OptionalDataSize = OptionalDataSize;
@@ -253,7 +255,8 @@ BootOptionCreate ( IN CHAR16* BootDescription,
IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,
IN ARM_BDS_LOADER_TYPE BootType,
- IN ARM_BDS_LOADER_ARGUMENTS* BootArguments,
+ IN UINT8* OptionalData,
+ IN UINTN OptionalDataSize,
OUT BDS_LOAD_OPTION** BdsLoadOption
)
{
@@ -272,7 +275,7 @@ BootOptionCreate ( BootOptionEntry->BdsLoadOption = (BDS_LOAD_OPTION*)AllocateZeroPool (sizeof(BDS_LOAD_OPTION));
BootOption = BootOptionEntry->BdsLoadOption;
- BootOptionSetFields (BootOption, Attributes, BootDescription, DevicePath, BootType, BootArguments);
+ BootOptionSetFields (BootOption, Attributes, BootDescription, DevicePath, BootType, OptionalData, OptionalDataSize);
//
// Set the related environment variables
@@ -326,14 +329,15 @@ BootOptionUpdate ( IN CHAR16* BootDescription,
IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,
IN ARM_BDS_LOADER_TYPE BootType,
- IN ARM_BDS_LOADER_ARGUMENTS* BootArguments
+ IN UINT8* OptionalData,
+ IN UINTN OptionalDataSize
)
{
EFI_STATUS Status;
CHAR16 BootVariableName[9];
// Update the BDS Load Option structure
- BootOptionSetFields (BdsLoadOption, Attributes, BootDescription, DevicePath, BootType, BootArguments);
+ BootOptionSetFields (BdsLoadOption, Attributes, BootDescription, DevicePath, BootType, OptionalData, OptionalDataSize);
// Update the related environment variables
UnicodeSPrint (BootVariableName, 9 * sizeof(CHAR16), L"Boot%04X", BdsLoadOption->LoadOptionIndex);
|