2008-04-03 12:36:52 +02:00
|
|
|
/**@file
|
2008-08-18 07:56:23 +02:00
|
|
|
Implement protocol interface related to package registrations.
|
2008-04-03 12:36:52 +02:00
|
|
|
|
|
|
|
Copyright (c) 2006 - 2008, Intel Corporation
|
|
|
|
All rights reserved. This program and the accompanying materials
|
|
|
|
are licensed and made available under the terms and conditions of the BSD License
|
|
|
|
which accompanies this distribution. The full text of the license may be found at
|
|
|
|
http://opensource.org/licenses/bsd-license.php
|
|
|
|
|
|
|
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
|
|
|
|
#include "HiiDatabase.h"
|
2008-08-20 16:17:24 +02:00
|
|
|
#include "HiiHandle.h"
|
2008-04-03 12:36:52 +02:00
|
|
|
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
STATIC BOOLEAN mInFrameworkHiiNewPack = FALSE;
|
|
|
|
STATIC BOOLEAN mInFrameworkHiiRemovePack = FALSE;
|
|
|
|
BOOLEAN mInFrameworkUpdatePakcage = FALSE;
|
2008-05-08 10:57:58 +02:00
|
|
|
|
|
|
|
|
2008-04-03 12:36:52 +02:00
|
|
|
EFI_STATUS
|
2008-08-18 07:56:23 +02:00
|
|
|
GetPackageCount (
|
2008-04-03 12:36:52 +02:00
|
|
|
IN CONST EFI_HII_PACKAGES *Packages,
|
2008-08-18 07:56:23 +02:00
|
|
|
UINTN *IfrPackageCount,
|
|
|
|
UINTN *StringPackageCount
|
2008-04-03 12:36:52 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
UINTN Index;
|
|
|
|
TIANO_AUTOGEN_PACKAGES_HEADER **TianoAutogenPackageHdrArray;
|
|
|
|
|
|
|
|
ASSERT (Packages != NULL);
|
2008-08-18 07:56:23 +02:00
|
|
|
ASSERT (IfrPackageCount != NULL);
|
|
|
|
ASSERT (StringPackageCount != NULL);
|
2008-04-03 12:36:52 +02:00
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
*IfrPackageCount = 0;
|
|
|
|
*StringPackageCount = 0;
|
2008-04-03 12:36:52 +02:00
|
|
|
|
|
|
|
TianoAutogenPackageHdrArray = (TIANO_AUTOGEN_PACKAGES_HEADER **) (((UINT8 *) &Packages->GuidId) + sizeof (Packages->GuidId));
|
2008-08-18 07:56:23 +02:00
|
|
|
|
2008-04-03 12:36:52 +02:00
|
|
|
for (Index = 0; Index < Packages->NumberOfPackages; Index++) {
|
|
|
|
//
|
2008-08-21 09:56:01 +02:00
|
|
|
// The current UEFI HII build tool generate a binary in the format defined by
|
2008-04-03 12:36:52 +02:00
|
|
|
// TIANO_AUTOGEN_PACKAGES_HEADER. We assume that all packages generated in
|
2008-08-18 07:56:23 +02:00
|
|
|
// this binary is with same package type. So the returned IfrPackageCount and StringPackageCount
|
2008-04-03 12:36:52 +02:00
|
|
|
// 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:
|
2008-08-18 07:56:23 +02:00
|
|
|
*IfrPackageCount += 1;
|
2008-04-03 12:36:52 +02:00
|
|
|
break;
|
|
|
|
case EFI_HII_PACKAGE_STRINGS:
|
2008-08-18 07:56:23 +02:00
|
|
|
*StringPackageCount += 1;
|
2008-04-03 12:36:52 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case EFI_HII_PACKAGE_SIMPLE_FONTS:
|
|
|
|
break;
|
|
|
|
|
|
|
|
//
|
|
|
|
// The following fonts are invalid for a module that using Framework to UEFI thunk layer.
|
|
|
|
//
|
|
|
|
case EFI_HII_PACKAGE_KEYBOARD_LAYOUT:
|
|
|
|
case EFI_HII_PACKAGE_FONTS:
|
|
|
|
case EFI_HII_PACKAGE_IMAGES:
|
|
|
|
default:
|
|
|
|
ASSERT (FALSE);
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2008-08-21 04:33:00 +02:00
|
|
|
VOID
|
|
|
|
UpdatePackListWithOnlyIfrPack (
|
2008-08-18 07:56:23 +02:00
|
|
|
IN HII_THUNK_PRIVATE_DATA *Private,
|
|
|
|
IN HII_THUNK_CONTEXT *StringPackageThunkContext,
|
2008-04-03 12:36:52 +02:00
|
|
|
IN CONST EFI_HII_PACKAGE_LIST_HEADER *StringPackageListHeader
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
2008-08-18 07:56:23 +02:00
|
|
|
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
|
|
|
|
);
|
2008-08-21 04:33:00 +02:00
|
|
|
ASSERT_EFI_ERROR (Status);
|
2008-08-18 07:56:23 +02:00
|
|
|
|
|
|
|
}
|
2008-04-03 12:36:52 +02:00
|
|
|
}
|
2008-08-18 07:56:23 +02:00
|
|
|
|
|
|
|
Link = GetNextNode (&Private->ThunkContextListHead, Link);
|
2008-04-03 12:36:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2008-08-18 07:56:23 +02:00
|
|
|
|
|
|
|
|
2008-04-03 12:36:52 +02:00
|
|
|
EFI_HII_PACKAGE_LIST_HEADER *
|
|
|
|
PrepareUefiPackageListFromFrameworkHiiPackages (
|
|
|
|
IN CONST EFI_HII_PACKAGES *Packages,
|
2008-05-08 10:57:58 +02:00
|
|
|
IN CONST EFI_GUID *PackageListGuid
|
2008-04-03 12:36:52 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
UINTN NumberOfPackages;
|
|
|
|
EFI_HII_PACKAGE_LIST_HEADER *PackageListHeader;
|
|
|
|
UINT8 *PackageListData;
|
|
|
|
UINT32 PackageListLength;
|
|
|
|
UINT32 PackageLength;
|
|
|
|
EFI_HII_PACKAGE_HEADER PackageHeader;
|
|
|
|
UINTN Index;
|
|
|
|
TIANO_AUTOGEN_PACKAGES_HEADER **TianoAutogenPackageHdrArray;
|
|
|
|
|
2008-05-08 10:57:58 +02:00
|
|
|
ASSERT (Packages != NULL);
|
|
|
|
ASSERT (PackageListGuid != NULL);
|
|
|
|
|
2008-04-03 12:36:52 +02:00
|
|
|
TianoAutogenPackageHdrArray = (TIANO_AUTOGEN_PACKAGES_HEADER **) ((UINT8 *) &Packages->GuidId + sizeof (Packages->GuidId));
|
|
|
|
NumberOfPackages = Packages->NumberOfPackages;
|
|
|
|
|
|
|
|
PackageListLength = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
|
|
|
|
|
|
|
|
for (Index = 0; Index < NumberOfPackages; Index++) {
|
|
|
|
CopyMem (&PackageLength, &TianoAutogenPackageHdrArray[Index]->BinaryLength, sizeof (UINT32));
|
2008-04-17 15:28:36 +02:00
|
|
|
//
|
|
|
|
//TIANO_AUTOGEN_PACKAGES_HEADER.BinaryLength include the BinaryLength itself.
|
|
|
|
//
|
|
|
|
PackageListLength += (PackageLength - sizeof(UINT32));
|
2008-04-03 12:36:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Include the lenght of EFI_HII_PACKAGE_END
|
|
|
|
//
|
|
|
|
PackageListLength += sizeof (EFI_HII_PACKAGE_HEADER);
|
|
|
|
PackageListHeader = AllocateZeroPool (PackageListLength);
|
|
|
|
ASSERT (PackageListHeader != NULL);
|
2008-05-08 10:57:58 +02:00
|
|
|
|
|
|
|
CopyMem (&PackageListHeader->PackageListGuid, PackageListGuid, sizeof (EFI_GUID));
|
2008-04-03 12:36:52 +02:00
|
|
|
PackageListHeader->PackageLength = PackageListLength;
|
|
|
|
|
|
|
|
PackageListData = ((UINT8 *) PackageListHeader) + sizeof (EFI_HII_PACKAGE_LIST_HEADER);
|
|
|
|
|
|
|
|
for (Index = 0; Index < NumberOfPackages; Index++) {
|
|
|
|
CopyMem (&PackageLength, &(TianoAutogenPackageHdrArray[Index]->BinaryLength), sizeof (UINT32));
|
|
|
|
PackageLength -= sizeof (UINT32);
|
|
|
|
CopyMem (PackageListData, &(TianoAutogenPackageHdrArray[Index]->PackageHeader), PackageLength);
|
|
|
|
PackageListData += PackageLength;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Append EFI_HII_PACKAGE_END
|
|
|
|
//
|
|
|
|
PackageHeader.Type = EFI_HII_PACKAGE_END;
|
|
|
|
PackageHeader.Length = sizeof (EFI_HII_PACKAGE_HEADER);
|
|
|
|
CopyMem (PackageListData, &PackageHeader, PackageHeader.Length);
|
|
|
|
|
|
|
|
return PackageListHeader;
|
|
|
|
}
|
|
|
|
|
2008-04-24 09:08:46 +02:00
|
|
|
VOID
|
2008-08-21 04:33:00 +02:00
|
|
|
GenerateRandomGuid (
|
|
|
|
OUT EFI_GUID * Guid
|
2008-04-03 12:36:52 +02:00
|
|
|
)
|
|
|
|
{
|
2008-08-29 03:53:37 +02:00
|
|
|
EFI_GUID GuidBase = { 0x14f95e01, 0xd562, 0x432e, { 0x84, 0x4a, 0x95, 0xa4, 0x39, 0x5, 0x10, 0x7e }};
|
|
|
|
static UINT64 Count = 0;
|
2008-04-03 12:36:52 +02:00
|
|
|
|
2008-08-21 04:33:00 +02:00
|
|
|
CopyGuid (Guid, &GuidBase);
|
2008-08-29 03:53:37 +02:00
|
|
|
|
|
|
|
Count++;
|
|
|
|
*((UINT64 *) Guid) = *((UINT64 *) Guid) + Count;
|
2008-04-03 12:36:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
EFI_STATUS
|
2008-08-21 04:33:00 +02:00
|
|
|
FindStringPackAndUpdatePackListWithOnlyIfrPack (
|
2008-08-18 07:56:23 +02:00
|
|
|
IN HII_THUNK_PRIVATE_DATA *Private,
|
|
|
|
IN HII_THUNK_CONTEXT *IfrThunkContext
|
2008-04-03 12:36:52 +02:00
|
|
|
)
|
|
|
|
{
|
2008-08-18 07:56:23 +02:00
|
|
|
EFI_STATUS Status;
|
|
|
|
LIST_ENTRY *Link;
|
|
|
|
EFI_HII_PACKAGE_LIST_HEADER *StringPackageListHeader;
|
|
|
|
UINTN Size;
|
|
|
|
HII_THUNK_CONTEXT *ThunkContext;
|
2008-04-03 12:36:52 +02:00
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
|
|
|
|
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;
|
2008-08-21 04:33:00 +02:00
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
}
|
|
|
|
}
|
2008-04-03 12:36:52 +02:00
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
Link = GetNextNode (&Private->ThunkContextListHead, Link);
|
|
|
|
}
|
|
|
|
|
2008-08-21 04:33:00 +02:00
|
|
|
ASSERT (FALSE);
|
2008-08-18 07:56:23 +02:00
|
|
|
return EFI_NOT_FOUND;
|
2008-08-21 04:33:00 +02:00
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-21 04:33:00 +02:00
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
2008-04-03 12:36:52 +02:00
|
|
|
EFI_STATUS
|
|
|
|
UefiRegisterPackageList(
|
2008-09-04 12:15:50 +02:00
|
|
|
IN EFI_HII_PROTOCOL *This,
|
2008-08-18 07:56:23 +02:00
|
|
|
IN HII_THUNK_PRIVATE_DATA *Private,
|
|
|
|
IN EFI_HII_PACKAGES *Packages,
|
|
|
|
OUT FRAMEWORK_EFI_HII_HANDLE *Handle
|
2008-04-03 12:36:52 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
2008-08-18 07:56:23 +02:00
|
|
|
UINTN StringPackageCount;
|
|
|
|
UINTN IfrPackageCount;
|
|
|
|
EFI_HII_PACKAGE_LIST_HEADER *PackageListHeader;
|
2008-08-21 04:33:00 +02:00
|
|
|
HII_THUNK_CONTEXT *ThunkContext;
|
2008-04-24 09:08:46 +02:00
|
|
|
EFI_GUID GuidId;
|
2008-04-03 12:36:52 +02:00
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
PackageListHeader = NULL;
|
2008-04-03 12:36:52 +02:00
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
Status = GetPackageCount (Packages, &IfrPackageCount, &StringPackageCount);
|
2008-04-03 12:36:52 +02:00
|
|
|
ASSERT_EFI_ERROR (Status);
|
2008-08-18 07:56:23 +02:00
|
|
|
|
|
|
|
if (IfrPackageCount > 1) {
|
|
|
|
//
|
|
|
|
// HII Thunk only handle package with 0 or 1 IFR package.
|
|
|
|
//
|
2008-08-21 04:33:00 +02:00
|
|
|
ASSERT (FALSE);
|
2008-04-24 09:08:46 +02:00
|
|
|
return EFI_UNSUPPORTED;
|
|
|
|
}
|
2008-04-03 12:36:52 +02:00
|
|
|
|
2008-04-24 09:08:46 +02:00
|
|
|
if (Packages->GuidId == NULL) {
|
2008-08-18 07:56:23 +02:00
|
|
|
//
|
|
|
|
// 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);
|
2008-08-21 04:33:00 +02:00
|
|
|
GenerateRandomGuid (&GuidId);
|
2008-05-08 10:57:58 +02:00
|
|
|
} else {
|
2008-09-04 12:15:50 +02:00
|
|
|
ThunkContext = TagGuidToIfrPackThunkContext (Private, Packages->GuidId);
|
|
|
|
|
|
|
|
if (IfrPackageCount > 0 &&
|
|
|
|
StringPackageCount > 0 &&
|
|
|
|
(ThunkContext!= NULL)) {
|
|
|
|
DEBUG((EFI_D_WARN, "Framework code registers HII package list with the same GUID more than once.\n"));
|
|
|
|
DEBUG((EFI_D_WARN, "This package list should be already registered. Just return successfully.\n"));
|
|
|
|
HiiRemovePack (This, ThunkContext->FwHiiHandle);
|
|
|
|
}
|
2008-05-08 10:57:58 +02:00
|
|
|
CopyGuid (&GuidId, Packages->GuidId);
|
2008-04-24 09:08:46 +02:00
|
|
|
}
|
2008-04-03 12:36:52 +02:00
|
|
|
|
2008-09-04 12:15:50 +02:00
|
|
|
ThunkContext = CreateThunkContext (Private, StringPackageCount, IfrPackageCount);
|
|
|
|
if (ThunkContext == NULL) {
|
|
|
|
return EFI_OUT_OF_RESOURCES;
|
|
|
|
}
|
|
|
|
ThunkContext->ByFrameworkHiiNewPack = TRUE;
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
//
|
|
|
|
// Record the Package List GUID, it is used as a name for the package list by Framework HII.
|
|
|
|
//
|
2008-08-21 04:33:00 +02:00
|
|
|
CopyGuid (&ThunkContext->TagGuid, &GuidId);
|
2008-08-18 07:56:23 +02:00
|
|
|
|
|
|
|
if ((StringPackageCount == 0) && (IfrPackageCount != 0)) {
|
2008-04-03 12:36:52 +02:00
|
|
|
//
|
|
|
|
// 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
|
|
|
|
// a PackageList with only IFR to a Package list the with String package.
|
|
|
|
//
|
2008-08-21 04:33:00 +02:00
|
|
|
GenerateRandomGuid (&GuidId);
|
2008-04-03 12:36:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// UEFI HII require EFI_HII_CONFIG_ACCESS_PROTOCOL to be installed on a EFI_HANDLE, so
|
2008-04-30 05:20:10 +02:00
|
|
|
// that Setup Utility can load the Buffer Storage using this protocol.
|
2008-04-03 12:36:52 +02:00
|
|
|
//
|
2008-08-18 07:56:23 +02:00
|
|
|
if (IfrPackageCount != 0) {
|
|
|
|
InstallDefaultConfigAccessProtocol (Packages, ThunkContext);
|
2008-04-03 12:36:52 +02:00
|
|
|
}
|
2008-08-18 07:56:23 +02:00
|
|
|
PackageListHeader = PrepareUefiPackageListFromFrameworkHiiPackages (Packages, &GuidId);
|
2008-04-24 09:08:46 +02:00
|
|
|
Status = mHiiDatabase->NewPackageList (
|
|
|
|
mHiiDatabase,
|
2008-08-18 07:56:23 +02:00
|
|
|
PackageListHeader,
|
|
|
|
ThunkContext->UefiHiiDriverHandle,
|
|
|
|
&ThunkContext->UefiHiiHandle
|
2008-04-03 12:36:52 +02:00
|
|
|
);
|
2008-08-18 07:56:23 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// BUGBUG: Remove when development is done
|
|
|
|
//
|
2008-04-03 12:36:52 +02:00
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
goto Done;
|
|
|
|
}
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
if (IfrPackageCount == 0) {
|
|
|
|
if (StringPackageCount != 0) {
|
2008-04-03 12:36:52 +02:00
|
|
|
//
|
2008-08-21 04:33:00 +02:00
|
|
|
// Look for a Package List with only IFR Package with the same GUID name.
|
|
|
|
// If found one, add the String Packages to it.
|
2008-04-03 12:36:52 +02:00
|
|
|
//
|
2008-08-21 04:33:00 +02:00
|
|
|
UpdatePackListWithOnlyIfrPack (
|
|
|
|
Private,
|
|
|
|
ThunkContext,
|
|
|
|
PackageListHeader
|
|
|
|
);
|
2008-04-03 12:36:52 +02:00
|
|
|
}
|
|
|
|
} else {
|
2008-08-18 07:56:23 +02:00
|
|
|
CreateQuestionIdMap (ThunkContext);
|
|
|
|
|
|
|
|
if (StringPackageCount == 0) {
|
2008-04-03 12:36:52 +02:00
|
|
|
//
|
|
|
|
// Register the Package List to UEFI HII first.
|
|
|
|
//
|
2008-08-21 04:33:00 +02:00
|
|
|
Status = FindStringPackAndUpdatePackListWithOnlyIfrPack (
|
2008-04-03 12:36:52 +02:00
|
|
|
Private,
|
2008-08-18 07:56:23 +02:00
|
|
|
ThunkContext
|
2008-04-03 12:36:52 +02:00
|
|
|
);
|
2008-08-21 04:33:00 +02:00
|
|
|
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
goto Done;
|
|
|
|
}
|
2008-04-03 12:36:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Done:
|
|
|
|
if (EFI_ERROR (Status)) {
|
2008-08-20 16:17:24 +02:00
|
|
|
DestroyThunkContext (ThunkContext);
|
2008-04-03 12:36:52 +02:00
|
|
|
} else {
|
2008-08-18 07:56:23 +02:00
|
|
|
InsertTailList (&Private->ThunkContextListHead, &ThunkContext->Link);
|
|
|
|
*Handle = ThunkContext->FwHiiHandle;
|
2008-04-03 12:36:52 +02:00
|
|
|
}
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
SafeFreePool (PackageListHeader);
|
2008-04-03 12:36:52 +02:00
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2008-05-07 10:49:04 +02:00
|
|
|
|
2008-04-03 12:36:52 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
HiiNewPack (
|
|
|
|
IN EFI_HII_PROTOCOL *This,
|
|
|
|
IN EFI_HII_PACKAGES *Packages,
|
|
|
|
OUT FRAMEWORK_EFI_HII_HANDLE *Handle
|
|
|
|
)
|
|
|
|
/*++
|
|
|
|
|
|
|
|
Routine Description:
|
|
|
|
|
|
|
|
Extracts the various packs from a package list.
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
|
|
|
|
This - Pointer of HII protocol.
|
|
|
|
Packages - Pointer of HII packages.
|
|
|
|
Handle - Handle value to be returned.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
EFI_SUCCESS - Pacakges has added to HII database successfully.
|
|
|
|
EFI_INVALID_PARAMETER - Invalid parameter.
|
|
|
|
|
|
|
|
--*/
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
2008-08-18 07:56:23 +02:00
|
|
|
HII_THUNK_PRIVATE_DATA *Private;
|
2008-05-08 10:57:58 +02:00
|
|
|
EFI_TPL OldTpl;
|
2008-04-03 12:36:52 +02:00
|
|
|
|
|
|
|
if (Handle == NULL) {
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Packages == NULL) {
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
2008-05-08 10:57:58 +02:00
|
|
|
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
|
|
|
|
|
2008-05-07 10:49:04 +02:00
|
|
|
//
|
|
|
|
// We use a simple Global variable to inform NewPackNotify
|
|
|
|
// that the package list registered here is already registered
|
|
|
|
// in the HII Thunk Layer. So NewPackNotify does not need to
|
|
|
|
// call RegisterUefiHiiHandle () to registered it.
|
|
|
|
//
|
|
|
|
mInFrameworkHiiNewPack = TRUE;
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
|
2008-04-03 12:36:52 +02:00
|
|
|
|
|
|
|
Status = UefiRegisterPackageList (
|
2008-09-04 12:15:50 +02:00
|
|
|
This,
|
2008-04-03 12:36:52 +02:00
|
|
|
Private,
|
|
|
|
Packages,
|
|
|
|
Handle
|
|
|
|
);
|
|
|
|
|
2008-05-07 10:49:04 +02:00
|
|
|
mInFrameworkHiiNewPack = FALSE;
|
|
|
|
|
2008-05-08 10:57:58 +02:00
|
|
|
gBS->RestoreTPL (OldTpl);
|
|
|
|
|
2008-04-03 12:36:52 +02:00
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
HiiRemovePack (
|
|
|
|
IN EFI_HII_PROTOCOL *This,
|
|
|
|
IN FRAMEWORK_EFI_HII_HANDLE Handle
|
|
|
|
)
|
|
|
|
/*++
|
|
|
|
|
|
|
|
Routine Description:
|
|
|
|
Removes the various packs from a Handle
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
--*/
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
2008-08-18 07:56:23 +02:00
|
|
|
HII_THUNK_PRIVATE_DATA *Private;
|
|
|
|
HII_THUNK_CONTEXT *ThunkContext;
|
2008-05-08 10:57:58 +02:00
|
|
|
EFI_TPL OldTpl;
|
|
|
|
|
|
|
|
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
|
|
|
|
|
|
|
|
mInFrameworkHiiRemovePack = TRUE;
|
2008-04-03 12:36:52 +02:00
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
|
2008-04-03 12:36:52 +02:00
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
ThunkContext = FwHiiHandleToThunkContext (Private, Handle);
|
2008-04-03 12:36:52 +02:00
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
if (ThunkContext != NULL) {
|
2008-04-24 09:08:46 +02:00
|
|
|
Status = mHiiDatabase->RemovePackageList (
|
|
|
|
mHiiDatabase,
|
2008-08-18 07:56:23 +02:00
|
|
|
ThunkContext->UefiHiiHandle
|
2008-04-17 15:28:36 +02:00
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
if (ThunkContext->IfrPackageCount != 0) {
|
|
|
|
UninstallDefaultConfigAccessProtocol (ThunkContext);
|
2008-04-03 12:36:52 +02:00
|
|
|
}
|
2008-04-17 15:28:36 +02:00
|
|
|
|
2008-08-20 16:17:24 +02:00
|
|
|
DestroyThunkContext (ThunkContext);
|
2008-05-08 10:57:58 +02:00
|
|
|
}else {
|
|
|
|
Status = EFI_NOT_FOUND;
|
2008-04-03 12:36:52 +02:00
|
|
|
}
|
|
|
|
|
2008-05-08 10:57:58 +02:00
|
|
|
mInFrameworkHiiRemovePack = FALSE;
|
|
|
|
gBS->RestoreTPL (OldTpl);
|
|
|
|
|
|
|
|
return Status;
|
2008-04-03 12:36:52 +02:00
|
|
|
}
|
2008-08-18 07:56:23 +02:00
|
|
|
|
|
|
|
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) {
|
2008-08-20 16:17:24 +02:00
|
|
|
ThunkContext = CreateThunkContextForUefiHiiHandle (Handle);
|
2008-08-18 07:56:23 +02:00
|
|
|
ASSERT (ThunkContext != NULL);
|
2008-08-20 16:17:24 +02:00
|
|
|
|
|
|
|
InsertTailList (&Private->ThunkContextListHead, &ThunkContext->Link);
|
2008-08-18 07:56:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (PackageType == EFI_HII_PACKAGE_FORM) {
|
2008-08-21 04:33:00 +02:00
|
|
|
GetAttributesOfFirstFormSet (ThunkContext);
|
2008-08-18 07:56:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2008-08-21 04:33:00 +02:00
|
|
|
//
|
2008-08-18 07:56:23 +02:00
|
|
|
// 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
|
|
|
|
)
|
|
|
|
{
|
2008-08-21 04:33:00 +02:00
|
|
|
EFI_STATUS Status;
|
|
|
|
HII_THUNK_PRIVATE_DATA *Private;
|
|
|
|
HII_THUNK_CONTEXT *ThunkContext;
|
|
|
|
EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList;
|
|
|
|
UINTN BufferSize;
|
2008-08-18 07:56:23 +02:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2008-09-05 09:01:47 +02:00
|
|
|
//
|
|
|
|
// BugBug: Change to ASSERT if HII Database fix the bug and to also invoke
|
|
|
|
// NEW_PACK_NOTIFY for package (String Package) created internally.
|
|
|
|
//
|
|
|
|
if (ThunkContext != NULL) {
|
|
|
|
if (!ThunkContext->ByFrameworkHiiNewPack) {
|
|
|
|
Status = HiiLibExportPackageLists (Handle, &HiiPackageList, &BufferSize);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
2008-08-21 04:33:00 +02:00
|
|
|
|
2008-09-05 09:01:47 +02:00
|
|
|
if (GetPackageCountByType (HiiPackageList, EFI_HII_PACKAGE_STRINGS) == 1) {
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
DestroyThunkContextForUefiHiiHandle (Private, Handle);
|
|
|
|
}
|
2008-08-21 04:33:00 +02:00
|
|
|
|
2008-09-05 09:01:47 +02:00
|
|
|
FreePool (HiiPackageList);
|
|
|
|
}
|
2008-08-18 07:56:23 +02:00
|
|
|
}
|
|
|
|
|
2008-09-05 09:01:47 +02:00
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|