2 This is an example of how a driver might export data to the HII protocol to be
3 later utilized by the Setup Protocol
5 Copyright (c) 2004 - 2008, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #include "DriverSample.h"
19 #define DISPLAY_ONLY_MY_ITEM 0x0002
21 EFI_GUID mFormSetGuid
= FORMSET_GUID
;
22 EFI_GUID mInventoryGuid
= INVENTORY_GUID
;
24 CHAR16 VariableName
[] = L
"MyIfrNVData";
27 Encode the password using a simple algorithm.
29 @param Password The string to be encoded.
30 @param MaxSize The size of the string.
45 Buffer
= AllocateZeroPool (MaxSize
);
46 ASSERT (Buffer
!= NULL
);
48 for (Index
= 0; Key
[Index
] != 0; Index
++) {
49 for (Loop
= 0; Loop
< (UINT8
) (MaxSize
/ 2); Loop
++) {
50 Buffer
[Loop
] = (CHAR16
) (Password
[Loop
] ^ Key
[Index
]);
54 CopyMem (Password
, Buffer
, MaxSize
);
61 Validate the user's password.
63 @param PrivateData This driver's private context data.
64 @param StringId The user's input.
66 @retval EFI_SUCCESS The user's input matches the password.
67 @retval EFI_NOT_READY The user's input does not match the password.
71 IN DRIVER_SAMPLE_PRIVATE_DATA
*PrivateData
,
72 IN EFI_STRING_ID StringId
79 CHAR16
*EncodedPassword
;
83 // Get encoded password first
85 BufferSize
= sizeof (DRIVER_SAMPLE_CONFIGURATION
);
86 Status
= gRT
->GetVariable (
91 &PrivateData
->Configuration
93 if (EFI_ERROR (Status
)) {
95 // Old password not exist, prompt for new password
102 // Check whether we have any old password set
104 for (Index
= 0; Index
< 20; Index
++) {
105 if (PrivateData
->Configuration
.WhatIsThePassword2
[Index
] != 0) {
112 // Old password not exist, return EFI_SUCCESS to prompt for new password
118 // Get user input password
120 BufferSize
= 21 * sizeof (CHAR16
);
121 Password
= AllocateZeroPool (BufferSize
);
122 ASSERT (Password
!= NULL
);
124 Status
= HiiLibGetString (PrivateData
->HiiHandle
[0], StringId
, Password
, &BufferSize
);
125 if (EFI_ERROR (Status
)) {
131 // Validate old password
133 EncodedPassword
= AllocateCopyPool (21 * sizeof (CHAR16
), Password
);
134 ASSERT (EncodedPassword
!= NULL
);
135 EncodePassword (EncodedPassword
, 20 * sizeof (CHAR16
));
136 if (CompareMem (EncodedPassword
, PrivateData
->Configuration
.WhatIsThePassword2
, 20 * sizeof (CHAR16
)) != 0) {
138 // Old password mismatch, return EFI_NOT_READY to prompt for error message
140 Status
= EFI_NOT_READY
;
142 Status
= EFI_SUCCESS
;
146 FreePool (EncodedPassword
);
152 Encode the password using a simple algorithm.
154 @param PrivateData This driver's private context data.
155 @param StringId The password from User.
157 @retval EFI_SUCESS The operation is successful.
158 @return Other value if gRT->SetVariable () fails.
163 IN DRIVER_SAMPLE_PRIVATE_DATA
*PrivateData
,
164 IN EFI_STRING_ID StringId
171 DRIVER_SAMPLE_CONFIGURATION
*Configuration
;
174 // Get Buffer Storage data from EFI variable
176 BufferSize
= sizeof (DRIVER_SAMPLE_CONFIGURATION
);
177 Status
= gRT
->GetVariable (
182 &PrivateData
->Configuration
184 if (EFI_ERROR (Status
)) {
189 // Get user input password
191 Password
= &PrivateData
->Configuration
.WhatIsThePassword2
[0];
192 PasswordSize
= sizeof (PrivateData
->Configuration
.WhatIsThePassword2
);
194 ZeroMem (Password
, PasswordSize
);
195 Status
= HiiLibGetString (PrivateData
->HiiHandle
[0], StringId
, Password
, &BufferSize
);
196 if (EFI_ERROR (Status
)) {
201 // Retrive uncommitted data from Browser
203 BufferSize
= sizeof (DRIVER_SAMPLE_CONFIGURATION
);
204 Configuration
= AllocateZeroPool (sizeof (DRIVER_SAMPLE_PRIVATE_DATA
));
205 ASSERT (Configuration
!= NULL
);
206 Status
= GetBrowserData (&mFormSetGuid
, VariableName
, &BufferSize
, (UINT8
*) Configuration
);
207 if (!EFI_ERROR (Status
)) {
209 // Update password's clear text in the screen
211 CopyMem (Configuration
->PasswordClearText
, Password
, PasswordSize
);
214 // Update uncommitted data of Browser
216 BufferSize
= sizeof (DRIVER_SAMPLE_CONFIGURATION
);
217 Status
= SetBrowserData (
221 (UINT8
*) Configuration
,
225 FreePool (Configuration
);
230 EncodePassword (Password
, PasswordSize
);
231 Status
= gRT
->SetVariable(
234 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,
235 sizeof (DRIVER_SAMPLE_CONFIGURATION
),
236 &PrivateData
->Configuration
243 This function allows a caller to extract the current configuration for one
244 or more named elements from the target driver.
246 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
247 @param Request A null-terminated Unicode string in
248 <ConfigRequest> format.
249 @param Progress On return, points to a character in the Request
250 string. Points to the string's null terminator if
251 request was successful. Points to the most recent
252 '&' before the first failing name/value pair (or
253 the beginning of the string if the failure is in
254 the first name/value pair) if the request was not
256 @param Results A null-terminated Unicode string in
257 <ConfigAltResp> format which has all values filled
258 in for the names in the Request string. String to
259 be allocated by the called function.
261 @retval EFI_SUCCESS The Results is filled with the requested values.
262 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.
263 @retval EFI_INVALID_PARAMETER Request is NULL, illegal syntax, or unknown name.
264 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this
271 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
272 IN CONST EFI_STRING Request
,
273 OUT EFI_STRING
*Progress
,
274 OUT EFI_STRING
*Results
279 DRIVER_SAMPLE_PRIVATE_DATA
*PrivateData
;
280 EFI_HII_CONFIG_ROUTING_PROTOCOL
*HiiConfigRouting
;
282 PrivateData
= DRIVER_SAMPLE_PRIVATE_FROM_THIS (This
);
283 HiiConfigRouting
= PrivateData
->HiiConfigRouting
;
287 // Get Buffer Storage data from EFI variable
289 BufferSize
= sizeof (DRIVER_SAMPLE_CONFIGURATION
);
290 Status
= gRT
->GetVariable (
295 &PrivateData
->Configuration
297 if (EFI_ERROR (Status
)) {
301 if (Request
== NULL
) {
303 // Request is set to NULL, return all configurable elements together with ALTCFG
305 Status
= ConstructConfigAltResp (
311 PrivateData
->DriverHandle
[0],
312 &PrivateData
->Configuration
,
314 VfrMyIfrNVDataBlockName
,
316 STRING_TOKEN (STR_STANDARD_DEFAULT_PROMPT
),
317 VfrMyIfrNVDataDefault0000
,
318 STRING_TOKEN (STR_MANUFACTURE_DEFAULT_PROMPT
),
319 VfrMyIfrNVDataDefault0001
326 // Check routing data in <ConfigHdr>.
327 // Note: if only one Storage is used, then this checking could be skipped.
329 if (!IsConfigHdrMatch (Request
, &mFormSetGuid
, VariableName
)) {
331 return EFI_NOT_FOUND
;
335 // Convert buffer data to <ConfigResp> by helper function BlockToConfig()
337 Status
= HiiConfigRouting
->BlockToConfig (
340 (UINT8
*) &PrivateData
->Configuration
,
350 This function processes the results of changes in configuration.
352 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
353 @param Configuration A null-terminated Unicode string in <ConfigResp>
355 @param Progress A pointer to a string filled in with the offset of
356 the most recent '&' before the first failing
357 name/value pair (or the beginning of the string if
358 the failure is in the first name/value pair) or
359 the terminating NULL if all was successful.
361 @retval EFI_SUCCESS The Results is processed successfully.
362 @retval EFI_INVALID_PARAMETER Configuration is NULL.
363 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this
370 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
371 IN CONST EFI_STRING Configuration
,
372 OUT EFI_STRING
*Progress
377 DRIVER_SAMPLE_PRIVATE_DATA
*PrivateData
;
378 EFI_HII_CONFIG_ROUTING_PROTOCOL
*HiiConfigRouting
;
380 if (Configuration
== NULL
) {
381 return EFI_INVALID_PARAMETER
;
384 PrivateData
= DRIVER_SAMPLE_PRIVATE_FROM_THIS (This
);
385 HiiConfigRouting
= PrivateData
->HiiConfigRouting
;
387 // Check routing data in <ConfigHdr>.
388 // Note: if only one Storage is used, then this checking could be skipped.
390 if (!IsConfigHdrMatch (Configuration
, &mFormSetGuid
, VariableName
)) {
391 *Progress
= Configuration
;
392 return EFI_NOT_FOUND
;
396 // Get Buffer Storage data from EFI variable
398 BufferSize
= sizeof (DRIVER_SAMPLE_CONFIGURATION
);
399 Status
= gRT
->GetVariable (
404 &PrivateData
->Configuration
406 if (EFI_ERROR (Status
)) {
411 // Convert <ConfigResp> to buffer data by helper function ConfigToBlock()
413 BufferSize
= sizeof (DRIVER_SAMPLE_CONFIGURATION
);
414 Status
= HiiConfigRouting
->ConfigToBlock (
417 (UINT8
*) &PrivateData
->Configuration
,
421 if (EFI_ERROR (Status
)) {
426 // Store Buffer Storage back to EFI variable
428 Status
= gRT
->SetVariable(
431 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,
432 sizeof (DRIVER_SAMPLE_CONFIGURATION
),
433 &PrivateData
->Configuration
441 This function processes the results of changes in configuration.
443 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
444 @param Action Specifies the type of action taken by the browser.
445 @param QuestionId A unique value which is sent to the original
446 exporting driver so that it can identify the type
448 @param Type The type of value for the question.
449 @param Value A pointer to the data being sent to the original
451 @param ActionRequest On return, points to the action requested by the
454 @retval EFI_SUCCESS The callback successfully handled the action.
455 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the
456 variable and its data.
457 @retval EFI_DEVICE_ERROR The variable could not be saved.
458 @retval EFI_UNSUPPORTED The specified Action is not supported by the
465 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
466 IN EFI_BROWSER_ACTION Action
,
467 IN EFI_QUESTION_ID QuestionId
,
469 IN EFI_IFR_TYPE_VALUE
*Value
,
470 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
473 DRIVER_SAMPLE_PRIVATE_DATA
*PrivateData
;
475 EFI_HII_UPDATE_DATA UpdateData
;
476 IFR_OPTION
*IfrOptionList
;
479 if ((Value
== NULL
) || (ActionRequest
== NULL
)) {
480 return EFI_INVALID_PARAMETER
;
483 Status
= EFI_SUCCESS
;
484 PrivateData
= DRIVER_SAMPLE_PRIVATE_FROM_THIS (This
);
486 switch (QuestionId
) {
489 // Initialize the container for dynamic opcodes
491 IfrLibInitUpdateData (&UpdateData
, 0x1000);
493 IfrOptionList
= AllocatePool (2 * sizeof (IFR_OPTION
));
494 ASSERT (IfrOptionList
!= NULL
);
496 IfrOptionList
[0].Flags
= 0;
497 IfrOptionList
[0].StringToken
= STRING_TOKEN (STR_BOOT_OPTION1
);
498 IfrOptionList
[0].Value
.u8
= 1;
499 IfrOptionList
[1].Flags
= EFI_IFR_OPTION_DEFAULT
;
500 IfrOptionList
[1].StringToken
= STRING_TOKEN (STR_BOOT_OPTION2
);
501 IfrOptionList
[1].Value
.u8
= 2;
504 0x1237, // Question ID
505 STRING_TOKEN(STR_EXIT_TEXT
), // Prompt text
506 STRING_TOKEN(STR_EXIT_TEXT
), // Help text
507 EFI_IFR_FLAG_CALLBACK
, // Question flag
508 0, // Action String ID
509 &UpdateData
// Container for dynamic created opcodes
513 // Prepare initial value for the dynamic created oneof Question
515 PrivateData
->Configuration
.DynamicOneof
= 2;
516 Status
= gRT
->SetVariable(
519 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,
520 sizeof (DRIVER_SAMPLE_CONFIGURATION
),
521 &PrivateData
->Configuration
524 0x8001, // Question ID (or call it "key")
525 CONFIGURATION_VARSTORE_ID
, // VarStore ID
526 (UINT16
) DYNAMIC_ONE_OF_VAR_OFFSET
, // Offset in Buffer Storage
527 STRING_TOKEN (STR_ONE_OF_PROMPT
), // Question prompt text
528 STRING_TOKEN (STR_ONE_OF_HELP
), // Question help text
529 EFI_IFR_FLAG_CALLBACK
, // Question flag
530 EFI_IFR_NUMERIC_SIZE_1
, // Data type of Question Value
531 IfrOptionList
, // Option list
532 2, // Number of options in Option list
533 &UpdateData
// Container for dynamic created opcodes
536 CreateOrderedListOpCode (
537 0x8002, // Question ID
538 CONFIGURATION_VARSTORE_ID
, // VarStore ID
539 (UINT16
) DYNAMIC_ORDERED_LIST_VAR_OFFSET
, // Offset in Buffer Storage
540 STRING_TOKEN (STR_BOOT_OPTIONS
), // Question prompt text
541 STRING_TOKEN (STR_BOOT_OPTIONS
), // Question help text
542 EFI_IFR_FLAG_RESET_REQUIRED
, // Question flag
543 0, // Ordered list flag, e.g. EFI_IFR_UNIQUE_SET
544 EFI_IFR_NUMERIC_SIZE_1
, // Data type of Question value
545 5, // Maximum container
546 IfrOptionList
, // Option list
547 2, // Number of options in Option list
548 &UpdateData
// Container for dynamic created opcodes
553 STRING_TOKEN (STR_GOTO_FORM1
), // Prompt text
554 STRING_TOKEN (STR_GOTO_HELP
), // Help text
556 0x8003, // Question ID
557 &UpdateData
// Container for dynamic created opcodes
560 Status
= IfrLibUpdateForm (
561 PrivateData
->HiiHandle
[0], // HII handle
562 &mFormSetGuid
, // Formset GUID
564 0x1234, // Label for where to insert opcodes
565 TRUE
, // Append or replace
566 &UpdateData
// Dynamic created opcodes
568 FreePool (IfrOptionList
);
569 IfrLibFreeUpdateData (&UpdateData
);
574 // We will reach here once the Question is refreshed
576 IfrLibInitUpdateData (&UpdateData
, 0x1000);
578 IfrOptionList
= AllocatePool (2 * sizeof (IFR_OPTION
));
579 ASSERT (IfrOptionList
!= NULL
);
582 0x1237, // Question ID
583 STRING_TOKEN(STR_EXIT_TEXT
), // Prompt text
584 STRING_TOKEN(STR_EXIT_TEXT
), // Help text
585 EFI_IFR_FLAG_CALLBACK
, // Question flag
586 0, // Action String ID
587 &UpdateData
// Container for dynamic created opcodes
590 Status
= IfrLibUpdateForm (
591 PrivateData
->HiiHandle
[0], // HII handle
592 &mFormSetGuid
, // Formset GUID
594 0x2234, // Label for where to insert opcodes
595 TRUE
, // Append or replace
596 &UpdateData
// Dynamic created opcodes
598 IfrLibFreeUpdateData (&UpdateData
);
601 // Refresh the Question value
603 PrivateData
->Configuration
.DynamicRefresh
++;
604 Status
= gRT
->SetVariable(
607 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,
608 sizeof (DRIVER_SAMPLE_CONFIGURATION
),
609 &PrivateData
->Configuration
613 // Change an EFI Variable storage (MyEfiVar) asynchronous, this will cause
614 // the first statement in Form 3 be suppressed
617 Status
= gRT
->SetVariable(
620 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,
628 // User press "Exit now", request Browser to exit
630 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_EXIT
;
635 // User press "Save now", request Browser to save the uncommitted data.
637 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_SUBMIT
;
642 // When try to set a new password, user will be chanlleged with old password.
643 // The Callback is responsible for validating old password input by user,
644 // If Callback return EFI_SUCCESS, it indicates validation pass.
646 switch (PrivateData
->PasswordState
) {
647 case BROWSER_STATE_VALIDATE_PASSWORD
:
648 Status
= ValidatePassword (PrivateData
, Value
->string
);
649 if (Status
== EFI_SUCCESS
) {
650 PrivateData
->PasswordState
= BROWSER_STATE_SET_PASSWORD
;
654 case BROWSER_STATE_SET_PASSWORD
:
655 Status
= SetPassword (PrivateData
, Value
->string
);
656 PrivateData
->PasswordState
= BROWSER_STATE_VALIDATE_PASSWORD
;
673 Main entry for this driver.
675 @param ImageHandle Image handle this driver.
676 @param SystemTable Pointer to SystemTable.
678 @retval EFI_SUCESS This function always complete successfully.
684 IN EFI_HANDLE ImageHandle
,
685 IN EFI_SYSTEM_TABLE
*SystemTable
689 EFI_STATUS SavedStatus
;
690 EFI_HII_PACKAGE_LIST_HEADER
*PackageList
;
691 EFI_HII_HANDLE HiiHandle
[2];
692 EFI_HANDLE DriverHandle
[2];
693 DRIVER_SAMPLE_PRIVATE_DATA
*PrivateData
;
694 EFI_SCREEN_DESCRIPTOR Screen
;
695 EFI_HII_DATABASE_PROTOCOL
*HiiDatabase
;
696 EFI_HII_STRING_PROTOCOL
*HiiString
;
697 EFI_FORM_BROWSER2_PROTOCOL
*FormBrowser2
;
698 EFI_HII_CONFIG_ROUTING_PROTOCOL
*HiiConfigRouting
;
701 DRIVER_SAMPLE_CONFIGURATION
*Configuration
;
702 BOOLEAN ExtractIfrDefault
;
705 // Initialize the library and our protocol.
709 // Initialize screen dimensions for SendForm().
710 // Remove 3 characters from top and bottom
712 ZeroMem (&Screen
, sizeof (EFI_SCREEN_DESCRIPTOR
));
713 gST
->ConOut
->QueryMode (gST
->ConOut
, gST
->ConOut
->Mode
->Mode
, &Screen
.RightColumn
, &Screen
.BottomRow
);
716 Screen
.BottomRow
= Screen
.BottomRow
- 3;
719 // Initialize driver private data
721 PrivateData
= AllocatePool (sizeof (DRIVER_SAMPLE_PRIVATE_DATA
));
722 if (PrivateData
== NULL
) {
723 return EFI_OUT_OF_RESOURCES
;
726 PrivateData
->Signature
= DRIVER_SAMPLE_PRIVATE_SIGNATURE
;
728 PrivateData
->ConfigAccess
.ExtractConfig
= ExtractConfig
;
729 PrivateData
->ConfigAccess
.RouteConfig
= RouteConfig
;
730 PrivateData
->ConfigAccess
.Callback
= DriverCallback
;
731 PrivateData
->PasswordState
= BROWSER_STATE_VALIDATE_PASSWORD
;
734 // Locate Hii Database protocol
736 Status
= gBS
->LocateProtocol (&gEfiHiiDatabaseProtocolGuid
, NULL
, (VOID
**) &HiiDatabase
);
737 if (EFI_ERROR (Status
)) {
740 PrivateData
->HiiDatabase
= HiiDatabase
;
743 // Locate HiiString protocol
745 Status
= gBS
->LocateProtocol (&gEfiHiiStringProtocolGuid
, NULL
, (VOID
**) &HiiString
);
746 if (EFI_ERROR (Status
)) {
749 PrivateData
->HiiString
= HiiString
;
752 // Locate Formbrowser2 protocol
754 Status
= gBS
->LocateProtocol (&gEfiFormBrowser2ProtocolGuid
, NULL
, (VOID
**) &FormBrowser2
);
755 if (EFI_ERROR (Status
)) {
758 PrivateData
->FormBrowser2
= FormBrowser2
;
761 // Locate ConfigRouting protocol
763 Status
= gBS
->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid
, NULL
, (VOID
**) &HiiConfigRouting
);
764 if (EFI_ERROR (Status
)) {
767 PrivateData
->HiiConfigRouting
= HiiConfigRouting
;
770 // Install Config Access protocol
772 Status
= HiiLibCreateHiiDriverHandle (&DriverHandle
[0]);
773 if (EFI_ERROR (Status
)) {
776 PrivateData
->DriverHandle
[0] = DriverHandle
[0];
778 Status
= gBS
->InstallProtocolInterface (
780 &gEfiHiiConfigAccessProtocolGuid
,
781 EFI_NATIVE_INTERFACE
,
782 &PrivateData
->ConfigAccess
784 ASSERT_EFI_ERROR (Status
);
787 // Publish our HII data
789 PackageList
= HiiLibPreparePackageList (
795 if (PackageList
== NULL
) {
796 return EFI_OUT_OF_RESOURCES
;
799 Status
= HiiDatabase
->NewPackageList (
805 FreePool (PackageList
);
806 if (EFI_ERROR (Status
)) {
809 PrivateData
->HiiHandle
[0] = HiiHandle
[0];
812 // Publish another Fromset
814 Status
= HiiLibCreateHiiDriverHandle (&DriverHandle
[1]);
815 if (EFI_ERROR (Status
)) {
818 PrivateData
->DriverHandle
[1] = DriverHandle
[1];
820 PackageList
= HiiLibPreparePackageList (
826 if (PackageList
== NULL
) {
827 return EFI_OUT_OF_RESOURCES
;
830 Status
= HiiDatabase
->NewPackageList (
836 FreePool (PackageList
);
837 if (EFI_ERROR (Status
)) {
840 PrivateData
->HiiHandle
[1] = HiiHandle
[1];
843 // Very simple example of how one would update a string that is already
844 // in the HII database
846 NewString
= L
"700 Mhz";
848 Status
= HiiLibSetString (HiiHandle
[0], STRING_TOKEN (STR_CPU_STRING2
), NewString
);
849 if (EFI_ERROR (Status
)) {
854 // Initialize configuration data
856 Configuration
= &PrivateData
->Configuration
;
857 ZeroMem (Configuration
, sizeof (DRIVER_SAMPLE_CONFIGURATION
));
860 // Try to read NV config EFI variable first
862 ExtractIfrDefault
= TRUE
;
863 BufferSize
= sizeof (DRIVER_SAMPLE_CONFIGURATION
);
864 Status
= gRT
->GetVariable (VariableName
, &mFormSetGuid
, NULL
, &BufferSize
, Configuration
);
865 if (!EFI_ERROR (Status
) && (BufferSize
== sizeof (DRIVER_SAMPLE_CONFIGURATION
))) {
866 ExtractIfrDefault
= FALSE
;
869 if (ExtractIfrDefault
) {
871 // EFI variable for NV config doesn't exit, we should build this variable
872 // based on default values stored in IFR
874 BufferSize
= sizeof (DRIVER_SAMPLE_CONFIGURATION
);
875 Status
= IfrLibExtractDefault (Configuration
, &BufferSize
, 1, VfrMyIfrNVDataDefault0000
);
877 if (!EFI_ERROR (Status
)) {
881 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,
882 sizeof (DRIVER_SAMPLE_CONFIGURATION
),
889 // Example of how to display only the item we sent to HII
891 if (DISPLAY_ONLY_MY_ITEM
== 0x0001) {
893 // Have the browser pull out our copy of the data, and only display our data
895 // Status = FormConfig->SendForm (FormConfig, TRUE, HiiHandle, NULL, NULL, NULL, &Screen, NULL);
897 Status
= FormBrowser2
->SendForm (
906 SavedStatus
= Status
;
908 Status
= HiiDatabase
->RemovePackageList (HiiDatabase
, HiiHandle
[0]);
909 if (EFI_ERROR (Status
)) {
913 Status
= HiiDatabase
->RemovePackageList (HiiDatabase
, HiiHandle
[1]);
914 if (EFI_ERROR (Status
)) {
921 // Have the browser pull out all the data in the HII Database and display it.
923 // Status = FormConfig->SendForm (FormConfig, TRUE, 0, NULL, NULL, NULL, NULL, NULL);