2008-04-03 12:36:52 +02:00
|
|
|
|
/**@file
|
|
|
|
|
This file contains the form processing code to the HII database.
|
|
|
|
|
|
|
|
|
|
Copyright (c) 2006 - 2008 Intel Corporation. <BR>
|
|
|
|
|
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-04-24 09:08:46 +02:00
|
|
|
|
#include "UefiIfrDefault.h"
|
2008-04-30 05:20:10 +02:00
|
|
|
|
#include "OpcodeCreation.h"
|
2008-04-03 12:36:52 +02:00
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
|
//
|
|
|
|
|
// This structure is only intended to be used in this file.
|
|
|
|
|
//
|
2008-05-07 10:49:04 +02:00
|
|
|
|
#pragma pack(push, 1)
|
|
|
|
|
typedef struct {
|
|
|
|
|
EFI_HII_PACK_HEADER PackageHeader;
|
|
|
|
|
FRAMEWORK_EFI_IFR_FORM_SET FormSet;
|
|
|
|
|
FRAMEWORK_EFI_IFR_END_FORM_SET EndFormSet;
|
2008-08-18 07:56:23 +02:00
|
|
|
|
} FW_HII_FORMSET_TEMPLATE;
|
2008-05-07 10:49:04 +02:00
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
|
FW_HII_FORMSET_TEMPLATE FormSetTemplate = {
|
2008-05-07 10:49:04 +02:00
|
|
|
|
{
|
2008-08-18 07:56:23 +02:00
|
|
|
|
sizeof (FW_HII_FORMSET_TEMPLATE),
|
2008-05-07 10:49:04 +02:00
|
|
|
|
EFI_HII_IFR
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
FRAMEWORK_EFI_IFR_FORM_SET_OP,
|
|
|
|
|
sizeof (FRAMEWORK_EFI_IFR_FORM_SET)
|
|
|
|
|
},
|
2008-08-21 09:56:01 +02:00
|
|
|
|
{0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}}, //Guid
|
2008-05-07 10:49:04 +02:00
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0
|
|
|
|
|
},
|
|
|
|
|
{
|
2008-05-16 11:43:38 +02:00
|
|
|
|
{
|
|
|
|
|
FRAMEWORK_EFI_IFR_END_FORM_SET_OP,
|
|
|
|
|
sizeof (FRAMEWORK_EFI_IFR_END_FORM_SET)
|
|
|
|
|
}
|
2008-05-07 10:49:04 +02:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2008-04-03 12:36:52 +02:00
|
|
|
|
|
2008-11-10 13:40:07 +01:00
|
|
|
|
EFI_GUID mTianoHiiIfrGuid = EFI_IFR_TIANO_GUID;
|
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
|
/**
|
2008-04-03 12:36:52 +02:00
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
|
This thunk module only handles UEFI HII packages. The caller of this function
|
|
|
|
|
won<EFBFBD><EFBFBD>t be able to parse the content. Therefore, it is not supported.
|
|
|
|
|
|
|
|
|
|
This function will ASSERT and return EFI_UNSUPPORTED.
|
2008-04-03 12:36:52 +02:00
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
|
@param This N.A.
|
|
|
|
|
@param Handle N.A.
|
|
|
|
|
@param BufferSize N.A.
|
|
|
|
|
@param Buffer N.A.
|
2008-04-03 12:36:52 +02:00
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
|
@retval EFI_UNSUPPORTED
|
2008-04-03 12:36:52 +02:00
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
|
**/
|
|
|
|
|
EFI_STATUS
|
|
|
|
|
EFIAPI
|
|
|
|
|
HiiExportDatabase (
|
|
|
|
|
IN EFI_HII_PROTOCOL *This,
|
|
|
|
|
IN FRAMEWORK_EFI_HII_HANDLE Handle,
|
|
|
|
|
IN OUT UINTN *BufferSize,
|
|
|
|
|
OUT VOID *Buffer
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
ASSERT (FALSE);
|
|
|
|
|
return EFI_UNSUPPORTED;
|
|
|
|
|
}
|
2008-04-03 12:36:52 +02:00
|
|
|
|
|
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
|
/**
|
|
|
|
|
This function allows a program to extract a form or form package that has
|
|
|
|
|
previously been registered with the EFI HII database.
|
2008-04-03 12:36:52 +02:00
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
|
In this thunk module, this function will create a IFR Package with only
|
|
|
|
|
one Formset. Effectively, only the GUID of the Formset is updated and return
|
|
|
|
|
in this IFR package to caller. This is enable the Framework modules which call
|
|
|
|
|
a API named GetStringFromToken. GetStringFromToken retieves a String based on
|
|
|
|
|
a String Token from a Package List known only by the Formset GUID.
|
|
|
|
|
|
2008-04-03 12:36:52 +02:00
|
|
|
|
|
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
|
@param This A pointer to the EFI_HII_PROTOCOL instance.
|
|
|
|
|
@param Handle Handle on which the form resides. Type FRAMEWORK_EFI_HII_HANDLE is defined in
|
|
|
|
|
EFI_HII_PROTOCOL.NewPack() in the Packages section.
|
|
|
|
|
@param FormId Ignored by this implementation.
|
|
|
|
|
@param BufferLengthTemp On input, the size of input buffer. On output, it
|
|
|
|
|
is the size of FW_HII_FORMSET_TEMPLATE.
|
|
|
|
|
@param Buffer The buffer designed to receive the form(s).
|
2008-04-03 12:36:52 +02:00
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
|
@retval EFI_SUCCESS Buffer filled with the requested forms. BufferLength
|
|
|
|
|
was updated.
|
|
|
|
|
@retval EFI_INVALID_PARAMETER The handle is unknown.
|
|
|
|
|
@retval EFI_NOT_FOUND A form on the requested handle cannot be found with the
|
|
|
|
|
requested FormId.
|
|
|
|
|
@retval EFI_BUFFER_TOO_SMALL The buffer provided was not large enough to allow the form to be stored.
|
2008-04-03 12:36:52 +02:00
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
|
**/
|
|
|
|
|
EFI_STATUS
|
|
|
|
|
EFIAPI
|
|
|
|
|
HiiGetForms (
|
2008-08-21 09:56:01 +02:00
|
|
|
|
IN EFI_HII_PROTOCOL *This,
|
|
|
|
|
IN FRAMEWORK_EFI_HII_HANDLE Handle,
|
|
|
|
|
IN EFI_FORM_ID FormId,
|
|
|
|
|
IN OUT UINTN *BufferLengthTemp,
|
|
|
|
|
OUT UINT8 *Buffer
|
2008-08-18 07:56:23 +02:00
|
|
|
|
)
|
2008-04-03 12:36:52 +02:00
|
|
|
|
{
|
2008-08-18 07:56:23 +02:00
|
|
|
|
HII_THUNK_PRIVATE_DATA *Private;
|
|
|
|
|
HII_THUNK_CONTEXT *ThunkContext;
|
|
|
|
|
FW_HII_FORMSET_TEMPLATE *OutputFormSet;
|
2008-05-07 10:49:04 +02:00
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
|
if (*BufferLengthTemp < sizeof(FW_HII_FORMSET_TEMPLATE)) {
|
|
|
|
|
*BufferLengthTemp = sizeof(FW_HII_FORMSET_TEMPLATE);
|
2008-05-07 10:49:04 +02:00
|
|
|
|
return EFI_BUFFER_TOO_SMALL;
|
|
|
|
|
}
|
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
|
Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
|
2008-05-07 10:49:04 +02:00
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
|
ThunkContext = FwHiiHandleToThunkContext (Private, Handle);
|
2008-05-07 10:49:04 +02:00
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
|
if (ThunkContext == NULL) {
|
2008-05-07 10:49:04 +02:00
|
|
|
|
return EFI_NOT_FOUND;
|
|
|
|
|
}
|
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
|
OutputFormSet = (FW_HII_FORMSET_TEMPLATE *) Buffer;
|
2008-05-07 10:49:04 +02:00
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
|
CopyMem (OutputFormSet, &FormSetTemplate, sizeof (FW_HII_FORMSET_TEMPLATE));
|
|
|
|
|
CopyMem (&OutputFormSet->FormSet.Guid, &ThunkContext->TagGuid, sizeof (EFI_GUID));
|
|
|
|
|
|
2008-11-10 13:40:07 +01:00
|
|
|
|
if (ThunkContext->FormSet != NULL) {
|
|
|
|
|
OutputFormSet->FormSet.Class = ThunkContext->FormSet->Class;
|
|
|
|
|
OutputFormSet->FormSet.SubClass = ThunkContext->FormSet->SubClass;
|
|
|
|
|
OutputFormSet->FormSet.Help = ThunkContext->FormSet->Help;
|
|
|
|
|
OutputFormSet->FormSet.FormSetTitle = ThunkContext->FormSet->FormSetTitle;
|
|
|
|
|
}
|
2008-08-18 07:56:23 +02:00
|
|
|
|
|
2008-05-07 10:49:04 +02:00
|
|
|
|
return EFI_SUCCESS;
|
2008-04-03 12:36:52 +02:00
|
|
|
|
}
|
|
|
|
|
|
2008-04-24 09:08:46 +02:00
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
|
/**
|
2008-04-03 12:36:52 +02:00
|
|
|
|
|
|
|
|
|
This function allows a program to extract the NV Image
|
|
|
|
|
that represents the default storage image
|
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
|
|
|
|
|
|
@param This A pointer to the EFI_HII_PROTOCOL instance.
|
|
|
|
|
@param Handle The HII handle from which will have default data retrieved.
|
|
|
|
|
UINTN - Mask used to retrieve the default image.
|
|
|
|
|
@param DefaultMask EDES_TODO: Add parameter description
|
|
|
|
|
@param VariablePackList Callee allocated, tightly-packed, link list data
|
2008-04-03 12:36:52 +02:00
|
|
|
|
structure that contain all default varaible packs
|
|
|
|
|
from the Hii Database.
|
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
|
@retval EFI_NOT_FOUND If Hii database does not contain any default images.
|
|
|
|
|
@retval EFI_INVALID_PARAMETER Invalid input parameter.
|
|
|
|
|
@retval EFI_SUCCESS Operation successful.
|
2008-04-03 12:36:52 +02:00
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
|
**/
|
|
|
|
|
EFI_STATUS
|
|
|
|
|
EFIAPI
|
|
|
|
|
HiiGetDefaultImage (
|
|
|
|
|
IN EFI_HII_PROTOCOL *This,
|
|
|
|
|
IN FRAMEWORK_EFI_HII_HANDLE Handle,
|
|
|
|
|
IN UINTN DefaultMask,
|
|
|
|
|
OUT EFI_HII_VARIABLE_PACK_LIST **VariablePackList
|
|
|
|
|
)
|
2008-04-03 12:36:52 +02:00
|
|
|
|
{
|
2008-04-24 09:08:46 +02:00
|
|
|
|
LIST_ENTRY *UefiDefaults;
|
|
|
|
|
EFI_STATUS Status;
|
2008-08-18 07:56:23 +02:00
|
|
|
|
HII_THUNK_PRIVATE_DATA *Private;
|
2008-11-10 13:40:07 +01:00
|
|
|
|
HII_THUNK_CONTEXT *ThunkContext;
|
2008-04-24 09:08:46 +02:00
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
|
Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
|
2008-04-24 09:08:46 +02:00
|
|
|
|
|
2008-11-10 13:40:07 +01:00
|
|
|
|
ThunkContext = FwHiiHandleToThunkContext (Private, Handle);
|
|
|
|
|
if (ThunkContext == NULL) {
|
2008-04-24 09:08:46 +02:00
|
|
|
|
ASSERT (FALSE);
|
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UefiDefaults = NULL;
|
2008-11-10 13:40:07 +01:00
|
|
|
|
Status = UefiIfrGetBufferTypeDefaults (ThunkContext, &UefiDefaults);
|
2008-04-24 09:08:46 +02:00
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
|
goto Done;
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-10 13:40:07 +01:00
|
|
|
|
Status = UefiDefaultsToFwDefaults (UefiDefaults, DefaultMask, ThunkContext->FormSet->DefaultVarStoreId, VariablePackList);
|
2008-04-24 09:08:46 +02:00
|
|
|
|
|
|
|
|
|
Done:
|
|
|
|
|
FreeDefaultList (UefiDefaults);
|
|
|
|
|
|
|
|
|
|
return Status;
|
2008-04-03 12:36:52 +02:00
|
|
|
|
}
|
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
|
/**
|
2008-11-10 13:40:07 +01:00
|
|
|
|
This function update the FormCallbackProtocol cached in Config Access
|
|
|
|
|
private context data.
|
2008-08-18 07:56:23 +02:00
|
|
|
|
|
2008-11-10 13:40:07 +01:00
|
|
|
|
@param CallbackHandle The EFI Handle on which the Framework FormCallbackProtocol is
|
|
|
|
|
installed.
|
|
|
|
|
@param ThunkContext The Thunk Context.
|
2008-08-18 07:56:23 +02:00
|
|
|
|
|
2008-11-10 13:40:07 +01:00
|
|
|
|
@retval EFI_SUCCESS The update is successful.
|
|
|
|
|
@retval EFI_INVALID_PARAMETER If no Framework FormCallbackProtocol is located on CallbackHandle.
|
2008-08-18 07:56:23 +02:00
|
|
|
|
|
|
|
|
|
**/
|
2008-04-16 09:36:51 +02:00
|
|
|
|
EFI_STATUS
|
2008-08-18 07:56:23 +02:00
|
|
|
|
UpdateFormCallBack (
|
2008-04-16 09:36:51 +02:00
|
|
|
|
IN EFI_HANDLE CallbackHandle,
|
2008-08-18 07:56:23 +02:00
|
|
|
|
IN CONST HII_THUNK_CONTEXT *ThunkContext
|
2008-04-16 09:36:51 +02:00
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
EFI_STATUS Status;
|
2008-08-18 07:56:23 +02:00
|
|
|
|
EFI_FORM_CALLBACK_PROTOCOL *FormCallbackProtocol;
|
2008-04-16 09:36:51 +02:00
|
|
|
|
EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccessProtocol;
|
|
|
|
|
EFI_HANDLE UefiDriverHandle;
|
2008-08-18 07:56:23 +02:00
|
|
|
|
CONFIG_ACCESS_PRIVATE *ConfigAccessPrivate;
|
2008-04-16 09:36:51 +02:00
|
|
|
|
|
|
|
|
|
Status = gBS->HandleProtocol (
|
|
|
|
|
CallbackHandle,
|
|
|
|
|
&gEfiFormCallbackProtocolGuid,
|
2008-08-18 07:56:23 +02:00
|
|
|
|
(VOID **) &FormCallbackProtocol
|
2008-04-16 09:36:51 +02:00
|
|
|
|
);
|
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
|
}
|
|
|
|
|
|
2008-04-24 09:08:46 +02:00
|
|
|
|
Status = mHiiDatabase->GetPackageListHandle (
|
|
|
|
|
mHiiDatabase,
|
2008-08-18 07:56:23 +02:00
|
|
|
|
ThunkContext->UefiHiiHandle,
|
2008-04-16 09:36:51 +02:00
|
|
|
|
&UefiDriverHandle
|
|
|
|
|
);
|
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
Status = gBS->HandleProtocol (
|
|
|
|
|
UefiDriverHandle,
|
|
|
|
|
&gEfiHiiConfigAccessProtocolGuid,
|
|
|
|
|
(VOID **) &ConfigAccessProtocol
|
|
|
|
|
);
|
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
|
ConfigAccessPrivate = CONFIG_ACCESS_PRIVATE_FROM_PROTOCOL (ConfigAccessProtocol);
|
2008-04-16 09:36:51 +02:00
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
|
ConfigAccessPrivate->FormCallbackProtocol = FormCallbackProtocol;
|
2008-04-16 09:36:51 +02:00
|
|
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
|
}
|
2008-04-03 12:36:52 +02:00
|
|
|
|
|
2008-04-24 09:08:46 +02:00
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
|
/**
|
2008-11-10 13:40:07 +01:00
|
|
|
|
Get the package data from the Package List.
|
2008-08-18 07:56:23 +02:00
|
|
|
|
|
2008-11-10 13:40:07 +01:00
|
|
|
|
@param HiiPackageList Package List.
|
|
|
|
|
@param PackageIndex The index of the Package in the Package List.
|
|
|
|
|
@param BufferLen The Length of the Pacage data.
|
|
|
|
|
@param Buffer On output, the Package data.
|
2008-08-18 07:56:23 +02:00
|
|
|
|
|
2008-11-10 13:40:07 +01:00
|
|
|
|
@return EFI_NOT_FOUND No Package is found for PackageIndex.
|
|
|
|
|
@return EFI_SUCCESS The package data is returned.
|
2008-08-18 07:56:23 +02:00
|
|
|
|
|
|
|
|
|
**/
|
2008-04-24 09:08:46 +02:00
|
|
|
|
EFI_STATUS
|
2008-08-18 07:56:23 +02:00
|
|
|
|
GetPackageData (
|
2008-04-24 09:08:46 +02:00
|
|
|
|
IN EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList,
|
|
|
|
|
IN UINT32 PackageIndex,
|
|
|
|
|
OUT UINT32 *BufferLen,
|
|
|
|
|
OUT EFI_HII_PACKAGE_HEADER **Buffer
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
UINT32 Index;
|
|
|
|
|
EFI_HII_PACKAGE_HEADER *Package;
|
|
|
|
|
UINT32 Offset;
|
|
|
|
|
UINT32 PackageListLength;
|
|
|
|
|
EFI_HII_PACKAGE_HEADER PackageHeader = {0, 0};
|
|
|
|
|
|
|
|
|
|
ASSERT(HiiPackageList != NULL);
|
|
|
|
|
|
|
|
|
|
if ((BufferLen == NULL) || (Buffer == NULL)) {
|
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Package = NULL;
|
|
|
|
|
Index = 0;
|
|
|
|
|
Offset = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
|
|
|
|
|
CopyMem (&PackageListLength, &HiiPackageList->PackageLength, sizeof (UINT32));
|
|
|
|
|
while (Offset < PackageListLength) {
|
|
|
|
|
Package = (EFI_HII_PACKAGE_HEADER *) (((UINT8 *) HiiPackageList) + Offset);
|
|
|
|
|
CopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));
|
|
|
|
|
if (Index == PackageIndex) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
Offset += PackageHeader.Length;
|
|
|
|
|
Index++;
|
|
|
|
|
}
|
|
|
|
|
if (Offset >= PackageListLength) {
|
|
|
|
|
//
|
|
|
|
|
// no package found in this Package List
|
|
|
|
|
//
|
|
|
|
|
return EFI_NOT_FOUND;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*BufferLen = PackageHeader.Length;
|
|
|
|
|
*Buffer = Package;
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2008-11-10 13:40:07 +01:00
|
|
|
|
Check if Label exist in the IFR form package and return the FormSet GUID
|
|
|
|
|
and Form ID.
|
2008-04-24 09:08:46 +02:00
|
|
|
|
|
2008-11-10 13:40:07 +01:00
|
|
|
|
@param Package The Package Header.
|
|
|
|
|
@param Label The Label ID.
|
|
|
|
|
@param FormsetGuid Returns the FormSet GUID.
|
|
|
|
|
@param FormId Returns the Form ID.
|
2008-04-24 09:08:46 +02:00
|
|
|
|
|
2008-11-10 13:40:07 +01:00
|
|
|
|
@retval EFI_SUCCESS The FORM ID is found.
|
|
|
|
|
@retval EFI_NOT_FOUND The FORM ID is not found.
|
2008-04-24 09:08:46 +02:00
|
|
|
|
**/
|
|
|
|
|
EFI_STATUS
|
|
|
|
|
LocateLabel (
|
|
|
|
|
IN CONST EFI_HII_PACKAGE_HEADER *Package,
|
|
|
|
|
IN EFI_FORM_LABEL Label,
|
|
|
|
|
OUT EFI_GUID *FormsetGuid,
|
|
|
|
|
OUT EFI_FORM_ID *FormId
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
UINTN Offset;
|
|
|
|
|
EFI_IFR_OP_HEADER *IfrOpHdr;
|
|
|
|
|
EFI_GUID InternalFormSetGuid;
|
|
|
|
|
EFI_FORM_ID InternalFormId;
|
|
|
|
|
BOOLEAN GetFormSet;
|
|
|
|
|
BOOLEAN GetForm;
|
2008-11-10 13:40:07 +01:00
|
|
|
|
EFI_IFR_GUID_LABEL *LabelOpcode;
|
2008-04-24 09:08:46 +02:00
|
|
|
|
|
|
|
|
|
IfrOpHdr = (EFI_IFR_OP_HEADER *)((UINT8 *) Package + sizeof (EFI_HII_PACKAGE_HEADER));
|
|
|
|
|
Offset = sizeof (EFI_HII_PACKAGE_HEADER);
|
|
|
|
|
|
|
|
|
|
InternalFormId= 0;
|
|
|
|
|
ZeroMem (&InternalFormSetGuid, sizeof (EFI_GUID));
|
|
|
|
|
GetFormSet = FALSE;
|
|
|
|
|
GetForm = FALSE;
|
|
|
|
|
|
|
|
|
|
while (Offset < Package->Length) {
|
|
|
|
|
switch (IfrOpHdr->OpCode) {
|
|
|
|
|
case EFI_IFR_FORM_SET_OP :
|
|
|
|
|
CopyMem (&InternalFormSetGuid, &((EFI_IFR_FORM_SET *) IfrOpHdr)->Guid, sizeof (EFI_GUID));
|
|
|
|
|
GetFormSet = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case EFI_IFR_FORM_OP:
|
|
|
|
|
CopyMem (&InternalFormId, &((EFI_IFR_FORM *) IfrOpHdr)->FormId, sizeof (EFI_FORM_ID));
|
|
|
|
|
GetForm = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case EFI_IFR_GUID_OP :
|
2008-11-10 13:40:07 +01:00
|
|
|
|
LabelOpcode = (EFI_IFR_GUID_LABEL *) IfrOpHdr;
|
|
|
|
|
//
|
|
|
|
|
// If it is an Label opcode.
|
|
|
|
|
//
|
|
|
|
|
if ((LabelOpcode->ExtendOpCode == EFI_IFR_EXTEND_OP_LABEL) && (CompareMem (&LabelOpcode->Guid, &mTianoHiiIfrGuid, sizeof (EFI_GUID)) == 0)) {
|
|
|
|
|
if (CompareMem (&Label, &LabelOpcode->Number, sizeof (UINT16)) == 0) {
|
|
|
|
|
ASSERT (GetForm && GetFormSet);
|
|
|
|
|
CopyGuid (FormsetGuid, &InternalFormSetGuid);
|
|
|
|
|
*FormId = InternalFormId;
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
|
}
|
2008-04-24 09:08:46 +02:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default :
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Go to the next Op-Code
|
|
|
|
|
//
|
|
|
|
|
Offset += IfrOpHdr->Length;
|
|
|
|
|
IfrOpHdr = (EFI_IFR_OP_HEADER *) ((CHAR8 *) (IfrOpHdr) + IfrOpHdr->Length);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return EFI_NOT_FOUND;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Find the first EFI_FORM_LABEL in FormSets for a given EFI_HII_HANLDE defined.
|
|
|
|
|
|
|
|
|
|
EFI_FORM_LABEL is a specific to Tiano implementation. The current implementation
|
|
|
|
|
does not restrict labels with same label value to be duplicated in either FormSet
|
|
|
|
|
scope or Form scope. This function will only locate the FIRST EFI_FORM_LABEL
|
|
|
|
|
with value as the same as the input Label in the Formset registered with UefiHiiHandle. The FormSet GUID
|
|
|
|
|
and Form ID is returned if such Label is found.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@retval EFI_INVALID_PARAMETER If UefiHiiHandle is not a valid handle.
|
|
|
|
|
@retval EFI_NOT_FOUND The package list identified by UefiHiiHandle deos not contain FormSet or
|
|
|
|
|
There is no Form ID with value Label found in all Form Sets in the pacakge
|
|
|
|
|
list.
|
|
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The first found Form ID is returned in FormId.
|
|
|
|
|
**/
|
|
|
|
|
EFI_STATUS
|
2008-08-18 07:56:23 +02:00
|
|
|
|
LocateFormId (
|
2008-04-24 09:08:46 +02:00
|
|
|
|
IN EFI_HII_HANDLE Handle,
|
|
|
|
|
IN EFI_FORM_LABEL Label,
|
|
|
|
|
OUT EFI_GUID *FormsetGuid,
|
|
|
|
|
OUT EFI_FORM_ID *FormId
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
EFI_STATUS Status;
|
|
|
|
|
EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList;
|
|
|
|
|
UINT32 Index;
|
|
|
|
|
UINTN BufferSize;
|
|
|
|
|
EFI_HII_PACKAGE_HEADER PackageHeader;
|
|
|
|
|
EFI_HII_PACKAGE_HEADER *Package;
|
|
|
|
|
UINT32 PackageLength;
|
|
|
|
|
|
|
|
|
|
BufferSize = 0;
|
|
|
|
|
HiiPackageList = NULL;
|
|
|
|
|
Status = mHiiDatabase->ExportPackageLists (mHiiDatabase, Handle, &BufferSize, HiiPackageList);
|
|
|
|
|
if (Status == EFI_BUFFER_TOO_SMALL) {
|
|
|
|
|
HiiPackageList = AllocatePool (BufferSize);
|
|
|
|
|
ASSERT (HiiPackageList != NULL);
|
|
|
|
|
|
|
|
|
|
Status = mHiiDatabase->ExportPackageLists (mHiiDatabase, Handle, &BufferSize, HiiPackageList);
|
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
|
goto Done;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (Index = 0; ; Index++) {
|
2008-08-18 07:56:23 +02:00
|
|
|
|
Status = GetPackageData (HiiPackageList, Index, &PackageLength, &Package);
|
2008-04-24 09:08:46 +02:00
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
|
CopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));
|
2008-11-04 15:47:21 +01:00
|
|
|
|
if (PackageHeader.Type == EFI_HII_PACKAGE_FORMS) {
|
2008-04-24 09:08:46 +02:00
|
|
|
|
Status = LocateLabel (Package, Label, FormsetGuid, FormId);
|
|
|
|
|
if (!EFI_ERROR(Status)) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Done:
|
|
|
|
|
FreePool (HiiPackageList);
|
|
|
|
|
|
|
|
|
|
return Status;
|
|
|
|
|
}
|
2008-11-10 13:40:07 +01:00
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
|
/**
|
|
|
|
|
This function allows the caller to update a form that has
|
|
|
|
|
previously been registered with the EFI HII database.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@param This EDES_TODO: Add parameter description
|
|
|
|
|
@param Handle Hii Handle associated with the Formset to modify
|
|
|
|
|
@param Label Update information starting immediately after this label in the IFR
|
|
|
|
|
@param AddData If TRUE, add data. If FALSE, remove data
|
|
|
|
|
@param Data If adding data, this is the pointer to the data to add
|
|
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS Update success.
|
|
|
|
|
@retval Other Update fail.
|
|
|
|
|
|
|
|
|
|
**/
|
2008-04-03 12:36:52 +02:00
|
|
|
|
EFI_STATUS
|
|
|
|
|
EFIAPI
|
|
|
|
|
HiiUpdateForm (
|
2008-08-18 07:56:23 +02:00
|
|
|
|
IN EFI_HII_PROTOCOL *This,
|
2008-04-03 12:36:52 +02:00
|
|
|
|
IN FRAMEWORK_EFI_HII_HANDLE Handle,
|
2008-08-18 07:56:23 +02:00
|
|
|
|
IN EFI_FORM_LABEL Label,
|
|
|
|
|
IN BOOLEAN AddData,
|
2008-04-17 15:28:36 +02:00
|
|
|
|
IN FRAMEWORK_EFI_HII_UPDATE_DATA *Data
|
2008-04-03 12:36:52 +02:00
|
|
|
|
)
|
|
|
|
|
{
|
2008-04-16 09:36:51 +02:00
|
|
|
|
EFI_STATUS Status;
|
2008-08-18 07:56:23 +02:00
|
|
|
|
HII_THUNK_PRIVATE_DATA *Private;
|
|
|
|
|
HII_THUNK_CONTEXT *ThunkContext;
|
2008-04-17 15:28:36 +02:00
|
|
|
|
EFI_HII_UPDATE_DATA *UefiHiiUpdateData;
|
|
|
|
|
EFI_HII_HANDLE UefiHiiHandle;
|
2008-04-24 09:08:46 +02:00
|
|
|
|
EFI_GUID FormsetGuid;
|
|
|
|
|
EFI_FORM_ID FormId;
|
2008-08-18 07:56:23 +02:00
|
|
|
|
EFI_TPL OldTpl;
|
2008-04-17 15:28:36 +02:00
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
|
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
|
|
|
|
|
|
|
|
|
|
mInFrameworkUpdatePakcage = TRUE;
|
2008-04-17 15:28:36 +02:00
|
|
|
|
Status = EFI_SUCCESS;
|
2008-08-18 07:56:23 +02:00
|
|
|
|
UefiHiiUpdateData = NULL;
|
2008-04-16 09:36:51 +02:00
|
|
|
|
|
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
|
Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
|
2008-04-16 09:36:51 +02:00
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
|
ThunkContext = FwHiiHandleToThunkContext (Private, Handle);
|
|
|
|
|
|
|
|
|
|
if (ThunkContext == NULL) {
|
|
|
|
|
Status = EFI_NOT_FOUND;
|
|
|
|
|
goto Done;
|
2008-04-16 09:36:51 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Data->FormSetUpdate) {
|
2008-08-18 07:56:23 +02:00
|
|
|
|
Status = UpdateFormCallBack ((EFI_HANDLE) (UINTN) Data->FormCallbackHandle, ThunkContext);
|
2008-04-16 09:36:51 +02:00
|
|
|
|
if (EFI_ERROR (Status)) {
|
2008-08-18 07:56:23 +02:00
|
|
|
|
goto Done;
|
2008-04-16 09:36:51 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2008-04-17 15:28:36 +02:00
|
|
|
|
|
2008-09-04 12:15:50 +02:00
|
|
|
|
if (ThunkContext->IfrPackageCount == 0) {
|
|
|
|
|
ASSERT (FALSE);
|
|
|
|
|
Status = EFI_INVALID_PARAMETER;
|
|
|
|
|
goto Done;
|
2008-04-30 08:35:24 +02:00
|
|
|
|
} else {
|
2008-08-18 07:56:23 +02:00
|
|
|
|
UefiHiiHandle = ThunkContext->UefiHiiHandle;
|
2008-04-30 08:35:24 +02:00
|
|
|
|
}
|
2008-04-17 15:28:36 +02:00
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
|
Status = LocateFormId (UefiHiiHandle, Label, &FormsetGuid, &FormId);
|
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
|
//
|
|
|
|
|
// Can't find the label.
|
|
|
|
|
//
|
|
|
|
|
goto Done;
|
|
|
|
|
}
|
2008-04-30 08:35:24 +02:00
|
|
|
|
|
|
|
|
|
if (AddData) {
|
|
|
|
|
if (Data->DataCount != 0) {
|
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
|
ThunkContext = UefiHiiHandleToThunkContext (Private, UefiHiiHandle);
|
2008-11-10 13:40:07 +01:00
|
|
|
|
Status = FwUpdateDataToUefiUpdateData (ThunkContext, Data, &UefiHiiUpdateData);
|
2008-04-30 08:35:24 +02:00
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
|
2008-11-10 13:40:07 +01:00
|
|
|
|
Status = IfrLibUpdateForm (UefiHiiHandle, &FormsetGuid, FormId, Label, TRUE, UefiHiiUpdateData);
|
2008-04-30 08:35:24 +02:00
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
|
2008-04-30 09:30:25 +02:00
|
|
|
|
}
|
2008-04-30 08:35:24 +02:00
|
|
|
|
} else {
|
|
|
|
|
//
|
|
|
|
|
// Delete Opcode starting from Labe in FormId found
|
|
|
|
|
//
|
2008-04-30 09:30:25 +02:00
|
|
|
|
UefiHiiUpdateData = AllocateZeroPool (sizeof (*UefiHiiUpdateData));
|
|
|
|
|
|
|
|
|
|
Status = IfrLibUpdateForm (UefiHiiHandle, &FormsetGuid, FormId, Label, FALSE, UefiHiiUpdateData);
|
2008-04-30 08:35:24 +02:00
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
}
|
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
|
Done:
|
2008-04-30 08:35:24 +02:00
|
|
|
|
if (UefiHiiUpdateData != NULL) {
|
2008-10-30 09:00:56 +01:00
|
|
|
|
if (UefiHiiUpdateData->Data != NULL) {
|
|
|
|
|
FreePool (UefiHiiUpdateData->Data);
|
|
|
|
|
}
|
|
|
|
|
FreePool (UefiHiiUpdateData);
|
2008-04-17 15:28:36 +02:00
|
|
|
|
}
|
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
|
mInFrameworkUpdatePakcage = FALSE;
|
|
|
|
|
|
|
|
|
|
gBS->RestoreTPL (OldTpl);
|
|
|
|
|
|
2008-04-17 15:28:36 +02:00
|
|
|
|
return Status;
|
2008-04-03 12:36:52 +02:00
|
|
|
|
}
|