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
->ThunkContext
->NvMapOverride
== NULL
) {
455 if (ConfigAccess
->FormCallbackProtocol
== NULL
||
456 ConfigAccess
->FormCallbackProtocol
->NvRead
== NULL
) {
457 Status
= GetUefiVariable (
463 Status
= CallFormCallBack (
465 ConfigAccess
->FormCallbackProtocol
,
471 DataSize
= BufferStorage
->Size
;
472 Data
= AllocateCopyPool (DataSize
, ConfigAccess
->ThunkContext
->NvMapOverride
);
475 Status
= EFI_SUCCESS
;
477 Status
= EFI_OUT_OF_RESOURCES
;
481 if (!EFI_ERROR (Status
)) {
482 Status
= mHiiConfigRoutingProtocol
->BlockToConfig (
483 mHiiConfigRoutingProtocol
,
498 This function implement the EFI_HII_CONFIG_ACCESS_PROTOCOL.RouteConfig
499 so that data can be written to the data storage such as UEFI Variable or module's
500 customized storage exposed by EFI_FRAMEWORK_CALLBACK.
502 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL
503 @param Configuration A null-terminated Unicode string in <ConfigResp> format.
504 @param Progress A pointer to a string filled in with the offset of the most recent '&' before the first
505 failing name / value pair (or the beginning of the string if the failure is in the first
506 name / value pair) or the terminating NULL if all was successful.
508 @retval EFI_INVALID_PARAMETER If there is no Buffer Storage for this Config Access instance.
509 @retval EFI_SUCCESS The setting is saved successfully.
510 @retval !EFI_SUCCESS The error returned by UEFI Set Variable or Framework Form Callback Nvwrite.
515 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
516 IN CONST EFI_STRING Configuration
,
517 OUT EFI_STRING
*Progress
521 CONFIG_ACCESS_PRIVATE
*ConfigAccess
;
523 BUFFER_STORAGE_ENTRY
*BufferStorage
;
527 UINTN LastModifiedByteIndex
;
528 BOOLEAN ResetRequired
;
529 BOOLEAN DataAllocated
;
532 ConfigAccess
= CONFIG_ACCESS_PRIVATE_FROM_PROTOCOL (This
);
535 // For now, only one var varstore is supported so that we don't need to parse the Configuration string.
537 Link
= GetFirstNode (&ConfigAccess
->BufferStorageListHead
);
540 return EFI_INVALID_PARAMETER
;
543 BufferStorage
= BUFFER_STORAGE_ENTRY_FROM_LINK (Link
);
544 DataSize2
= BufferStorage
->Size
;
545 if (ConfigAccess
->ThunkContext
->NvMapOverride
== NULL
) {
546 DataAllocated
= TRUE
;
547 if (ConfigAccess
->FormCallbackProtocol
== NULL
||
548 ConfigAccess
->FormCallbackProtocol
->NvRead
== NULL
) {
549 Status
= GetUefiVariable (
555 Status
= CallFormCallBack (
557 ConfigAccess
->FormCallbackProtocol
,
564 // ConfigToBlock will convert the Config String and update the NvMapOverride accordingly.
566 Status
= EFI_SUCCESS
;
567 Data
= ConfigAccess
->ThunkContext
->NvMapOverride
;
568 DataSize
= DataSize2
;
569 DataAllocated
= FALSE
;
571 if (EFI_ERROR (Status
) || (DataSize2
!= DataSize
)) {
573 Data
= AllocateZeroPool (DataSize2
);
577 Status
= mHiiConfigRoutingProtocol
->ConfigToBlock (
578 mHiiConfigRoutingProtocol
,
581 &LastModifiedByteIndex
,
584 if (EFI_ERROR (Status
)) {
588 if (ConfigAccess
->ThunkContext
->NvMapOverride
== NULL
) {
589 if (ConfigAccess
->FormCallbackProtocol
== NULL
||
590 ConfigAccess
->FormCallbackProtocol
->NvWrite
== NULL
) {
591 Status
= gRT
->SetVariable (
593 &BufferStorage
->Guid
,
594 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_RUNTIME_ACCESS
,
599 Status
= ConfigAccess
->FormCallbackProtocol
->NvWrite (
600 ConfigAccess
->FormCallbackProtocol
,
602 &BufferStorage
->Guid
,
603 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_RUNTIME_ACCESS
,
613 if (DataAllocated
&& (Data
!= NULL
)) {
620 FRAMEWORK_EFI_IFR_DATA_ARRAY
*
622 IN CONFIG_ACCESS_PRIVATE
*ConfigAccess
,
623 IN EFI_QUESTION_ID QuestionId
,
625 IN EFI_IFR_TYPE_VALUE
*Value
,
626 OUT BOOLEAN
*NvMapAllocated
629 FRAMEWORK_EFI_IFR_DATA_ARRAY
*IfrDataArray
;
630 FRAMEWORK_EFI_IFR_DATA_ENTRY
*IfrDataEntry
;
631 UINTN BrowserDataSize
;
632 BUFFER_STORAGE_ENTRY
*BufferStorageEntry
;
636 IfrDataArray
= AllocateZeroPool (0x100);
637 ASSERT (IfrDataArray
!= NULL
);
639 Link
= GetFirstNode (&ConfigAccess
->BufferStorageListHead
);
640 ASSERT (!IsNull (&ConfigAccess
->BufferStorageListHead
, Link
));
642 BufferStorageEntry
= BUFFER_STORAGE_ENTRY_FROM_LINK(Link
);
643 BrowserDataSize
= BufferStorageEntry
->Size
;
645 if (ConfigAccess
->ThunkContext
->NvMapOverride
== NULL
) {
646 *NvMapAllocated
= TRUE
;
647 IfrDataArray
->NvRamMap
= AllocateZeroPool (BrowserDataSize
);
649 *NvMapAllocated
= FALSE
;
650 IfrDataArray
->NvRamMap
= ConfigAccess
->ThunkContext
->NvMapOverride
;
653 Status
= GetBrowserData (NULL
, NULL
, &BrowserDataSize
, IfrDataArray
->NvRamMap
);
654 ASSERT_EFI_ERROR (Status
);
656 IfrDataEntry
= (FRAMEWORK_EFI_IFR_DATA_ENTRY
*) (IfrDataArray
+ 1);
659 case EFI_IFR_TYPE_NUM_SIZE_8
:
660 case EFI_IFR_TYPE_NUM_SIZE_16
:
661 case EFI_IFR_TYPE_NUM_SIZE_32
:
662 case EFI_IFR_TYPE_NUM_SIZE_64
:
663 case EFI_IFR_TYPE_BOOLEAN
:
664 CopyMem (&IfrDataEntry
->Data
, &(Value
->u8
), sizeof (*Value
));
676 SyncBrowserDataForNvMapOverride (
677 IN CONFIG_ACCESS_PRIVATE
*ConfigAccess
680 BUFFER_STORAGE_ENTRY
*BufferStorageEntry
;
683 UINTN BrowserDataSize
;
685 if (ConfigAccess
->ThunkContext
->NvMapOverride
!= NULL
) {
687 Link
= GetFirstNode (&ConfigAccess
->BufferStorageListHead
);
688 ASSERT (!IsNull (&ConfigAccess
->BufferStorageListHead
, Link
));
690 BufferStorageEntry
= BUFFER_STORAGE_ENTRY_FROM_LINK(Link
);
691 BrowserDataSize
= BufferStorageEntry
->Size
;
693 Status
= SetBrowserData (NULL
, NULL
, BrowserDataSize
, ConfigAccess
->ThunkContext
->NvMapOverride
, NULL
);
694 ASSERT_EFI_ERROR (Status
);
700 DestroyIfrDataArray (
701 IN FRAMEWORK_EFI_IFR_DATA_ARRAY
*Array
,
702 IN BOOLEAN NvMapAllocated
705 if (NvMapAllocated
) {
706 FreePool (Array
->NvRamMap
);
713 ONE_OF_OPTION_MAP_ENTRY
*
714 GetOneOfOptionMapEntry (
715 IN HII_THUNK_CONTEXT
*ThunkContext
,
716 IN EFI_QUESTION_ID QuestionId
,
718 IN EFI_IFR_TYPE_VALUE
*Value
723 ONE_OF_OPTION_MAP_ENTRY
*OneOfOptionMapEntry
;
724 ONE_OF_OPTION_MAP
*OneOfOptionMap
;
726 Link
= GetFirstNode (&ThunkContext
->OneOfOptionMapListHead
);
728 while (!IsNull (&ThunkContext
->OneOfOptionMapListHead
, Link
)) {
729 OneOfOptionMap
= ONE_OF_OPTION_MAP_FROM_LINK(Link
);
730 if (OneOfOptionMap
->QuestionId
== QuestionId
) {
731 ASSERT (OneOfOptionMap
->ValueType
== Type
);
733 Link2
= GetFirstNode (&OneOfOptionMap
->OneOfOptionMapEntryListHead
);
735 while (!IsNull (&OneOfOptionMap
->OneOfOptionMapEntryListHead
, Link2
)) {
736 OneOfOptionMapEntry
= ONE_OF_OPTION_MAP_ENTRY_FROM_LINK (Link2
);
738 if (CompareMem (Value
, &OneOfOptionMapEntry
->Value
, sizeof (EFI_IFR_TYPE_VALUE
)) == 0) {
739 return OneOfOptionMapEntry
;
742 Link2
= GetNextNode (&OneOfOptionMap
->OneOfOptionMapEntryListHead
, Link2
);
746 Link
= GetNextNode (&ThunkContext
->OneOfOptionMapListHead
, Link
);
754 Functions which are registered to receive notification of
755 database events have this prototype. The actual event is encoded
756 in NotifyType. The following table describes how PackageType,
757 PackageGuid, Handle, and Package are used for each of the
760 @param PackageType Package type of the notification.
762 @param PackageGuid If PackageType is
763 EFI_HII_PACKAGE_TYPE_GUID, then this is
764 the pointer to the GUID from the Guid
765 field of EFI_HII_PACKAGE_GUID_HEADER.
766 Otherwise, it must be NULL.
768 @param Package Points to the package referred to by the
769 notification Handle The handle of the package
770 list which contains the specified package.
772 @param Handle The HII handle.
774 @param NotifyType The type of change concerning the
776 EFI_HII_DATABASE_NOTIFY_TYPE.
782 IN UINT8 PackageType
,
783 IN CONST EFI_GUID
*PackageGuid
,
784 IN CONST EFI_HII_PACKAGE_HEADER
*Package
,
785 IN EFI_HII_HANDLE Handle
,
786 IN EFI_HII_DATABASE_NOTIFY_TYPE NotifyType
789 mHiiPackageListUpdated
= TRUE
;
795 Wrap the EFI_HII_CONFIG_ACCESS_PROTOCOL.CallBack to EFI_FORM_CALLBACK_PROTOCOL.Callback. Therefor,
796 the framework HII module willl do no porting (except some porting works needed for callback for EFI_ONE_OF_OPTION opcode)
797 and still work with a UEFI HII SetupBrowser.
799 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
800 @param Action Specifies the type of action taken by the browser. See EFI_BROWSER_ACTION_x.
801 @param QuestionId A unique value which is sent to the original exporting driver so that it can identify the
802 type of data to expect. The format of the data tends to vary based on the opcode that
803 generated the callback.
804 @param Type The type of value for the question. See EFI_IFR_TYPE_x in
805 EFI_IFR_ONE_OF_OPTION.
806 @param Value A pointer to the data being sent to the original exporting driver. The type is specified
807 by Type. Type EFI_IFR_TYPE_VALUE is defined in
808 EFI_IFR_ONE_OF_OPTION.
809 @param ActionRequest On return, points to the action requested by the callback function. Type
810 EFI_BROWSER_ACTION_REQUEST is specified in SendForm() in the Form
813 @retval EFI_UNSUPPORTED If the Framework HII module does not register Callback although it specify the opcode under
814 focuse to be INTERRACTIVE.
815 @retval EFI_SUCCESS The callback complete successfully.
816 @retval !EFI_SUCCESS The error code returned by EFI_FORM_CALLBACK_PROTOCOL.Callback.
822 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
823 IN EFI_BROWSER_ACTION Action
,
824 IN EFI_QUESTION_ID QuestionId
,
826 IN EFI_IFR_TYPE_VALUE
*Value
,
827 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
831 CONFIG_ACCESS_PRIVATE
*ConfigAccess
;
832 EFI_FORM_CALLBACK_PROTOCOL
*FormCallbackProtocol
;
833 EFI_HII_CALLBACK_PACKET
*Packet
;
834 FRAMEWORK_EFI_IFR_DATA_ARRAY
*Data
;
835 FRAMEWORK_EFI_IFR_DATA_ENTRY
*DataEntry
;
837 ONE_OF_OPTION_MAP_ENTRY
*OneOfOptionMapEntry
;
838 EFI_HANDLE NotifyHandle
;
840 BOOLEAN NvMapAllocated
;
842 ASSERT (This
!= NULL
);
843 ASSERT (Value
!= NULL
);
844 ASSERT (ActionRequest
!= NULL
);
846 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
848 ConfigAccess
= CONFIG_ACCESS_PRIVATE_FROM_PROTOCOL (This
);
850 FormCallbackProtocol
= ConfigAccess
->FormCallbackProtocol
;
851 if (FormCallbackProtocol
== NULL
) {
853 return EFI_UNSUPPORTED
;
857 // Check if the QuestionId match a OneOfOption.
859 OneOfOptionMapEntry
= GetOneOfOptionMapEntry (ConfigAccess
->ThunkContext
, QuestionId
, Type
, Value
);
861 if (OneOfOptionMapEntry
== NULL
) {
863 // This is not a One-Of-Option opcode. QuestionId is the KeyValue
865 KeyValue
= QuestionId
;
867 KeyValue
= OneOfOptionMapEntry
->FwKey
;
871 // Build the FRAMEWORK_EFI_IFR_DATA_ARRAY
873 Data
= CreateIfrDataArray (ConfigAccess
, QuestionId
, Type
, Value
, &NvMapAllocated
);
875 Status
= mHiiDatabase
->RegisterPackageNotify (
877 EFI_HII_PACKAGE_FORM
,
880 EFI_HII_DATABASE_NOTIFY_REMOVE_PACK
,
887 Status
= FormCallbackProtocol
->Callback (
888 FormCallbackProtocol
,
893 SyncBrowserDataForNvMapOverride (ConfigAccess
);
896 // Callback require browser to perform action
898 if (EFI_ERROR (Status
)) {
899 if (Packet
!= NULL
) {
901 // BUGBUG: need to restore the changing question to default value
905 IfrLibCreatePopUp (1, &Key
, Packet
->String
);
907 } while (Key
.UnicodeChar
!= CHAR_CARRIAGE_RETURN
);
912 // Error Code in Status is discarded.
915 if (Packet
!= NULL
) {
916 if (Packet
->DataArray
.EntryCount
== 1 && Packet
->DataArray
.NvRamMap
== NULL
) {
917 DataEntry
= (FRAMEWORK_EFI_IFR_DATA_ENTRY
*) ((UINT8
*) Packet
+ sizeof (FRAMEWORK_EFI_IFR_DATA_ARRAY
));
918 if ((DataEntry
->Flags
& EXIT_REQUIRED
) == EXIT_REQUIRED
) {
919 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_EXIT
;
922 if ((DataEntry
->Flags
& SAVE_REQUIRED
) == SAVE_REQUIRED
) {
923 Status
= ConfigAccess
->ConfigAccessProtocol
.RouteConfig (
924 &ConfigAccess
->ConfigAccessProtocol
,
935 // Unregister notify for Form package update
937 Status
= mHiiDatabase
->UnregisterPackageNotify (
942 // UEFI SetupBrowser handles scenario differently with Framework SetupBrowser when call back function
943 // update any forms in HII database. UEFI SetupBrowser will re-parse the displaying form package and load
944 // the values from variable storages. Framework SetupBrowser will only re-parse the displaying form packages.
945 // To make sure customer's previous changes is saved and the changing question behaves as expected, we
946 // issue a EFI_BROWSER_ACTION_REQUEST_SUBMIT to ask UEFI SetupBrowser to save the changes proceed to re-parse
947 // the form and load all the variable storages.
949 if (*ActionRequest
== EFI_BROWSER_ACTION_REQUEST_NONE
&& mHiiPackageListUpdated
) {
950 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_SUBMIT
;
953 DestroyIfrDataArray (Data
, NvMapAllocated
);