ArmPkg: update BdsLib to updated definition of EFI_LOAD_OPTION

Since there is now a formal definition of EFI_LOAD_OPTION, we can no
longer typedef it as a UINT8*. So update the code to use the common
definition, which is not a pointer type, hence the additional changes
to the C code.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Olivier Martin <olivier.martin@arm.com>
Reviewed-by: Ronald Cron <Ronald.Cron@arm.com>



git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17410 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Ard Biesheuvel 2015-05-11 17:37:24 +00:00 committed by oliviermartin
parent c8ed578786
commit 459823d9b2
3 changed files with 16 additions and 16 deletions

View File

@ -15,14 +15,12 @@
#ifndef __BDS_ENTRY_H__ #ifndef __BDS_ENTRY_H__
#define __BDS_ENTRY_H__ #define __BDS_ENTRY_H__
typedef UINT8* EFI_LOAD_OPTION;
/** /**
This is defined by the UEFI specs, don't change it This is defined by the UEFI specs, don't change it
**/ **/
typedef struct { typedef struct {
UINT16 LoadOptionIndex; UINT16 LoadOptionIndex;
EFI_LOAD_OPTION LoadOption; EFI_LOAD_OPTION *LoadOption;
UINTN LoadOptionSize; UINTN LoadOptionSize;
UINT32 Attributes; UINT32 Attributes;

View File

@ -16,13 +16,14 @@
EFI_STATUS EFI_STATUS
BootOptionParseLoadOption ( BootOptionParseLoadOption (
IN EFI_LOAD_OPTION EfiLoadOption, IN EFI_LOAD_OPTION *EfiLoadOption,
IN UINTN EfiLoadOptionSize, IN UINTN EfiLoadOptionSize,
IN OUT BDS_LOAD_OPTION **BdsLoadOption IN OUT BDS_LOAD_OPTION **BdsLoadOption
) )
{ {
BDS_LOAD_OPTION *LoadOption; BDS_LOAD_OPTION *LoadOption;
UINTN DescriptionLength; UINTN DescriptionLength;
UINTN EfiLoadOptionPtr;
if (EfiLoadOption == NULL) { if (EfiLoadOption == NULL) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
@ -41,22 +42,23 @@ BootOptionParseLoadOption (
LoadOption = *BdsLoadOption; LoadOption = *BdsLoadOption;
} }
EfiLoadOptionPtr = (UINTN)EfiLoadOption;
LoadOption->LoadOption = EfiLoadOption; LoadOption->LoadOption = EfiLoadOption;
LoadOption->LoadOptionSize = EfiLoadOptionSize; LoadOption->LoadOptionSize = EfiLoadOptionSize;
LoadOption->Attributes = *(UINT32*)EfiLoadOption; LoadOption->Attributes = *(UINT32*)EfiLoadOptionPtr;
LoadOption->FilePathListLength = *(UINT16*)(EfiLoadOption + sizeof(UINT32)); LoadOption->FilePathListLength = *(UINT16*)(EfiLoadOptionPtr + sizeof(UINT32));
LoadOption->Description = (CHAR16*)(EfiLoadOption + sizeof(UINT32) + sizeof(UINT16)); LoadOption->Description = (CHAR16*)(EfiLoadOptionPtr + sizeof(UINT32) + sizeof(UINT16));
DescriptionLength = StrSize (LoadOption->Description); DescriptionLength = StrSize (LoadOption->Description);
LoadOption->FilePathList = (EFI_DEVICE_PATH_PROTOCOL*)(EfiLoadOption + sizeof(UINT32) + sizeof(UINT16) + DescriptionLength); LoadOption->FilePathList = (EFI_DEVICE_PATH_PROTOCOL*)(EfiLoadOptionPtr + sizeof(UINT32) + sizeof(UINT16) + DescriptionLength);
// If ((End of EfiLoadOptiony - Start of EfiLoadOption) == EfiLoadOptionSize) then No Optional Data // If ((End of EfiLoadOptiony - Start of EfiLoadOption) == EfiLoadOptionSize) then No Optional Data
if ((UINTN)((UINTN)LoadOption->FilePathList + LoadOption->FilePathListLength - (UINTN)EfiLoadOption) == EfiLoadOptionSize) { if ((UINTN)((UINTN)LoadOption->FilePathList + LoadOption->FilePathListLength - EfiLoadOptionPtr) == EfiLoadOptionSize) {
LoadOption->OptionalData = NULL; LoadOption->OptionalData = NULL;
LoadOption->OptionalDataSize = 0; LoadOption->OptionalDataSize = 0;
} else { } else {
LoadOption->OptionalData = (VOID*)((UINTN)(LoadOption->FilePathList) + LoadOption->FilePathListLength); LoadOption->OptionalData = (VOID*)((UINTN)(LoadOption->FilePathList) + LoadOption->FilePathListLength);
LoadOption->OptionalDataSize = EfiLoadOptionSize - ((UINTN)LoadOption->OptionalData - (UINTN)EfiLoadOption); LoadOption->OptionalDataSize = EfiLoadOptionSize - ((UINTN)LoadOption->OptionalData - EfiLoadOptionPtr);
} }
if (*BdsLoadOption == NULL) { if (*BdsLoadOption == NULL) {
@ -73,7 +75,7 @@ BootOptionFromLoadOptionVariable (
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_LOAD_OPTION EfiLoadOption; EFI_LOAD_OPTION *EfiLoadOption;
UINTN EfiLoadOptionSize; UINTN EfiLoadOptionSize;
Status = GetGlobalEnvironmentVariable (BootVariableName, NULL, &EfiLoadOptionSize, (VOID**)&EfiLoadOption); Status = GetGlobalEnvironmentVariable (BootVariableName, NULL, &EfiLoadOptionSize, (VOID**)&EfiLoadOption);
@ -141,12 +143,12 @@ BootOptionToLoadOptionVariable (
// Allocate the memory for the EFI Load Option // Allocate the memory for the EFI Load Option
BdsLoadOption->LoadOptionSize = sizeof(UINT32) + sizeof(UINT16) + DescriptionSize + BdsLoadOption->FilePathListLength + BdsLoadOption->OptionalDataSize; BdsLoadOption->LoadOptionSize = sizeof(UINT32) + sizeof(UINT16) + DescriptionSize + BdsLoadOption->FilePathListLength + BdsLoadOption->OptionalDataSize;
BdsLoadOption->LoadOption = (EFI_LOAD_OPTION)AllocateZeroPool (BdsLoadOption->LoadOptionSize); BdsLoadOption->LoadOption = (EFI_LOAD_OPTION *)AllocateZeroPool (BdsLoadOption->LoadOptionSize);
if (BdsLoadOption->LoadOption == NULL) { if (BdsLoadOption->LoadOption == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
EfiLoadOptionPtr = BdsLoadOption->LoadOption; EfiLoadOptionPtr = (UINT8 *) BdsLoadOption->LoadOption;
// //
// Populate the EFI Load Option and BDS Boot Option structures // Populate the EFI Load Option and BDS Boot Option structures

View File

@ -141,7 +141,7 @@ BootOptionSetFields (
IN UINTN OptionalDataSize IN UINTN OptionalDataSize
) )
{ {
EFI_LOAD_OPTION EfiLoadOption; EFI_LOAD_OPTION *EfiLoadOption;
UINTN EfiLoadOptionSize; UINTN EfiLoadOptionSize;
UINTN BootDescriptionSize; UINTN BootDescriptionSize;
UINT16 FilePathListLength; UINT16 FilePathListLength;
@ -168,8 +168,8 @@ BootOptionSetFields (
// Allocate the memory for the EFI Load Option // Allocate the memory for the EFI Load Option
EfiLoadOptionSize = sizeof(UINT32) + sizeof(UINT16) + BootDescriptionSize + FilePathListLength + OptionalDataSize; EfiLoadOptionSize = sizeof(UINT32) + sizeof(UINT16) + BootDescriptionSize + FilePathListLength + OptionalDataSize;
EfiLoadOption = (EFI_LOAD_OPTION)AllocatePool(EfiLoadOptionSize); EfiLoadOption = (EFI_LOAD_OPTION *)AllocatePool(EfiLoadOptionSize);
EfiLoadOptionPtr = EfiLoadOption; EfiLoadOptionPtr = (UINT8 *)EfiLoadOption;
// //
// Populate the EFI Load Option and BDS Boot Option structures // Populate the EFI Load Option and BDS Boot Option structures