Re: [edk2] efi varstore

Subject: Re: [edk2] efi varstore

From: Stanley Gan <stanley.ganyezu@gmail.com>

To: "Dong, Eric" <eric.dong@intel.com>

Date: 2012-06-14 02:02:06

Hi Eric,
In UEFI 2.3.1, the brower parse EFI_IFR_VARSTORE_EFI_OP like the below,it will initialize the <ConfigHdr>
case EFI_IFR_VARSTORE_EFI_OP:
//
// Create a EFI variable Storage for this FormSet
//
Storage = CreateStorage (FormSet);
CopyMem (&Storage->VarStoreId, &((EFI_IFR_VARSTORE_EFI *) OpCodeData)->VarStoreId, sizeof (EFI_VARSTORE_ID));
CopyMem (&Storage->Guid, &((EFI_IFR_VARSTORE_EFI *) OpCodeData)->Guid, sizeof (EFI_GUID));
CopyMem (&Storage->Attributes, &((EFI_IFR_VARSTORE_EFI *) OpCodeData)->Attributes, sizeof (UINT32));
CopyMem (&Storage->Size, &((EFI_IFR_VARSTORE_EFI *) OpCodeData)->Size, sizeof (UINT16));
if (OpCodeLength < sizeof (EFI_IFR_VARSTORE_EFI)) {
Storage->Type = EFI_HII_VARSTORE_EFI_VARIABLE;
break;
}
Storage->Type = EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER;
Storage->Buffer = AllocateZeroPool (Storage->Size);
Storage->EditBuffer = AllocateZeroPool (Storage->Size);
AsciiString = (CHAR8 *) ((EFI_IFR_VARSTORE_EFI *) OpCodeData)->Name;
Storage->Name = AllocateZeroPool (AsciiStrSize (AsciiString) * 2);
ASSERT (Storage->Name != NULL);
for (Index = 0; AsciiString[Index] != 0; Index++) {
Storage->Name[Index] = (CHAR16) AsciiString[Index];
}
//
// Initialize <ConfigHdr>
//
InitializeConfigHdr (FormSet, Storage);
break;
But in UEFI 2.1, the brower parse EFI_IFR_VARSTORE_EFI_OP like the below.Itdon'tinitialize the <ConfigHdr>. So where dothe brower initialize the <ConfigHdr>?
case EFI_IFR_VARSTORE_EFI_OP:
//
// Create a EFI variable Storage for this FormSet
//
Storage = CreateStorage (FormSet);
Storage->Type = EFI_HII_VARSTORE_EFI_VARIABLE;
CopyMem (&Storage->VarStoreId, &((EFI_IFR_VARSTORE_EFI *) OpCodeData)->VarStoreId, sizeof (EFI_VARSTORE_ID));
CopyMem (&Storage->Guid, &((EFI_IFR_VARSTORE_EFI *) OpCodeData)->Guid, sizeof (EFI_GUID));
CopyMem (&Storage->Attributes, &((EFI_IFR_VARSTORE_EFI *) OpCodeData)->Attributes, sizeof (UINT32));
break;


2012/6/13 Dong, Eric <eric.dong@intel.com>

Hi Stanley,

In UEFI 2.1, the vfrcompile saves the string token info in the checkboxs ifr data. When the browser parses the ifr data, it will get the string info base on the token ID and use it.

Thanks,

Eric

From: Stanley Gan [mailto:stanley.ganyezu@gmail.com]
Sent: Wednesday, June 13, 2012 3:06 PM
To: Dong, Eric
Cc: edk2-devel@lists.sourceforge.net
Subject: Re: [edk2] efi varstore


Hi Eric,

Your talk is right in UEFI 2.3.1. But it's different in UEFI 2.1.

The below is section of our binary code. You can see that there is no variable name in line >00000079. It's ver werid for me.

efivarstore VarEqAdminName,
>00000079: 26 18 02 00 CA ED 85 D9 F3 0C 4E D3 A6 B7 83 EE 32 57 69 96 02 00 00 00
attribute = 0x00000002,
name = STRING_TOKEN(0x003F),
varsize = 1,
guid = { 0xD985EDCA, 0x0CF3, 0xd34e, {0xA6, 0xB7, 0x83, 0xEE, 0x32, 0x57, 0x69, 0x96} };

form formid = 0x0b,
>00000091: 01 86 0B 00 02 00


title = STRING_TOKEN(0x0002);

suppressif TRUE;
>00000097: 0A 82
>00000099: 46 02
checkbox varid = VarEqAdminName,
>0000009B: 06 8E 0A 00 0A 00 01 00 02 00 3F 00 00 00
prompt = STRING_TOKEN(0x000A),
help = STRING_TOKEN(0x000A),
endcheckbox;
>000000A9: 29 02
endif;
>000000AB: 29 02


2012/6/12 Dong, Eric <eric.dong@intel.com>

Hi Stanley,

name = STRING_TOKEN(VAR_EQ_ADMIN_NAME),

The efivarstore name is get from the string token VAR_EQ_ADMIN_NAME; it is defined in the uni file.

Also VAR_EQ_ADMIN_DECIMAL_NAME has the same value with VAR_EQ_ADMIN_NAME, so it can use SetVariable to change the variable.

Thanks,

Eric

From: Stanley Gan [mailto:stanley.ganyezu@gmail.com]
Sent: Tuesday, June 12, 2012 1:10 AM
To: edk2-devel@lists.sourceforge.net
Subject: [edk2] efi varstore

In UEFI 2.1, we can declear one efi varstore like the below, it don't have one variable name in the IFR binary code.

efivarstore VarEqAdminName,
attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS,
name = STRING_TOKEN(VAR_EQ_ADMIN_NAME),
varsize = 1,
guid = FORMSET_GUID;

but we can change the variable by variable name like the below. It's curious. How do it work?

Status = gRT->SetVariable(
VAR_EQ_ADMIN_DECIMAL_NAME,
&gEfiPlatformSetupFromsetGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS,
1,
&State
);