summaryrefslogtreecommitdiff
path: root/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Package.c
diff options
context:
space:
mode:
authorqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>2008-08-18 05:56:23 +0000
committerqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>2008-08-18 05:56:23 +0000
commit0368663fd609e2e008031a2025693f190d19b0c7 (patch)
treec6bc48d410d8f397b9dc8749bf19aede404cc13f /EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Package.c
parent0514e9c3c9b46f74c232942759388c46ed89802a (diff)
downloadedk2-platforms-0368663fd609e2e008031a2025693f190d19b0c7.tar.xz
Bug fixes for FrameworkHiiToUefiHiiThunk;
1) Update variable name to better names. 2) Change List Entry in all data structure to "Link". 3) Update to use proper list manipulation functions in BaseLib. 4) Add in more comments and clean up HiiNewString. 5) Clean up for HiiNewPack, HiiRemovePack and the notify functions. 6) Create better name such as GetPackageCount and AssignFrameworkHiiHandle 7) Clean up the InitializeHiiDatabase entry point. 8) Remove the confusing data field in the HII_THUNK_ENTRY HiiDatabase.h. 9) Add in cleanup code for DestoryThunkContext 10) Add in code to handle the save of browser data after invoke callback 11) Map the UEFI One Of Option code to Framework One Of Option code before calling Framework Callback. 12) Add in CreatePopUp support. 13) Add in SendForm support. 14) HiiGetPrimaryLanguages and HiiGetSecondaryLanguages should support language code in RFC639 format from Caller. Then, they should conver them to 3066 format before calling UEFI HII interfaces. 15) Make ResetStrings a NOP. 16) Remove the unnecessary dependency. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5659 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Package.c')
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Package.c633
1 files changed, 428 insertions, 205 deletions
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Package.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Package.c
index 847a8fbf57..994c67b9a0 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Package.c
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Package.c
@@ -1,6 +1,5 @@
/**@file
-
- This file contains the keyboard processing code to the HII database.
+ Implement protocol interface related to package registrations.
Copyright (c) 2006 - 2008, Intel Corporation
All rights reserved. This program and the accompanying materials
@@ -17,42 +16,44 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "HiiDatabase.h"
-BOOLEAN mInFrameworkHiiNewPack = FALSE;
-BOOLEAN mInFrameworkHiiRemovePack = FALSE;
+STATIC BOOLEAN mInFrameworkHiiNewPack = FALSE;
+STATIC BOOLEAN mInFrameworkHiiRemovePack = FALSE;
+BOOLEAN mInFrameworkUpdatePakcage = FALSE;
EFI_STATUS
-GetIfrAndStringPackNum (
+GetPackageCount (
IN CONST EFI_HII_PACKAGES *Packages,
- UINTN *IfrPackNum,
- UINTN *StringPackNum
+ UINTN *IfrPackageCount,
+ UINTN *StringPackageCount
)
{
UINTN Index;
TIANO_AUTOGEN_PACKAGES_HEADER **TianoAutogenPackageHdrArray;
ASSERT (Packages != NULL);
- ASSERT (IfrPackNum != NULL);
- ASSERT (StringPackNum != NULL);
+ ASSERT (IfrPackageCount != NULL);
+ ASSERT (StringPackageCount != NULL);
- *IfrPackNum = 0;
- *StringPackNum = 0;
+ *IfrPackageCount = 0;
+ *StringPackageCount = 0;
TianoAutogenPackageHdrArray = (TIANO_AUTOGEN_PACKAGES_HEADER **) (((UINT8 *) &Packages->GuidId) + sizeof (Packages->GuidId));
+
for (Index = 0; Index < Packages->NumberOfPackages; Index++) {
//
// BugBug: The current UEFI HII build tool generate a binary in the format defined in:
// TIANO_AUTOGEN_PACKAGES_HEADER. We assume that all packages generated in
- // this binary is with same package type. So the returned IfrPackNum and StringPackNum
+ // this binary is with same package type. So the returned IfrPackageCount and StringPackageCount
// may not be the exact number of valid package number in the binary generated
// by HII Build tool.
//
switch (TianoAutogenPackageHdrArray[Index]->PackageHeader.Type) {
case EFI_HII_PACKAGE_FORM:
- *IfrPackNum += 1;
+ *IfrPackageCount += 1;
break;
case EFI_HII_PACKAGE_STRINGS:
- *StringPackNum += 1;
+ *StringPackageCount += 1;
break;
case EFI_HII_PACKAGE_SIMPLE_FONTS:
@@ -74,71 +75,6 @@ GetIfrAndStringPackNum (
return EFI_SUCCESS;
}
-EFI_STATUS
-LibExportPackageLists (
- IN EFI_HII_HANDLE UefiHiiHandle,
- OUT EFI_HII_PACKAGE_LIST_HEADER **PackageListHeader,
- OUT UINTN *PackageListSize
- )
-{
- EFI_STATUS Status;
- UINTN Size;
- EFI_HII_PACKAGE_LIST_HEADER *PackageListHdr;
-
- ASSERT (PackageListSize != NULL);
- ASSERT (PackageListHeader != NULL);
-
- Size = 0;
- PackageListHdr = NULL;
- Status = mHiiDatabase->ExportPackageLists (
- mHiiDatabase,
- UefiHiiHandle,
- &Size,
- PackageListHdr
- );
- ASSERT_EFI_ERROR (Status == EFI_BUFFER_TOO_SMALL);
- if (Status == EFI_BUFFER_TOO_SMALL) {
- PackageListHdr = AllocateZeroPool (Size);
- ASSERT (PackageListHdr != NULL);
-
- if (PackageListHeader == NULL) {
- return EFI_OUT_OF_RESOURCES;
- } else {
- Status = mHiiDatabase->ExportPackageLists (
- mHiiDatabase,
- UefiHiiHandle,
- &Size,
- PackageListHdr
- );
- ASSERT_EFI_ERROR (Status);
- }
- }
-
- if (!EFI_ERROR (Status)) {
- *PackageListHeader = PackageListHdr;
- *PackageListSize = Size;
- }
-
- return Status;
-}
-
-EFI_STATUS
-InsertStringPackagesToIfrPackageList (
- IN CONST EFI_HII_PACKAGE_LIST_HEADER *StringPackageListHeader,
- IN EFI_HII_HANDLE UefiHiiHandle
- )
-{
- EFI_STATUS Status;
- Status = mHiiDatabase->UpdatePackageList (
- mHiiDatabase,
- UefiHiiHandle,
- StringPackageListHeader
- );
-
- return Status;
-}
-
-
/**
Removes a node from a doubly linked list, and returns the node that follows
the removed node.
@@ -161,27 +97,53 @@ InsertStringPackagesToIfrPackageList (
**/
EFI_STATUS
-AddStringPackagesToMatchingIfrPackageList (
- IN EFI_HII_THUNK_PRIVATE_DATA *Private,
+FindPackListWithOnlyIfrPackAndAddStringPack (
+ IN HII_THUNK_PRIVATE_DATA *Private,
+ IN HII_THUNK_CONTEXT *StringPackageThunkContext,
IN CONST EFI_HII_PACKAGE_LIST_HEADER *StringPackageListHeader
)
{
EFI_STATUS Status;
- LIST_ENTRY *ListEntry;
- HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *HandleMapEntry;
-
- for (ListEntry = Private->HiiThunkHandleMappingDBListHead.ForwardLink;
- ListEntry != &Private->HiiThunkHandleMappingDBListHead;
- ListEntry = ListEntry->ForwardLink
- ) {
- HandleMapEntry = HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY_FROM_LISTENTRY (ListEntry);
- if (CompareGuid (&StringPackageListHeader->PackageListGuid, &HandleMapEntry->TagGuid)) {
- Status = InsertStringPackagesToIfrPackageList (StringPackageListHeader, HandleMapEntry->UefiHiiHandle);
+ LIST_ENTRY *Link;
+ HII_THUNK_CONTEXT *ThunkContext;
+
+ Link = GetFirstNode (&Private->ThunkContextListHead);
+ while (!IsNull (&Private->ThunkContextListHead, Link)) {
+
+ ThunkContext = HII_THUNK_CONTEXT_FROM_LINK (Link);
+
+ if (StringPackageThunkContext != ThunkContext) {
+ //
+ // Skip the String Package Thunk Entry itself.
+ //
+
+ if (CompareGuid (&StringPackageListHeader->PackageListGuid, &ThunkContext->TagGuid)) {
+
+ ASSERT (ThunkContext->StringPackageCount == 0 && ThunkContext->IfrPackageCount == 1);
+
+ ThunkContext->StringPackageCount = GetPackageCountByType (StringPackageListHeader, EFI_HII_PACKAGE_STRINGS);
+
+ Status = mHiiDatabase->UpdatePackageList (
+ mHiiDatabase,
+ ThunkContext->UefiHiiHandle,
+ StringPackageListHeader
+ );
+ ASSERT (Status != EFI_NOT_FOUND);
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ }
}
+
+ Link = GetNextNode (&Private->ThunkContextListHead, Link);
}
+
return EFI_NOT_FOUND;
}
+
+
EFI_HII_PACKAGE_LIST_HEADER *
PrepareUefiPackageListFromFrameworkHiiPackages (
IN CONST EFI_HII_PACKAGES *Packages,
@@ -260,41 +222,169 @@ GenerateGuidId (
}
EFI_STATUS
-FindAndAddStringPackageToIfrPackageList(
- EFI_HII_THUNK_PRIVATE_DATA *Private,
- EFI_GUID *GuidId,
- EFI_HII_HANDLE UefiIfrHiiHandle
+FindStringPackAndAddToPackListWithOnlyIfrPack(
+ IN HII_THUNK_PRIVATE_DATA *Private,
+ IN HII_THUNK_CONTEXT *IfrThunkContext
)
{
- EFI_STATUS Status;
- LIST_ENTRY *ListEntry;
- HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *HandleMapEntry;
- EFI_HII_PACKAGE_LIST_HEADER *StringPackageListHeader;
- UINTN Size;
-
- for (ListEntry = Private->HiiThunkHandleMappingDBListHead.ForwardLink;
- ListEntry != &Private->HiiThunkHandleMappingDBListHead;
- ListEntry = ListEntry->ForwardLink
- ) {
- HandleMapEntry = HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY_FROM_LISTENTRY (ListEntry);
- if (CompareGuid (GuidId, &HandleMapEntry->TagGuid) && (!HandleMapEntry->DoesPackageListImportStringPackages)) {
- Status = LibExportPackageLists (HandleMapEntry->UefiHiiHandle, &StringPackageListHeader, &Size);
- ASSERT_EFI_ERROR (Status);
+ EFI_STATUS Status;
+ LIST_ENTRY *Link;
+ EFI_HII_PACKAGE_LIST_HEADER *StringPackageListHeader;
+ UINTN Size;
+ HII_THUNK_CONTEXT *ThunkContext;
- //
- // Add Function to only get only String Packages from the Package List
- //
+
+ Link = GetFirstNode (&Private->ThunkContextListHead);
+
+ while (!IsNull (&Private->ThunkContextListHead, Link)) {
+
+ ThunkContext = HII_THUNK_CONTEXT_FROM_LINK (Link);
+
+ if (ThunkContext != IfrThunkContext) {
+ if (CompareGuid (&IfrThunkContext->TagGuid, &ThunkContext->TagGuid) && (ThunkContext->IfrPackageCount == 0)) {
+ Status = HiiLibExportPackageLists (ThunkContext->UefiHiiHandle, &StringPackageListHeader, &Size);
+ ASSERT_EFI_ERROR (Status);
+
+ IfrThunkContext->StringPackageCount = GetPackageCountByType (StringPackageListHeader, EFI_HII_PACKAGE_STRINGS);
+ //
+ // Add Function to only get only String Packages from the Package List
+ //
+ Status = mHiiDatabase->UpdatePackageList (
+ mHiiDatabase,
+ IfrThunkContext->UefiHiiHandle,
+ StringPackageListHeader
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ FreePool (StringPackageListHeader);
+ return EFI_SUCCESS;
+ }
+ }
- Status = InsertStringPackagesToIfrPackageList (StringPackageListHeader, UefiIfrHiiHandle);
- ASSERT_EFI_ERROR (Status);
+ Link = GetNextNode (&Private->ThunkContextListHead, Link);
+ }
+
+ return EFI_NOT_FOUND;
+
+}
+
+HII_THUNK_CONTEXT *
+CreateThunkContext (
+ IN HII_THUNK_PRIVATE_DATA *Private,
+ IN UINTN StringPackageCount,
+ IN UINTN IfrPackageCount
+ )
+{
+ EFI_STATUS Status;
+ HII_THUNK_CONTEXT *ThunkContext;
+
+ ThunkContext = AllocateZeroPool (sizeof (HII_THUNK_CONTEXT));
+ ASSERT (ThunkContext != NULL);
+
+ ThunkContext->Signature = HII_THUNK_CONTEXT_SIGNATURE;
+ ThunkContext->IfrPackageCount = IfrPackageCount;
+ ThunkContext->StringPackageCount = StringPackageCount;
+ Status = AssignFrameworkHiiHandle (Private, TRUE, &ThunkContext->FwHiiHandle);
+ if (EFI_ERROR (Status)) {
+ return NULL;
+ }
+
+ InitializeListHead (&ThunkContext->QuestionIdMapListHead);
+ InitializeListHead (&ThunkContext->OneOfOptionMapListHead);
+
+
+ return ThunkContext;
+
+}
+
+VOID
+FreeFrameworkHiiHandle (
+ IN HII_THUNK_PRIVATE_DATA *Private,
+ IN FRAMEWORK_EFI_HII_HANDLE FwHandle
+ )
+{
+ //
+ // TODO:
+ //
+
+ return;
+}
+
+VOID
+DestoryOneOfOptionMap (
+ IN LIST_ENTRY *OneOfOptionMapListHead
+ )
+{
+ ONE_OF_OPTION_MAP *Map;
+ ONE_OF_OPTION_MAP_ENTRY *MapEntry;
+ LIST_ENTRY *Link;
+ LIST_ENTRY *Link2;
+
+ while (!IsListEmpty (OneOfOptionMapListHead)) {
+ Link = GetFirstNode (OneOfOptionMapListHead);
+
+ Map = ONE_OF_OPTION_MAP_FROM_LINK (Link);
+
+ while (!IsListEmpty (&Map->OneOfOptionMapEntryListHead)) {
+ Link2 = GetFirstNode (&Map->OneOfOptionMapEntryListHead);
- FreePool (StringPackageListHeader);
- return EFI_SUCCESS;
+ MapEntry = ONE_OF_OPTION_MAP_ENTRY_FROM_LINK (Link);
+
+ RemoveEntryList (Link2);
+
+ FreePool (MapEntry);
}
+
+ RemoveEntryList (Link);
+ FreePool (Map);
}
+}
- return EFI_NOT_FOUND;
+VOID
+DestroyQuestionIdMap (
+ IN LIST_ENTRY *QuestionIdMapListHead
+ )
+{
+ QUESTION_ID_MAP *IdMap;
+ QUESTION_ID_MAP_ENTRY *IdMapEntry;
+ LIST_ENTRY *Link;
+ LIST_ENTRY *Link2;
+ while (!IsListEmpty (QuestionIdMapListHead)) {
+ Link = GetFirstNode (QuestionIdMapListHead);
+
+ IdMap = QUESTION_ID_MAP_FROM_LINK (Link);
+
+ while (!IsListEmpty (&IdMap->MapEntryListHead)) {
+ Link2 = GetFirstNode (&IdMap->MapEntryListHead);
+
+ IdMapEntry = QUESTION_ID_MAP_ENTRY_FROM_LINK (Link);
+
+ RemoveEntryList (Link2);
+
+ FreePool (IdMapEntry);
+ }
+
+ RemoveEntryList (Link);
+ FreePool (IdMap);
+ }
+}
+
+VOID
+DestroyThunkContext (
+ IN HII_THUNK_PRIVATE_DATA *Private,
+ IN HII_THUNK_CONTEXT *ThunkContext
+ )
+{
+ ASSERT (ThunkContext != NULL);
+
+ FreeFrameworkHiiHandle (Private, ThunkContext->FwHiiHandle);
+
+ DestroyQuestionIdMap (&ThunkContext->QuestionIdMapListHead);
+
+ DestoryOneOfOptionMap (&ThunkContext->OneOfOptionMapListHead);
+
+ FreePool (ThunkContext);
}
CONST EFI_GUID mAGuid =
@@ -302,53 +392,59 @@ CONST EFI_GUID mAGuid =
EFI_STATUS
UefiRegisterPackageList(
- EFI_HII_THUNK_PRIVATE_DATA *Private,
- EFI_HII_PACKAGES *Packages,
- FRAMEWORK_EFI_HII_HANDLE *Handle
+ IN HII_THUNK_PRIVATE_DATA *Private,
+ IN EFI_HII_PACKAGES *Packages,
+ OUT FRAMEWORK_EFI_HII_HANDLE *Handle
)
{
EFI_STATUS Status;
- UINTN StringPackNum;
- UINTN IfrPackNum;
- EFI_HII_PACKAGE_LIST_HEADER *UefiPackageListHeader;
- HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *HandleMappingEntry;
+ UINTN StringPackageCount;
+ UINTN IfrPackageCount;
+ EFI_HII_PACKAGE_LIST_HEADER *PackageListHeader;
+ HII_THUNK_CONTEXT *ThunkContext;
EFI_GUID GuidId;
- UefiPackageListHeader = NULL;
+ PackageListHeader = NULL;
- Status = GetIfrAndStringPackNum (Packages, &IfrPackNum, &StringPackNum);
+ Status = GetPackageCount (Packages, &IfrPackageCount, &StringPackageCount);
ASSERT_EFI_ERROR (Status);
- //
- // Thunk Layer only handle the following combinations of IfrPack, StringPkg and FontPack.
- // Thunk Layer only allow zero or one IfrPack in the Package List.
- //
- if (IfrPackNum > 1) {
+
+ if (IfrPackageCount > 1) {
+ //
+ // HII Thunk only handle package with 0 or 1 IFR package.
+ //
return EFI_UNSUPPORTED;
}
- HandleMappingEntry = AllocateZeroPool (sizeof (*HandleMappingEntry));
- ASSERT (HandleMappingEntry != NULL);
-
- HandleMappingEntry->Signature = HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY_SIGNATURE;
- Status = AssignHiiHandle (Private, &HandleMappingEntry->FrameworkHiiHandle);
- if (EFI_ERROR (Status)) {
- goto Done;
+ ThunkContext = CreateThunkContext (Private, StringPackageCount, IfrPackageCount);
+ if (ThunkContext == NULL) {
+ return EFI_OUT_OF_RESOURCES;
}
- //
- // Packages->GuidId may be NULL. In such case, caller of FramworkHii->NewPack is registering
- // package with StringPack and IfrPack.
- //
if (Packages->GuidId == NULL) {
+ //
+ // UEFI HII Database require Package List GUID must be unique.
+ //
+ // If Packages->GuidId is NULL, the caller of FramworkHii->NewPack is registering
+ // packages with at least 1 StringPack and 1 IfrPack. Therefore, Packages->GuidId is
+ // not used as the name of the package list. A GUID is generated as a Package List
+ // GUID.
+ //
+ ASSERT (StringPackageCount >=1 && IfrPackageCount == 1);
Packages->GuidId = &GuidId;
GenerateGuidId (&mAGuid, Packages->GuidId);
} else {
+ //BugBug We need fix this.
+ //ASSERT (StringPackageCount == 0 || IfrPackageCount == 0);
CopyGuid (&GuidId, Packages->GuidId);
}
-
- CopyGuid (&HandleMappingEntry->TagGuid, Packages->GuidId);
- if ((StringPackNum == 0) && (IfrPackNum != 0)) {
+ //
+ // Record the Package List GUID, it is used as a name for the package list by Framework HII.
+ //
+ CopyGuid (&ThunkContext->TagGuid, Packages->GuidId);
+
+ if ((StringPackageCount == 0) && (IfrPackageCount != 0)) {
//
// UEFI HII database does not allow two package list with the same GUID.
// In Framework HII implementation, Packages->GuidId is used as an identifier to associate
@@ -361,68 +457,65 @@ UefiRegisterPackageList(
// UEFI HII require EFI_HII_CONFIG_ACCESS_PROTOCOL to be installed on a EFI_HANDLE, so
// that Setup Utility can load the Buffer Storage using this protocol.
//
- if (IfrPackNum != 0) {
- InstallDefaultUefiConfigAccessProtocol (Packages, HandleMappingEntry);
+ if (IfrPackageCount != 0) {
+ InstallDefaultConfigAccessProtocol (Packages, ThunkContext);
}
- UefiPackageListHeader = PrepareUefiPackageListFromFrameworkHiiPackages (Packages, &GuidId);
+ PackageListHeader = PrepareUefiPackageListFromFrameworkHiiPackages (Packages, &GuidId);
Status = mHiiDatabase->NewPackageList (
mHiiDatabase,
- UefiPackageListHeader,
- HandleMappingEntry->UefiHiiDriverHandle,
- &HandleMappingEntry->UefiHiiHandle
+ PackageListHeader,
+ ThunkContext->UefiHiiDriverHandle,
+ &ThunkContext->UefiHiiHandle
);
+
+ //
+ // BUGBUG: Remove when development is done
+ //
ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status)) {
goto Done;
}
- if (IfrPackNum == 0) {
- if (StringPackNum != 0) {
+ if (IfrPackageCount == 0) {
+ if (StringPackageCount != 0) {
//
- // Look for a package list with IFR Pack which has already registed with HII Database
+ // Find if there is Package List with only IFR Package in the databasee with the same
+ // tag. If found, add the String Package to this Package List.
//
- HandleMappingEntry->IsPackageListWithOnlyStringPackages = TRUE;
- Status = AddStringPackagesToMatchingIfrPackageList (
+ Status = FindPackListWithOnlyIfrPackAndAddStringPack (
Private,
- UefiPackageListHeader
+ ThunkContext,
+ PackageListHeader
);
- if (!EFI_ERROR (Status) || Status == EFI_NOT_FOUND) {
-
- if (Status == EFI_NOT_FOUND) {
- Status = EFI_SUCCESS;
- }
+ if (Status == EFI_NOT_FOUND) {
+ Status = EFI_SUCCESS;
}
}
} else {
- if (StringPackNum == 0) {
+ CreateQuestionIdMap (ThunkContext);
+
+ if (StringPackageCount == 0) {
//
// Register the Package List to UEFI HII first.
//
- Status = FindAndAddStringPackageToIfrPackageList (
+ Status = FindStringPackAndAddToPackListWithOnlyIfrPack (
Private,
- Packages->GuidId,
- HandleMappingEntry->UefiHiiHandle
+ ThunkContext
);
ASSERT_EFI_ERROR (Status);
- if (!EFI_ERROR (Status)) {
- HandleMappingEntry->DoesPackageListImportStringPackages = TRUE;
- }
}
}
- if (!EFI_ERROR (Status)) {
- InsertTailList (&Private->HiiThunkHandleMappingDBListHead, &HandleMappingEntry->List);
- }
-
Done:
if (EFI_ERROR (Status)) {
- FreePool (HandleMappingEntry);
+ DestroyThunkContext (Private, ThunkContext);
} else {
- *Handle = HandleMappingEntry->FrameworkHiiHandle;
+ InsertTailList (&Private->ThunkContextListHead, &ThunkContext->Link);
+ *Handle = ThunkContext->FwHiiHandle;
}
- SafeFreePool (UefiPackageListHeader);
+ SafeFreePool (PackageListHeader);
return Status;
}
@@ -455,7 +548,7 @@ Returns:
--*/
{
EFI_STATUS Status;
- EFI_HII_THUNK_PRIVATE_DATA *Private;
+ HII_THUNK_PRIVATE_DATA *Private;
EFI_TPL OldTpl;
if (Handle == NULL) {
@@ -476,7 +569,7 @@ Returns:
//
mInFrameworkHiiNewPack = TRUE;
- Private = EFI_HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
+ Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
Status = UefiRegisterPackageList (
Private,
@@ -509,49 +602,32 @@ Returns:
--*/
{
EFI_STATUS Status;
- EFI_HII_THUNK_PRIVATE_DATA *Private;
- HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *HandleMapEntry;
+ HII_THUNK_PRIVATE_DATA *Private;
+ HII_THUNK_CONTEXT *ThunkContext;
EFI_TPL OldTpl;
- EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess;
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
mInFrameworkHiiRemovePack = TRUE;
- Private = EFI_HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
+ Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
- HandleMapEntry = FrameworkHiiHandleToMapDatabaseEntry (Private, Handle);
+ ThunkContext = FwHiiHandleToThunkContext (Private, Handle);
- if (HandleMapEntry != NULL) {
+ if (ThunkContext != NULL) {
Status = mHiiDatabase->RemovePackageList (
mHiiDatabase,
- HandleMapEntry->UefiHiiHandle
+ ThunkContext->UefiHiiHandle
);
ASSERT_EFI_ERROR (Status);
- HiiLibDestroyHiiDriverHandle (HandleMapEntry->UefiHiiHandle);
-
- Status = gBS->HandleProtocol (
- HandleMapEntry->UefiHiiDriverHandle,
- &gEfiHiiConfigAccessProtocolGuid,
- (VOID **) &ConfigAccess
- );
-
- if (!EFI_ERROR (Status)) {
- Status = gBS->UninstallProtocolInterface (
- HandleMapEntry->UefiHiiDriverHandle,
- &gEfiHiiConfigAccessProtocolGuid,
- ConfigAccess
- );
- ASSERT_EFI_ERROR (Status);
- } else {
- Status = EFI_SUCCESS;
+ if (ThunkContext->IfrPackageCount != 0) {
+ UninstallDefaultConfigAccessProtocol (ThunkContext);
}
- RemoveEntryList (&HandleMapEntry->List);
-
- FreePool (HandleMapEntry);
+ RemoveEntryList (&ThunkContext->Link);
+ DestroyThunkContext (Private, ThunkContext);
}else {
Status = EFI_NOT_FOUND;
}
@@ -562,3 +638,150 @@ Returns:
return Status;
}
+
+EFI_STATUS
+EFIAPI
+NewOrAddPackNotify (
+ IN UINT8 PackageType,
+ IN CONST EFI_GUID *PackageGuid,
+ IN CONST EFI_HII_PACKAGE_HEADER *Package,
+ IN EFI_HII_HANDLE Handle,
+ IN EFI_HII_DATABASE_NOTIFY_TYPE NotifyType
+ )
+{
+ EFI_STATUS Status;
+ HII_THUNK_PRIVATE_DATA *Private;
+ HII_THUNK_CONTEXT *ThunkContext;
+
+ ASSERT (PackageType == EFI_HII_PACKAGE_STRINGS || PackageType == EFI_HII_PACKAGE_FORM);
+ ASSERT (NotifyType == EFI_HII_DATABASE_NOTIFY_ADD_PACK || NotifyType == EFI_HII_DATABASE_NOTIFY_NEW_PACK);
+
+ Status = EFI_SUCCESS;
+ Private = mHiiThunkPrivateData;
+
+ if (mInFrameworkHiiNewPack || mInFrameworkUpdatePakcage) {
+ return EFI_SUCCESS;
+ }
+
+ //
+ // We only create a ThunkContext if the Uefi Hii Handle is only already registered
+ // by the HII Thunk Layer.
+ //
+ ThunkContext = UefiHiiHandleToThunkContext (Private, Handle);
+ if (ThunkContext == NULL) {
+ ThunkContext = CreateThunkContextForUefiHiiHandle (Private, Handle);
+ ASSERT (ThunkContext != NULL);
+ }
+
+
+ if (PackageType == EFI_HII_PACKAGE_FORM) {
+ Status = CreateQuestionIdMap (ThunkContext);
+ }
+
+ return Status;
+}
+
+
+BOOLEAN
+IsRemovingLastStringPack (
+ IN EFI_HII_HANDLE Handle
+ )
+{
+ EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList;
+ UINTN BufferSize;
+ EFI_STATUS Status;
+ EFI_HII_PACKAGE_HEADER *PackageHeader;
+ UINTN StringPackageCount;
+
+ HiiPackageList = NULL;
+ BufferSize = 0;
+ StringPackageCount = 0;
+
+ Status = HiiLibExportPackageLists (Handle, &HiiPackageList, &BufferSize);
+ ASSERT_EFI_ERROR (Status);
+
+ PackageHeader = (EFI_HII_PACKAGE_HEADER *) ((UINT8 *) HiiPackageList + sizeof (EFI_HII_PACKAGE_LIST_HEADER));
+
+ while (PackageHeader->Type != EFI_HII_PACKAGE_END) {
+ switch (PackageHeader->Type) {
+ case EFI_HII_PACKAGE_STRINGS:
+ StringPackageCount++;
+
+ if (StringPackageCount > 1) {
+ //
+ // More than one String Pack in the package list
+ //
+ FreePool (HiiPackageList);
+ return FALSE;
+ }
+ break;
+
+ default:
+ break;
+ }
+ //
+ // goto header of next package
+ //
+ PackageHeader = (EFI_HII_PACKAGE_HEADER *) ((UINT8 *) PackageHeader + PackageHeader->Length);
+ }
+
+
+ //
+ // We will always be notified for the removal of String Pack from a package list.
+ // So StringPackageCount must be one at this point.
+ //
+ ASSERT (StringPackageCount == 1);
+
+ FreePool (HiiPackageList);
+ return TRUE;
+}
+
+
+
+// Framework HII module may cache a GUID as the name of the package list.
+// Then search for the Framework HII handle database for the handle matching
+// this GUID
+
+EFI_STATUS
+EFIAPI
+RemovePackNotify (
+ IN UINT8 PackageType,
+ IN CONST EFI_GUID *PackageGuid,
+ IN CONST EFI_HII_PACKAGE_HEADER *Package,
+ IN EFI_HII_HANDLE Handle,
+ IN EFI_HII_DATABASE_NOTIFY_TYPE NotifyType
+ )
+{
+ EFI_STATUS Status;
+ HII_THUNK_PRIVATE_DATA *Private;
+ HII_THUNK_CONTEXT * ThunkContext;
+
+ Status = EFI_SUCCESS;
+
+ ASSERT (PackageType == EFI_HII_PACKAGE_STRINGS);
+ ASSERT (NotifyType == EFI_HII_DATABASE_NOTIFY_REMOVE_PACK);
+
+ if (mInFrameworkHiiRemovePack || mInFrameworkUpdatePakcage) {
+ return EFI_SUCCESS;
+ }
+
+ Private = mHiiThunkPrivateData;
+
+ ThunkContext = UefiHiiHandleToThunkContext (Private, Handle);
+
+ if (ThunkContext->FwHiiHandle > Private->StaticHiiHandle) {
+ if (IsRemovingLastStringPack (Handle)) {
+ //
+ // If the string package will be removed is the last string package
+ // in the package list, we will remove the HII Thunk entry from the
+ // database.
+ //
+ Status = DestroyThunkContextForUefiHiiHandle (Private, Handle);
+ }
+ }
+
+ return Status;
+}
+
+
+