ArmPlatformPkg/Bds: Add a signature in front of the Boot Argument propoer to this Bds

Each application loader has its own OptionalData format. To avoid to start a Boot Entry
that has not been created by ArmPlatform/Bds a signature has been added to the
OptionalData.


ArmPlatformPkg/Bds: Rename some internal structure from BDS_* to ARM_BDS_*



git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12311 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
oliviermartin 2011-09-09 10:51:13 +00:00
parent 74b961324c
commit 2ccfb71ebe
6 changed files with 350 additions and 250 deletions

View File

@ -203,8 +203,11 @@ DefineDefaultBootEntries (
EFI_STATUS Status; EFI_STATUS Status;
EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL* EfiDevicePathFromTextProtocol; EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL* EfiDevicePathFromTextProtocol;
EFI_DEVICE_PATH* BootDevicePath; EFI_DEVICE_PATH* BootDevicePath;
BDS_LOADER_ARGUMENTS BootArguments; ARM_BDS_LOADER_ARGUMENTS* BootArguments;
BDS_LOADER_TYPE BootType; ARM_BDS_LOADER_TYPE BootType;
EFI_DEVICE_PATH* InitrdPath;
UINTN CmdLineSize;
UINTN InitrdSize;
// //
// If Boot Order does not exist then create a default entry // If Boot Order does not exist then create a default entry
@ -240,19 +243,28 @@ DefineDefaultBootEntries (
// Create the entry is the Default values are correct // Create the entry is the Default values are correct
if (BootDevicePath != NULL) { if (BootDevicePath != NULL) {
BootType = (BDS_LOADER_TYPE)PcdGet32 (PcdDefaultBootType); BootType = (ARM_BDS_LOADER_TYPE)PcdGet32 (PcdDefaultBootType);
if (BootType == BDS_LOADER_KERNEL_LINUX_ATAG) { if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_FDT)) {
BootArguments.LinuxAtagArguments.CmdLine[0] = '\0'; CmdLineSize = AsciiStrSize ((CHAR8*)PcdGetPtr(PcdDefaultBootArgument));
AsciiStrnCpy (BootArguments.LinuxAtagArguments.CmdLine,(CHAR8*)PcdGetPtr(PcdDefaultBootArgument),BOOT_DEVICE_OPTION_MAX); InitrdPath = EfiDevicePathFromTextProtocol->ConvertTextToDevicePath ((CHAR16*)PcdGetPtr(PcdDefaultBootInitrdPath));
BootArguments.LinuxAtagArguments.InitrdPathList = EfiDevicePathFromTextProtocol->ConvertTextToDevicePath ((CHAR16*)PcdGetPtr(PcdDefaultBootInitrdPath)); InitrdSize = GetDevicePathSize (InitrdPath);
BootArguments = (ARM_BDS_LOADER_ARGUMENTS*)AllocatePool (sizeof(ARM_BDS_LOADER_ARGUMENTS) + CmdLineSize + InitrdSize);
BootArguments->LinuxArguments.CmdLineSize = CmdLineSize;
BootArguments->LinuxArguments.InitrdSize = InitrdSize;
CopyMem ((VOID*)(BootArguments + 1), (CHAR8*)PcdGetPtr(PcdDefaultBootArgument), CmdLineSize);
CopyMem ((VOID*)(BootArguments + 1) + CmdLineSize, (CHAR8*)PcdGetPtr(PcdDefaultBootArgument), InitrdSize);
} else {
BootArguments = NULL;
} }
BootOptionCreate (LOAD_OPTION_ACTIVE | LOAD_OPTION_CATEGORY_BOOT, BootOptionCreate (LOAD_OPTION_ACTIVE | LOAD_OPTION_CATEGORY_BOOT,
(CHAR16*)PcdGetPtr(PcdDefaultBootDescription), (CHAR16*)PcdGetPtr(PcdDefaultBootDescription),
BootDevicePath, BootDevicePath,
BootType, BootType,
&BootArguments, BootArguments,
&BdsLoadOption &BdsLoadOption
); );
FreePool (BdsLoadOption); FreePool (BdsLoadOption);

View File

@ -343,3 +343,34 @@ BdsStartBootOption (
} }
return Status; return Status;
} }
UINTN
GetUnalignedDevicePathSize (
IN EFI_DEVICE_PATH* DevicePath
)
{
UINTN Size;
EFI_DEVICE_PATH* AlignedDevicePath;
if ((UINTN)DevicePath & 0x1) {
AlignedDevicePath = DuplicateDevicePath (DevicePath);
Size = GetDevicePathSize (AlignedDevicePath);
FreePool (AlignedDevicePath);
} else {
Size = GetDevicePathSize (DevicePath);
}
return Size;
}
EFI_DEVICE_PATH*
GetAlignedDevicePath (
IN EFI_DEVICE_PATH* DevicePath
)
{
if ((UINTN)DevicePath & 0x1) {
return DuplicateDevicePath (DevicePath);
} else {
return DevicePath;
}
}

View File

@ -38,26 +38,38 @@
#define BOOT_DEVICE_OPTION_MAX 300 #define BOOT_DEVICE_OPTION_MAX 300
#define BOOT_DEVICE_ADDRESS_MAX 20 #define BOOT_DEVICE_ADDRESS_MAX 20
#define ARM_BDS_OPTIONAL_DATA_SIGNATURE SIGNATURE_32('a', 'b', 'o', 'd')
#define IS_ARM_BDS_BOOTENTRY(ptr) (ReadUnaligned32 ((CONST UINT32*)&((ARM_BDS_LOADER_OPTIONAL_DATA*)((ptr)->OptionalData))->Header.Signature) == ARM_BDS_OPTIONAL_DATA_SIGNATURE)
typedef enum { typedef enum {
BDS_LOADER_EFI_APPLICATION = 0, BDS_LOADER_EFI_APPLICATION = 0,
BDS_LOADER_KERNEL_LINUX_ATAG, BDS_LOADER_KERNEL_LINUX_ATAG,
BDS_LOADER_KERNEL_LINUX_FDT, BDS_LOADER_KERNEL_LINUX_FDT,
} BDS_LOADER_TYPE; } ARM_BDS_LOADER_TYPE;
typedef struct{
UINT16 InitrdPathListLength;
EFI_DEVICE_PATH_PROTOCOL *InitrdPathList;
CHAR8 CmdLine[BOOT_DEVICE_OPTION_MAX + 1];
} BDS_LINUX_ATAG_ARGUMENTS;
typedef union {
BDS_LINUX_ATAG_ARGUMENTS LinuxAtagArguments;
} BDS_LOADER_ARGUMENTS;
typedef struct { typedef struct {
BDS_LOADER_TYPE LoaderType; UINT16 CmdLineSize;
BDS_LOADER_ARGUMENTS Arguments; UINT16 InitrdSize;
} BDS_LOADER_OPTIONAL_DATA;
// These following fields have variable length and are packed:
//CHAR8 *CmdLine;
//EFI_DEVICE_PATH_PROTOCOL *InitrdPathList;
} ARM_BDS_LINUX_ARGUMENTS;
typedef union {
ARM_BDS_LINUX_ARGUMENTS LinuxArguments;
} ARM_BDS_LOADER_ARGUMENTS;
typedef struct {
UINT32 Signature;
ARM_BDS_LOADER_TYPE LoaderType;
} ARM_BDS_LOADER_OPTIONAL_DATA_HEADER;
typedef struct {
ARM_BDS_LOADER_OPTIONAL_DATA_HEADER Header;
ARM_BDS_LOADER_ARGUMENTS Arguments;
} ARM_BDS_LOADER_OPTIONAL_DATA;
typedef enum { typedef enum {
BDS_DEVICE_FILESYSTEM = 0, BDS_DEVICE_FILESYSTEM = 0,
@ -97,8 +109,8 @@ typedef struct _BDS_LOAD_OPTION_SUPPORT {
BDS_SUPPORTED_DEVICE_TYPE Type; BDS_SUPPORTED_DEVICE_TYPE Type;
EFI_STATUS (*ListDevices)(IN OUT LIST_ENTRY* BdsLoadOptionList); EFI_STATUS (*ListDevices)(IN OUT LIST_ENTRY* BdsLoadOptionList);
BOOLEAN (*IsSupported)(IN BDS_LOAD_OPTION* BdsLoadOption); BOOLEAN (*IsSupported)(IN BDS_LOAD_OPTION* BdsLoadOption);
EFI_STATUS (*CreateDevicePathNode)(IN BDS_SUPPORTED_DEVICE* BdsLoadOption, OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode, OUT BDS_LOADER_TYPE *BootType, OUT UINT32 *Attributes); 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 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);
} BDS_LOAD_OPTION_SUPPORT; } BDS_LOAD_OPTION_SUPPORT;
#define LOAD_OPTION_FROM_LINK(a) BASE_CR(a, BDS_LOAD_OPTION, Link) #define LOAD_OPTION_FROM_LINK(a) BASE_CR(a, BDS_LOAD_OPTION, Link)
@ -182,6 +194,16 @@ BdsStartBootOption (
IN CHAR16* BootOption IN CHAR16* BootOption
); );
UINTN
GetUnalignedDevicePathSize (
IN EFI_DEVICE_PATH* DevicePath
);
EFI_DEVICE_PATH*
GetAlignedDevicePath (
IN EFI_DEVICE_PATH* DevicePath
);
EFI_STATUS EFI_STATUS
GenerateDeviceDescriptionName ( GenerateDeviceDescriptionName (
IN EFI_HANDLE Handle, IN EFI_HANDLE Handle,
@ -207,22 +229,22 @@ BootOptionStart (
EFI_STATUS EFI_STATUS
BootOptionCreate ( BootOptionCreate (
IN UINT32 Attributes, IN UINT32 Attributes,
IN CHAR16* BootDescription, IN CHAR16* BootDescription,
IN EFI_DEVICE_PATH_PROTOCOL* DevicePath, IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,
IN BDS_LOADER_TYPE BootType, IN ARM_BDS_LOADER_TYPE BootType,
IN BDS_LOADER_ARGUMENTS *BootArguments, IN ARM_BDS_LOADER_ARGUMENTS* BootArguments,
OUT BDS_LOAD_OPTION **BdsLoadOption OUT BDS_LOAD_OPTION** BdsLoadOption
); );
EFI_STATUS EFI_STATUS
BootOptionUpdate ( BootOptionUpdate (
IN BDS_LOAD_OPTION *BdsLoadOption, IN BDS_LOAD_OPTION* BdsLoadOption,
IN UINT32 Attributes, IN UINT32 Attributes,
IN CHAR16* BootDescription, IN CHAR16* BootDescription,
IN EFI_DEVICE_PATH_PROTOCOL* DevicePath, IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,
IN BDS_LOADER_TYPE BootType, IN ARM_BDS_LOADER_TYPE BootType,
IN BDS_LOADER_ARGUMENTS *BootArguments IN ARM_BDS_LOADER_ARGUMENTS* BootArguments
); );
EFI_STATUS EFI_STATUS

View File

@ -113,22 +113,26 @@ BootMenuAddBootOption (
IN LIST_ENTRY *BootOptionsList IN LIST_ENTRY *BootOptionsList
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
BDS_SUPPORTED_DEVICE* SupportedBootDevice; BDS_SUPPORTED_DEVICE* SupportedBootDevice;
BDS_LOADER_ARGUMENTS BootArguments; ARM_BDS_LOADER_ARGUMENTS* BootArguments;
CHAR16 BootDescription[BOOT_DEVICE_DESCRIPTION_MAX]; CHAR16 BootDescription[BOOT_DEVICE_DESCRIPTION_MAX];
UINT32 Attributes; CHAR8 CmdLine[BOOT_DEVICE_OPTION_MAX];
BDS_LOADER_TYPE BootType; UINT32 Attributes;
ARM_BDS_LOADER_TYPE BootType;
BDS_LOAD_OPTION *BdsLoadOption; BDS_LOAD_OPTION *BdsLoadOption;
EFI_DEVICE_PATH *DevicePath; EFI_DEVICE_PATH *DevicePath;
EFI_DEVICE_PATH_PROTOCOL *DevicePathNode; EFI_DEVICE_PATH_PROTOCOL *DevicePathNode;
EFI_DEVICE_PATH_PROTOCOL *InitrdPathNode; EFI_DEVICE_PATH_PROTOCOL *InitrdPathNode;
EFI_DEVICE_PATH_PROTOCOL *InitrdPath;
UINTN CmdLineSize;
UINTN InitrdSize;
Attributes = 0; Attributes = 0;
SupportedBootDevice = NULL; SupportedBootDevice = NULL;
// List the Boot Devices supported // List the Boot Devices supported
Status = SelectBootDevice(&SupportedBootDevice); Status = SelectBootDevice (&SupportedBootDevice);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
Status = EFI_ABORTED; Status = EFI_ABORTED;
goto EXIT; goto EXIT;
@ -144,7 +148,7 @@ BootMenuAddBootOption (
// Append the Device Path node to the select device path // Append the Device Path node to the select device path
DevicePath = AppendDevicePathNode (SupportedBootDevice->DevicePathProtocol, (CONST EFI_DEVICE_PATH_PROTOCOL *)DevicePathNode); DevicePath = AppendDevicePathNode (SupportedBootDevice->DevicePathProtocol, (CONST EFI_DEVICE_PATH_PROTOCOL *)DevicePathNode);
if (BootType == BDS_LOADER_KERNEL_LINUX_ATAG) { if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_FDT)) {
// Create the specific device path node // Create the specific device path node
Print(L"File path of the initrd: "); Print(L"File path of the initrd: ");
Status = SupportedBootDevice->Support->CreateDevicePathNode (SupportedBootDevice, &InitrdPathNode, NULL, NULL); Status = SupportedBootDevice->Support->CreateDevicePathNode (SupportedBootDevice, &InitrdPathNode, NULL, NULL);
@ -155,18 +159,29 @@ BootMenuAddBootOption (
if (InitrdPathNode != NULL) { if (InitrdPathNode != NULL) {
// Append the Device Path node to the select device path // Append the Device Path node to the select device path
BootArguments.LinuxAtagArguments.InitrdPathList = AppendDevicePathNode (SupportedBootDevice->DevicePathProtocol, (CONST EFI_DEVICE_PATH_PROTOCOL *)InitrdPathNode); InitrdPath = AppendDevicePathNode (SupportedBootDevice->DevicePathProtocol, (CONST EFI_DEVICE_PATH_PROTOCOL *)InitrdPathNode);
} else { } else {
BootArguments.LinuxAtagArguments.InitrdPathList = NULL; InitrdPath = NULL;
} }
Print(L"Arguments to pass to the binary: "); Print(L"Arguments to pass to the binary: ");
Status = GetHIInputAscii (BootArguments.LinuxAtagArguments.CmdLine,BOOT_DEVICE_OPTION_MAX); Status = GetHIInputAscii (CmdLine,BOOT_DEVICE_OPTION_MAX);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
Status = EFI_ABORTED; Status = EFI_ABORTED;
goto FREE_DEVICE_PATH; goto FREE_DEVICE_PATH;
} }
BootArguments.LinuxAtagArguments.CmdLine[BOOT_DEVICE_OPTION_MAX]= '\0';
CmdLineSize = AsciiStrSize (CmdLine);
InitrdSize = GetDevicePathSize (InitrdPath);
BootArguments = (ARM_BDS_LOADER_ARGUMENTS*)AllocatePool (sizeof(ARM_BDS_LOADER_ARGUMENTS) + CmdLineSize + InitrdSize);
BootArguments->LinuxArguments.CmdLineSize = CmdLineSize;
BootArguments->LinuxArguments.InitrdSize = InitrdSize;
CopyMem ((VOID*)(&BootArguments->LinuxArguments + 1), CmdLine, CmdLineSize);
CopyMem ((VOID*)((UINTN)(&BootArguments->LinuxArguments + 1) + CmdLineSize), InitrdPath, InitrdSize);
} else {
BootArguments = NULL;
} }
Print(L"Description for this new Entry: "); Print(L"Description for this new Entry: ");
@ -222,14 +237,17 @@ BootMenuSelectBootOption (
DEBUG_CODE_BEGIN(); DEBUG_CODE_BEGIN();
CHAR16* DevicePathTxt; CHAR16* DevicePathTxt;
EFI_DEVICE_PATH_TO_TEXT_PROTOCOL* DevicePathToTextProtocol; EFI_DEVICE_PATH_TO_TEXT_PROTOCOL* DevicePathToTextProtocol;
ARM_BDS_LOADER_TYPE LoaderType;
Status = gBS->LocateProtocol(&gEfiDevicePathToTextProtocolGuid, NULL, (VOID **)&DevicePathToTextProtocol); Status = gBS->LocateProtocol(&gEfiDevicePathToTextProtocolGuid, NULL, (VOID **)&DevicePathToTextProtocol);
ASSERT_EFI_ERROR(Status); ASSERT_EFI_ERROR(Status);
DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText(BootOption->FilePathList,TRUE,TRUE); DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText(BootOption->FilePathList,TRUE,TRUE);
Print(L"\t- %s\n",DevicePathTxt); Print(L"\t- %s\n",DevicePathTxt);
if ((BDS_LOADER_TYPE)ReadUnaligned32(&BootOption->OptionalData->LoaderType) == BDS_LOADER_KERNEL_LINUX_ATAG) { OptionalData = BdsLoadOption->OptionalData;
Print(L"\t- Arguments: %a\n",BootOption->OptionalData->Arguments.LinuxAtagArguments.CmdLine); LoaderType = (ARM_BDS_LOADER_TYPE)ReadUnaligned32 ((CONST UINT32*)&OptionalData->Header.LoaderType);
if ((LoaderType == BDS_LOADER_KERNEL_LINUX_ATAG) || (LoaderType == BDS_LOADER_KERNEL_LINUX_FDT)) {
Print (L"\t- Arguments: %a\n",&OptionalData->Arguments.LinuxArguments + 1);
} }
FreePool(DevicePathTxt); FreePool(DevicePathTxt);
@ -292,13 +310,19 @@ BootMenuUpdateBootOption (
IN LIST_ENTRY *BootOptionsList IN LIST_ENTRY *BootOptionsList
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
BDS_LOAD_OPTION *BootOption; BDS_LOAD_OPTION *BootOption;
BDS_LOAD_OPTION_SUPPORT *DeviceSupport; BDS_LOAD_OPTION_SUPPORT* DeviceSupport;
BDS_LOADER_ARGUMENTS BootArguments; ARM_BDS_LOADER_ARGUMENTS* BootArguments;
CHAR16 BootDescription[BOOT_DEVICE_DESCRIPTION_MAX]; CHAR16 BootDescription[BOOT_DEVICE_DESCRIPTION_MAX];
EFI_DEVICE_PATH* DevicePath; CHAR8 CmdLine[BOOT_DEVICE_OPTION_MAX];
BDS_LOADER_TYPE BootType; EFI_DEVICE_PATH* DevicePath;
ARM_BDS_LOADER_TYPE BootType;
ARM_BDS_LOADER_OPTIONAL_DATA* OptionalData;
ARM_BDS_LINUX_ARGUMENTS* LinuxArguments;
EFI_DEVICE_PATH* InitrdPathList;
UINTN InitrdSize;
UINTN CmdLineSize;
Status = BootMenuSelectBootOption (BootOptionsList,L"Update entry: ",&BootOption); Status = BootMenuSelectBootOption (BootOptionsList,L"Update entry: ",&BootOption);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
@ -319,41 +343,46 @@ BootMenuUpdateBootOption (
goto EXIT; goto EXIT;
} }
BootType = (BDS_LOADER_TYPE)ReadUnaligned32((UINT32 *)(&BootOption->OptionalData->LoaderType)); OptionalData = BootOption->OptionalData;
BootType = (ARM_BDS_LOADER_TYPE)ReadUnaligned32 ((UINT32 *)(&OptionalData->Header.LoaderType));
// TODO: Allow adding an initrd to a boot entry without one // TODO: Allow adding an initrd to a boot entry without one
if (BootType == BDS_LOADER_KERNEL_LINUX_ATAG) { if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_FDT)) {
if (ReadUnaligned16(&BootOption->OptionalData->Arguments.LinuxAtagArguments.InitrdPathListLength) > 0 LinuxArguments = &OptionalData->Arguments.LinuxArguments;
&& (EFI_DEVICE_PATH_PROTOCOL *)ReadUnaligned32((UINT32 *)(&BootOption->OptionalData->Arguments.LinuxAtagArguments.InitrdPathList)) != NULL) {
Print(L"File path of the initrd: "); CmdLineSize = ReadUnaligned16 ((CONST UINT16*)&LinuxArguments->CmdLineSize);
Status = DeviceSupport->UpdateDevicePathNode ( InitrdSize = GetUnalignedDevicePathSize ((EFI_DEVICE_PATH*)((LinuxArguments + 1) + CmdLineSize));
(EFI_DEVICE_PATH_PROTOCOL *)ReadUnaligned32((UINT32 *)(&BootOption->OptionalData->Arguments.LinuxAtagArguments.InitrdPathList)),
&BootArguments.LinuxAtagArguments.InitrdPathList, Print(L"File path of the initrd: ");
NULL, Status = DeviceSupport->UpdateDevicePathNode (
NULL); (EFI_DEVICE_PATH_PROTOCOL *)((UINTN)(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 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; Status = EFI_ABORTED;
goto EXIT; goto EXIT;
}
} else {
BootArguments.LinuxAtagArguments.InitrdPathList = NULL;
BootArguments.LinuxAtagArguments.InitrdPathListLength = 0;
} }
Print(L"Arguments to pass to the binary: "); Print(L"Arguments to pass to the binary: ");
if (ReadUnaligned32((CONST UINT32*)&BootOption->OptionalData->Arguments.LinuxAtagArguments.CmdLine)) { if (CmdLineSize > 0) {
AsciiStrnCpy(BootArguments.LinuxAtagArguments.CmdLine, AsciiStrnCpy(CmdLine, (CONST CHAR8*)(LinuxArguments + 1), CmdLineSize);
BootOption->OptionalData->Arguments.LinuxAtagArguments.CmdLine,
BOOT_DEVICE_OPTION_MAX+1);
} else { } else {
BootArguments.LinuxAtagArguments.CmdLine[0] = '\0'; CmdLine[0] = '\0';
} }
Status = EditHIInputAscii (BootArguments.LinuxAtagArguments.CmdLine, BOOT_DEVICE_OPTION_MAX); Status = EditHIInputAscii (CmdLine, BOOT_DEVICE_OPTION_MAX);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
Status = EFI_ABORTED; Status = EFI_ABORTED;
goto FREE_DEVICE_PATH; goto FREE_DEVICE_PATH;
} }
CmdLineSize = AsciiStrSize (CmdLine);
InitrdSize = GetDevicePathSize (InitrdPathList);
BootArguments = (ARM_BDS_LOADER_ARGUMENTS*)AllocatePool(sizeof(ARM_BDS_LOADER_ARGUMENTS) + CmdLineSize + InitrdSize);
BootArguments->LinuxArguments.CmdLineSize = CmdLineSize;
BootArguments->LinuxArguments.InitrdSize = InitrdSize;
CopyMem (&BootArguments->LinuxArguments + 1, CmdLine, CmdLineSize);
CopyMem ((UINTN)(&BootArguments->LinuxArguments + 1) + CmdLine, InitrdPathList, InitrdSize);
} else {
BootArguments = NULL;
} }
Print(L"Description for this new Entry: "); Print(L"Description for this new Entry: ");
@ -364,7 +393,7 @@ BootMenuUpdateBootOption (
} }
// Update the entry // Update the entry
Status = BootOptionUpdate (BootOption, BootOption->Attributes, BootDescription, DevicePath, BootType, &BootArguments); Status = BootOptionUpdate (BootOption, BootOption->Attributes, BootDescription, DevicePath, BootType, BootArguments);
FREE_DEVICE_PATH: FREE_DEVICE_PATH:
FreePool (DevicePath); FreePool (DevicePath);
@ -452,15 +481,15 @@ BootMenuMain (
VOID VOID
) )
{ {
LIST_ENTRY BootOptionsList; LIST_ENTRY BootOptionsList;
UINTN OptionCount; UINTN OptionCount;
UINTN BootOptionCount; UINTN BootOptionCount;
EFI_STATUS Status; EFI_STATUS Status;
LIST_ENTRY *Entry; LIST_ENTRY* Entry;
BDS_LOAD_OPTION *BootOption; BDS_LOAD_OPTION* BootOption;
UINTN BootOptionSelected; UINTN BootOptionSelected;
UINTN Index; UINTN Index;
UINTN BootMainEntryCount; UINTN BootMainEntryCount;
BootOption = NULL; BootOption = NULL;
BootMainEntryCount = sizeof(BootMainEntries) / sizeof(struct BOOT_MAIN_ENTRY); BootMainEntryCount = sizeof(BootMainEntries) / sizeof(struct BOOT_MAIN_ENTRY);
@ -484,6 +513,9 @@ BootMenuMain (
DEBUG_CODE_BEGIN(); DEBUG_CODE_BEGIN();
CHAR16* DevicePathTxt; CHAR16* DevicePathTxt;
EFI_DEVICE_PATH_TO_TEXT_PROTOCOL* DevicePathToTextProtocol; EFI_DEVICE_PATH_TO_TEXT_PROTOCOL* DevicePathToTextProtocol;
ARM_BDS_LOADER_OPTIONAL_DATA* OptionalData;
UINTN CmdLineSize;
ARM_BDS_LOADER_TYPE LoaderType;
Status = gBS->LocateProtocol(&gEfiDevicePathToTextProtocolGuid, NULL, (VOID **)&DevicePathToTextProtocol); Status = gBS->LocateProtocol(&gEfiDevicePathToTextProtocolGuid, NULL, (VOID **)&DevicePathToTextProtocol);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
@ -494,18 +526,22 @@ BootMenuMain (
DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText(BootOption->FilePathList,TRUE,TRUE); DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText(BootOption->FilePathList,TRUE,TRUE);
Print(L"\t- %s\n",DevicePathTxt); Print(L"\t- %s\n",DevicePathTxt);
if (ReadUnaligned32(&BootOption->OptionalData->LoaderType) == BDS_LOADER_KERNEL_LINUX_ATAG) {
if (ReadUnaligned16(&BootOption->OptionalData->Arguments.LinuxAtagArguments.InitrdPathListLength) > 0 // If it is a supported BootEntry then print its details
&& (EFI_DEVICE_PATH_PROTOCOL *)ReadUnaligned32((UINT32 *)(&BootOption->OptionalData->Arguments.LinuxAtagArguments.InitrdPathList)) != NULL) { if (IS_ARM_BDS_BOOTENTRY (BootOption)) {
DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText((EFI_DEVICE_PATH_PROTOCOL *)ReadUnaligned32((UINT32 *)(&BootOption->OptionalData->Arguments.LinuxAtagArguments.InitrdPathList)),TRUE,TRUE); OptionalData = BootOption->OptionalData;
Print(L"\t- Initrd: %s\n", DevicePathTxt); LoaderType = (ARM_BDS_LOADER_TYPE)ReadUnaligned32 ((CONST UINT32*)&OptionalData->Header.LoaderType);
if ((LoaderType == BDS_LOADER_KERNEL_LINUX_ATAG) || (LoaderType == BDS_LOADER_KERNEL_LINUX_FDT)) {
if (ReadUnaligned16 (&OptionalData->Arguments.LinuxArguments.InitrdSize) > 0) {
CmdLineSize = ReadUnaligned16 (&OptionalData->Arguments.LinuxArguments.CmdLineSize);
DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText (
GetAlignedDevicePath ((EFI_DEVICE_PATH*)((UINTN)(&OptionalData->Arguments.LinuxArguments + 1) + CmdLineSize)), TRUE, TRUE);
Print(L"\t- Initrd: %s\n", DevicePathTxt);
}
Print(L"\t- Arguments: %a\n", (&OptionalData->Arguments.LinuxArguments + 1));
} }
Print(L"\t- LoaderType: %d\n", LoaderType);
Print(L"\t- Arguments: %a\n", BootOption->OptionalData->Arguments.LinuxAtagArguments.CmdLine);
} }
Print(L"\t- LoaderType: %d\n", ReadUnaligned32 (&BootOption->OptionalData->LoaderType));
FreePool(DevicePathTxt); FreePool(DevicePathTxt);
DEBUG_CODE_END(); DEBUG_CODE_END();

View File

@ -25,33 +25,64 @@ BootOptionStart (
EFI_DEVICE_PATH* FdtDevicePath; EFI_DEVICE_PATH* FdtDevicePath;
EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL* EfiDevicePathFromTextProtocol; EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL* EfiDevicePathFromTextProtocol;
UINT32 LoaderType; UINT32 LoaderType;
ARM_BDS_LOADER_OPTIONAL_DATA* OptionalData;
ARM_BDS_LINUX_ARGUMENTS* LinuxArguments;
EFI_DEVICE_PATH_PROTOCOL* FdtDevicePath;
EFI_DEVICE_PATH_PROTOCOL* DefaultFdtDevicePath;
UINTN FdtDevicePathSize;
UINTN CmdLineSize;
UINTN InitrdSize;
EFI_DEVICE_PATH* Initrd;
Status = EFI_UNSUPPORTED; Status = EFI_UNSUPPORTED;
LoaderType = ReadUnaligned32 (&BootOption->OptionalData->LoaderType); OptionalData = BootOption->OptionalData;
LoaderType = ReadUnaligned32 ((CONST UINT32*)&OptionalData->Header.LoaderType);
if (LoaderType == BDS_LOADER_EFI_APPLICATION) { if (LoaderType == BDS_LOADER_EFI_APPLICATION) {
// Need to connect every drivers to ensure no dependencies are missing for the application // Need to connect every drivers to ensure no dependencies are missing for the application
BdsConnectAllDrivers(); BdsConnectAllDrivers();
Status = BdsStartEfiApplication (mImageHandle, BootOption->FilePathList); Status = BdsStartEfiApplication (mImageHandle, BootOption->FilePathList, 0, NULL);
} else if (LoaderType == BDS_LOADER_KERNEL_LINUX_ATAG) { } else if (LoaderType == BDS_LOADER_KERNEL_LINUX_ATAG) {
Status = BdsBootLinux (BootOption->FilePathList, LinuxArguments = &(OptionalData->Arguments.LinuxArguments);
(EFI_DEVICE_PATH_PROTOCOL*)ReadUnaligned32((UINT32*)(&BootOption->OptionalData->Arguments.LinuxAtagArguments.InitrdPathList)), CmdLineSize = ReadUnaligned16 ((CONST UINT16*)&LinuxArguments->CmdLineSize);
BootOption->OptionalData->Arguments.LinuxAtagArguments.CmdLine, InitrdSize = ReadUnaligned16 ((CONST UINT16*)&LinuxArguments->InitrdSize);
NULL);
} else if (LoaderType == BDS_LOADER_KERNEL_LINUX_FDT) {
// Convert the FDT path into a Device Path
Status = gBS->LocateProtocol (&gEfiDevicePathFromTextProtocolGuid, NULL, (VOID **)&EfiDevicePathFromTextProtocol);
ASSERT_EFI_ERROR(Status);
FdtDevicePath = EfiDevicePathFromTextProtocol->ConvertTextToDevicePath ((CHAR16*)PcdGetPtr(PcdFdtDevicePath));
Status = BdsBootLinux (BootOption->FilePathList, if (InitrdSize > 0) {
NULL, Initrd = GetAlignedDevicePath ((EFI_DEVICE_PATH*)((UINTN)(LinuxArguments + 1) + CmdLineSize));
NULL, } else {
FdtDevicePath); Initrd = NULL;
}
FreePool(FdtDevicePath); Status = BdsBootLinux (BootOption->FilePathList,
} Initrd, // Initrd
(CHAR8*)(LinuxArguments + 1), // CmdLine
NULL);
} else if (LoaderType == BDS_LOADER_KERNEL_LINUX_FDT) {
LinuxArguments = &(OptionalData->Arguments.LinuxArguments);
CmdLineSize = ReadUnaligned16 ((CONST UINT16*)&LinuxArguments->CmdLineSize);
InitrdSize = ReadUnaligned16 ((CONST UINT16*)&LinuxArguments->InitrdSize);
if (InitrdSize > 0) {
Initrd = GetAlignedDevicePath ((EFI_DEVICE_PATH*)((UINTN)(LinuxArguments + 1) + CmdLineSize));
} else {
Initrd = NULL;
}
// Get the default FDT device path
Status = gBS->LocateProtocol (&gEfiDevicePathFromTextProtocolGuid, NULL, (VOID **)&EfiDevicePathFromTextProtocol);
ASSERT_EFI_ERROR(Status);
DefaultFdtDevicePath = EfiDevicePathFromTextProtocol->ConvertTextToDevicePath ((CHAR16*)PcdGetPtr(PcdFdtDevicePath));
// Get the FDT device path
FdtDevicePathSize = GetDevicePathSize (DefaultFdtDevicePath);
Status = GetEnvironmentVariable ((CHAR16 *)L"FDT", DefaultFdtDevicePath, &FdtDevicePathSize, (VOID **)&FdtDevicePath);
ASSERT_EFI_ERROR(Status);
Status = BdsBootLinux (BootOption->FilePathList,
Initrd, // Initrd
(CHAR8*)(LinuxArguments + 1),
FdtDevicePath);
return Status; return Status;
} }
@ -191,53 +222,34 @@ BootOptionSetFields (
IN UINT32 Attributes, IN UINT32 Attributes,
IN CHAR16* BootDescription, IN CHAR16* BootDescription,
IN EFI_DEVICE_PATH_PROTOCOL* DevicePath, IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,
IN BDS_LOADER_TYPE BootType, IN ARM_BDS_LOADER_TYPE BootType,
IN BDS_LOADER_ARGUMENTS* BootArguments IN ARM_BDS_LOADER_ARGUMENTS* BootArguments
) )
{ {
EFI_LOAD_OPTION EfiLoadOption; EFI_LOAD_OPTION EfiLoadOption;
UINTN EfiLoadOptionSize; UINTN EfiLoadOptionSize;
UINTN BootDescriptionSize; UINTN BootDescriptionSize;
UINTN BootOptionalDataSize; UINTN BootOptionalDataSize;
UINT16 FilePathListLength; UINT16 FilePathListLength;
UINT16 InitrdPathListLength; UINT8* EfiLoadOptionPtr;
EFI_DEVICE_PATH_PROTOCOL* DevicePathNode; UINT8* InitrdPathListPtr;
EFI_DEVICE_PATH_PROTOCOL* InitrdPathNode; UINTN OptionalDataSize;
UINTN NodeLength; ARM_BDS_LINUX_ARGUMENTS* DestLinuxArguments;
UINT8* EfiLoadOptionPtr; ARM_BDS_LINUX_ARGUMENTS* SrcLinuxArguments;
UINT8 *InitrdPathListPtr;
// If we are overwriting an existent Boot Option then we have to free previously allocated memory // If we are overwriting an existent Boot Option then we have to free previously allocated memory
if (BootOption->LoadOption) { if (BootOption->LoadOption) {
FreePool(BootOption->LoadOption); FreePool(BootOption->LoadOption);
} }
BootDescriptionSize = StrSize(BootDescription); BootDescriptionSize = StrSize (BootDescription);
BootOptionalDataSize = sizeof(BDS_LOADER_TYPE) + (BootType == BDS_LOADER_KERNEL_LINUX_ATAG ? BootOptionalDataSize = sizeof(ARM_BDS_LOADER_OPTIONAL_DATA_HEADER);
(sizeof(UINT16) + sizeof(EFI_DEVICE_PATH_PROTOCOL*) + BOOT_DEVICE_OPTION_MAX + 1) if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_FDT)) {
: 0); BootOptionalDataSize += sizeof(ARM_BDS_LINUX_ARGUMENTS) + BootArguments->LinuxArguments.CmdLineSize + BootArguments->LinuxArguments.InitrdSize;
}
// Compute the size of the FilePath list // Compute the size of the FilePath list
FilePathListLength = 0; FilePathListLength = GetUnalignedDevicePathSize (DevicePath);
DevicePathNode = DevicePath;
while (!IsDevicePathEndType (DevicePathNode)) {
FilePathListLength += DevicePathNodeLength (DevicePathNode);
DevicePathNode = NextDevicePathNode (DevicePathNode);
}
// Add the length of the DevicePath EndType
FilePathListLength += DevicePathNodeLength (DevicePathNode);
InitrdPathListLength = 0;
if (BootType == BDS_LOADER_KERNEL_LINUX_ATAG && BootArguments->LinuxAtagArguments.InitrdPathList != NULL) {
// Compute the size of the InitrdPath list
InitrdPathNode = BootArguments->LinuxAtagArguments.InitrdPathList;
while (!IsDevicePathEndType (InitrdPathNode)) {
InitrdPathListLength += DevicePathNodeLength (InitrdPathNode);
InitrdPathNode = NextDevicePathNode (InitrdPathNode);
}
// Add the length of the DevicePath EndType
InitrdPathListLength += DevicePathNodeLength (InitrdPathNode);
}
// Allocate the memory for the EFI Load Option // Allocate the memory for the EFI Load Option
EfiLoadOptionSize = sizeof(UINT32) + sizeof(UINT16) + BootDescriptionSize + FilePathListLength + BootOptionalDataSize; EfiLoadOptionSize = sizeof(UINT32) + sizeof(UINT16) + BootDescriptionSize + FilePathListLength + BootOptionalDataSize;
@ -265,53 +277,40 @@ BootOptionSetFields (
// File path fields // File path fields
BootOption->FilePathList = (EFI_DEVICE_PATH_PROTOCOL*)EfiLoadOptionPtr; BootOption->FilePathList = (EFI_DEVICE_PATH_PROTOCOL*)EfiLoadOptionPtr;
DevicePathNode = DevicePath; CopyMem (EfiLoadOptionPtr, DevicePath, FilePathListLength);
while (!IsDevicePathEndType (DevicePathNode)) { EfiLoadOptionPtr += FilePathListLength;
NodeLength = DevicePathNodeLength(DevicePathNode);
CopyMem (EfiLoadOptionPtr, DevicePathNode, NodeLength);
EfiLoadOptionPtr += NodeLength;
DevicePathNode = NextDevicePathNode (DevicePathNode);
}
// Set the End Device Path Type
SetDevicePathEndNode (EfiLoadOptionPtr);
EfiLoadOptionPtr = (UINT8 *)EfiLoadOptionPtr + sizeof(EFI_DEVICE_PATH);
// Optional Data fields, Do unaligned writes // Optional Data fields, Do unaligned writes
WriteUnaligned32 ((UINT32 *)EfiLoadOptionPtr, BootType); BootOption->OptionalData = EfiLoadOptionPtr;
WriteUnaligned32 ((UINT32 *)EfiLoadOptionPtr, ARM_BDS_OPTIONAL_DATA_SIGNATURE);
WriteUnaligned32 ((UINT32 *)(EfiLoadOptionPtr + 4), BootType);
BootOption->OptionalData = (BDS_LOADER_OPTIONAL_DATA *)EfiLoadOptionPtr; OptionalDataSize = sizeof(ARM_BDS_LOADER_OPTIONAL_DATA_HEADER);
if (BootType == BDS_LOADER_KERNEL_LINUX_ATAG) { if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_FDT)) {
CopyMem (&((BDS_LOADER_OPTIONAL_DATA*)EfiLoadOptionPtr)->Arguments.LinuxAtagArguments.CmdLine, SrcLinuxArguments = &(BootArguments->LinuxArguments);
BootArguments->LinuxAtagArguments.CmdLine, DestLinuxArguments = &((ARM_BDS_LOADER_OPTIONAL_DATA*)EfiLoadOptionPtr)->Arguments.LinuxArguments;
AsciiStrSize(BootArguments->LinuxAtagArguments.CmdLine));
WriteUnaligned32 ((UINT32 *)(&BootOption->OptionalData->Arguments.LinuxAtagArguments.InitrdPathListLength), InitrdPathListLength); WriteUnaligned16 ((UINT16 *)&(DestLinuxArguments->CmdLineSize), SrcLinuxArguments->CmdLineSize);
WriteUnaligned16 ((UINT16 *)&(DestLinuxArguments->InitrdSize), SrcLinuxArguments->InitrdSize);
OptionalDataSize += sizeof (ARM_BDS_LINUX_ARGUMENTS);
if ((EFI_DEVICE_PATH_PROTOCOL*)ReadUnaligned32((UINT32 *)&BootOption->OptionalData->Arguments.LinuxAtagArguments.InitrdPathList) != NULL if (SrcLinuxArguments->CmdLineSize > 0) {
&& BootArguments->LinuxAtagArguments.InitrdPathList != NULL) { CopyMem ((VOID*)(DestLinuxArguments + 1), (VOID*)(SrcLinuxArguments + 1), SrcLinuxArguments->CmdLineSize);
InitrdPathListPtr = AllocatePool(InitrdPathListLength); OptionalDataSize += SrcLinuxArguments->CmdLineSize;
WriteUnaligned32 ((UINT32 *)(&BootOption->OptionalData->Arguments.LinuxAtagArguments.InitrdPathList), (UINT32)InitrdPathListPtr); }
InitrdPathNode = BootArguments->LinuxAtagArguments.InitrdPathList;
while (!IsDevicePathEndType (InitrdPathNode)) { if (SrcLinuxArguments->InitrdSize > 0) {
NodeLength = DevicePathNodeLength(InitrdPathNode); InitrdPathListPtr = (UINT8*)((UINTN)(DestLinuxArguments + 1) + SrcLinuxArguments->CmdLineSize);
CopyMem (InitrdPathListPtr, InitrdPathNode, NodeLength); CopyMem (InitrdPathListPtr, (VOID*)((UINTN)(SrcLinuxArguments + 1) + SrcLinuxArguments->CmdLineSize), SrcLinuxArguments->InitrdSize);
InitrdPathListPtr += NodeLength;
InitrdPathNode = NextDevicePathNode (InitrdPathNode);
}
// Set the End Device Path Type
SetDevicePathEndNode (InitrdPathListPtr);
} else {
WriteUnaligned32 ((UINT32 *)(&BootOption->OptionalData->Arguments.LinuxAtagArguments.InitrdPathList), (UINT32)NULL);
} }
} }
BootOption->OptionalDataSize = OptionalDataSize;
// If this function is called at the creation of the Boot Device entry (not at the update) the // If this function is called at the creation of the Boot Device entry (not at the update) the
// BootOption->LoadOptionSize must be zero then we get a new BootIndex for this entry // BootOption->LoadOptionSize must be zero then we get a new BootIndex for this entry
if (BootOption->LoadOptionSize == 0) { if (BootOption->LoadOptionSize == 0) {
BootOption->LoadOptionIndex = BootOptionAllocateBootIndex(); BootOption->LoadOptionIndex = BootOptionAllocateBootIndex ();
} }
// Fill the EFI Load option fields // Fill the EFI Load option fields
@ -326,8 +325,8 @@ BootOptionCreate (
IN UINT32 Attributes, IN UINT32 Attributes,
IN CHAR16* BootDescription, IN CHAR16* BootDescription,
IN EFI_DEVICE_PATH_PROTOCOL* DevicePath, IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,
IN BDS_LOADER_TYPE BootType, IN ARM_BDS_LOADER_TYPE BootType,
IN BDS_LOADER_ARGUMENTS* BootArguments, IN ARM_BDS_LOADER_ARGUMENTS* BootArguments,
OUT BDS_LOAD_OPTION **BdsLoadOption OUT BDS_LOAD_OPTION **BdsLoadOption
) )
{ {
@ -387,12 +386,12 @@ BootOptionCreate (
EFI_STATUS EFI_STATUS
BootOptionUpdate ( BootOptionUpdate (
IN BDS_LOAD_OPTION *BdsLoadOption, IN BDS_LOAD_OPTION* BdsLoadOption,
IN UINT32 Attributes, IN UINT32 Attributes,
IN CHAR16* BootDescription, IN CHAR16* BootDescription,
IN EFI_DEVICE_PATH_PROTOCOL* DevicePath, IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,
IN BDS_LOADER_TYPE BootType, IN ARM_BDS_LOADER_TYPE BootType,
IN BDS_LOADER_ARGUMENTS* BootArguments IN ARM_BDS_LOADER_ARGUMENTS* BootArguments
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;

View File

@ -35,7 +35,7 @@ EFI_STATUS
BdsLoadOptionFileSystemCreateDevicePath ( BdsLoadOptionFileSystemCreateDevicePath (
IN BDS_SUPPORTED_DEVICE* BdsLoadOption, IN BDS_SUPPORTED_DEVICE* BdsLoadOption,
OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode, OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,
OUT BDS_LOADER_TYPE *BootType, OUT ARM_BDS_LOADER_TYPE *BootType,
OUT UINT32 *Attributes OUT UINT32 *Attributes
); );
@ -43,7 +43,7 @@ EFI_STATUS
BdsLoadOptionFileSystemUpdateDevicePath ( BdsLoadOptionFileSystemUpdateDevicePath (
IN EFI_DEVICE_PATH *OldDevicePath, IN EFI_DEVICE_PATH *OldDevicePath,
OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath, OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,
OUT BDS_LOADER_TYPE *BootType, OUT ARM_BDS_LOADER_TYPE *BootType,
OUT UINT32 *Attributes OUT UINT32 *Attributes
); );
@ -61,7 +61,7 @@ EFI_STATUS
BdsLoadOptionMemMapCreateDevicePath ( BdsLoadOptionMemMapCreateDevicePath (
IN BDS_SUPPORTED_DEVICE* BdsLoadOption, IN BDS_SUPPORTED_DEVICE* BdsLoadOption,
OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode, OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,
OUT BDS_LOADER_TYPE *BootType, OUT ARM_BDS_LOADER_TYPE *BootType,
OUT UINT32 *Attributes OUT UINT32 *Attributes
); );
@ -69,7 +69,7 @@ EFI_STATUS
BdsLoadOptionMemMapUpdateDevicePath ( BdsLoadOptionMemMapUpdateDevicePath (
IN EFI_DEVICE_PATH *OldDevicePath, IN EFI_DEVICE_PATH *OldDevicePath,
OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath, OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,
OUT BDS_LOADER_TYPE *BootType, OUT ARM_BDS_LOADER_TYPE *BootType,
OUT UINT32 *Attributes OUT UINT32 *Attributes
); );
@ -87,7 +87,7 @@ EFI_STATUS
BdsLoadOptionPxeCreateDevicePath ( BdsLoadOptionPxeCreateDevicePath (
IN BDS_SUPPORTED_DEVICE* BdsLoadOption, IN BDS_SUPPORTED_DEVICE* BdsLoadOption,
OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode, OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,
OUT BDS_LOADER_TYPE *BootType, OUT ARM_BDS_LOADER_TYPE *BootType,
OUT UINT32 *Attributes OUT UINT32 *Attributes
); );
@ -95,7 +95,7 @@ EFI_STATUS
BdsLoadOptionPxeUpdateDevicePath ( BdsLoadOptionPxeUpdateDevicePath (
IN EFI_DEVICE_PATH *OldDevicePath, IN EFI_DEVICE_PATH *OldDevicePath,
OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath, OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,
OUT BDS_LOADER_TYPE *BootType, OUT ARM_BDS_LOADER_TYPE *BootType,
OUT UINT32 *Attributes OUT UINT32 *Attributes
); );
@ -113,7 +113,7 @@ EFI_STATUS
BdsLoadOptionTftpCreateDevicePath ( BdsLoadOptionTftpCreateDevicePath (
IN BDS_SUPPORTED_DEVICE* BdsLoadOption, IN BDS_SUPPORTED_DEVICE* BdsLoadOption,
OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode, OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,
OUT BDS_LOADER_TYPE *BootType, OUT ARM_BDS_LOADER_TYPE *BootType,
OUT UINT32 *Attributes OUT UINT32 *Attributes
); );
@ -121,7 +121,7 @@ EFI_STATUS
BdsLoadOptionTftpUpdateDevicePath ( BdsLoadOptionTftpUpdateDevicePath (
IN EFI_DEVICE_PATH *OldDevicePath, IN EFI_DEVICE_PATH *OldDevicePath,
OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath, OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,
OUT BDS_LOADER_TYPE *BootType, OUT ARM_BDS_LOADER_TYPE *BootType,
OUT UINT32 *Attributes OUT UINT32 *Attributes
); );
@ -131,34 +131,34 @@ BdsLoadOptionTftpIsSupported (
); );
BDS_LOAD_OPTION_SUPPORT BdsLoadOptionSupportList[] = { BDS_LOAD_OPTION_SUPPORT BdsLoadOptionSupportList[] = {
{ {
BDS_DEVICE_FILESYSTEM, BDS_DEVICE_FILESYSTEM,
BdsLoadOptionFileSystemList, BdsLoadOptionFileSystemList,
BdsLoadOptionFileSystemIsSupported, BdsLoadOptionFileSystemIsSupported,
BdsLoadOptionFileSystemCreateDevicePath, BdsLoadOptionFileSystemCreateDevicePath,
BdsLoadOptionFileSystemUpdateDevicePath BdsLoadOptionFileSystemUpdateDevicePath
}, },
{ {
BDS_DEVICE_MEMMAP, BDS_DEVICE_MEMMAP,
BdsLoadOptionMemMapList, BdsLoadOptionMemMapList,
BdsLoadOptionMemMapIsSupported, BdsLoadOptionMemMapIsSupported,
BdsLoadOptionMemMapCreateDevicePath, BdsLoadOptionMemMapCreateDevicePath,
BdsLoadOptionMemMapUpdateDevicePath BdsLoadOptionMemMapUpdateDevicePath
}, },
{ {
BDS_DEVICE_PXE, BDS_DEVICE_PXE,
BdsLoadOptionPxeList, BdsLoadOptionPxeList,
BdsLoadOptionPxeIsSupported, BdsLoadOptionPxeIsSupported,
BdsLoadOptionPxeCreateDevicePath, BdsLoadOptionPxeCreateDevicePath,
BdsLoadOptionPxeUpdateDevicePath BdsLoadOptionPxeUpdateDevicePath
}, },
{ {
BDS_DEVICE_TFTP, BDS_DEVICE_TFTP,
BdsLoadOptionTftpList, BdsLoadOptionTftpList,
BdsLoadOptionTftpIsSupported, BdsLoadOptionTftpIsSupported,
BdsLoadOptionTftpCreateDevicePath, BdsLoadOptionTftpCreateDevicePath,
BdsLoadOptionTftpUpdateDevicePath BdsLoadOptionTftpUpdateDevicePath
} }
}; };
EFI_STATUS EFI_STATUS
@ -172,7 +172,7 @@ BootDeviceListSupportedInit (
InitializeListHead (SupportedDeviceList); InitializeListHead (SupportedDeviceList);
for (Index = 0; Index < BDS_DEVICE_MAX; Index++) { for (Index = 0; Index < BDS_DEVICE_MAX; Index++) {
BdsLoadOptionSupportList[Index].ListDevices(SupportedDeviceList); BdsLoadOptionSupportList[Index].ListDevices (SupportedDeviceList);
} }
return EFI_SUCCESS; return EFI_SUCCESS;
@ -192,7 +192,7 @@ BootDeviceListSupportedFree (
SupportedDevice = SUPPORTED_BOOT_DEVICE_FROM_LINK(Entry); SupportedDevice = SUPPORTED_BOOT_DEVICE_FROM_LINK(Entry);
Entry = RemoveEntryList (Entry); Entry = RemoveEntryList (Entry);
if (SupportedDevice != Except) { if (SupportedDevice != Except) {
FreePool(SupportedDevice); FreePool (SupportedDevice);
} }
} }
@ -222,7 +222,7 @@ STATIC
EFI_STATUS EFI_STATUS
BootDeviceGetType ( BootDeviceGetType (
IN CHAR16* FileName, IN CHAR16* FileName,
OUT BDS_LOADER_TYPE *BootType, OUT ARM_BDS_LOADER_TYPE *BootType,
OUT UINT32 *Attributes OUT UINT32 *Attributes
) )
{ {
@ -295,7 +295,7 @@ BdsLoadOptionFileSystemList (
Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID **)&DevicePathProtocol); Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID **)&DevicePathProtocol);
if (!EFI_ERROR(Status)) { if (!EFI_ERROR(Status)) {
// Allocate BDS Supported Device structure // Allocate BDS Supported Device structure
SupportedDevice = (BDS_SUPPORTED_DEVICE*)AllocatePool(sizeof(BDS_SUPPORTED_DEVICE)); SupportedDevice = (BDS_SUPPORTED_DEVICE*)AllocatePool (sizeof(BDS_SUPPORTED_DEVICE));
FileProtocol = NULL; FileProtocol = NULL;
Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiSimpleFileSystemProtocolGuid, (VOID **)&FileProtocol); Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiSimpleFileSystemProtocolGuid, (VOID **)&FileProtocol);
@ -329,7 +329,7 @@ EFI_STATUS
BdsLoadOptionFileSystemCreateDevicePath ( BdsLoadOptionFileSystemCreateDevicePath (
IN BDS_SUPPORTED_DEVICE* BdsLoadOption, IN BDS_SUPPORTED_DEVICE* BdsLoadOption,
OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode, OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,
OUT BDS_LOADER_TYPE *BootType, OUT ARM_BDS_LOADER_TYPE *BootType,
OUT UINT32 *Attributes OUT UINT32 *Attributes
) )
{ {
@ -373,7 +373,7 @@ EFI_STATUS
BdsLoadOptionFileSystemUpdateDevicePath ( BdsLoadOptionFileSystemUpdateDevicePath (
IN EFI_DEVICE_PATH *OldDevicePath, IN EFI_DEVICE_PATH *OldDevicePath,
OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath, OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,
OUT BDS_LOADER_TYPE *BootType, OUT ARM_BDS_LOADER_TYPE *BootType,
OUT UINT32 *Attributes OUT UINT32 *Attributes
) )
{ {
@ -527,7 +527,7 @@ EFI_STATUS
BdsLoadOptionMemMapCreateDevicePath ( BdsLoadOptionMemMapCreateDevicePath (
IN BDS_SUPPORTED_DEVICE* BdsLoadOption, IN BDS_SUPPORTED_DEVICE* BdsLoadOption,
OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode, OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,
OUT BDS_LOADER_TYPE *BootType, OUT ARM_BDS_LOADER_TYPE *BootType,
OUT UINT32 *Attributes OUT UINT32 *Attributes
) )
{ {
@ -549,7 +549,7 @@ BdsLoadOptionMemMapCreateDevicePath (
} }
// Create the MemMap Device Path Node // Create the MemMap Device Path Node
MemMapDevicePath = (MEMMAP_DEVICE_PATH*)AllocatePool(sizeof(MEMMAP_DEVICE_PATH)); MemMapDevicePath = (MEMMAP_DEVICE_PATH*)AllocatePool (sizeof(MEMMAP_DEVICE_PATH));
MemMapDevicePath->Header.Type = HARDWARE_DEVICE_PATH; MemMapDevicePath->Header.Type = HARDWARE_DEVICE_PATH;
MemMapDevicePath->Header.SubType = HW_MEMMAP_DP; MemMapDevicePath->Header.SubType = HW_MEMMAP_DP;
MemMapDevicePath->MemoryType = EfiBootServicesData; MemMapDevicePath->MemoryType = EfiBootServicesData;
@ -570,7 +570,7 @@ EFI_STATUS
BdsLoadOptionMemMapUpdateDevicePath ( BdsLoadOptionMemMapUpdateDevicePath (
IN EFI_DEVICE_PATH *OldDevicePath, IN EFI_DEVICE_PATH *OldDevicePath,
OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath, OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,
OUT BDS_LOADER_TYPE *BootType, OUT ARM_BDS_LOADER_TYPE *BootType,
OUT UINT32 *Attributes OUT UINT32 *Attributes
) )
{ {
@ -674,7 +674,7 @@ EFI_STATUS
BdsLoadOptionPxeCreateDevicePath ( BdsLoadOptionPxeCreateDevicePath (
IN BDS_SUPPORTED_DEVICE* BdsLoadOption, IN BDS_SUPPORTED_DEVICE* BdsLoadOption,
OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode, OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,
OUT BDS_LOADER_TYPE *BootType, OUT ARM_BDS_LOADER_TYPE *BootType,
OUT UINT32 *Attributes OUT UINT32 *Attributes
) )
{ {
@ -688,7 +688,7 @@ EFI_STATUS
BdsLoadOptionPxeUpdateDevicePath ( BdsLoadOptionPxeUpdateDevicePath (
IN EFI_DEVICE_PATH *OldDevicePath, IN EFI_DEVICE_PATH *OldDevicePath,
OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath, OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,
OUT BDS_LOADER_TYPE *BootType, OUT ARM_BDS_LOADER_TYPE *BootType,
OUT UINT32 *Attributes OUT UINT32 *Attributes
) )
{ {
@ -775,7 +775,7 @@ EFI_STATUS
BdsLoadOptionTftpCreateDevicePath ( BdsLoadOptionTftpCreateDevicePath (
IN BDS_SUPPORTED_DEVICE* BdsLoadOption, IN BDS_SUPPORTED_DEVICE* BdsLoadOption,
OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode, OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,
OUT BDS_LOADER_TYPE *BootType, OUT ARM_BDS_LOADER_TYPE *BootType,
OUT UINT32 *Attributes OUT UINT32 *Attributes
) )
{ {
@ -854,7 +854,7 @@ EFI_STATUS
BdsLoadOptionTftpUpdateDevicePath ( BdsLoadOptionTftpUpdateDevicePath (
IN EFI_DEVICE_PATH *OldDevicePath, IN EFI_DEVICE_PATH *OldDevicePath,
OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath, OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,
OUT BDS_LOADER_TYPE *BootType, OUT ARM_BDS_LOADER_TYPE *BootType,
OUT UINT32 *Attributes OUT UINT32 *Attributes
) )
{ {