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
170 DRIVER_SAMPLE_CONFIGURATION
*Configuration
;
173 // Get Buffer Storage data from EFI variable
175 BufferSize
= sizeof (DRIVER_SAMPLE_CONFIGURATION
);
176 Status
= gRT
->GetVariable (
181 &PrivateData
->Configuration
183 if (EFI_ERROR (Status
)) {
188 // Get user input password
190 Password
= &PrivateData
->Configuration
.WhatIsThePassword2
[0];
191 ZeroMem (Password
, 20 * sizeof (CHAR16
));
192 Status
= HiiLibGetString (PrivateData
->HiiHandle
[0], StringId
, Password
, &BufferSize
);
193 if (EFI_ERROR (Status
)) {
198 // Retrive uncommitted data from Browser
200 BufferSize
= sizeof (DRIVER_SAMPLE_CONFIGURATION
);
201 Configuration
= AllocateZeroPool (sizeof (DRIVER_SAMPLE_PRIVATE_DATA
));
202 ASSERT (Configuration
!= NULL
);
203 Status
= GetBrowserData (&mFormSetGuid
, VariableName
, &BufferSize
, (UINT8
*) Configuration
);
204 if (!EFI_ERROR (Status
)) {
206 // Update password's clear text in the screen
208 CopyMem (Configuration
->PasswordClearText
, Password
, 20 * sizeof (CHAR16
));
211 // Update uncommitted data of Browser
213 BufferSize
= sizeof (DRIVER_SAMPLE_CONFIGURATION
);
214 Status
= SetBrowserData (
218 (UINT8
*) Configuration
,
222 FreePool (Configuration
);
227 EncodePassword (Password
, 20 * sizeof (CHAR16
));
228 Status
= gRT
->SetVariable(
231 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,
232 sizeof (DRIVER_SAMPLE_CONFIGURATION
),
233 &PrivateData
->Configuration
240 This function allows a caller to extract the current configuration for one
241 or more named elements from the target driver.
243 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
244 @param Request A null-terminated Unicode string in
245 <ConfigRequest> format.
246 @param Progress On return, points to a character in the Request
247 string. Points to the string's null terminator if
248 request was successful. Points to the most recent
249 '&' before the first failing name/value pair (or
250 the beginning of the string if the failure is in
251 the first name/value pair) if the request was not
253 @param Results A null-terminated Unicode string in
254 <ConfigAltResp> format which has all values filled
255 in for the names in the Request string. String to
256 be allocated by the called function.
258 @retval EFI_SUCCESS The Results is filled with the requested values.
259 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.
260 @retval EFI_INVALID_PARAMETER Request is NULL, illegal syntax, or unknown name.
261 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this
268 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
269 IN CONST EFI_STRING Request
,
270 OUT EFI_STRING
*Progress
,
271 OUT EFI_STRING
*Results
276 DRIVER_SAMPLE_PRIVATE_DATA
*PrivateData
;
277 EFI_HII_CONFIG_ROUTING_PROTOCOL
*HiiConfigRouting
;
279 PrivateData
= DRIVER_SAMPLE_PRIVATE_FROM_THIS (This
);
280 HiiConfigRouting
= PrivateData
->HiiConfigRouting
;
284 // Get Buffer Storage data from EFI variable
286 BufferSize
= sizeof (DRIVER_SAMPLE_CONFIGURATION
);
287 Status
= gRT
->GetVariable (
292 &PrivateData
->Configuration
294 if (EFI_ERROR (Status
)) {
298 if (Request
== NULL
) {
300 // Request is set to NULL, return all configurable elements together with ALTCFG
302 Status
= ConstructConfigAltResp (
308 PrivateData
->DriverHandle
[0],
309 &PrivateData
->Configuration
,
311 VfrMyIfrNVDataBlockName
,
313 STRING_TOKEN (STR_STANDARD_DEFAULT_PROMPT
),
314 VfrMyIfrNVDataDefault0000
,
315 STRING_TOKEN (STR_MANUFACTURE_DEFAULT_PROMPT
),
316 VfrMyIfrNVDataDefault0001
323 // Check routing data in <ConfigHdr>.
324 // Note: if only one Storage is used, then this checking could be skipped.
326 if (!IsConfigHdrMatch (Request
, &mFormSetGuid
, VariableName
)) {
328 return EFI_NOT_FOUND
;
332 // Convert buffer data to <ConfigResp> by helper function BlockToConfig()
334 Status
= HiiConfigRouting
->BlockToConfig (
337 (UINT8
*) &PrivateData
->Configuration
,
347 This function processes the results of changes in configuration.
349 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
350 @param Configuration A null-terminated Unicode string in <ConfigResp>
352 @param Progress A pointer to a string filled in with the offset of
353 the most recent '&' before the first failing
354 name/value pair (or the beginning of the string if
355 the failure is in the first name/value pair) or
356 the terminating NULL if all was successful.
358 @retval EFI_SUCCESS The Results is processed successfully.
359 @retval EFI_INVALID_PARAMETER Configuration is NULL.
360 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this
367 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
368 IN CONST EFI_STRING Configuration
,
369 OUT EFI_STRING
*Progress
374 DRIVER_SAMPLE_PRIVATE_DATA
*PrivateData
;
375 EFI_HII_CONFIG_ROUTING_PROTOCOL
*HiiConfigRouting
;
377 if (Configuration
== NULL
) {
378 return EFI_INVALID_PARAMETER
;
381 PrivateData
= DRIVER_SAMPLE_PRIVATE_FROM_THIS (This
);
382 HiiConfigRouting
= PrivateData
->HiiConfigRouting
;
384 // Check routing data in <ConfigHdr>.
385 // Note: if only one Storage is used, then this checking could be skipped.
387 if (!IsConfigHdrMatch (Configuration
, &mFormSetGuid
, VariableName
)) {
388 *Progress
= Configuration
;
389 return EFI_NOT_FOUND
;
393 // Get Buffer Storage data from EFI variable
395 BufferSize
= sizeof (DRIVER_SAMPLE_CONFIGURATION
);
396 Status
= gRT
->GetVariable (
401 &PrivateData
->Configuration
403 if (EFI_ERROR (Status
)) {
408 // Convert <ConfigResp> to buffer data by helper function ConfigToBlock()
410 BufferSize
= sizeof (DRIVER_SAMPLE_CONFIGURATION
);
411 Status
= HiiConfigRouting
->ConfigToBlock (
414 (UINT8
*) &PrivateData
->Configuration
,
418 if (EFI_ERROR (Status
)) {
423 // Store Buffer Storage back to EFI variable
425 Status
= gRT
->SetVariable(
428 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,
429 sizeof (DRIVER_SAMPLE_CONFIGURATION
),
430 &PrivateData
->Configuration
438 This function processes the results of changes in configuration.
440 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
441 @param Action Specifies the type of action taken by the browser.
442 @param QuestionId A unique value which is sent to the original
443 exporting driver so that it can identify the type
445 @param Type The type of value for the question.
446 @param Value A pointer to the data being sent to the original
448 @param ActionRequest On return, points to the action requested by the
451 @retval EFI_SUCCESS The callback successfully handled the action.
452 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the
453 variable and its data.
454 @retval EFI_DEVICE_ERROR The variable could not be saved.
455 @retval EFI_UNSUPPORTED The specified Action is not supported by the
462 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
463 IN EFI_BROWSER_ACTION Action
,
464 IN EFI_QUESTION_ID QuestionId
,
466 IN EFI_IFR_TYPE_VALUE
*Value
,
467 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
470 DRIVER_SAMPLE_PRIVATE_DATA
*PrivateData
;
472 EFI_HII_UPDATE_DATA UpdateData
;
473 IFR_OPTION
*IfrOptionList
;
476 if ((Value
== NULL
) || (ActionRequest
== NULL
)) {
477 return EFI_INVALID_PARAMETER
;
480 Status
= EFI_SUCCESS
;
481 PrivateData
= DRIVER_SAMPLE_PRIVATE_FROM_THIS (This
);
483 switch (QuestionId
) {
486 // Initialize the container for dynamic opcodes
488 IfrLibInitUpdateData (&UpdateData
, 0x1000);
490 IfrOptionList
= AllocatePool (2 * sizeof (IFR_OPTION
));
491 ASSERT (IfrOptionList
!= NULL
);
493 IfrOptionList
[0].Flags
= 0;
494 IfrOptionList
[0].StringToken
= STRING_TOKEN (STR_BOOT_OPTION1
);
495 IfrOptionList
[0].Value
.u8
= 1;
496 IfrOptionList
[1].Flags
= EFI_IFR_OPTION_DEFAULT
;
497 IfrOptionList
[1].StringToken
= STRING_TOKEN (STR_BOOT_OPTION2
);
498 IfrOptionList
[1].Value
.u8
= 2;
501 0x1237, // Question ID
502 STRING_TOKEN(STR_EXIT_TEXT
), // Prompt text
503 STRING_TOKEN(STR_EXIT_TEXT
), // Help text
504 EFI_IFR_FLAG_CALLBACK
, // Question flag
505 0, // Action String ID
506 &UpdateData
// Container for dynamic created opcodes
510 // Prepare initial value for the dynamic created oneof Question
512 PrivateData
->Configuration
.DynamicOneof
= 2;
513 Status
= gRT
->SetVariable(
516 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,
517 sizeof (DRIVER_SAMPLE_CONFIGURATION
),
518 &PrivateData
->Configuration
521 0x8001, // Question ID (or call it "key")
522 CONFIGURATION_VARSTORE_ID
, // VarStore ID
523 DYNAMIC_ONE_OF_VAR_OFFSET
, // Offset in Buffer Storage
524 STRING_TOKEN (STR_ONE_OF_PROMPT
), // Question prompt text
525 STRING_TOKEN (STR_ONE_OF_HELP
), // Question help text
526 EFI_IFR_FLAG_CALLBACK
, // Question flag
527 EFI_IFR_NUMERIC_SIZE_1
, // Data type of Question Value
528 IfrOptionList
, // Option list
529 2, // Number of options in Option list
530 &UpdateData
// Container for dynamic created opcodes
533 CreateOrderedListOpCode (
534 0x8002, // Question ID
535 CONFIGURATION_VARSTORE_ID
, // VarStore ID
536 DYNAMIC_ORDERED_LIST_VAR_OFFSET
, // Offset in Buffer Storage
537 STRING_TOKEN (STR_BOOT_OPTIONS
), // Question prompt text
538 STRING_TOKEN (STR_BOOT_OPTIONS
), // Question help text
539 EFI_IFR_FLAG_RESET_REQUIRED
, // Question flag
540 0, // Ordered list flag, e.g. EFI_IFR_UNIQUE_SET
541 EFI_IFR_NUMERIC_SIZE_1
, // Data type of Question value
542 5, // Maximum container
543 IfrOptionList
, // Option list
544 2, // Number of options in Option list
545 &UpdateData
// Container for dynamic created opcodes
550 STRING_TOKEN (STR_GOTO_FORM1
), // Prompt text
551 STRING_TOKEN (STR_GOTO_HELP
), // Help text
553 0x8003, // Question ID
554 &UpdateData
// Container for dynamic created opcodes
557 Status
= IfrLibUpdateForm (
558 PrivateData
->HiiHandle
[0], // HII handle
559 &mFormSetGuid
, // Formset GUID
561 0x1234, // Label for where to insert opcodes
562 TRUE
, // Append or replace
563 &UpdateData
// Dynamic created opcodes
565 FreePool (IfrOptionList
);
566 IfrLibFreeUpdateData (&UpdateData
);
571 // We will reach here once the Question is refreshed
573 IfrLibInitUpdateData (&UpdateData
, 0x1000);
575 IfrOptionList
= AllocatePool (2 * sizeof (IFR_OPTION
));
576 ASSERT (IfrOptionList
!= NULL
);
579 0x1237, // Question ID
580 STRING_TOKEN(STR_EXIT_TEXT
), // Prompt text
581 STRING_TOKEN(STR_EXIT_TEXT
), // Help text
582 EFI_IFR_FLAG_CALLBACK
, // Question flag
583 0, // Action String ID
584 &UpdateData
// Container for dynamic created opcodes
587 Status
= IfrLibUpdateForm (
588 PrivateData
->HiiHandle
[0], // HII handle
589 &mFormSetGuid
, // Formset GUID
591 0x2234, // Label for where to insert opcodes
592 TRUE
, // Append or replace
593 &UpdateData
// Dynamic created opcodes
595 IfrLibFreeUpdateData (&UpdateData
);
598 // Refresh the Question value
600 PrivateData
->Configuration
.DynamicRefresh
++;
601 Status
= gRT
->SetVariable(
604 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,
605 sizeof (DRIVER_SAMPLE_CONFIGURATION
),
606 &PrivateData
->Configuration
610 // Change an EFI Variable storage (MyEfiVar) asynchronous, this will cause
611 // the first statement in Form 3 be suppressed
614 Status
= gRT
->SetVariable(
617 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,
625 // User press "Exit now", request Browser to exit
627 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_EXIT
;
632 // User press "Save now", request Browser to save the uncommitted data.
634 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_SUBMIT
;
639 // When try to set a new password, user will be chanlleged with old password.
640 // The Callback is responsible for validating old password input by user,
641 // If Callback return EFI_SUCCESS, it indicates validation pass.
643 switch (PrivateData
->PasswordState
) {
644 case BROWSER_STATE_VALIDATE_PASSWORD
:
645 Status
= ValidatePassword (PrivateData
, Value
->string
);
646 if (Status
== EFI_SUCCESS
) {
647 PrivateData
->PasswordState
= BROWSER_STATE_SET_PASSWORD
;
651 case BROWSER_STATE_SET_PASSWORD
:
652 Status
= SetPassword (PrivateData
, Value
->string
);
653 PrivateData
->PasswordState
= BROWSER_STATE_VALIDATE_PASSWORD
;
670 Main entry for this driver.
672 @param ImageHandle Image handle this driver.
673 @param SystemTable Pointer to SystemTable.
675 @retval EFI_SUCESS This function always complete successfully.
681 IN EFI_HANDLE ImageHandle
,
682 IN EFI_SYSTEM_TABLE
*SystemTable
686 EFI_STATUS SavedStatus
;
687 EFI_HII_PACKAGE_LIST_HEADER
*PackageList
;
688 EFI_HII_HANDLE HiiHandle
[2];
689 EFI_HANDLE DriverHandle
[2];
690 DRIVER_SAMPLE_PRIVATE_DATA
*PrivateData
;
691 EFI_SCREEN_DESCRIPTOR Screen
;
692 EFI_HII_DATABASE_PROTOCOL
*HiiDatabase
;
693 EFI_HII_STRING_PROTOCOL
*HiiString
;
694 EFI_FORM_BROWSER2_PROTOCOL
*FormBrowser2
;
695 EFI_HII_CONFIG_ROUTING_PROTOCOL
*HiiConfigRouting
;
698 DRIVER_SAMPLE_CONFIGURATION
*Configuration
;
699 BOOLEAN ExtractIfrDefault
;
702 // Initialize the library and our protocol.
706 // Initialize screen dimensions for SendForm().
707 // Remove 3 characters from top and bottom
709 ZeroMem (&Screen
, sizeof (EFI_SCREEN_DESCRIPTOR
));
710 gST
->ConOut
->QueryMode (gST
->ConOut
, gST
->ConOut
->Mode
->Mode
, &Screen
.RightColumn
, &Screen
.BottomRow
);
713 Screen
.BottomRow
= Screen
.BottomRow
- 3;
716 // Initialize driver private data
718 PrivateData
= AllocatePool (sizeof (DRIVER_SAMPLE_PRIVATE_DATA
));
719 if (PrivateData
== NULL
) {
720 return EFI_OUT_OF_RESOURCES
;
723 PrivateData
->Signature
= DRIVER_SAMPLE_PRIVATE_SIGNATURE
;
725 PrivateData
->ConfigAccess
.ExtractConfig
= ExtractConfig
;
726 PrivateData
->ConfigAccess
.RouteConfig
= RouteConfig
;
727 PrivateData
->ConfigAccess
.Callback
= DriverCallback
;
728 PrivateData
->PasswordState
= BROWSER_STATE_VALIDATE_PASSWORD
;
731 // Locate Hii Database protocol
733 Status
= gBS
->LocateProtocol (&gEfiHiiDatabaseProtocolGuid
, NULL
, (VOID
**) &HiiDatabase
);
734 if (EFI_ERROR (Status
)) {
737 PrivateData
->HiiDatabase
= HiiDatabase
;
740 // Locate HiiString protocol
742 Status
= gBS
->LocateProtocol (&gEfiHiiStringProtocolGuid
, NULL
, (VOID
**) &HiiString
);
743 if (EFI_ERROR (Status
)) {
746 PrivateData
->HiiString
= HiiString
;
749 // Locate Formbrowser2 protocol
751 Status
= gBS
->LocateProtocol (&gEfiFormBrowser2ProtocolGuid
, NULL
, (VOID
**) &FormBrowser2
);
752 if (EFI_ERROR (Status
)) {
755 PrivateData
->FormBrowser2
= FormBrowser2
;
758 // Locate ConfigRouting protocol
760 Status
= gBS
->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid
, NULL
, (VOID
**) &HiiConfigRouting
);
761 if (EFI_ERROR (Status
)) {
764 PrivateData
->HiiConfigRouting
= HiiConfigRouting
;
767 // Install Config Access protocol
769 Status
= HiiLibCreateHiiDriverHandle (&DriverHandle
[0]);
770 if (EFI_ERROR (Status
)) {
773 PrivateData
->DriverHandle
[0] = DriverHandle
[0];
775 Status
= gBS
->InstallProtocolInterface (
777 &gEfiHiiConfigAccessProtocolGuid
,
778 EFI_NATIVE_INTERFACE
,
779 &PrivateData
->ConfigAccess
781 ASSERT_EFI_ERROR (Status
);
784 // Publish our HII data
786 PackageList
= HiiLibPreparePackageList (
792 if (PackageList
== NULL
) {
793 return EFI_OUT_OF_RESOURCES
;
796 Status
= HiiDatabase
->NewPackageList (
802 FreePool (PackageList
);
803 if (EFI_ERROR (Status
)) {
806 PrivateData
->HiiHandle
[0] = HiiHandle
[0];
809 // Publish another Fromset
811 Status
= HiiLibCreateHiiDriverHandle (&DriverHandle
[1]);
812 if (EFI_ERROR (Status
)) {
815 PrivateData
->DriverHandle
[1] = DriverHandle
[1];
817 PackageList
= HiiLibPreparePackageList (
823 if (PackageList
== NULL
) {
824 return EFI_OUT_OF_RESOURCES
;
827 Status
= HiiDatabase
->NewPackageList (
833 FreePool (PackageList
);
834 if (EFI_ERROR (Status
)) {
837 PrivateData
->HiiHandle
[1] = HiiHandle
[1];
840 // Very simple example of how one would update a string that is already
841 // in the HII database
843 NewString
= L
"700 Mhz";
845 Status
= HiiLibSetString (HiiHandle
[0], STRING_TOKEN (STR_CPU_STRING2
), NewString
);
846 if (EFI_ERROR (Status
)) {
851 // Initialize configuration data
853 Configuration
= &PrivateData
->Configuration
;
854 ZeroMem (Configuration
, sizeof (DRIVER_SAMPLE_CONFIGURATION
));
857 // Try to read NV config EFI variable first
859 ExtractIfrDefault
= TRUE
;
860 BufferSize
= sizeof (DRIVER_SAMPLE_CONFIGURATION
);
861 Status
= gRT
->GetVariable (VariableName
, &mFormSetGuid
, NULL
, &BufferSize
, Configuration
);
862 if (!EFI_ERROR (Status
) && (BufferSize
== sizeof (DRIVER_SAMPLE_CONFIGURATION
))) {
863 ExtractIfrDefault
= FALSE
;
866 if (ExtractIfrDefault
) {
868 // EFI variable for NV config doesn't exit, we should build this variable
869 // based on default values stored in IFR
871 BufferSize
= sizeof (DRIVER_SAMPLE_CONFIGURATION
);
872 Status
= IfrLibExtractDefault (Configuration
, &BufferSize
, 1, VfrMyIfrNVDataDefault0000
);
874 if (!EFI_ERROR (Status
)) {
878 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,
879 sizeof (DRIVER_SAMPLE_CONFIGURATION
),
886 // Example of how to display only the item we sent to HII
888 if (DISPLAY_ONLY_MY_ITEM
== 0x0001) {
890 // Have the browser pull out our copy of the data, and only display our data
892 // Status = FormConfig->SendForm (FormConfig, TRUE, HiiHandle, NULL, NULL, NULL, &Screen, NULL);
894 Status
= FormBrowser2
->SendForm (
903 SavedStatus
= Status
;
905 Status
= HiiDatabase
->RemovePackageList (HiiDatabase
, HiiHandle
[0]);
906 if (EFI_ERROR (Status
)) {
910 Status
= HiiDatabase
->RemovePackageList (HiiDatabase
, HiiHandle
[1]);
911 if (EFI_ERROR (Status
)) {
918 // Have the browser pull out all the data in the HII Database and display it.
920 // Status = FormConfig->SendForm (FormConfig, TRUE, 0, NULL, NULL, NULL, NULL, NULL);