2 Implement protocol interface related to package registrations.
4 Copyright (c) 2006 - 2008, Intel Corporation
5 All rights reserved. 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 package IFR and STRING 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.
36 @retval EFI_INVALID_PARAMETER If the Package List has package with type of
37 EFI_HII_PACKAGE_KEYBOARD_LAYOUT, EFI_HII_PACKAGE_FONTS, EFI_HII_PACKAGE_IMAGES.
38 @reval EFI_SUCCESS Successfully get the number of IFR and STRING package.
44 IN CONST EFI_HII_PACKAGES
*Packages
,
45 OUT UINTN
*IfrPackageCount
,
46 OUT UINTN
*StringPackageCount
,
47 OUT UINTN
*FontPackageCount
51 TIANO_AUTOGEN_PACKAGES_HEADER
**TianoAutogenPackageHdrArray
;
53 ASSERT (Packages
!= NULL
);
54 ASSERT (IfrPackageCount
!= NULL
);
55 ASSERT (StringPackageCount
!= NULL
);
56 ASSERT (FontPackageCount
!= NULL
);
59 *StringPackageCount
= 0;
60 *FontPackageCount
= 0;
62 TianoAutogenPackageHdrArray
= (TIANO_AUTOGEN_PACKAGES_HEADER
**) (((UINT8
*) &Packages
->GuidId
) + sizeof (Packages
->GuidId
));
64 for (Index
= 0; Index
< Packages
->NumberOfPackages
; Index
++) {
66 // The current UEFI HII build tool generate a binary in the format defined by
67 // TIANO_AUTOGEN_PACKAGES_HEADER. We assume that all packages generated in
68 // this binary is with same package type. So the returned IfrPackageCount and StringPackageCount
69 // may not be the exact number of valid package number in the binary generated
72 switch (TianoAutogenPackageHdrArray
[Index
]->FrameworkPackageHeader
.Type
) {
74 *IfrPackageCount
+= 1;
77 *StringPackageCount
+= 1;
81 *FontPackageCount
+= 1;
85 // The following fonts are invalid for a module that using Framework to UEFI thunk layer.
89 return EFI_INVALID_PARAMETER
;
98 Insert the String Package into the Package Lists which has the TAG GUID matching
99 the PackageListGuid of the String Package.
101 The Package List must have only IFR Package and no String Package.
104 @param Private The HII THUNK driver context data.
105 @param StringPackageThunkContext The HII THUNK context data.
106 @param StringPackageListHeader The String Package List Header.
110 UpdatePackListWithOnlyIfrPack (
111 IN HII_THUNK_PRIVATE_DATA
*Private
,
112 IN HII_THUNK_CONTEXT
*StringPackageThunkContext
,
113 IN CONST EFI_HII_PACKAGE_LIST_HEADER
*StringPackageListHeader
118 HII_THUNK_CONTEXT
*ThunkContext
;
120 Link
= GetFirstNode (&Private
->ThunkContextListHead
);
121 while (!IsNull (&Private
->ThunkContextListHead
, Link
)) {
123 ThunkContext
= HII_THUNK_CONTEXT_FROM_LINK (Link
);
125 if (StringPackageThunkContext
!= ThunkContext
) {
127 // Skip the String Package Thunk Entry itself.
130 if (CompareGuid (&StringPackageListHeader
->PackageListGuid
, &ThunkContext
->TagGuid
)) {
132 ASSERT (ThunkContext
->StringPackageCount
== 0 && ThunkContext
->IfrPackageCount
== 1);
134 ThunkContext
->StringPackageCount
= GetPackageCountByType (StringPackageListHeader
, EFI_HII_PACKAGE_STRINGS
);
136 Status
= mHiiDatabase
->UpdatePackageList (
138 ThunkContext
->UefiHiiHandle
,
139 StringPackageListHeader
141 ASSERT_EFI_ERROR (Status
);
143 ThunkContext
->SharingStringPack
= TRUE
;
144 StringPackageThunkContext
->SharingStringPack
= TRUE
;
149 Link
= GetNextNode (&Private
->ThunkContextListHead
, Link
);
155 Caculate the size of UEFI Simple Font Package that is needed to
156 convert all the font a Framework Font Paackage.
158 ONLY Narrow Font is supported. Wide Font is discarded.
160 If the Package Header is not of EFI_HII_FONT type, then ASSERT.
162 @param The Package header of the Framework Font Package.
164 @return The size of the UEFI Simple Font Package.
168 GetUefiSimpleFontPackSize (
169 IN CONST EFI_HII_PACK_HEADER
* PackHeader
173 EFI_HII_FONT_PACK
*FwFontPack
;
175 FwFontPack
= (EFI_HII_FONT_PACK
*) PackHeader
;
177 ASSERT (FwFontPack
->Header
.Type
== EFI_HII_FONT
);
179 Size
= sizeof (EFI_HII_SIMPLE_FONT_PACKAGE_HDR
)
180 + (FwFontPack
->NumberOfNarrowGlyphs
* sizeof (EFI_NARROW_GLYPH
));
187 Convert Font Package in Framework format to a newly allocated UEFI
190 ONLY Narrow Font is supported. Wide Font is discarded.
192 If memory allocation fails, then ASSERT.
194 @param FwFontPack Framework Font Package.
196 @reture UEFI Simple Font Package.
198 EFI_HII_SIMPLE_FONT_PACKAGE_HDR
*
199 FrameworkFontPackToUefiSimpliedFont (
200 IN CONST EFI_HII_PACK_HEADER
* PackHeader
203 EFI_HII_SIMPLE_FONT_PACKAGE_HDR
*FontPack
;
205 EFI_NARROW_GLYPH
*FwNarrowGlyph
;
206 EFI_NARROW_GLYPH
*NarrowGlyph
;
208 EFI_HII_FONT_PACK
*FwFontPack
;
210 Size
= GetUefiSimpleFontPackSize (PackHeader
);
212 FwFontPack
= (EFI_HII_FONT_PACK
*) PackHeader
;
214 FontPack
= AllocateZeroPool (Size
);
215 ASSERT (FontPack
!= NULL
);
218 // Prepare the Header information.
220 FontPack
->Header
.Length
= (UINT32
) Size
;
221 FontPack
->Header
.Type
= EFI_HII_PACKAGE_SIMPLE_FONTS
;
223 FontPack
->NumberOfNarrowGlyphs
= FwFontPack
->NumberOfNarrowGlyphs
;
226 // ONLY Narrow Font is supported. Wide Font is discarded.
228 FontPack
->NumberOfWideGlyphs
= 0;
233 NarrowGlyph
= (EFI_NARROW_GLYPH
*) (FontPack
+ 1);
234 FwNarrowGlyph
= (EFI_NARROW_GLYPH
*) (FwFontPack
+ 1);
235 CopyMem (NarrowGlyph
, FwNarrowGlyph
, sizeof (EFI_NARROW_GLYPH
) * FwFontPack
->NumberOfNarrowGlyphs
);
236 for (Idx
= 0; Idx
< FwFontPack
->NumberOfNarrowGlyphs
; Idx
++) {
238 // Clear the GLYPH_NON_BREAKING (EFI_GLYPH_WIDE is used here as they are all 0x02)
239 // attribute which is not defined in UEFI EFI_NARROW_GLYPH
241 NarrowGlyph
[Idx
].Attributes
= (UINT8
) (NarrowGlyph
[Idx
].Attributes
& ~(EFI_GLYPH_WIDE
));
248 Prepare a UEFI Package List from a Framework HII package list registered
249 from a Framework HII NewPack () function.
251 If either Packages or PackageListGuid is NULL, then ASSERT.
253 @param Packages The Framework HII Package List.
254 @param PackageListGuid The Package List GUID.
257 @return The UEFI Package List.
259 EFI_HII_PACKAGE_LIST_HEADER
*
260 PrepareUefiPackageListFromFrameworkHiiPackages (
261 IN CONST EFI_HII_PACKAGES
*Packages
,
262 IN CONST EFI_GUID
*PackageListGuid
265 UINTN NumberOfPackages
;
266 EFI_HII_PACKAGE_LIST_HEADER
*PackageListHeader
;
267 UINT8
*PackageListData
;
268 UINT32 PackageListLength
;
269 UINT32 PackageLength
;
270 EFI_HII_PACKAGE_HEADER PackageHeader
;
272 TIANO_AUTOGEN_PACKAGES_HEADER
**TianoAutogenPackageHdrArray
;
273 EFI_HII_SIMPLE_FONT_PACKAGE_HDR
*FontPack
;
276 ASSERT (Packages
!= NULL
);
277 ASSERT (PackageListGuid
!= NULL
);
279 TianoAutogenPackageHdrArray
= (TIANO_AUTOGEN_PACKAGES_HEADER
**) ((UINT8
*) &Packages
->GuidId
+ sizeof (Packages
->GuidId
));
280 NumberOfPackages
= Packages
->NumberOfPackages
;
282 PackageListLength
= sizeof (EFI_HII_PACKAGE_LIST_HEADER
);
284 for (Index
= 0; Index
< NumberOfPackages
; Index
++) {
285 if (TianoAutogenPackageHdrArray
[Index
]->FrameworkPackageHeader
.Type
== EFI_HII_FONT
) {
287 // There is no tool to generate Font package in Framework HII's implementation.
288 // Therefore, Font Package be a C structure defined in Framework HII code.
289 // Therefore, Font Package will be in Framework HII format defined by EFI_HII_FONT_PACK.
290 // We need to create a UEFI Simple Font Package and copy over all data. Hence, EFI_HII_FONT
291 // is handled differently than EFI_HII_IFR and EFI_HII_STRING.
293 PackageListLength
= (UINT32
) (PackageListLength
+ GetUefiSimpleFontPackSize (&TianoAutogenPackageHdrArray
[Index
]->FrameworkPackageHeader
));
297 // For EFI_HII_IFR and EFI_HII_STRING, EDK II's VFR Compiler and Build.exe will generate a binary in a format
298 // defined by TIANO_AUTOGEN_PACKAGES_HEADER. A Framework HII's EFI_HII_PACK_HEADER is inserted before
299 // the UEFI package data.
301 CopyMem (&PackageLength
, &TianoAutogenPackageHdrArray
[Index
]->FrameworkPackageHeader
.Length
, sizeof (UINT32
));
303 // EFI_HII_PACK_HEADER.FrameworkPackageHeader.Length include the sizeof FrameworkPackageHeader itself.
305 PackageListLength
+= (PackageLength
- sizeof(EFI_HII_PACK_HEADER
));
311 // Include the lenght of EFI_HII_PACKAGE_END
313 PackageListLength
+= sizeof (EFI_HII_PACKAGE_HEADER
);
314 PackageListHeader
= AllocateZeroPool (PackageListLength
);
315 ASSERT (PackageListHeader
!= NULL
);
317 CopyMem (&PackageListHeader
->PackageListGuid
, PackageListGuid
, sizeof (EFI_GUID
));
318 PackageListHeader
->PackageLength
= PackageListLength
;
320 PackageListData
= ((UINT8
*) PackageListHeader
) + sizeof (EFI_HII_PACKAGE_LIST_HEADER
);
323 // Build the UEFI Package List.
325 for (Index
= 0; Index
< NumberOfPackages
; Index
++) {
326 if (TianoAutogenPackageHdrArray
[Index
]->FrameworkPackageHeader
.Type
== EFI_HII_FONT
) {
327 PackageLength
= (UINT32
) GetUefiSimpleFontPackSize (&TianoAutogenPackageHdrArray
[Index
]->FrameworkPackageHeader
);
328 FontPack
= FrameworkFontPackToUefiSimpliedFont (&TianoAutogenPackageHdrArray
[Index
]->FrameworkPackageHeader
);
329 CopyMem (PackageListData
, FontPack
, PackageLength
);
333 CopyMem (&PackageLength
, &(TianoAutogenPackageHdrArray
[Index
]->FrameworkPackageHeader
.Length
), sizeof (UINT32
));
334 PackageLength
-= sizeof (EFI_HII_PACK_HEADER
);
335 CopyMem (PackageListData
, &(TianoAutogenPackageHdrArray
[Index
]->PackageHeader
), PackageLength
);
338 PackageListData
+= PackageLength
;
342 // Append EFI_HII_PACKAGE_END
344 PackageHeader
.Type
= EFI_HII_PACKAGE_END
;
345 PackageHeader
.Length
= sizeof (EFI_HII_PACKAGE_HEADER
);
346 CopyMem (PackageListData
, &PackageHeader
, PackageHeader
.Length
);
348 return PackageListHeader
;
353 Generate a Random GUID.
355 @param Guid On output, a Random GUID will be filled.
363 CopyGuid (Guid
, &mGuidBase
);
366 *((UINT64
*) Guid
) = *((UINT64
*) Guid
) + mGuidCount
;
370 Given a Package List with only a IFR package, find the Package List that only has a String Package based on
371 the TAG GUID. Then export the String Package from the Package List and insert it
372 to the given IFR package.
374 This is to handle the case of Framework HII interface which allow String Package
375 and IFR package to be registered using two different NewPack () calls.
377 @param Private The HII THUNK driver context data.
378 @param IfrThunkContext Package List with only a IFR package.
380 @retval EFI_SUCCESS If the String Package is found and inserted to the
381 Package List with only a IFR package.
382 @retval EFI_NOT_FOUND No String Package matching the TAG GUID is found.
385 FindStringPackAndUpdatePackListWithOnlyIfrPack (
386 IN HII_THUNK_PRIVATE_DATA
*Private
,
387 IN HII_THUNK_CONTEXT
*IfrThunkContext
392 EFI_HII_PACKAGE_LIST_HEADER
*StringPackageListHeader
;
394 HII_THUNK_CONTEXT
*ThunkContext
;
396 Link
= GetFirstNode (&Private
->ThunkContextListHead
);
398 while (!IsNull (&Private
->ThunkContextListHead
, Link
)) {
400 ThunkContext
= HII_THUNK_CONTEXT_FROM_LINK (Link
);
402 if (ThunkContext
!= IfrThunkContext
) {
403 if (CompareGuid (&IfrThunkContext
->TagGuid
, &ThunkContext
->TagGuid
) && (ThunkContext
->IfrPackageCount
== 0)) {
404 StringPackageListHeader
= NULL
;
405 Status
= ExportPackageLists (ThunkContext
->UefiHiiHandle
, &StringPackageListHeader
, &Size
);
406 ASSERT_EFI_ERROR (Status
);
407 if (StringPackageListHeader
== NULL
) {
408 return EFI_NOT_FOUND
;
411 IfrThunkContext
->StringPackageCount
= GetPackageCountByType (StringPackageListHeader
, EFI_HII_PACKAGE_STRINGS
);
413 // Add Function to only get only String Packages from the Package List
415 Status
= mHiiDatabase
->UpdatePackageList (
417 IfrThunkContext
->UefiHiiHandle
,
418 StringPackageListHeader
420 ASSERT_EFI_ERROR (Status
);
422 FreePool (StringPackageListHeader
);
424 IfrThunkContext
->SharingStringPack
= TRUE
;
425 ThunkContext
->SharingStringPack
= TRUE
;
432 Link
= GetNextNode (&Private
->ThunkContextListHead
, Link
);
436 // A Form Package must have a String Package to function.
437 // If ASSERT here, check the sequence of call to Hii->NewPack.
438 // String Pack must be registered before Ifr Package is registered.
441 return EFI_NOT_FOUND
;
447 Register the Package List passed from the Framework HII NewPack () interface.
448 The FRAMEWORK_EFI_HII_HANDLE will be returned.
450 @param This The EFI_HII_PROTOCOL context data. Only used
451 to call HiiRemovePack.
452 @param Private The HII THUNK driver context data.
453 @param Package Package List.
454 @param Handle On output, a FRAMEWORK_EFI_HII_HANDLE number is
457 @retval EFI_SUCCESS The Package List is registered successfull in
459 @retval EFI_UNSUPPORTED The number of IFR package in the package list
461 @retval EFI_OUT_OF_RESOURCE Not enough resouce.
465 UefiRegisterPackageList (
466 IN EFI_HII_PROTOCOL
*This
,
467 IN HII_THUNK_PRIVATE_DATA
*Private
,
468 IN EFI_HII_PACKAGES
*Packages
,
469 OUT FRAMEWORK_EFI_HII_HANDLE
*Handle
473 UINTN StringPackageCount
;
474 UINTN IfrPackageCount
;
475 UINTN FontPackageCount
;
476 EFI_HII_PACKAGE_LIST_HEADER
*PackageListHeader
;
477 HII_THUNK_CONTEXT
*ThunkContext
;
478 HII_THUNK_CONTEXT
*ThunkContextToRemove
;
480 EFI_HII_PACKAGE_HEADER
*IfrPackage
;
482 PackageListHeader
= NULL
;
484 Status
= GetPackageCount (Packages
, &IfrPackageCount
, &StringPackageCount
, &FontPackageCount
);
485 ASSERT_EFI_ERROR (Status
);
487 if (IfrPackageCount
> 1) {
489 // HII Thunk only handle package with 0 or 1 IFR package.
492 return EFI_UNSUPPORTED
;
495 ThunkContext
= CreateThunkContext (Private
, StringPackageCount
, IfrPackageCount
);
496 if (ThunkContext
== NULL
) {
497 return EFI_OUT_OF_RESOURCES
;
499 ThunkContext
->ByFrameworkHiiNewPack
= TRUE
;
501 if (Packages
->GuidId
== NULL
) {
503 // UEFI HII Database require Package List GUID must be unique.
505 // If Packages->GuidId is NULL, the caller of FramworkHii->NewPack is registering
506 // packages with at least 1 StringPack and 1 IfrPack. Therefore, Packages->GuidId is
507 // not used as the name of the package list. Formset GUID is used as the Package List
510 ASSERT ((StringPackageCount
>=1 && IfrPackageCount
== 1) || (FontPackageCount
> 0));
511 if (IfrPackageCount
> 0) {
512 IfrPackage
= GetIfrPackage (Packages
);
513 if (IfrPackage
== NULL
) {
514 Status
= EFI_NOT_FOUND
;
517 GetFormSetGuid (IfrPackage
, &ThunkContext
->TagGuid
);
519 ASSERT (FontPackageCount
> 0);
520 GenerateRandomGuid (&ThunkContext
->TagGuid
);
524 ThunkContextToRemove
= TagGuidToIfrPackThunkContext (Private
, Packages
->GuidId
);
526 if (IfrPackageCount
> 0 &&
527 StringPackageCount
> 0 &&
528 (ThunkContextToRemove
!= NULL
)) {
529 DEBUG((EFI_D_WARN
, "Framework code registers HII package list with the same GUID more than once.\n"));
530 DEBUG((EFI_D_WARN
, "Remove the previously registered package list and register the new one.\n"));
531 HiiRemovePack (This
, ThunkContextToRemove
->FwHiiHandle
);
533 CopyGuid (&ThunkContext
->TagGuid
, Packages
->GuidId
);
538 // UEFI HII require EFI_HII_CONFIG_ACCESS_PROTOCOL to be installed on a EFI_HANDLE, so
539 // that Setup Utility can load the Buffer Storage using this protocol. An UEFI VFR can only
540 // produce IFR package generated with Buffer Storage type and EFI Variable Storage.
541 // The default EFI_HII_CONFIG_ACCESS_PROTOCOL is used to Get/Set the Buffer Storage.
543 if (IfrPackageCount
!= 0) {
544 InstallDefaultConfigAccessProtocol (Packages
, ThunkContext
);
547 PackageListHeader
= PrepareUefiPackageListFromFrameworkHiiPackages (Packages
, &ThunkContext
->TagGuid
);
548 Status
= mHiiDatabase
->NewPackageList (
551 ThunkContext
->UefiHiiDriverHandle
,
552 &ThunkContext
->UefiHiiHandle
554 if (Status
== EFI_INVALID_PARAMETER
) {
555 FreePool (PackageListHeader
);
558 // UEFI HII database does not allow two package list with the same GUID.
559 // In Framework HII implementation, Packages->GuidId is used as an identifier to associate
560 // a PackageList with only IFR to a Package list the with String package.
562 GenerateRandomGuid (&GuidId
);
564 PackageListHeader
= PrepareUefiPackageListFromFrameworkHiiPackages (Packages
, &GuidId
);
565 Status
= mHiiDatabase
->NewPackageList (
568 ThunkContext
->UefiHiiDriverHandle
,
569 &ThunkContext
->UefiHiiHandle
574 // BUGBUG: Remove when development is done
576 ASSERT_EFI_ERROR (Status
);
577 if (EFI_ERROR (Status
)) {
581 if (IfrPackageCount
== 0) {
582 if (StringPackageCount
!= 0) {
584 // Look for a Package List with only IFR Package with the same TAG GUID name.
585 // If found one, add the String Packages to the found Package List.
586 // This is needed because Framework HII Module may not register the String Package
587 // and IFR Package in one NewPack () call.
589 UpdatePackListWithOnlyIfrPack (
596 if (StringPackageCount
== 0) {
598 // Look for the String Package with the same TAG GUID name and add
599 // the found String Package to this Package List.
600 // This is needed because Framework HII Module may not register the String Package
601 // and IFR Package in one NewPack () call.
603 Status
= FindStringPackAndUpdatePackListWithOnlyIfrPack (
608 if (EFI_ERROR (Status
)) {
614 // Parse the Formset. Must be called after FindStringPackAndUpdatePackListWithOnlyIfrPack is called so
615 // that String Package is ready.
617 ThunkContext
->FormSet
= ParseFormSet (ThunkContext
->UefiHiiHandle
);
618 ASSERT (ThunkContext
->FormSet
!= NULL
);
623 if (EFI_ERROR (Status
)) {
624 DestroyThunkContext (ThunkContext
);
626 InsertTailList (&Private
->ThunkContextListHead
, &ThunkContext
->Link
);
627 *Handle
= ThunkContext
->FwHiiHandle
;
630 if (PackageListHeader
!= NULL
) {
631 FreePool (PackageListHeader
);
640 Registers the various packages that are passed in a Package List.
642 @param This Pointer of Frameowk HII protocol instance.
643 @param Packages Pointer of HII packages.
644 @param Handle Handle value to be returned.
646 @retval EFI_SUCCESS Pacakges has added to HII database successfully.
647 @retval EFI_INVALID_PARAMETER If Handle or Packages is NULL.
653 IN EFI_HII_PROTOCOL
*This
,
654 IN EFI_HII_PACKAGES
*Packages
,
655 OUT FRAMEWORK_EFI_HII_HANDLE
*Handle
659 HII_THUNK_PRIVATE_DATA
*Private
;
662 if (Handle
== NULL
) {
663 return EFI_INVALID_PARAMETER
;
666 if (Packages
== NULL
) {
667 return EFI_INVALID_PARAMETER
;
670 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
673 // We use a simple Global variable to inform NewOrAddPackNotify()
674 // that the package list registered here is already registered
675 // in the HII Thunk Layer. So NewOrAddPackNotify () does not need to
676 // call registered the Package List again.
678 mInFrameworkHiiNewPack
= TRUE
;
680 Private
= HII_THUNK_PRIVATE_DATA_FROM_THIS(This
);
682 Status
= UefiRegisterPackageList (
689 mInFrameworkHiiNewPack
= FALSE
;
691 gBS
->RestoreTPL (OldTpl
);
698 Remove a package from the HII database.
700 @param This Pointer of Frameowk HII protocol instance.
701 @param Handle Handle value to be removed.
703 @retval EFI_SUCCESS Pacakges has added to HII database successfully.
704 @retval EFI_INVALID_PARAMETER If Handle or Packages is NULL.
710 IN EFI_HII_PROTOCOL
*This
,
711 IN FRAMEWORK_EFI_HII_HANDLE Handle
715 HII_THUNK_PRIVATE_DATA
*Private
;
716 HII_THUNK_CONTEXT
*ThunkContext
;
719 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
721 mInFrameworkHiiRemovePack
= TRUE
;
723 Private
= HII_THUNK_PRIVATE_DATA_FROM_THIS(This
);
725 ThunkContext
= FwHiiHandleToThunkContext (Private
, Handle
);
727 if (ThunkContext
!= NULL
) {
728 Status
= mHiiDatabase
->RemovePackageList (
730 ThunkContext
->UefiHiiHandle
732 ASSERT_EFI_ERROR (Status
);
734 if (ThunkContext
->IfrPackageCount
!= 0) {
735 UninstallDefaultConfigAccessProtocol (ThunkContext
);
738 DestroyThunkContext (ThunkContext
);
740 Status
= EFI_NOT_FOUND
;
743 mInFrameworkHiiRemovePack
= FALSE
;
744 gBS
->RestoreTPL (OldTpl
);
750 This notification function will be called when a Package List is registered
751 using UEFI HII interface. The Package List registered need to be recorded in
752 Framework Thunk module as Thunk Module may need to look for String Package in
753 the package registered.
755 If the Package List registered is not either Sting Package or IFR package,
756 then ASSERT. If the NotifyType is not ADD_PACK or NEW_PACK, then ASSERT.
757 Both cases means UEFI HII Database itself is buggy.
759 @param PackageType The Package Type.
760 @param PackageGuid The Package GUID.
761 @param Package The Package Header.
762 @param Handle The HII Handle of this Package List.
763 @param NotifyType The reason of the notification.
765 @retval EFI_SUCCESS The notification function is successful.
771 IN UINT8 PackageType
,
772 IN CONST EFI_GUID
*PackageGuid
,
773 IN CONST EFI_HII_PACKAGE_HEADER
*Package
,
774 IN EFI_HII_HANDLE Handle
,
775 IN EFI_HII_DATABASE_NOTIFY_TYPE NotifyType
779 HII_THUNK_PRIVATE_DATA
*Private
;
780 HII_THUNK_CONTEXT
*ThunkContext
;
782 ASSERT (PackageType
== EFI_HII_PACKAGE_STRINGS
|| PackageType
== EFI_HII_PACKAGE_FORMS
);
783 ASSERT (NotifyType
== EFI_HII_DATABASE_NOTIFY_ADD_PACK
|| NotifyType
== EFI_HII_DATABASE_NOTIFY_NEW_PACK
);
785 Status
= EFI_SUCCESS
;
786 Private
= mHiiThunkPrivateData
;
788 if (mInFrameworkHiiNewPack
|| mInFrameworkUpdatePakcage
) {
793 // We will create a ThunkContext to log the package list only if the
794 // package is not registered with by Framework HII Thunk module yet.
796 ThunkContext
= UefiHiiHandleToThunkContext (Private
, Handle
);
797 if (ThunkContext
== NULL
) {
798 ThunkContext
= CreateThunkContextForUefiHiiHandle (Handle
);
799 ASSERT (ThunkContext
!= NULL
);
801 InsertTailList (&Private
->ThunkContextListHead
, &ThunkContext
->Link
);
804 if (PackageType
== EFI_HII_PACKAGE_FORMS
) {
805 if (ThunkContext
->FormSet
!= NULL
) {
806 DestroyFormSet (ThunkContext
->FormSet
);
810 // Reparse the FormSet.
812 ThunkContext
->FormSet
= ParseFormSet (ThunkContext
->UefiHiiHandle
);
819 This notification function will be called when a Package List is removed
820 using UEFI HII interface. The Package List removed need to be removed from
821 Framework Thunk module too.
823 If the Package List registered is not Sting Package,
824 then ASSERT. If the NotifyType is not REMOVE_PACK, then ASSERT.
825 Both cases means UEFI HII Database itself is buggy.
827 @param PackageType The Package Type.
828 @param PackageGuid The Package GUID.
829 @param Package The Package Header.
830 @param Handle The HII Handle of this Package List.
831 @param NotifyType The reason of the notification.
833 @retval EFI_SUCCESS The notification function is successful.
839 IN UINT8 PackageType
,
840 IN CONST EFI_GUID
*PackageGuid
,
841 IN CONST EFI_HII_PACKAGE_HEADER
*Package
,
842 IN EFI_HII_HANDLE Handle
,
843 IN EFI_HII_DATABASE_NOTIFY_TYPE NotifyType
847 HII_THUNK_PRIVATE_DATA
*Private
;
848 HII_THUNK_CONTEXT
*ThunkContext
;
849 EFI_HII_PACKAGE_LIST_HEADER
*HiiPackageList
;
852 Status
= EFI_SUCCESS
;
854 ASSERT (PackageType
== EFI_HII_PACKAGE_STRINGS
);
855 ASSERT (NotifyType
== EFI_HII_DATABASE_NOTIFY_REMOVE_PACK
);
857 if (mInFrameworkHiiRemovePack
|| mInFrameworkUpdatePakcage
) {
861 Private
= mHiiThunkPrivateData
;
863 ThunkContext
= UefiHiiHandleToThunkContext (Private
, Handle
);
866 // BugBug: Change to ASSERT if HII Database fix the bug and to also invoke
867 // NEW_PACK_NOTIFY for package (String Package) created internally.
869 if (ThunkContext
!= NULL
) {
870 if (!ThunkContext
->ByFrameworkHiiNewPack
) {
871 HiiPackageList
= NULL
;
872 Status
= ExportPackageLists (Handle
, &HiiPackageList
, &BufferSize
);
873 ASSERT_EFI_ERROR (Status
);
874 if (HiiPackageList
== NULL
) {
875 return EFI_NOT_FOUND
;
878 if (GetPackageCountByType (HiiPackageList
, EFI_HII_PACKAGE_STRINGS
) == 1) {
880 // If the string package will be removed is the last string package
881 // in the package list, we will remove the HII Thunk entry from the
884 DestroyThunkContextForUefiHiiHandle (Private
, Handle
);
887 FreePool (HiiPackageList
);