Add in code to convert the Default VarStore name to be L"Setup" based on Framework HII's assumption.

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.


git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7040 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
qwang12 2008-12-16 05:27:24 +00:00
parent dfc1f033ea
commit 73d1dcbb46
3 changed files with 38 additions and 23 deletions

View File

@ -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 // VARSTORE ID of 0 for Buffer Storage Type Storage is defined as invalid in UEFI 2.1 HII. VARSTORE ID
// 0 in Framework IFR is the default VarStore ID for storage without explicit declaration. So we have // 0 is the default VarStore ID for storage without explicit declaration in Framework HII 0.92. EDK II UEFI VFR compiler
// to reseved 0x0001 in UEFI VARSTORE ID to represetn default storage id in Framework IFR. // in compatible mode will assign 0x0001 as UEFI VARSTORE ID to this default storage id in Framework VFR without
// Framework VFR has to be ported or pre-processed to change the default VARSTORE to a VARSTORE // VARSTORE declaration.
// with ID equal to 0x0001. //
// 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_ID 0x0001
#define FRAMEWORK_RESERVED_VARSTORE_NAME L"Setup"
#pragma pack (1) #pragma pack (1)

View File

@ -12,18 +12,6 @@
**/ **/
#include <FrameworkDxe.h>
#include <Protocol/FrameworkHii.h>
#include <Protocol/HiiDatabase.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include "HiiDatabase.h" #include "HiiDatabase.h"
#include "UefiIfrParser.h" #include "UefiIfrParser.h"
#include "UefiIfrDefault.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_STRING_PROTOCOL *mHiiStringProtocol;
extern CONST EFI_HII_CONFIG_ROUTING_PROTOCOL *mHiiConfigRoutingProtocol; 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 Set the data position at Offset with Width in Node->Buffer based
the value passed in. the value passed in.
@ -452,7 +442,14 @@ UefiDefaultsToFwDefaults (
if (Node->DefaultId == DefaultId) { if (Node->DefaultId == DefaultId) {
Size += Node->Size; 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++; Count++;
} }
@ -481,7 +478,6 @@ UefiDefaultsToFwDefaults (
Size = 0; Size = 0;
if (Node->DefaultId == DefaultId) { if (Node->DefaultId == DefaultId) {
Size += Node->Size; Size += Node->Size;
Size += StrSize (Node->Name);
Size += sizeof (EFI_HII_VARIABLE_PACK); Size += sizeof (EFI_HII_VARIABLE_PACK);
// //
@ -489,20 +485,28 @@ UefiDefaultsToFwDefaults (
// So the default storage of Var Store in VFR from a Framework module // So the default storage of Var Store in VFR from a Framework module
// should be translated to the default Varstore ID. // 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->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 { } else {
Pack->VariableId = Node->StoreId; 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 // Initialize EFI_HII_VARIABLE_PACK
// //
Pack->Header.Type = 0; Pack->Header.Type = 0;
Pack->Header.Length = (UINT32) Size; Pack->Header.Length = (UINT32) Size;
Pack->VariableNameLength = (UINT32) StrSize (Node->Name);
CopyMem (&Pack->VariableGuid, &Node->Guid, sizeof (EFI_GUID)); 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); CopyMem ((UINT8 *) Pack + sizeof (EFI_HII_VARIABLE_PACK) + Pack->VariableNameLength, Node->Buffer, Node->Size);
Size += sizeof (EFI_HII_VARIABLE_PACK_LIST); Size += sizeof (EFI_HII_VARIABLE_PACK_LIST);

View File

@ -416,9 +416,12 @@ GetFormsetDefaultVarstoreId (
while (!IsNull (&FormSet->StorageListHead, StorageList)) { while (!IsNull (&FormSet->StorageListHead, StorageList)) {
Storage = FORMSET_STORAGE_FROM_LINK (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) { 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; FormSet->DefaultVarStoreId = FRAMEWORK_RESERVED_VARSTORE_ID;
break; break;
} }
@ -427,6 +430,11 @@ GetFormsetDefaultVarstoreId (
} }
if (FormSet->DefaultVarStoreId != FRAMEWORK_RESERVED_VARSTORE_ID) { 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); StorageList = GetFirstNode (&FormSet->StorageListHead);
if (!IsNull (&FormSet->StorageListHead, StorageList)) { if (!IsNull (&FormSet->StorageListHead, StorageList)) {
Storage = FORMSET_STORAGE_FROM_LINK (StorageList); Storage = FORMSET_STORAGE_FROM_LINK (StorageList);