2 This file contains functions related to Config Access Protocols installed by
3 by HII Thunk Modules which is used to thunk UEFI Config Access Callback to
4 Framework HII Callback.
6 Copyright (c) 2008, Intel Corporation
7 All rights reserved. This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #include "HiiDatabase.h"
19 BOOLEAN mHiiPackageListUpdated
;
21 CONFIG_ACCESS_PRIVATE gConfigAccessPrivateTempate
= {
22 CONFIG_ACCESS_PRIVATE_SIGNATURE
,
27 }, //ConfigAccessProtocol
28 NULL
, //FormCallbackProtocol
29 {NULL
, NULL
}, //ConfigAccessStorageListHead
34 Find and return the pointer to Package Header of the Form package
35 in the Framework Package List. The Framework Package List is created
36 by a module calling the Framework HII interface.
37 The Framwork Package List contains package data
38 generated by Intel's UEFI VFR Compiler and String gather tool. The data format
39 of the package data is defined by TIANO_AUTOGEN_PACKAGES_HEADER.
41 If the package list contains other type of packages such as KEYBOARD_LAYOUT,
42 FONTS and IMAGES, the ASSERT. This is to make sure the caller is a
43 Framework Module which does not include packages introduced by UEFI Specification
44 or packages that is not supported by Thunk layer.
46 @param Packages The Framework Package List
48 @retval EFI_HII_PACKAGE_HEADER* Return the Package Header of Form Package.
49 @retval NULL If no Form Package is found.
51 EFI_HII_PACKAGE_HEADER
*
53 IN CONST EFI_HII_PACKAGES
*Packages
56 TIANO_AUTOGEN_PACKAGES_HEADER
**TianoAutogenPackageHdrArray
;
57 EFI_HII_PACKAGE_HEADER
*IfrPackage
;
60 ASSERT (Packages
!= NULL
);
64 TianoAutogenPackageHdrArray
= (TIANO_AUTOGEN_PACKAGES_HEADER
**) (((UINT8
*) &Packages
->GuidId
) + sizeof (Packages
->GuidId
));
65 for (Index
= 0; Index
< Packages
->NumberOfPackages
; Index
++) {
67 // BugBug: The current UEFI HII build tool generate a binary in the format defined in:
68 // TIANO_AUTOGEN_PACKAGES_HEADER. We assume that all packages generated in
69 // this binary is with same package type. So the returned IfrPackNum and StringPackNum
70 // may not be the exact number of valid package number in the binary generated
73 switch (TianoAutogenPackageHdrArray
[Index
]->PackageHeader
.Type
) {
74 case EFI_HII_PACKAGE_FORM
:
75 return &TianoAutogenPackageHdrArray
[Index
]->PackageHeader
;
78 case EFI_HII_PACKAGE_STRINGS
:
79 case EFI_HII_PACKAGE_SIMPLE_FONTS
:
83 // The following fonts are invalid for a module that using Framework to UEFI thunk layer.
85 case EFI_HII_PACKAGE_KEYBOARD_LAYOUT
:
86 case EFI_HII_PACKAGE_FONTS
:
87 case EFI_HII_PACKAGE_IMAGES
:
94 return (EFI_HII_PACKAGE_HEADER
*) NULL
;
98 This function scan EFI_IFR_VARSTORE_OP in the Form Package.
99 It create entries for these VARSTORE found and append the entry
102 If FormSetPackage is not EFI_HII_PACKAGE_FORM, then ASSERT.
103 If there is no linear buffer storage in this formset, then ASSERT.
105 @param FormSetPackage The Form Package header.
106 @param BufferStorageListHead The link list for the VARSTORE found in the form package.
108 @retval EFI_SUCCESS The function scan the form set and find one or more VARSTOREs.
109 @retval EFI_OUT_OF_RESOURCES There is not enough memory to complete the function.
113 IN CONST EFI_HII_PACKAGE_HEADER
*FormSetPackage
,
114 OUT LIST_ENTRY
*BufferStorageListHead
121 EFI_IFR_VARSTORE
*VarStoreOpCode
;
122 BUFFER_STORAGE_ENTRY
*BufferStorage
;
124 ASSERT (FormSetPackage
->Type
== EFI_HII_PACKAGE_FORM
);
126 OpCodeOffset
= sizeof (EFI_HII_PACKAGE_HEADER
);
128 // Scan all opcode for the FormSet Package for
129 // EFI_IFR_VARSTORE_OP opcode.
131 while (OpCodeOffset
< FormSetPackage
->Length
) {
132 OpCodeData
= (UINT8
*) FormSetPackage
+ OpCodeOffset
;
134 OpCodeLength
= ((EFI_IFR_OP_HEADER
*) OpCodeData
)->Length
;
135 OpCodeOffset
+= OpCodeLength
;
136 Operand
= ((EFI_IFR_OP_HEADER
*) OpCodeData
)->OpCode
;
138 if (Operand
== EFI_IFR_VARSTORE_OP
) {
139 VarStoreOpCode
= (EFI_IFR_VARSTORE
*)OpCodeData
;
140 BufferStorage
= AllocateZeroPool (sizeof (*BufferStorage
));
141 if (BufferStorage
== NULL
) {
142 return EFI_OUT_OF_RESOURCES
;
145 // Record the attributes: GUID, Name, VarStoreId and Size.
147 CopyMem (&BufferStorage
->Guid
, &VarStoreOpCode
->Guid
, sizeof (EFI_GUID
));
149 BufferStorage
->Name
= AllocateZeroPool (AsciiStrSize (VarStoreOpCode
->Name
) * 2);
150 AsciiStrToUnicodeStr (VarStoreOpCode
->Name
, BufferStorage
->Name
);
152 BufferStorage
->VarStoreId
= VarStoreOpCode
->VarStoreId
;
154 BufferStorage
->Size
= VarStoreOpCode
->Size
;
155 BufferStorage
->Signature
= BUFFER_STORAGE_ENTRY_SIGNATURE
;
157 InsertTailList (BufferStorageListHead
, &BufferStorage
->Link
);
166 This function installs a EFI_CONFIG_ACCESS_PROTOCOL instance for a form package registered
167 by a module using Framework HII Protocol Interfaces.
169 UEFI HII require EFI_HII_CONFIG_ACCESS_PROTOCOL to be installed on a EFI_HANDLE, so
170 that Setup Utility can load the Buffer Storage using this protocol.
172 @param Packages The framework package list.
173 @param ThunkContext The Thunk Layer Handle Mapping Database Entry.
175 @retval EFI_SUCCESS The Config Access Protocol is installed successfully.
176 @retval EFI_OUT_RESOURCE There is not enough memory.
180 InstallDefaultConfigAccessProtocol (
181 IN CONST EFI_HII_PACKAGES
*Packages
,
182 IN OUT HII_THUNK_CONTEXT
*ThunkContext
185 EFI_HII_PACKAGE_HEADER
*FormSetPackage
;
187 CONFIG_ACCESS_PRIVATE
*ConfigAccessInstance
;
189 Status
= HiiLibCreateHiiDriverHandle (&ThunkContext
->UefiHiiDriverHandle
);
190 ConfigAccessInstance
= AllocateCopyPool (
191 sizeof (CONFIG_ACCESS_PRIVATE
),
192 &gConfigAccessPrivateTempate
194 ASSERT (ConfigAccessInstance
!= NULL
);
196 InitializeListHead (&ConfigAccessInstance
->BufferStorageListHead
);
199 // We assume there is only one formset package in each Forms Package
201 FormSetPackage
= GetIfrFormSet (Packages
);
202 ASSERT (FormSetPackage
!= NULL
);
204 Status
= GetBufferStorage (FormSetPackage
, &ConfigAccessInstance
->BufferStorageListHead
);
205 if (EFI_ERROR (Status
)) {
206 FreePool (ConfigAccessInstance
);
211 Status
= gBS
->InstallMultipleProtocolInterfaces (
212 &ThunkContext
->UefiHiiDriverHandle
,
213 &gEfiHiiConfigAccessProtocolGuid
,
214 &ConfigAccessInstance
->ConfigAccessProtocol
,
218 //BUGBUG: Remove when done.
220 ASSERT_EFI_ERROR (Status
);
222 if (EFI_ERROR (Status
)) {
223 FreePool (ConfigAccessInstance
);
227 ConfigAccessInstance
->ThunkContext
= ThunkContext
;
233 DestroyBufferStorageList (
234 IN LIST_ENTRY
*ListHead
238 BUFFER_STORAGE_ENTRY
*Entry
;
240 while (!IsListEmpty (ListHead
)) {
241 Link
= GetFirstNode (ListHead
);
243 Entry
= BUFFER_STORAGE_ENTRY_FROM_LINK(Link
);
245 FreePool (Entry
->Name
);
246 Link
= RemoveEntryList (Link
);
253 UninstallDefaultConfigAccessProtocol (
254 IN HII_THUNK_CONTEXT
*ThunkContext
258 EFI_HII_CONFIG_ACCESS_PROTOCOL
*ConfigAccess
;
259 CONFIG_ACCESS_PRIVATE
*ConfigAccessInstance
;
261 HiiLibDestroyHiiDriverHandle (ThunkContext
->UefiHiiDriverHandle
);
263 Status
= gBS
->HandleProtocol (
264 ThunkContext
->UefiHiiDriverHandle
,
265 &gEfiHiiConfigAccessProtocolGuid
,
266 (VOID
**) &ConfigAccess
269 ASSERT_EFI_ERROR (Status
);
271 Status
= gBS
->UninstallProtocolInterface (
272 ThunkContext
->UefiHiiDriverHandle
,
273 &gEfiHiiConfigAccessProtocolGuid
,
276 ASSERT_EFI_ERROR (Status
);
278 ConfigAccessInstance
= CONFIG_ACCESS_PRIVATE_FROM_PROTOCOL (ConfigAccess
);
280 DestroyBufferStorageList (&ConfigAccessInstance
->BufferStorageListHead
);
286 Wrap the EFI_HII_CONFIG_ACCESS_PROTOCOL.ExtractConfig to a call to EFI_FORM_CALLBACK_PROTOCOL.NvRead.
288 @param BufferStorage The key with all attributes needed to call EFI_FORM_CALLBACK_PROTOCOL.NvRead.
289 @param FwFormCallBack The EFI_FORM_CALLBACK_PROTOCOL registered by Framework HII module.
290 @param Data The data read.
291 @param DataSize The size of data.
293 @retval EFI_STATUS The status returned by the EFI_FORM_CALLBACK_PROTOCOL.NvWrite.
294 @retval EFI_INVALID_PARAMETER If the EFI_FORM_CALLBACK_PROTOCOL.NvRead return the size information of the data
295 does not match what has been recorded early in he BUFFER_STORAGE_ENTRY.
299 IN BUFFER_STORAGE_ENTRY
*BufferStorage
,
300 IN EFI_FORM_CALLBACK_PROTOCOL
*FwFormCallBack
,
310 Status
= FwFormCallBack
->NvRead (
313 &BufferStorage
->Guid
,
318 if (Status
== EFI_BUFFER_TOO_SMALL
) {
319 if (BufferStorage
->Size
!= *DataSize
) {
321 return EFI_INVALID_PARAMETER
;
324 *Data
= AllocateZeroPool (*DataSize
);
326 return EFI_OUT_OF_RESOURCES
;
329 FwFormCallBack
->NvRead (
332 &BufferStorage
->Guid
,
344 Wrap the EFI_HII_CONFIG_ACCESS_PROTOCOL.ExtractConfig to a call to UEFI Variable Get Service.
346 @param BufferStorage The key with all attributes needed to call a UEFI Variable Get Service.
347 @param Data The data read.
348 @param DataSize The size of data.
350 If the UEFI Variable Get Service return the size information of the data
351 does not match what has been recorded early in he BUFFER_STORAGE_ENTRY.
354 @retval EFI_STATUS The status returned by the UEFI Variable Get Service.
355 @retval EFI_INVALID_PARAMETER If the UEFI Variable Get Service return the size information of the data
356 does not match what has been recorded early in he BUFFER_STORAGE_ENTRY.
361 IN BUFFER_STORAGE_ENTRY
*BufferStorage
,
370 Status
= gRT
->GetVariable (
372 &BufferStorage
->Guid
,
377 if (Status
== EFI_BUFFER_TOO_SMALL
) {
379 if (BufferStorage
->Size
!= *DataSize
) {
381 return EFI_INVALID_PARAMETER
;
384 *Data
= AllocateZeroPool (*DataSize
);
386 return EFI_OUT_OF_RESOURCES
;
389 Status
= gRT
->GetVariable (
391 &BufferStorage
->Guid
,
403 This function implement the EFI_HII_CONFIG_ACCESS_PROTOCOL.ExtractConfig
404 so that data can be read from the data storage such as UEFI Variable or module's
405 customized storage exposed by EFI_FRAMEWORK_CALLBACK.
407 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL
408 @param Request A null-terminated Unicode string in <ConfigRequest> format. Note that this
409 includes the routing information as well as the configurable name / value pairs. It is
410 invalid for this string to be in <MultiConfigRequest> format.
412 @param Progress On return, points to a character in the Request string. Points to the string's null
413 terminator if request was successful. Points to the most recent '&' before the first
414 failing name / value pair (or the beginning of the string if the failure is in the first
415 name / value pair) if the request was not successful
416 @param Results A null-terminated Unicode string in <ConfigAltResp> format which has all
417 values filled in for the names in the Request string. String to be allocated by the called
420 @retval EFI_INVALID_PARAMETER If there is no Buffer Storage for this Config Access instance.
421 @retval EFI_SUCCESS The setting is retrived successfully.
422 @retval !EFI_SUCCESS The error returned by UEFI Get Variable or Framework Form Callback Nvread.
427 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
428 IN CONST EFI_STRING Request
,
429 OUT EFI_STRING
*Progress
,
430 OUT EFI_STRING
*Results
434 CONFIG_ACCESS_PRIVATE
*ConfigAccess
;
436 BUFFER_STORAGE_ENTRY
*BufferStorage
;
441 ConfigAccess
= CONFIG_ACCESS_PRIVATE_FROM_PROTOCOL (This
);
444 // For now, only one var varstore is supported so that we don't need to parse the Configuration string.
446 Link
= GetFirstNode (&ConfigAccess
->BufferStorageListHead
);
449 return EFI_INVALID_PARAMETER
;
452 BufferStorage
= BUFFER_STORAGE_ENTRY_FROM_LINK (Link
);
454 if (ConfigAccess
->FormCallbackProtocol
== NULL
||
455 ConfigAccess
->FormCallbackProtocol
->NvRead
== NULL
) {
456 Status
= GetUefiVariable (
462 Status
= CallFormCallBack (
464 ConfigAccess
->FormCallbackProtocol
,
470 if (!EFI_ERROR (Status
)) {
471 Status
= mHiiConfigRoutingProtocol
->BlockToConfig (
472 mHiiConfigRoutingProtocol
,
487 This function implement the EFI_HII_CONFIG_ACCESS_PROTOCOL.RouteConfig
488 so that data can be written to the data storage such as UEFI Variable or module's
489 customized storage exposed by EFI_FRAMEWORK_CALLBACK.
491 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL
492 @param Configuration A null-terminated Unicode string in <ConfigResp> format.
493 @param Progress A pointer to a string filled in with the offset of the most recent '&' before the first
494 failing name / value pair (or the beginning of the string if the failure is in the first
495 name / value pair) or the terminating NULL if all was successful.
497 @retval EFI_INVALID_PARAMETER If there is no Buffer Storage for this Config Access instance.
498 @retval EFI_SUCCESS The setting is saved successfully.
499 @retval !EFI_SUCCESS The error returned by UEFI Set Variable or Framework Form Callback Nvwrite.
504 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
505 IN CONST EFI_STRING Configuration
,
506 OUT EFI_STRING
*Progress
510 CONFIG_ACCESS_PRIVATE
*ConfigAccess
;
512 BUFFER_STORAGE_ENTRY
*BufferStorage
;
516 UINTN LastModifiedByteIndex
;
517 BOOLEAN ResetRequired
;
518 BOOLEAN DataAllocated
;
521 DataAllocated
= TRUE
;
522 ConfigAccess
= CONFIG_ACCESS_PRIVATE_FROM_PROTOCOL (This
);
525 // For now, only one var varstore is supported so that we don't need to parse the Configuration string.
527 Link
= GetFirstNode (&ConfigAccess
->BufferStorageListHead
);
530 return EFI_INVALID_PARAMETER
;
533 BufferStorage
= BUFFER_STORAGE_ENTRY_FROM_LINK (Link
);
534 DataSize2
= BufferStorage
->Size
;
535 if (ConfigAccess
->ThunkContext
->NvMapOverride
== NULL
) {
536 if (ConfigAccess
->FormCallbackProtocol
== NULL
||
537 ConfigAccess
->FormCallbackProtocol
->NvRead
== NULL
) {
538 Status
= GetUefiVariable (
543 ASSERT (DataSize
== DataSize2
);
546 Status
= CallFormCallBack (
548 ConfigAccess
->FormCallbackProtocol
,
552 ASSERT (DataSize
== DataSize2
);
556 Status
= EFI_SUCCESS
;
557 Data
= ConfigAccess
->ThunkContext
->NvMapOverride
;
558 DataSize
= DataSize2
;
559 DataAllocated
= FALSE
;
561 if (EFI_ERROR (Status
)) {
565 Status
= mHiiConfigRoutingProtocol
->ConfigToBlock (
566 mHiiConfigRoutingProtocol
,
569 &LastModifiedByteIndex
,
572 if (EFI_ERROR (Status
)) {
576 if (ConfigAccess
->FormCallbackProtocol
== NULL
||
577 ConfigAccess
->FormCallbackProtocol
->NvWrite
== NULL
) {
578 Status
= gRT
->SetVariable (
580 &BufferStorage
->Guid
,
581 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_RUNTIME_ACCESS
,
586 Status
= ConfigAccess
->FormCallbackProtocol
->NvWrite (
587 ConfigAccess
->FormCallbackProtocol
,
589 &BufferStorage
->Guid
,
590 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_RUNTIME_ACCESS
,
599 if (DataAllocated
&& (Data
!= NULL
)) {
606 FRAMEWORK_EFI_IFR_DATA_ARRAY
*
608 IN CONFIG_ACCESS_PRIVATE
*ConfigAccess
,
609 IN EFI_QUESTION_ID QuestionId
,
611 IN EFI_IFR_TYPE_VALUE
*Value
,
612 OUT BOOLEAN
*NvMapAllocated
615 FRAMEWORK_EFI_IFR_DATA_ARRAY
*IfrDataArray
;
616 FRAMEWORK_EFI_IFR_DATA_ENTRY
*IfrDataEntry
;
617 UINTN BrowserDataSize
;
618 BUFFER_STORAGE_ENTRY
*BufferStorageEntry
;
621 IfrDataArray
= AllocateZeroPool (0x100);
622 ASSERT (IfrDataArray
!= NULL
);
624 if (ConfigAccess
->ThunkContext
->NvMapOverride
== NULL
) {
625 Link
= GetFirstNode (&ConfigAccess
->BufferStorageListHead
);
627 ASSERT (!IsNull (&ConfigAccess
->BufferStorageListHead
, Link
));
629 BufferStorageEntry
= BUFFER_STORAGE_ENTRY_FROM_LINK(Link
);
631 BrowserDataSize
= BufferStorageEntry
->Size
;
632 *NvMapAllocated
= TRUE
;
633 IfrDataArray
->NvRamMap
= AllocateZeroPool (BrowserDataSize
);
634 GetBrowserData (NULL
, NULL
, &BrowserDataSize
, IfrDataArray
->NvRamMap
);
636 *NvMapAllocated
= FALSE
;
637 IfrDataArray
->NvRamMap
= ConfigAccess
->ThunkContext
->NvMapOverride
;
640 IfrDataEntry
= (FRAMEWORK_EFI_IFR_DATA_ENTRY
*) (IfrDataArray
+ 1);
643 case EFI_IFR_TYPE_NUM_SIZE_8
:
644 case EFI_IFR_TYPE_NUM_SIZE_16
:
645 case EFI_IFR_TYPE_NUM_SIZE_32
:
646 case EFI_IFR_TYPE_NUM_SIZE_64
:
647 case EFI_IFR_TYPE_BOOLEAN
:
648 CopyMem (&IfrDataEntry
->Data
, &(Value
->u8
), sizeof (*Value
));
660 DestroyIfrDataArray (
661 IN FRAMEWORK_EFI_IFR_DATA_ARRAY
*Array
,
662 IN BOOLEAN NvMapAllocated
665 if (NvMapAllocated
) {
666 FreePool (Array
->NvRamMap
);
673 ONE_OF_OPTION_MAP_ENTRY
*
674 GetOneOfOptionMapEntry (
675 IN HII_THUNK_CONTEXT
*ThunkContext
,
676 IN EFI_QUESTION_ID QuestionId
,
678 IN EFI_IFR_TYPE_VALUE
*Value
683 ONE_OF_OPTION_MAP_ENTRY
*OneOfOptionMapEntry
;
684 ONE_OF_OPTION_MAP
*OneOfOptionMap
;
686 Link
= GetFirstNode (&ThunkContext
->OneOfOptionMapListHead
);
688 while (!IsNull (&ThunkContext
->OneOfOptionMapListHead
, Link
)) {
689 OneOfOptionMap
= ONE_OF_OPTION_MAP_FROM_LINK(Link
);
690 if (OneOfOptionMap
->QuestionId
== QuestionId
) {
691 ASSERT (OneOfOptionMap
->ValueType
== Type
);
693 Link2
= GetFirstNode (&OneOfOptionMap
->OneOfOptionMapEntryListHead
);
695 while (!IsNull (&OneOfOptionMap
->OneOfOptionMapEntryListHead
, Link2
)) {
696 OneOfOptionMapEntry
= ONE_OF_OPTION_MAP_ENTRY_FROM_LINK (Link2
);
698 if (CompareMem (Value
, &OneOfOptionMapEntry
->Value
, sizeof (EFI_IFR_TYPE_VALUE
)) == 0) {
699 return OneOfOptionMapEntry
;
702 Link2
= GetNextNode (&OneOfOptionMap
->OneOfOptionMapEntryListHead
, Link2
);
706 Link
= GetNextNode (&ThunkContext
->OneOfOptionMapListHead
, Link
);
714 Functions which are registered to receive notification of
715 database events have this prototype. The actual event is encoded
716 in NotifyType. The following table describes how PackageType,
717 PackageGuid, Handle, and Package are used for each of the
720 @param PackageType Package type of the notification.
722 @param PackageGuid If PackageType is
723 EFI_HII_PACKAGE_TYPE_GUID, then this is
724 the pointer to the GUID from the Guid
725 field of EFI_HII_PACKAGE_GUID_HEADER.
726 Otherwise, it must be NULL.
728 @param Package Points to the package referred to by the
729 notification Handle The handle of the package
730 list which contains the specified package.
732 @param Handle The HII handle.
734 @param NotifyType The type of change concerning the
736 EFI_HII_DATABASE_NOTIFY_TYPE.
742 IN UINT8 PackageType
,
743 IN CONST EFI_GUID
*PackageGuid
,
744 IN CONST EFI_HII_PACKAGE_HEADER
*Package
,
745 IN EFI_HII_HANDLE Handle
,
746 IN EFI_HII_DATABASE_NOTIFY_TYPE NotifyType
749 mHiiPackageListUpdated
= TRUE
;
755 Wrap the EFI_HII_CONFIG_ACCESS_PROTOCOL.CallBack to EFI_FORM_CALLBACK_PROTOCOL.Callback. Therefor,
756 the framework HII module willl do no porting (except some porting works needed for callback for EFI_ONE_OF_OPTION opcode)
757 and still work with a UEFI HII SetupBrowser.
759 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
760 @param Action Specifies the type of action taken by the browser. See EFI_BROWSER_ACTION_x.
761 @param QuestionId A unique value which is sent to the original exporting driver so that it can identify the
762 type of data to expect. The format of the data tends to vary based on the opcode that
763 generated the callback.
764 @param Type The type of value for the question. See EFI_IFR_TYPE_x in
765 EFI_IFR_ONE_OF_OPTION.
766 @param Value A pointer to the data being sent to the original exporting driver. The type is specified
767 by Type. Type EFI_IFR_TYPE_VALUE is defined in
768 EFI_IFR_ONE_OF_OPTION.
769 @param ActionRequest On return, points to the action requested by the callback function. Type
770 EFI_BROWSER_ACTION_REQUEST is specified in SendForm() in the Form
773 @retval EFI_UNSUPPORTED If the Framework HII module does not register Callback although it specify the opcode under
774 focuse to be INTERRACTIVE.
775 @retval EFI_SUCCESS The callback complete successfully.
776 @retval !EFI_SUCCESS The error code returned by EFI_FORM_CALLBACK_PROTOCOL.Callback.
782 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
783 IN EFI_BROWSER_ACTION Action
,
784 IN EFI_QUESTION_ID QuestionId
,
786 IN EFI_IFR_TYPE_VALUE
*Value
,
787 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
791 CONFIG_ACCESS_PRIVATE
*ConfigAccess
;
792 EFI_FORM_CALLBACK_PROTOCOL
*FormCallbackProtocol
;
793 EFI_HII_CALLBACK_PACKET
*Packet
;
794 FRAMEWORK_EFI_IFR_DATA_ARRAY
*Data
;
795 FRAMEWORK_EFI_IFR_DATA_ENTRY
*DataEntry
;
797 ONE_OF_OPTION_MAP_ENTRY
*OneOfOptionMapEntry
;
798 EFI_HANDLE NotifyHandle
;
800 BOOLEAN NvMapAllocated
;
802 ASSERT (This
!= NULL
);
803 ASSERT (Value
!= NULL
);
804 ASSERT (ActionRequest
!= NULL
);
806 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
808 ConfigAccess
= CONFIG_ACCESS_PRIVATE_FROM_PROTOCOL (This
);
810 FormCallbackProtocol
= ConfigAccess
->FormCallbackProtocol
;
811 if (FormCallbackProtocol
== NULL
) {
813 return EFI_UNSUPPORTED
;
817 // Check if the QuestionId match a OneOfOption.
819 OneOfOptionMapEntry
= GetOneOfOptionMapEntry (ConfigAccess
->ThunkContext
, QuestionId
, Type
, Value
);
821 if (OneOfOptionMapEntry
== NULL
) {
823 // This is not a One-Of-Option opcode. QuestionId is the KeyValue
825 KeyValue
= QuestionId
;
827 KeyValue
= OneOfOptionMapEntry
->FwKey
;
831 // Build the FRAMEWORK_EFI_IFR_DATA_ARRAY
833 Data
= CreateIfrDataArray (ConfigAccess
, QuestionId
, Type
, Value
, &NvMapAllocated
);
835 Status
= mHiiDatabase
->RegisterPackageNotify (
837 EFI_HII_PACKAGE_FORM
,
840 EFI_HII_DATABASE_NOTIFY_REMOVE_PACK
,
847 Status
= FormCallbackProtocol
->Callback (
848 FormCallbackProtocol
,
855 // Callback require browser to perform action
857 if (EFI_ERROR (Status
)) {
858 if (Packet
!= NULL
) {
860 // BUGBUG: need to restore the changing question to default value
864 IfrLibCreatePopUp (1, &Key
, Packet
->String
);
866 } while (Key
.UnicodeChar
!= CHAR_CARRIAGE_RETURN
);
871 // Error Code in Status is discarded.
874 if (Packet
!= NULL
) {
875 if (Packet
->DataArray
.EntryCount
== 1 && Packet
->DataArray
.NvRamMap
== NULL
) {
876 DataEntry
= (FRAMEWORK_EFI_IFR_DATA_ENTRY
*) ((UINT8
*) Packet
+ sizeof (FRAMEWORK_EFI_IFR_DATA_ARRAY
));
877 if ((DataEntry
->Flags
& EXIT_REQUIRED
) == EXIT_REQUIRED
) {
878 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_EXIT
;
881 if ((DataEntry
->Flags
& SAVE_REQUIRED
) == SAVE_REQUIRED
) {
882 Status
= ConfigAccess
->ConfigAccessProtocol
.RouteConfig (
883 &ConfigAccess
->ConfigAccessProtocol
,
894 // Unregister notify for Form package update
896 Status
= mHiiDatabase
->UnregisterPackageNotify (
901 // UEFI SetupBrowser handles scenario differently with Framework SetupBrowser when call back function
902 // update any forms in HII database. UEFI SetupBrowser will re-parse the displaying form package and load
903 // the values from variable storages. Framework SetupBrowser will only re-parse the displaying form packages.
904 // To make sure customer's previous changes is saved and the changing question behaves as expected, we
905 // issue a EFI_BROWSER_ACTION_REQUEST_SUBMIT to ask UEFI SetupBrowser to save the changes proceed to re-parse
906 // the form and load all the variable storages.
908 if (*ActionRequest
== EFI_BROWSER_ACTION_REQUEST_NONE
&& mHiiPackageListUpdated
) {
909 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_SUBMIT
;
912 DestroyIfrDataArray (Data
, NvMapAllocated
);