1) Fix a bug. Before this fix, a Module that calling UEFI HII Interface to get the String Information will fail to locate the Package List based on a Package GUID if a required String Pack is registered using Framework HII NewPack instance.

2) Correct a few other minor issues.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5185 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
qwang12 2008-05-08 08:57:58 +00:00
parent adf74fc6b2
commit 63dd6a961c
5 changed files with 57 additions and 28 deletions

View File

@ -120,7 +120,6 @@ GetBufferStorage (
EFI_STATUS EFI_STATUS
InstallDefaultUefiConfigAccessProtocol ( InstallDefaultUefiConfigAccessProtocol (
IN CONST EFI_HII_PACKAGES *Packages, IN CONST EFI_HII_PACKAGES *Packages,
OUT EFI_HANDLE *Handle,
IN OUT HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *MapEntry IN OUT HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *MapEntry
) )
{ {
@ -128,7 +127,7 @@ InstallDefaultUefiConfigAccessProtocol (
EFI_STATUS Status; EFI_STATUS Status;
HII_TRHUNK_CONFIG_ACCESS_PROTOCOL_INSTANCE *ConfigAccessInstance; HII_TRHUNK_CONFIG_ACCESS_PROTOCOL_INSTANCE *ConfigAccessInstance;
Status = HiiLibCreateHiiDriverHandle (Handle); Status = HiiLibCreateHiiDriverHandle (&MapEntry->UefiHiiDriverHandle);
ConfigAccessInstance = AllocateCopyPool ( ConfigAccessInstance = AllocateCopyPool (
sizeof (HII_TRHUNK_CONFIG_ACCESS_PROTOCOL_INSTANCE), sizeof (HII_TRHUNK_CONFIG_ACCESS_PROTOCOL_INSTANCE),
&ConfigAccessProtocolInstanceTempate &ConfigAccessProtocolInstanceTempate
@ -147,7 +146,7 @@ InstallDefaultUefiConfigAccessProtocol (
} }
Status = gBS->InstallMultipleProtocolInterfaces ( Status = gBS->InstallMultipleProtocolInterfaces (
Handle, &MapEntry->UefiHiiDriverHandle,
&gEfiHiiConfigAccessProtocolGuid, &gEfiHiiConfigAccessProtocolGuid,
&ConfigAccessInstance->ConfigAccessProtocol, &ConfigAccessInstance->ConfigAccessProtocol,
NULL NULL

View File

@ -21,7 +21,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
EFI_STATUS EFI_STATUS
InstallDefaultUefiConfigAccessProtocol ( InstallDefaultUefiConfigAccessProtocol (
IN CONST EFI_HII_PACKAGES *Packages, IN CONST EFI_HII_PACKAGES *Packages,
OUT EFI_HANDLE *Handle,
IN OUT HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *MapEntry IN OUT HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *MapEntry
) )
; ;

View File

@ -136,6 +136,10 @@ AddPackNotify (
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
Private = mHiiThunkPrivateData; Private = mHiiThunkPrivateData;
if (mInFrameworkHiiNewPack) {
return EFI_SUCCESS;
}
// //
// We only create a MapEntry if the Uefi Hii Handle is only already registered // We only create a MapEntry if the Uefi Hii Handle is only already registered
// by the HII Thunk Layer. // by the HII Thunk Layer.
@ -252,6 +256,10 @@ RemovePackNotify (
ASSERT (PackageType == EFI_HII_PACKAGE_STRINGS); ASSERT (PackageType == EFI_HII_PACKAGE_STRINGS);
ASSERT (NotifyType == EFI_HII_DATABASE_NOTIFY_REMOVE_PACK); ASSERT (NotifyType == EFI_HII_DATABASE_NOTIFY_REMOVE_PACK);
if (mInFrameworkHiiRemovePack) {
return EFI_SUCCESS;
}
Private = mHiiThunkPrivateData; Private = mHiiThunkPrivateData;
MapEntry = UefiHiiHandleToMapDatabaseEntry (Private, Handle); MapEntry = UefiHiiHandleToMapDatabaseEntry (Private, Handle);

View File

@ -95,6 +95,7 @@ typedef struct {
UINT32 Signature; UINT32 Signature;
FRAMEWORK_EFI_HII_HANDLE FrameworkHiiHandle; FRAMEWORK_EFI_HII_HANDLE FrameworkHiiHandle;
EFI_HII_HANDLE UefiHiiHandle; EFI_HII_HANDLE UefiHiiHandle;
EFI_HANDLE UefiHiiDriverHandle;
BOOLEAN IsPackageListWithOnlyStringPackages; BOOLEAN IsPackageListWithOnlyStringPackages;
// //
@ -151,6 +152,7 @@ extern CONST EFI_HII_STRING_PROTOCOL *mHiiStringProtocol;
extern CONST EFI_HII_CONFIG_ROUTING_PROTOCOL *mHiiConfigRoutingProtocol; extern CONST EFI_HII_CONFIG_ROUTING_PROTOCOL *mHiiConfigRoutingProtocol;
extern BOOLEAN mInFrameworkHiiNewPack; extern BOOLEAN mInFrameworkHiiNewPack;
extern BOOLEAN mInFrameworkHiiRemovePack;
// //

View File

@ -17,6 +17,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "HiiDatabase.h" #include "HiiDatabase.h"
BOOLEAN mInFrameworkHiiNewPack = FALSE;
BOOLEAN mInFrameworkHiiRemovePack = FALSE;
EFI_STATUS EFI_STATUS
GetIfrAndStringPackNum ( GetIfrAndStringPackNum (
IN CONST EFI_HII_PACKAGES *Packages, IN CONST EFI_HII_PACKAGES *Packages,
@ -196,7 +200,7 @@ AddStringPackagesToMatchingIfrPackageList (
EFI_HII_PACKAGE_LIST_HEADER * EFI_HII_PACKAGE_LIST_HEADER *
PrepareUefiPackageListFromFrameworkHiiPackages ( PrepareUefiPackageListFromFrameworkHiiPackages (
IN CONST EFI_HII_PACKAGES *Packages, IN CONST EFI_HII_PACKAGES *Packages,
IN CONST EFI_GUID *GuidId OPTIONAL IN CONST EFI_GUID *PackageListGuid
) )
{ {
UINTN NumberOfPackages; UINTN NumberOfPackages;
@ -208,6 +212,9 @@ PrepareUefiPackageListFromFrameworkHiiPackages (
UINTN Index; UINTN Index;
TIANO_AUTOGEN_PACKAGES_HEADER **TianoAutogenPackageHdrArray; TIANO_AUTOGEN_PACKAGES_HEADER **TianoAutogenPackageHdrArray;
ASSERT (Packages != NULL);
ASSERT (PackageListGuid != NULL);
TianoAutogenPackageHdrArray = (TIANO_AUTOGEN_PACKAGES_HEADER **) ((UINT8 *) &Packages->GuidId + sizeof (Packages->GuidId)); TianoAutogenPackageHdrArray = (TIANO_AUTOGEN_PACKAGES_HEADER **) ((UINT8 *) &Packages->GuidId + sizeof (Packages->GuidId));
NumberOfPackages = Packages->NumberOfPackages; NumberOfPackages = Packages->NumberOfPackages;
@ -227,11 +234,8 @@ PrepareUefiPackageListFromFrameworkHiiPackages (
PackageListLength += sizeof (EFI_HII_PACKAGE_HEADER); PackageListLength += sizeof (EFI_HII_PACKAGE_HEADER);
PackageListHeader = AllocateZeroPool (PackageListLength); PackageListHeader = AllocateZeroPool (PackageListLength);
ASSERT (PackageListHeader != NULL); ASSERT (PackageListHeader != NULL);
if (GuidId == NULL) {
CopyMem (&PackageListHeader->PackageListGuid, Packages->GuidId, sizeof (EFI_GUID)); CopyMem (&PackageListHeader->PackageListGuid, PackageListGuid, sizeof (EFI_GUID));
} else {
CopyMem (&PackageListHeader->PackageListGuid, GuidId, sizeof (EFI_GUID));
}
PackageListHeader->PackageLength = PackageListLength; PackageListHeader->PackageLength = PackageListLength;
PackageListData = ((UINT8 *) PackageListHeader) + sizeof (EFI_HII_PACKAGE_LIST_HEADER); PackageListData = ((UINT8 *) PackageListHeader) + sizeof (EFI_HII_PACKAGE_LIST_HEADER);
@ -324,9 +328,7 @@ UefiRegisterPackageList(
EFI_HII_PACKAGE_LIST_HEADER *UefiPackageListHeader; EFI_HII_PACKAGE_LIST_HEADER *UefiPackageListHeader;
HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *HandleMappingEntry; HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *HandleMappingEntry;
EFI_GUID GuidId; EFI_GUID GuidId;
EFI_HANDLE UefiHiiDriverHandle;
UefiHiiDriverHandle = NULL;
UefiPackageListHeader = NULL; UefiPackageListHeader = NULL;
Status = GetIfrAndStringPackNum (Packages, &IfrPackNum, &StringPackNum); Status = GetIfrAndStringPackNum (Packages, &IfrPackNum, &StringPackNum);
@ -355,6 +357,8 @@ UefiRegisterPackageList(
if (Packages->GuidId == NULL) { if (Packages->GuidId == NULL) {
Packages->GuidId = &GuidId; Packages->GuidId = &GuidId;
GenerateGuidId (&mAGuid, Packages->GuidId); GenerateGuidId (&mAGuid, Packages->GuidId);
} else {
CopyGuid (&GuidId, Packages->GuidId);
} }
CopyGuid (&HandleMappingEntry->TagGuid, Packages->GuidId); CopyGuid (&HandleMappingEntry->TagGuid, Packages->GuidId);
@ -373,13 +377,13 @@ UefiRegisterPackageList(
// that Setup Utility can load the Buffer Storage using this protocol. // that Setup Utility can load the Buffer Storage using this protocol.
// //
if (IfrPackNum != 0) { if (IfrPackNum != 0) {
InstallDefaultUefiConfigAccessProtocol (Packages, &UefiHiiDriverHandle, HandleMappingEntry); InstallDefaultUefiConfigAccessProtocol (Packages, HandleMappingEntry);
} }
UefiPackageListHeader = PrepareUefiPackageListFromFrameworkHiiPackages (Packages, &GuidId); UefiPackageListHeader = PrepareUefiPackageListFromFrameworkHiiPackages (Packages, &GuidId);
Status = mHiiDatabase->NewPackageList ( Status = mHiiDatabase->NewPackageList (
mHiiDatabase, mHiiDatabase,
UefiPackageListHeader, UefiPackageListHeader,
UefiHiiDriverHandle, HandleMappingEntry->UefiHiiDriverHandle,
&HandleMappingEntry->UefiHiiHandle &HandleMappingEntry->UefiHiiHandle
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
@ -438,7 +442,6 @@ Done:
return Status; return Status;
} }
BOOLEAN mInFrameworkHiiNewPack = FALSE;
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
@ -468,6 +471,7 @@ Returns:
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_HII_THUNK_PRIVATE_DATA *Private; EFI_HII_THUNK_PRIVATE_DATA *Private;
EFI_TPL OldTpl;
if (Handle == NULL) { if (Handle == NULL) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
@ -477,6 +481,8 @@ Returns:
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
// //
// We use a simple Global variable to inform NewPackNotify // We use a simple Global variable to inform NewPackNotify
// that the package list registered here is already registered // that the package list registered here is already registered
@ -495,6 +501,8 @@ Returns:
mInFrameworkHiiNewPack = FALSE; mInFrameworkHiiNewPack = FALSE;
gBS->RestoreTPL (OldTpl);
return Status; return Status;
} }
@ -518,41 +526,54 @@ Returns:
EFI_STATUS Status; EFI_STATUS Status;
EFI_HII_THUNK_PRIVATE_DATA *Private; EFI_HII_THUNK_PRIVATE_DATA *Private;
HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *HandleMapEntry; HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *HandleMapEntry;
EFI_DEVICE_PATH_PROTOCOL *Path; 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 = EFI_HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
HandleMapEntry = FrameworkHiiHandleToMapDatabaseEntry (Private, Handle); HandleMapEntry = FrameworkHiiHandleToMapDatabaseEntry (Private, Handle);
if (HandleMapEntry->UefiHiiHandle != NULL) { if (HandleMapEntry != NULL) {
Status = mHiiDatabase->RemovePackageList ( Status = mHiiDatabase->RemovePackageList (
mHiiDatabase, mHiiDatabase,
HandleMapEntry->UefiHiiHandle HandleMapEntry->UefiHiiHandle
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
HiiLibDestroyHiiDriverHandle (HandleMapEntry->UefiHiiHandle);
Status = gBS->HandleProtocol ( Status = gBS->HandleProtocol (
HandleMapEntry->UefiHiiHandle, HandleMapEntry->UefiHiiDriverHandle,
&gEfiDevicePathProtocolGuid, &gEfiHiiConfigAccessProtocolGuid,
&Path (VOID **) &ConfigAccess
); );
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Status = gBS->UninstallProtocolInterface ( Status = gBS->UninstallProtocolInterface (
HandleMapEntry->UefiHiiHandle, HandleMapEntry->UefiHiiDriverHandle,
&gEfiDevicePathProtocolGuid, &gEfiHiiConfigAccessProtocolGuid,
Path ConfigAccess
); );
if (!EFI_ERROR (Status)) { ASSERT_EFI_ERROR (Status);
FreePool (Path); } else {
} Status = EFI_SUCCESS;
} }
RemoveEntryList (&HandleMapEntry->List); RemoveEntryList (&HandleMapEntry->List);
FreePool (HandleMapEntry); FreePool (HandleMapEntry);
return Status;
}else {
Status = EFI_NOT_FOUND;
} }
return EFI_NOT_FOUND; mInFrameworkHiiRemovePack = FALSE;
gBS->RestoreTPL (OldTpl);
return Status;
} }