diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/HiiDatabase.h b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/HiiDatabase.h index b2f35eb69a..64a6b3b433 100644 --- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/HiiDatabase.h +++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/HiiDatabase.h @@ -55,13 +55,16 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. // -// VARSTORE ID of 0 for Buffer Storage Type Storage is reserved in UEFI IFR form. But VARSTORE ID -// 0 in Framework IFR is the default VarStore ID for storage without explicit declaration. So we have -// to reseved 0x0001 in UEFI VARSTORE ID to represetn default storage id in Framework IFR. -// Framework VFR has to be ported or pre-processed to change the default VARSTORE to a VARSTORE -// with ID equal to 0x0001. +// VARSTORE ID of 0 for Buffer Storage Type Storage is defined as invalid in UEFI 2.1 HII. VARSTORE ID +// 0 is the default VarStore ID for storage without explicit declaration in Framework HII 0.92. EDK II UEFI VFR compiler +// in compatible mode will assign 0x0001 as UEFI VARSTORE ID to this default storage id in Framework VFR without +// VARSTORE declaration. +// +// In addition, the Name of Default VarStore is assumed to be L"Setup" for those storage without explicit VARSTORE declaration in the formset +// by Framework HII. EDK II UEFI VFR compiler in compatible mode hard-coded L"Setup" as VARSTORE name. // #define FRAMEWORK_RESERVED_VARSTORE_ID 0x0001 +#define FRAMEWORK_RESERVED_VARSTORE_NAME L"Setup" #pragma pack (1) diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/UefiIfrDefault.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/UefiIfrDefault.c index 34d6cba6f8..4b190477f1 100644 --- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/UefiIfrDefault.c +++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/UefiIfrDefault.c @@ -12,18 +12,6 @@ **/ - -#include - -#include -#include - -#include -#include -#include -#include -#include - #include "HiiDatabase.h" #include "UefiIfrParser.h" #include "UefiIfrDefault.h" @@ -36,6 +24,8 @@ extern CONST EFI_HII_IMAGE_PROTOCOL *mHiiImageProtocol; extern CONST EFI_HII_STRING_PROTOCOL *mHiiStringProtocol; extern CONST EFI_HII_CONFIG_ROUTING_PROTOCOL *mHiiConfigRoutingProtocol; +CHAR16 FrameworkReservedVarstoreName[] = FRAMEWORK_RESERVED_VARSTORE_NAME; + /** Set the data position at Offset with Width in Node->Buffer based the value passed in. @@ -452,7 +442,14 @@ UefiDefaultsToFwDefaults ( if (Node->DefaultId == DefaultId) { Size += Node->Size; - Size += StrSize (Node->Name); + if ((Node->StoreId == UefiFormSetDefaultVarStoreId) && (StrCmp (FrameworkReservedVarstoreName, Node->Name) != 0)) { + // The name of default VARSTORE with a Explicit declaration statement will be updated to L"Setup" to make sure + // the Framework HII Setup module will run correctly. Framework HII Setup module always assumed that default + // VARSTORE to have L"Setup" as name, Formset GUID as GUID. + Size += StrSize (FrameworkReservedVarstoreName); + } else { + Size += StrSize (Node->Name); + } Count++; } @@ -481,7 +478,6 @@ UefiDefaultsToFwDefaults ( Size = 0; if (Node->DefaultId == DefaultId) { Size += Node->Size; - Size += StrSize (Node->Name); Size += sizeof (EFI_HII_VARIABLE_PACK); // @@ -489,20 +485,28 @@ UefiDefaultsToFwDefaults ( // So the default storage of Var Store in VFR from a Framework module // should be translated to the default Varstore ID. // - if (Node->StoreId == UefiFormSetDefaultVarStoreId) { + if (Node->StoreId == UefiFormSetDefaultVarStoreId && (StrCmp (FrameworkReservedVarstoreName, Node->Name) != 0)) { + // The name of default VARSTORE with a Explicit declaration statement will be updated to L"Setup" to make sure + // the Framework HII Setup module will run correctly. Framework HII Setup module always assumed that default + // VARSTORE to have L"Setup" as name, Formset GUID as GUID. Pack->VariableId = 0; + Pack->VariableNameLength = (UINT32) StrSize (FrameworkReservedVarstoreName); + CopyMem ((UINT8 *) Pack + sizeof (EFI_HII_VARIABLE_PACK), FrameworkReservedVarstoreName, StrSize (FrameworkReservedVarstoreName)); + DEBUG ((EFI_D_INFO, "VarstoreID: %x; Name: %s -> %s.\n", UefiFormSetDefaultVarStoreId, Node->Name, FrameworkReservedVarstoreName)); } else { Pack->VariableId = Node->StoreId; + Pack->VariableNameLength = (UINT32) StrSize (Node->Name); + CopyMem ((UINT8 *) Pack + sizeof (EFI_HII_VARIABLE_PACK), Node->Name, StrSize (Node->Name)); } + + Size += Pack->VariableNameLength; // // Initialize EFI_HII_VARIABLE_PACK // Pack->Header.Type = 0; Pack->Header.Length = (UINT32) Size; - Pack->VariableNameLength = (UINT32) StrSize (Node->Name); CopyMem (&Pack->VariableGuid, &Node->Guid, sizeof (EFI_GUID)); - CopyMem ((UINT8 *) Pack + sizeof (EFI_HII_VARIABLE_PACK), Node->Name, StrSize (Node->Name)); CopyMem ((UINT8 *) Pack + sizeof (EFI_HII_VARIABLE_PACK) + Pack->VariableNameLength, Node->Buffer, Node->Size); Size += sizeof (EFI_HII_VARIABLE_PACK_LIST); diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.c index ca5ecbf0b6..a18ef0aa09 100644 --- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.c +++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.c @@ -416,9 +416,12 @@ GetFormsetDefaultVarstoreId ( while (!IsNull (&FormSet->StorageListHead, StorageList)) { Storage = FORMSET_STORAGE_FROM_LINK (StorageList); - DEBUG ((EFI_D_INFO, "FormSet %g: Found Varstore ID %x\n", &FormSet->Guid, Storage->VarStoreId)); + DEBUG ((EFI_D_INFO, "FormSet %g: Found Varstore ID %x Name %s Size 0x%x\n", &FormSet->Guid, Storage->VarStoreId, Storage->Name, Storage->Size)); if (Storage->VarStoreId == FRAMEWORK_RESERVED_VARSTORE_ID) { + // + // 1) If VarStore ID of FRAMEWORK_RESERVED_VARSTORE_ID (0x01) is found, Var Store ID is used. + // FormSet->DefaultVarStoreId = FRAMEWORK_RESERVED_VARSTORE_ID; break; } @@ -427,6 +430,11 @@ GetFormsetDefaultVarstoreId ( } if (FormSet->DefaultVarStoreId != FRAMEWORK_RESERVED_VARSTORE_ID) { + // + // + // 2) If VarStore ID of FRAMEWORK_RESERVED_VARSTORE_ID is not found, First Var Store ID is used + // as the default Var Store ID. + // StorageList = GetFirstNode (&FormSet->StorageListHead); if (!IsNull (&FormSet->StorageListHead, StorageList)) { Storage = FORMSET_STORAGE_FROM_LINK (StorageList);