diff options
-rw-r--r-- | MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c | 131 | ||||
-rw-r--r-- | MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h | 1 | ||||
-rw-r--r-- | MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h | 8 | ||||
-rw-r--r-- | MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr | 104 | ||||
-rw-r--r-- | MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni | bin | 56050 -> 58936 bytes |
5 files changed, 182 insertions, 62 deletions
diff --git a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c index e20e030..1484404 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c +++ b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c @@ -23,6 +23,7 @@ EFI_GUID mInventoryGuid = INVENTORY_GUID; EFI_GUID MyEventGroupGuid = EFI_IFR_REFRESH_ID_OP_GUID;
CHAR16 VariableName[] = L"MyIfrNVData";
+CHAR16 MyEfiVar[] = L"MyEfiVar";
EFI_HANDLE DriverHandle[2] = {NULL, NULL};
DRIVER_SAMPLE_PRIVATE_DATA *PrivateData = NULL;
EFI_EVENT mEvent;
@@ -868,6 +869,13 @@ ExtractConfig ( return EFI_NOT_FOUND;
}
//
+ // Check whether request for EFI Varstore. EFI varstore get data
+ // through hii database, not support in this path.
+ //
+ if (HiiIsConfigHdrMatch(Request, &mFormSetGuid, MyEfiVar)) {
+ return EFI_UNSUPPORTED;
+ }
+ //
// Set Request to the unified request string.
//
ConfigRequest = Request;
@@ -1071,6 +1079,14 @@ RouteConfig ( }
//
+ // Check whether request for EFI Varstore. EFI varstore get data
+ // through hii database, not support in this path.
+ //
+ if (HiiIsConfigHdrMatch(Configuration, &mFormSetGuid, MyEfiVar)) {
+ return EFI_UNSUPPORTED;
+ }
+
+ //
// Get Buffer Storage data from EFI variable
//
BufferSize = sizeof (DRIVER_SAMPLE_CONFIGURATION);
@@ -1269,7 +1285,6 @@ DriverCallback ( {
DRIVER_SAMPLE_PRIVATE_DATA *PrivateData;
EFI_STATUS Status;
- UINT8 MyVar;
VOID *StartOpCodeHandle;
VOID *OptionsOpCodeHandle;
EFI_IFR_GUID_LABEL *StartLabel;
@@ -1277,7 +1292,7 @@ DriverCallback ( EFI_IFR_GUID_LABEL *EndLabel;
EFI_INPUT_KEY Key;
DRIVER_SAMPLE_CONFIGURATION *Configuration;
- UINTN MyVarSize;
+ MY_EFI_VARSTORE_DATA *EfiData;
EFI_FORM_ID FormId;
if (((Value == NULL) && (Action != EFI_BROWSER_ACTION_FORM_OPEN) && (Action != EFI_BROWSER_ACTION_FORM_CLOSE))||
@@ -1370,21 +1385,14 @@ DriverCallback ( case EFI_BROWSER_ACTION_RETRIEVE:
{
- if (QuestionId == 0x1111) {
- //
- // EfiVarstore question takes sample action (print value as debug information)
- // after read/write question.
- //
- MyVarSize = 1;
- Status = gRT->GetVariable(
- L"MyVar",
- &mFormSetGuid,
- NULL,
- &MyVarSize,
- &MyVar
- );
- ASSERT_EFI_ERROR (Status);
- DEBUG ((DEBUG_INFO, "EfiVarstore question: Tall value is %d with value width %d\n", MyVar, MyVarSize));
+ if (QuestionId == 0x1248) {
+ {
+ if (Type != EFI_IFR_TYPE_REF) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Value->ref.FormId = 0x3;
+ }
}
}
break;
@@ -1420,6 +1428,15 @@ DriverCallback ( case EFI_BROWSER_ACTION_CHANGING:
{
switch (QuestionId) {
+ case 0x1249:
+ {
+ if (Type != EFI_IFR_TYPE_REF) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Value->ref.FormId = 0x1234;
+ }
+ break;
case 0x1234:
//
// Initialize the container for dynamic opcodes
@@ -1612,7 +1629,7 @@ DriverCallback ( PrivateData->Configuration.DynamicRefresh++;
} else if (QuestionId == 0x1247 ) {
StartLabel->Number = LABEL_UPDATE3;
- FormId = 0x05;
+ FormId = 0x06;
PrivateData->Configuration.RefreshGuidCount++;
}
@@ -1648,18 +1665,21 @@ DriverCallback ( if (QuestionId == 0x5678) {
//
- // Change an EFI Variable storage (MyEfiVar) asynchronous, this will cause
- // the first statement in Form 3 be suppressed
+ // Update uncommitted data of Browser
//
- MyVarSize = 1;
- MyVar = 111;
- Status = gRT->SetVariable(
- L"MyVar",
- &mFormSetGuid,
- EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
- MyVarSize,
- &MyVar
- );
+ EfiData = AllocateZeroPool (sizeof (MY_EFI_VARSTORE_DATA));
+ ASSERT (EfiData != NULL);
+ if (HiiGetBrowserData (&mFormSetGuid, MyEfiVar, sizeof (MY_EFI_VARSTORE_DATA), (UINT8 *) EfiData)) {
+ EfiData->Field8 = 111;
+ HiiSetBrowserData (
+ &mFormSetGuid,
+ MyEfiVar,
+ sizeof (MY_EFI_VARSTORE_DATA),
+ (UINT8 *) EfiData,
+ NULL
+ );
+ }
+ FreePool (EfiData);
}
break;
@@ -1741,21 +1761,6 @@ DriverCallback ( break;
- case 0x1111:
- //
- // EfiVarstore question takes sample action (print value as debug information)
- // after read/write question.
- //
- MyVarSize = 1;
- Status = gRT->GetVariable(
- L"MyVar",
- &mFormSetGuid,
- NULL,
- &MyVarSize,
- &MyVar
- );
- ASSERT_EFI_ERROR (Status);
- DEBUG ((DEBUG_INFO, "EfiVarstore question: Tall value is %d with value width %d\n", MyVar, MyVarSize));
default:
break;
}
@@ -1798,6 +1803,7 @@ DriverSampleInit ( DRIVER_SAMPLE_CONFIGURATION *Configuration;
BOOLEAN ActionFlag;
EFI_STRING ConfigRequestHdr;
+ MY_EFI_VARSTORE_DATA *VarStoreConfig;
//
// Initialize the local variables.
@@ -1978,7 +1984,44 @@ DriverSampleInit ( ActionFlag = HiiValidateSettings (ConfigRequestHdr);
ASSERT (ActionFlag);
}
+ FreePool (ConfigRequestHdr);
+ //
+ // Initialize efi varstore configuration data
+ //
+ VarStoreConfig = &PrivateData->VarStoreConfig;
+ ZeroMem (VarStoreConfig, sizeof (MY_EFI_VARSTORE_DATA));
+
+ ConfigRequestHdr = HiiConstructConfigHdr (&mFormSetGuid, MyEfiVar, DriverHandle[0]);
+ ASSERT (ConfigRequestHdr != NULL);
+
+ BufferSize = sizeof (MY_EFI_VARSTORE_DATA);
+ Status = gRT->GetVariable (MyEfiVar, &mFormSetGuid, NULL, &BufferSize, VarStoreConfig);
+ if (EFI_ERROR (Status)) {
+ //
+ // Store zero data to EFI variable Storage.
+ //
+ Status = gRT->SetVariable(
+ MyEfiVar,
+ &mFormSetGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ sizeof (MY_EFI_VARSTORE_DATA),
+ VarStoreConfig
+ );
+ ASSERT (Status == EFI_SUCCESS);
+ //
+ // EFI variable for NV config doesn't exit, we should build this variable
+ // based on default values stored in IFR
+ //
+ ActionFlag = HiiSetToDefaults (ConfigRequestHdr, EFI_HII_DEFAULT_CLASS_STANDARD);
+ ASSERT (ActionFlag);
+ } else {
+ //
+ // EFI variable does exist and Validate Current Setting
+ //
+ ActionFlag = HiiValidateSettings (ConfigRequestHdr);
+ ASSERT (ActionFlag);
+ }
FreePool (ConfigRequestHdr);
Status = gBS->CreateEventEx (
diff --git a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h index a644566..29f4611 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h +++ b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h @@ -81,6 +81,7 @@ typedef struct { EFI_HANDLE DriverHandle[2];
EFI_HII_HANDLE HiiHandle[2];
DRIVER_SAMPLE_CONFIGURATION Configuration;
+ MY_EFI_VARSTORE_DATA VarStoreConfig;
UINT8 PasswordState;
//
diff --git a/MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h b/MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h index f024030..06953ca 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h +++ b/MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h @@ -46,6 +46,11 @@ Revision History: 0xF5E655D9, 0x02A6, 0x46f2, {0x9E, 0x76, 0xB8, 0xBE, 0x8E, 0x60, 0xAB, 0x22} \
}
+#define ZERO_GUID \
+ { \
+ 0x0, 0x0, 0x0, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0} \
+ }
+
#define CONFIGURATION_VARSTORE_ID 0x1234
#pragma pack(1)
@@ -72,6 +77,7 @@ typedef struct { UINT8 DynamicOneof;
UINT8 DynamicOrderedList[5];
UINT8 Reserved;
+ EFI_HII_REF RefData;
UINT8 NameValueVar0;
UINT16 NameValueVar1;
UINT16 NameValueVar2[20];
@@ -92,7 +98,7 @@ typedef struct { UINT8 Field8;
UINT16 Field16;
UINT8 OrderedList[3];
-} MY_DATA2;
+} MY_EFI_VARSTORE_DATA;
//
// Labels definition
diff --git a/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr b/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr index 47304ab..d316511 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr +++ b/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr @@ -74,20 +74,12 @@ formset guid = FORMSET_GUID; // GUID of this buffer storage
//
- // Define another Buffer Storage
- //
- varstore MY_DATA2,
- name = MyIfrNVData2,
- guid = FORMSET_GUID;
-
- //
// Define a EFI variable Storage (EFI_IFR_VARSTORE_EFI)
//
- efivarstore MyEfiVar, // Define referenced name in vfr
- attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE, // EFI variable attribures
- name = STRING_TOKEN(STR_VAR_NAME), // EFI variable name
- varsize = 1, // Size of the EFI variable
- guid = FORMSET_GUID; // EFI variable GUID
+ efivarstore MY_EFI_VARSTORE_DATA,
+ attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE, // EFI variable attribures
+ name = MyEfiVar,
+ guid = FORMSET_GUID;
//
// Define a Name/Value Storage (EFI_IFR_VARSTORE_NAME_VALUE)
@@ -330,21 +322,22 @@ formset inconsistentif prompt = STRING_TOKEN(STR_ERROR_POPUP),
ideqval MyIfrNVData.HowOldAreYouInYearsManual == 99
OR
- ideqid MyIfrNVData.HowOldAreYouInYearsManual == MyEfiVar
+ ideqid MyIfrNVData.HowOldAreYouInYearsManual == MyEfiVar.Field8
OR
ideqvallist MyIfrNVData.HowOldAreYouInYearsManual == 1 3 5 7
endif
endnumeric;
- numeric varid = MyEfiVar, // Reference of EFI variable storage
+ numeric varid = MyEfiVar.Field8, // Reference of EFI variable storage
questionid = 0x1111,
prompt = STRING_TOKEN(STR_TALL_HEX_PROMPT),
help = STRING_TOKEN(STR_NUMERIC_HELP1),
flags = DISPLAY_UINT_HEX | INTERACTIVE, // Display in HEX format (if not specified, default is in decimal format)
minimum = 0,
maximum = 250,
- default = 175,
+ default = 18, defaultstore = MyStandardDefault, // This is standard default value
+ default = 19, defaultstore = MyManufactureDefault, // This is manufacture default value
endnumeric;
@@ -383,6 +376,13 @@ formset maxsize = 0x14,
endstring;
+ oneof varid = MyEfiVar.Field16,
+ prompt = STRING_TOKEN(STR_ONE_OF_PROMPT),
+ help = STRING_TOKEN(STR_NUMERIC_NUM_HELP),
+ option text = STRING_TOKEN(STR_BOOT_ORDER1), value = 0x0, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_ORDER2), value = 0x1, flags = DEFAULT;
+ endoneof;
+
label LABEL_1_VALUE;
label LABEL_2_VALUE;
@@ -483,9 +483,17 @@ formset prompt = STRING_TOKEN(STR_GOTO_FORM4), //FourthSetupPage // this too has no end-op and basically it's a jump to a form ONLY
help = STRING_TOKEN(STR_GOTO_HELP);
+ goto 5,
+ prompt = STRING_TOKEN(STR_GOTO_FORM5), //FifthSetupPage // this too has no end-op and basically it's a jump to a form ONLY
+ help = STRING_TOKEN(STR_GOTO_FORM5_HELP);
+
+ goto 6,
+ prompt = STRING_TOKEN(STR_GOTO_FORM6), //SixthSetupPage // this too has no end-op and basically it's a jump to a form ONLY
+ help = STRING_TOKEN(STR_GOTO_HELP);
+
guidop
guid = FORMSET_GUID,
- datatype = MY_DATA2,
+ datatype = MY_EFI_VARSTORE_DATA,
data.Field8 = 0x21,
data.Field16 = 0x2121,
data.OrderedList[0] = 0x21,
@@ -621,12 +629,29 @@ formset prompt = STRING_TOKEN(STR_GOTO_FORM1), //MainSetupPage // this too has no end-op and basically it's a jump to a form ONLY
help = STRING_TOKEN(STR_GOTO_HELP);
+ goto
+ varid = MyIfrNVData.RefData,
+ prompt = STRING_TOKEN(STR_GOTO_DYNAMIC3),
+ help = STRING_TOKEN(STR_GOTO_DYNAMIC3_HELP),
+ flags = INTERACTIVE,
+ key = 0x1248;
+ //
+ // Set the defult value, format is QuestionId; FormId; FormsetGuid; Device Path String Token
+ //
+ default = 0;0;ZERO_GUID;STRING_TOKEN(STR_NULL_STRING),
+
+ goto
+ prompt = STRING_TOKEN(STR_GOTO_DYNAMIC4),
+ help = STRING_TOKEN(STR_GOTO_DYNAMIC4_HELP),
+ flags = INTERACTIVE,
+ key = 0x1249;
+
endform;
endif;
form formid = 3, title = STRING_TOKEN(STR_FORM3_TITLE); // note formid is a variable (for readability) (UINT16) - also added Form to the line to signify the Op-Code
- suppressif ideqval MyEfiVar == 111;
+ suppressif ideqval MyEfiVar.Field8 == 111;
text
help = STRING_TOKEN(STR_TEXT_HELP),
text = STRING_TOKEN(STR_TEXT_TEXT_1);
@@ -712,6 +737,51 @@ formset endform;
+ form formid = 5, // Modal form
+ title = STRING_TOKEN(STR_MODAL_FORM_TITLE);
+ //
+ // This form is a modal form.
+ //
+ modal;
+ text
+ help = STRING_TOKEN(STR_EXIT_TEXT),
+ text = STRING_TOKEN(STR_EXIT_TEXT),
+ text = STRING_TOKEN(STR_EXIT_TEXT),
+ flags = INTERACTIVE, // VfrCompiler will generate opcode EFI_IFR_ACTION for Text marked as INTERACTIVE
+ key = 0x1245;
+
+ text
+ help = STRING_TOKEN(STR_SAVE_TEXT),
+ text = STRING_TOKEN(STR_SAVE_TEXT),
+ text = STRING_TOKEN(STR_SAVE_TEXT),
+ flags = INTERACTIVE, // VfrCompiler will generate opcode EFI_IFR_ACTION for Text marked as INTERACTIVE
+ key = 0x1246;
+ endform;
+
+ form formid = 6, // Form to show the refresh guid group op-code
+ title = STRING_TOKEN(STR_FORM6_TITLE);
+
+ text
+ help = STRING_TOKEN(STR_TEXT_REFRESH_GUID),
+ text = STRING_TOKEN(STR_TEXT_REFRESH_GUID);
+
+ numeric varid = MyIfrNVData.RefreshGuidCount,
+ prompt = STRING_TOKEN(STR_TEXT_REFRESH_GUID_COUNT),
+ help = STRING_TOKEN(STR_NUMERIC_HELP0),
+ flags = INTERACTIVE,
+ key = 0x1247,
+ minimum = 0,
+ maximum = 0xff,
+ step = 0,
+ default = 0,
+ refreshguid = EFI_IFR_REFRESH_ID_OP_GUID,
+ endnumeric;
+
+ label LABEL_UPDATE3;
+ label LABEL_END;
+
+ endform;
+
form formid = 0x1234, // Dynamically created page,
title = STRING_TOKEN(STR_DYNAMIC_TITLE); // note formid is a variable (for readability) (UINT16) - also added Form to the line to signify the Op-Code
diff --git a/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni b/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni Binary files differindex d09fa5f..8aa526b 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni +++ b/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni |