2 Implement protocol interface related to package registrations.
4 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include "HiiDatabase.h"
17 #include "HiiHandle.h"
20 BOOLEAN mInFrameworkHiiNewPack
= FALSE
;
21 BOOLEAN mInFrameworkHiiRemovePack
= FALSE
;
22 BOOLEAN mInFrameworkUpdatePakcage
= FALSE
;
23 UINT64 mGuidCount
= 0;
25 EFI_GUID mGuidBase
= { 0x14f95e01, 0xd562, 0x432e, { 0x84, 0x4a, 0x95, 0xa4, 0x39, 0x5, 0x10, 0x7e }};
30 Get the number of Form, STRING and Font packages in the package list passed in.
32 @param Packages Package List.
33 @param IfrPackageCount Number of IFR Packages.
34 @param StringPackageCount Number of String Packages.
35 @param FontPackageCount Number of Font Packages.
37 @retval EFI_INVALID_PARAMETER If the Package List has package with type of
38 EFI_HII_PACKAGE_KEYBOARD_LAYOUT, EFI_HII_PACKAGE_FONTS, EFI_HII_PACKAGE_IMAGES.
39 @retval EFI_SUCCESS Successfully get the number of IFR and STRING package.
45 IN CONST EFI_HII_PACKAGES
*Packages
,
46 OUT UINTN
*IfrPackageCount
,
47 OUT UINTN
*StringPackageCount
,
48 OUT UINTN
*FontPackageCount
52 TIANO_AUTOGEN_PACKAGES_HEADER
**TianoAutogenPackageHdrArray
;
54 ASSERT (Packages
!= NULL
);
55 ASSERT (IfrPackageCount
!= NULL
);
56 ASSERT (StringPackageCount
!= NULL
);
57 ASSERT (FontPackageCount
!= NULL
);
60 *StringPackageCount
= 0;
61 *FontPackageCount
= 0;
63 TianoAutogenPackageHdrArray
= (TIANO_AUTOGEN_PACKAGES_HEADER
**) (((UINT8
*) &Packages
->GuidId
) + sizeof (Packages
->GuidId
));
65 for (Index
= 0; Index
< Packages
->NumberOfPackages
; Index
++) {
67 // The current UEFI HII build tool generate a binary in the format defined by
68 // TIANO_AUTOGEN_PACKAGES_HEADER. We assume that all packages generated in
69 // this binary is with same package type. So the returned IfrPackageCount and StringPackageCount
70 // may not be the exact number of valid package number in the binary generated
73 switch (TianoAutogenPackageHdrArray
[Index
]->FrameworkPackageHeader
.Type
) {
75 *IfrPackageCount
+= 1;
78 *StringPackageCount
+= 1;
82 *FontPackageCount
+= 1;
86 // The following fonts are invalid for a module that using Framework to UEFI thunk layer.
90 return EFI_INVALID_PARAMETER
;
99 Insert the String Package into the Package Lists which has the TAG GUID matching
100 the PackageListGuid of the String Package.
102 The Package List must have only IFR Package and no String Package.
105 @param Private The HII THUNK driver context data.
106 @param StringPackageThunkContext The HII THUNK context data.
107 @param StringPackageListHeader The String Package List Header.
111 UpdatePackListWithOnlyIfrPack (
112 IN HII_THUNK_PRIVATE_DATA
*Private
,
113 IN HII_THUNK_CONTEXT
*StringPackageThunkContext
,
114 IN CONST EFI_HII_PACKAGE_LIST_HEADER
*StringPackageListHeader
119 HII_THUNK_CONTEXT
*ThunkContext
;
121 Link
= GetFirstNode (&Private
->ThunkContextListHead
);
122 while (!IsNull (&Private
->ThunkContextListHead
, Link
)) {
124 ThunkContext
= HII_THUNK_CONTEXT_FROM_LINK (Link
);
126 if (StringPackageThunkContext
!= ThunkContext
) {
128 // Skip the String Package Thunk Entry itself.
131 if (CompareGuid (&StringPackageListHeader
->PackageListGuid
, &ThunkContext
->TagGuid
)) {
133 ASSERT (ThunkContext
->StringPackageCount
== 0 && ThunkContext
->IfrPackageCount
== 1);
135 ThunkContext
->StringPackageCount
= GetPackageCountByType (StringPackageListHeader
, EFI_HII_PACKAGE_STRINGS
);
137 Status
= mHiiDatabase
->UpdatePackageList (
139 ThunkContext
->UefiHiiHandle
,
140 StringPackageListHeader
142 ASSERT_EFI_ERROR (Status
);
144 ThunkContext
->SharingStringPack
= TRUE
;
145 StringPackageThunkContext
->SharingStringPack
= TRUE
;
150 Link
= GetNextNode (&Private
->ThunkContextListHead
, Link
);
156 Caculate the size of UEFI Simple Font Package that is needed to
157 convert all the font a Framework Font Paackage.
159 ONLY Narrow Font is supported. Wide Font is discarded.
161 If the Package Header is not of EFI_HII_FONT type, then ASSERT.
163 @param PackHeader Pointer to Framework Font Package.
165 @return The size of the UEFI Simple Font Package.
169 GetUefiSimpleFontPackSize (
170 IN CONST EFI_HII_PACK_HEADER
* PackHeader
174 EFI_HII_FONT_PACK
*FwFontPack
;
176 FwFontPack
= (EFI_HII_FONT_PACK
*) PackHeader
;
178 ASSERT (FwFontPack
->Header
.Type
== EFI_HII_FONT
);
180 Size
= sizeof (EFI_HII_SIMPLE_FONT_PACKAGE_HDR
)
181 + (FwFontPack
->NumberOfNarrowGlyphs
* sizeof (EFI_NARROW_GLYPH
));
188 Convert Font Package in Framework format to a newly allocated UEFI
191 ONLY Narrow Font is supported. Wide Font is discarded.
193 If memory allocation fails, then ASSERT.
195 @param PackHeader Pointer to Framework Font Package header.
197 @return UEFI Simple Font Package.
199 EFI_HII_SIMPLE_FONT_PACKAGE_HDR
*
200 FrameworkFontPackToUefiSimpliedFont (
201 IN CONST EFI_HII_PACK_HEADER
* PackHeader
204 EFI_HII_SIMPLE_FONT_PACKAGE_HDR
*FontPack
;
206 EFI_NARROW_GLYPH
*FwNarrowGlyph
;
207 EFI_NARROW_GLYPH
*NarrowGlyph
;
209 EFI_HII_FONT_PACK
*FwFontPack
;
211 Size
= GetUefiSimpleFontPackSize (PackHeader
);
213 FwFontPack
= (EFI_HII_FONT_PACK
*) PackHeader
;
215 FontPack
= AllocateZeroPool (Size
);
216 ASSERT (FontPack
!= NULL
);
219 // Prepare the Header information.
221 FontPack
->Header
.Length
= (UINT32
) Size
;
222 FontPack
->Header
.Type
= EFI_HII_PACKAGE_SIMPLE_FONTS
;
224 FontPack
->NumberOfNarrowGlyphs
= FwFontPack
->NumberOfNarrowGlyphs
;
227 // ONLY Narrow Font is supported. Wide Font is discarded.
229 FontPack
->NumberOfWideGlyphs
= 0;
234 NarrowGlyph
= (EFI_NARROW_GLYPH
*) (FontPack
+ 1);
235 FwNarrowGlyph
= (EFI_NARROW_GLYPH
*) (FwFontPack
+ 1);
236 CopyMem (NarrowGlyph
, FwNarrowGlyph
, sizeof (EFI_NARROW_GLYPH
) * FwFontPack
->NumberOfNarrowGlyphs
);
237 for (Idx
= 0; Idx
< FwFontPack
->NumberOfNarrowGlyphs
; Idx
++) {
239 // Clear the GLYPH_NON_BREAKING (EFI_GLYPH_WIDE is used here as they are all 0x02)
240 // attribute which is not defined in UEFI EFI_NARROW_GLYPH
242 NarrowGlyph
[Idx
].Attributes
= (UINT8
) (NarrowGlyph
[Idx
].Attributes
& ~(EFI_GLYPH_WIDE
));
249 Prepare a UEFI Package List from a Framework HII package list registered
250 from a Framework HII NewPack () function.
252 If either Packages or PackageListGuid is NULL, then ASSERT.
254 @param Packages The Framework HII Package List.
255 @param PackageListGuid The Package List GUID.
258 @return The UEFI Package List.
260 EFI_HII_PACKAGE_LIST_HEADER
*
261 PrepareUefiPackageListFromFrameworkHiiPackages (
262 IN CONST EFI_HII_PACKAGES
*Packages
,
263 IN CONST EFI_GUID
*PackageListGuid
266 UINTN NumberOfPackages
;
267 EFI_HII_PACKAGE_LIST_HEADER
*PackageListHeader
;
268 UINT8
*PackageListData
;
269 UINT32 PackageListLength
;
270 UINT32 PackageLength
;
271 EFI_HII_PACKAGE_HEADER PackageHeader
;
273 TIANO_AUTOGEN_PACKAGES_HEADER
**TianoAutogenPackageHdrArray
;
274 EFI_HII_SIMPLE_FONT_PACKAGE_HDR
*FontPack
;
277 ASSERT (Packages
!= NULL
);
278 ASSERT (PackageListGuid
!= NULL
);
280 TianoAutogenPackageHdrArray
= (TIANO_AUTOGEN_PACKAGES_HEADER
**) ((UINT8
*) &Packages
->GuidId
+ sizeof (Packages
->GuidId
));
281 NumberOfPackages
= Packages
->NumberOfPackages
;
283 PackageListLength
= sizeof (EFI_HII_PACKAGE_LIST_HEADER
);
285 for (Index
= 0; Index
< NumberOfPackages
; Index
++) {
286 if (TianoAutogenPackageHdrArray
[Index
]->FrameworkPackageHeader
.Type
== EFI_HII_FONT
) {
288 // There is no tool to generate Font package in Framework HII's implementation.
289 // Therefore, Font Package be a C structure defined in Framework HII code.
290 // Therefore, Font Package will be in Framework HII format defined by EFI_HII_FONT_PACK.
291 // We need to create a UEFI Simple Font Package and copy over all data. Hence, EFI_HII_FONT
292 // is handled differently than EFI_HII_IFR and EFI_HII_STRING.
294 PackageListLength
= (UINT32
) (PackageListLength
+ GetUefiSimpleFontPackSize (&TianoAutogenPackageHdrArray
[Index
]->FrameworkPackageHeader
));
298 // For EFI_HII_IFR and EFI_HII_STRING, EDK II's VFR Compiler and Build.exe will generate a binary in a format
299 // defined by TIANO_AUTOGEN_PACKAGES_HEADER. A Framework HII's EFI_HII_PACK_HEADER is inserted before
300 // the UEFI package data.
302 CopyMem (&PackageLength
, &TianoAutogenPackageHdrArray
[Index
]->FrameworkPackageHeader
.Length
, sizeof (UINT32
));
304 // EFI_HII_PACK_HEADER.FrameworkPackageHeader.Length include the sizeof FrameworkPackageHeader itself.
306 PackageListLength
+= (PackageLength
- sizeof(EFI_HII_PACK_HEADER
));
312 // Include the lenght of EFI_HII_PACKAGE_END
314 PackageListLength
+= sizeof (EFI_HII_PACKAGE_HEADER
);
315 PackageListHeader
= AllocateZeroPool (PackageListLength
);
316 ASSERT (PackageListHeader
!= NULL
);
318 CopyMem (&PackageListHeader
->PackageListGuid
, PackageListGuid
, sizeof (EFI_GUID
));
319 PackageListHeader
->PackageLength
= PackageListLength
;
321 PackageListData
= ((UINT8
*) PackageListHeader
) + sizeof (EFI_HII_PACKAGE_LIST_HEADER
);
324 // Build the UEFI Package List.
326 for (Index
= 0; Index
< NumberOfPackages
; Index
++) {
327 if (TianoAutogenPackageHdrArray
[Index
]->FrameworkPackageHeader
.Type
== EFI_HII_FONT
) {
328 PackageLength
= (UINT32
) GetUefiSimpleFontPackSize (&TianoAutogenPackageHdrArray
[Index
]->FrameworkPackageHeader
);
329 FontPack
= FrameworkFontPackToUefiSimpliedFont (&TianoAutogenPackageHdrArray
[Index
]->FrameworkPackageHeader
);
330 CopyMem (PackageListData
, FontPack
, PackageLength
);
334 CopyMem (&PackageLength
, &(TianoAutogenPackageHdrArray
[Index
]->FrameworkPackageHeader
.Length
), sizeof (UINT32
));
335 PackageLength
-= sizeof (EFI_HII_PACK_HEADER
);
336 CopyMem (PackageListData
, &(TianoAutogenPackageHdrArray
[Index
]->PackageHeader
), PackageLength
);
339 PackageListData
+= PackageLength
;
343 // Append EFI_HII_PACKAGE_END
345 PackageHeader
.Type
= EFI_HII_PACKAGE_END
;
346 PackageHeader
.Length
= sizeof (EFI_HII_PACKAGE_HEADER
);
347 CopyMem (PackageListData
, &PackageHeader
, PackageHeader
.Length
);
349 return PackageListHeader
;
354 Generate a Random GUID.
356 @param Guid On output, a Random GUID will be filled.
364 CopyGuid (Guid
, &mGuidBase
);
367 *((UINT64
*) Guid
) = *((UINT64
*) Guid
) + mGuidCount
;
371 Given a Package List with only a IFR package, find the Package List that only has a String Package based on
372 the TAG GUID. Then export the String Package from the Package List and insert it
373 to the given IFR package.
375 This is to handle the case of Framework HII interface which allow String Package
376 and IFR package to be registered using two different NewPack () calls.
378 @param Private The HII THUNK driver context data.
379 @param IfrThunkContext Package List with only a IFR package.
381 @retval EFI_SUCCESS If the String Package is found and inserted to the
382 Package List with only a IFR package.
383 @retval EFI_NOT_FOUND No String Package matching the TAG GUID is found.
386 FindStringPackAndUpdatePackListWithOnlyIfrPack (
387 IN HII_THUNK_PRIVATE_DATA
*Private
,
388 IN HII_THUNK_CONTEXT
*IfrThunkContext
393 EFI_HII_PACKAGE_LIST_HEADER
*StringPackageListHeader
;
395 HII_THUNK_CONTEXT
*ThunkContext
;
397 Link
= GetFirstNode (&Private
->ThunkContextListHead
);
399 while (!IsNull (&Private
->ThunkContextListHead
, Link
)) {
401 ThunkContext
= HII_THUNK_CONTEXT_FROM_LINK (Link
);
403 if (ThunkContext
!= IfrThunkContext
) {
404 if (CompareGuid (&IfrThunkContext
->TagGuid
, &ThunkContext
->TagGuid
) && (ThunkContext
->IfrPackageCount
== 0)) {
405 StringPackageListHeader
= NULL
;
406 Status
= ExportPackageLists (ThunkContext
->UefiHiiHandle
, &StringPackageListHeader
, &Size
);
407 ASSERT_EFI_ERROR (Status
);
408 if (StringPackageListHeader
== NULL
) {
409 return EFI_NOT_FOUND
;
412 IfrThunkContext
->StringPackageCount
= GetPackageCountByType (StringPackageListHeader
, EFI_HII_PACKAGE_STRINGS
);
414 // Add Function to only get only String Packages from the Package List
416 Status
= mHiiDatabase
->UpdatePackageList (
418 IfrThunkContext
->UefiHiiHandle
,
419 StringPackageListHeader
421 ASSERT_EFI_ERROR (Status
);
423 FreePool (StringPackageListHeader
);
425 IfrThunkContext
->SharingStringPack
= TRUE
;
426 ThunkContext
->SharingStringPack
= TRUE
;
433 Link
= GetNextNode (&Private
->ThunkContextListHead
, Link
);
437 // A Form Package must have a String Package to function.
438 // If ASSERT here, check the sequence of call to Hii->NewPack.
439 // String Pack must be registered before Ifr Package is registered.
442 return EFI_NOT_FOUND
;
448 Register the Package List passed from the Framework HII NewPack () interface.
449 The FRAMEWORK_EFI_HII_HANDLE will be returned.
451 @param This The EFI_HII_PROTOCOL context data. Only used
452 to call HiiRemovePack.
453 @param Private The HII THUNK driver context data.
454 @param Packages Package List.
455 @param Handle On output, a FRAMEWORK_EFI_HII_HANDLE number is
458 @retval EFI_SUCCESS The Package List is registered successfull in
460 @retval EFI_UNSUPPORTED The number of IFR package in the package list
462 @retval EFI_OUT_OF_RESOURCE Not enough resouce.
466 UefiRegisterPackageList (
467 IN EFI_HII_PROTOCOL
*This
,
468 IN HII_THUNK_PRIVATE_DATA
*Private
,
469 IN EFI_HII_PACKAGES
*Packages
,
470 OUT FRAMEWORK_EFI_HII_HANDLE
*Handle
474 UINTN StringPackageCount
;
475 UINTN IfrPackageCount
;
476 UINTN FontPackageCount
;
477 EFI_HII_PACKAGE_LIST_HEADER
*PackageListHeader
;
478 HII_THUNK_CONTEXT
*ThunkContext
;
479 HII_THUNK_CONTEXT
*ThunkContextToRemove
;
481 EFI_HII_PACKAGE_HEADER
*IfrPackage
;
483 PackageListHeader
= NULL
;
485 Status
= GetPackageCount (Packages
, &IfrPackageCount
, &StringPackageCount
, &FontPackageCount
);
486 ASSERT_EFI_ERROR (Status
);
488 if (IfrPackageCount
> 1) {
490 // HII Thunk only handle package with 0 or 1 IFR package.
493 return EFI_UNSUPPORTED
;
496 ThunkContext
= CreateThunkContext (Private
, StringPackageCount
, IfrPackageCount
);
497 if (ThunkContext
== NULL
) {
498 return EFI_OUT_OF_RESOURCES
;
500 ThunkContext
->ByFrameworkHiiNewPack
= TRUE
;
502 if (Packages
->GuidId
== NULL
) {
504 // UEFI HII Database require Package List GUID must be unique.
506 // If Packages->GuidId is NULL, the caller of FramworkHii->NewPack is registering
507 // packages with at least 1 StringPack and 1 IfrPack. Therefore, Packages->GuidId is
508 // not used as the name of the package list. Formset GUID is used as the Package List
511 ASSERT ((StringPackageCount
>=1 && IfrPackageCount
== 1) || (FontPackageCount
> 0));
512 if (IfrPackageCount
> 0) {
513 IfrPackage
= GetIfrPackage (Packages
);
514 if (IfrPackage
== NULL
) {
515 Status
= EFI_NOT_FOUND
;
518 GetFormSetGuid (IfrPackage
, &ThunkContext
->TagGuid
);
520 ASSERT (FontPackageCount
> 0);
521 GenerateRandomGuid (&ThunkContext
->TagGuid
);
525 ThunkContextToRemove
= TagGuidToIfrPackThunkContext (Private
, Packages
->GuidId
);
527 if (IfrPackageCount
> 0 &&
528 StringPackageCount
> 0 &&
529 (ThunkContextToRemove
!= NULL
)) {
530 DEBUG((EFI_D_WARN
, "Framework code registers HII package list with the same GUID more than once.\n"));
531 DEBUG((EFI_D_WARN
, "Remove the previously registered package list and register the new one.\n"));
532 HiiRemovePack (This
, ThunkContextToRemove
->FwHiiHandle
);
534 CopyGuid (&ThunkContext
->TagGuid
, Packages
->GuidId
);
539 // UEFI HII require EFI_HII_CONFIG_ACCESS_PROTOCOL to be installed on a EFI_HANDLE, so
540 // that Setup Utility can load the Buffer Storage using this protocol. An UEFI VFR can only
541 // produce IFR package generated with Buffer Storage type and EFI Variable Storage.
542 // The default EFI_HII_CONFIG_ACCESS_PROTOCOL is used to Get/Set the Buffer Storage.
544 if (IfrPackageCount
!= 0) {
545 InstallDefaultConfigAccessProtocol (Packages
, ThunkContext
);
548 PackageListHeader
= PrepareUefiPackageListFromFrameworkHiiPackages (Packages
, &ThunkContext
->TagGuid
);
549 Status
= mHiiDatabase
->NewPackageList (
552 ThunkContext
->UefiHiiDriverHandle
,
553 &ThunkContext
->UefiHiiHandle
555 if (Status
== EFI_INVALID_PARAMETER
) {
556 FreePool (PackageListHeader
);
559 // UEFI HII database does not allow two package list with the same GUID.
560 // In Framework HII implementation, Packages->GuidId is used as an identifier to associate
561 // a PackageList with only IFR to a Package list the with String package.
563 GenerateRandomGuid (&GuidId
);
565 PackageListHeader
= PrepareUefiPackageListFromFrameworkHiiPackages (Packages
, &GuidId
);
566 Status
= mHiiDatabase
->NewPackageList (
569 ThunkContext
->UefiHiiDriverHandle
,
570 &ThunkContext
->UefiHiiHandle
575 // BUGBUG: Remove when development is done
577 ASSERT_EFI_ERROR (Status
);
578 if (EFI_ERROR (Status
)) {
582 if (IfrPackageCount
== 0) {
583 if (StringPackageCount
!= 0) {
585 // Look for a Package List with only IFR Package with the same TAG GUID name.
586 // If found one, add the String Packages to the found Package List.
587 // This is needed because Framework HII Module may not register the String Package
588 // and IFR Package in one NewPack () call.
590 UpdatePackListWithOnlyIfrPack (
597 if (StringPackageCount
== 0) {
599 // Look for the String Package with the same TAG GUID name and add
600 // the found String Package to this Package List.
601 // This is needed because Framework HII Module may not register the String Package
602 // and IFR Package in one NewPack () call.
604 Status
= FindStringPackAndUpdatePackListWithOnlyIfrPack (
609 if (EFI_ERROR (Status
)) {
615 // Parse the Formset. Must be called after FindStringPackAndUpdatePackListWithOnlyIfrPack is called so
616 // that String Package is ready.
618 ThunkContext
->FormSet
= ParseFormSet (ThunkContext
->UefiHiiHandle
);
619 ASSERT (ThunkContext
->FormSet
!= NULL
);
624 if (EFI_ERROR (Status
)) {
625 DestroyThunkContext (ThunkContext
);
627 InsertTailList (&Private
->ThunkContextListHead
, &ThunkContext
->Link
);
628 *Handle
= ThunkContext
->FwHiiHandle
;
631 if (PackageListHeader
!= NULL
) {
632 FreePool (PackageListHeader
);
641 Registers the various packages that are passed in a Package List.
643 @param This Pointer of Frameowk HII protocol instance.
644 @param Packages Pointer of HII packages.
645 @param Handle Handle value to be returned.
647 @retval EFI_SUCCESS Pacakges has added to HII database successfully.
648 @retval EFI_INVALID_PARAMETER If Handle or Packages is NULL.
654 IN EFI_HII_PROTOCOL
*This
,
655 IN EFI_HII_PACKAGES
*Packages
,
656 OUT FRAMEWORK_EFI_HII_HANDLE
*Handle
660 HII_THUNK_PRIVATE_DATA
*Private
;
663 if (Handle
== NULL
) {
664 return EFI_INVALID_PARAMETER
;
667 if (Packages
== NULL
) {
668 return EFI_INVALID_PARAMETER
;
671 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
674 // We use a simple Global variable to inform NewOrAddPackNotify()
675 // that the package list registered here is already registered
676 // in the HII Thunk Layer. So NewOrAddPackNotify () does not need to
677 // call registered the Package List again.
679 mInFrameworkHiiNewPack
= TRUE
;
681 Private
= HII_THUNK_PRIVATE_DATA_FROM_THIS(This
);
683 Status
= UefiRegisterPackageList (
690 mInFrameworkHiiNewPack
= FALSE
;
692 gBS
->RestoreTPL (OldTpl
);
699 Remove a package from the HII database.
701 @param This Pointer of Frameowk HII protocol instance.
702 @param Handle Handle value to be removed.
704 @retval EFI_SUCCESS Pacakges has added to HII database successfully.
705 @retval EFI_INVALID_PARAMETER If Handle or Packages is NULL.
711 IN EFI_HII_PROTOCOL
*This
,
712 IN FRAMEWORK_EFI_HII_HANDLE Handle
716 HII_THUNK_PRIVATE_DATA
*Private
;
717 HII_THUNK_CONTEXT
*ThunkContext
;
720 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
722 mInFrameworkHiiRemovePack
= TRUE
;
724 Private
= HII_THUNK_PRIVATE_DATA_FROM_THIS(This
);
726 ThunkContext
= FwHiiHandleToThunkContext (Private
, Handle
);
728 if (ThunkContext
!= NULL
) {
729 Status
= mHiiDatabase
->RemovePackageList (
731 ThunkContext
->UefiHiiHandle
733 ASSERT_EFI_ERROR (Status
);
735 if (ThunkContext
->IfrPackageCount
!= 0) {
736 UninstallDefaultConfigAccessProtocol (ThunkContext
);
739 DestroyThunkContext (ThunkContext
);
741 Status
= EFI_NOT_FOUND
;
744 mInFrameworkHiiRemovePack
= FALSE
;
745 gBS
->RestoreTPL (OldTpl
);
751 This notification function will be called when a Package List is registered
752 using UEFI HII interface. The Package List registered need to be recorded in
753 Framework Thunk module as Thunk Module may need to look for String Package in
754 the package registered.
756 If the Package List registered is not either Sting Package or IFR package,
757 then ASSERT. If the NotifyType is not ADD_PACK or NEW_PACK, then ASSERT.
758 Both cases means UEFI HII Database itself is buggy.
760 @param PackageType The Package Type.
761 @param PackageGuid The Package GUID.
762 @param Package The Package Header.
763 @param Handle The HII Handle of this Package List.
764 @param NotifyType The reason of the notification.
766 @retval EFI_SUCCESS The notification function is successful.
772 IN UINT8 PackageType
,
773 IN CONST EFI_GUID
*PackageGuid
,
774 IN CONST EFI_HII_PACKAGE_HEADER
*Package
,
775 IN EFI_HII_HANDLE Handle
,
776 IN EFI_HII_DATABASE_NOTIFY_TYPE NotifyType
780 HII_THUNK_PRIVATE_DATA
*Private
;
781 HII_THUNK_CONTEXT
*ThunkContext
;
783 ASSERT (PackageType
== EFI_HII_PACKAGE_STRINGS
|| PackageType
== EFI_HII_PACKAGE_FORMS
);
784 ASSERT (NotifyType
== EFI_HII_DATABASE_NOTIFY_ADD_PACK
|| NotifyType
== EFI_HII_DATABASE_NOTIFY_NEW_PACK
);
786 Status
= EFI_SUCCESS
;
787 Private
= mHiiThunkPrivateData
;
789 if (mInFrameworkHiiNewPack
|| mInFrameworkUpdatePakcage
) {
794 // We will create a ThunkContext to log the package list only if the
795 // package is not registered with by Framework HII Thunk module yet.
797 ThunkContext
= UefiHiiHandleToThunkContext (Private
, Handle
);
798 if (ThunkContext
== NULL
) {
799 ThunkContext
= CreateThunkContextForUefiHiiHandle (Handle
);
800 ASSERT (ThunkContext
!= NULL
);
802 InsertTailList (&Private
->ThunkContextListHead
, &ThunkContext
->Link
);
805 if (PackageType
== EFI_HII_PACKAGE_FORMS
) {
806 if (ThunkContext
->FormSet
!= NULL
) {
807 DestroyFormSet (ThunkContext
->FormSet
);
811 // Reparse the FormSet.
813 ThunkContext
->FormSet
= ParseFormSet (ThunkContext
->UefiHiiHandle
);
820 This notification function will be called when a Package List is removed
821 using UEFI HII interface. The Package List removed need to be removed from
822 Framework Thunk module too.
824 If the Package List registered is not Sting Package,
825 then ASSERT. If the NotifyType is not REMOVE_PACK, then ASSERT.
826 Both cases means UEFI HII Database itself is buggy.
828 @param PackageType The Package Type.
829 @param PackageGuid The Package GUID.
830 @param Package The Package Header.
831 @param Handle The HII Handle of this Package List.
832 @param NotifyType The reason of the notification.
834 @retval EFI_SUCCESS The notification function is successful.
840 IN UINT8 PackageType
,
841 IN CONST EFI_GUID
*PackageGuid
,
842 IN CONST EFI_HII_PACKAGE_HEADER
*Package
,
843 IN EFI_HII_HANDLE Handle
,
844 IN EFI_HII_DATABASE_NOTIFY_TYPE NotifyType
848 HII_THUNK_PRIVATE_DATA
*Private
;
849 HII_THUNK_CONTEXT
*ThunkContext
;
850 EFI_HII_PACKAGE_LIST_HEADER
*HiiPackageList
;
853 Status
= EFI_SUCCESS
;
855 ASSERT (PackageType
== EFI_HII_PACKAGE_STRINGS
);
856 ASSERT (NotifyType
== EFI_HII_DATABASE_NOTIFY_REMOVE_PACK
);
858 if (mInFrameworkHiiRemovePack
|| mInFrameworkUpdatePakcage
) {
862 Private
= mHiiThunkPrivateData
;
864 ThunkContext
= UefiHiiHandleToThunkContext (Private
, Handle
);
867 // BugBug: Change to ASSERT if HII Database fix the bug and to also invoke
868 // NEW_PACK_NOTIFY for package (String Package) created internally.
870 if (ThunkContext
!= NULL
) {
871 if (!ThunkContext
->ByFrameworkHiiNewPack
) {
872 HiiPackageList
= NULL
;
873 Status
= ExportPackageLists (Handle
, &HiiPackageList
, &BufferSize
);
874 ASSERT_EFI_ERROR (Status
);
875 if (HiiPackageList
== NULL
) {
876 return EFI_NOT_FOUND
;
879 if (GetPackageCountByType (HiiPackageList
, EFI_HII_PACKAGE_STRINGS
) == 1) {
881 // If the string package will be removed is the last string package
882 // in the package list, we will remove the HII Thunk entry from the
885 DestroyThunkContextForUefiHiiHandle (Private
, Handle
);
888 FreePool (HiiPackageList
);