Remove UefiHiiLib & UefiIfrSupportLib. They have been moved to MdeModulePkg.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6518 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
qhuang8 2008-11-13 09:07:30 +00:00
parent 08e4b3cfed
commit ca2a999d4e
9 changed files with 0 additions and 3996 deletions

View File

@ -1,206 +0,0 @@
/** @file
Language related HII Library implementation.
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 "InternalHiiLib.h"
/**
Get next language from language code list (with separator ';').
If LangCode is NULL, then ASSERT.
If Lang is NULL, then ASSERT.
@param LangCode On input: point to first language in the list. On
output: point to next language in the list, or
NULL if no more language in the list.
@param Lang The first language in the list.
**/
VOID
EFIAPI
HiiLibGetNextLanguage (
IN OUT CHAR8 **LangCode,
OUT CHAR8 *Lang
)
{
UINTN Index;
CHAR8 *StringPtr;
ASSERT (LangCode != NULL);
ASSERT (*LangCode != NULL);
ASSERT (Lang != NULL);
Index = 0;
StringPtr = *LangCode;
while (StringPtr[Index] != 0 && StringPtr[Index] != ';') {
Index++;
}
CopyMem (Lang, StringPtr, Index);
Lang[Index] = 0;
if (StringPtr[Index] == ';') {
Index++;
}
*LangCode = StringPtr + Index;
}
/**
This function returns the list of supported languages, in the format specified
in UEFI specification Appendix M.
If HiiHandle is not a valid Handle in the default HII database, then ASSERT.
@param HiiHandle The HII package list handle.
@retval !NULL The supported languages.
@retval NULL If Supported Languages can not be retrived.
**/
CHAR8 *
EFIAPI
HiiLibGetSupportedLanguages (
IN EFI_HII_HANDLE HiiHandle
)
{
EFI_STATUS Status;
UINTN BufferSize;
CHAR8 *LanguageString;
ASSERT (IsHiiHandleRegistered (HiiHandle));
//
// Collect current supported Languages for given HII handle
// First try allocate 4K buffer to store the current supported languages.
//
BufferSize = 0x1000;
LanguageString = AllocateZeroPool (BufferSize);
if (LanguageString == NULL) {
return NULL;
}
Status = mHiiStringProt->GetLanguages (mHiiStringProt, HiiHandle, LanguageString, &BufferSize);
if (Status == EFI_BUFFER_TOO_SMALL) {
FreePool (LanguageString);
LanguageString = AllocateZeroPool (BufferSize);
if (LanguageString == NULL) {
return NULL;
}
Status = mHiiStringProt->GetLanguages (mHiiStringProt, HiiHandle, LanguageString, &BufferSize);
}
if (EFI_ERROR (Status)) {
LanguageString = NULL;
}
return LanguageString;
}
/**
This function returns the number of supported languages on HiiHandle.
If HiiHandle is not a valid Handle in the default HII database, then ASSERT.
If not enough resource to complete the operation, then ASSERT.
@param HiiHandle The HII package list handle.
@return The number of supported languages.
**/
UINT16
EFIAPI
HiiLibGetSupportedLanguageNumber (
IN EFI_HII_HANDLE HiiHandle
)
{
CHAR8 *Languages;
CHAR8 *LanguageString;
UINT16 LangNumber;
CHAR8 Lang[RFC_3066_ENTRY_SIZE];
Languages = HiiLibGetSupportedLanguages (HiiHandle);
if (Languages == NULL) {
return 0;
}
LangNumber = 0;
LanguageString = Languages;
while (*LanguageString != 0) {
HiiLibGetNextLanguage (&LanguageString, Lang);
LangNumber++;
}
FreePool (Languages);
return LangNumber;
}
/**
This function returns the list of supported 2nd languages, in the format specified
in UEFI specification Appendix M.
If HiiHandle is not a valid Handle in the default HII database, then ASSERT.
If not enough resource to complete the operation, then ASSERT.
@param HiiHandle The HII package list handle.
@param FirstLanguage Pointer to language name buffer.
@return The supported languages.
**/
CHAR8 *
EFIAPI
HiiLibGetSupportedSecondaryLanguages (
IN EFI_HII_HANDLE HiiHandle,
IN CONST CHAR8 *FirstLanguage
)
{
EFI_STATUS Status;
UINTN BufferSize;
CHAR8 *LanguageString;
ASSERT (HiiHandle != NULL);
ASSERT (IsHiiHandleRegistered (HiiHandle));
//
// Collect current supported 2nd Languages for given HII handle
// First try allocate 4K buffer to store the current supported 2nd languages.
//
BufferSize = 0x1000;
LanguageString = AllocateZeroPool (BufferSize);
if (LanguageString == NULL) {
return NULL;
}
Status = mHiiStringProt->GetSecondaryLanguages (mHiiStringProt, HiiHandle, FirstLanguage, LanguageString, &BufferSize);
if (Status == EFI_BUFFER_TOO_SMALL) {
FreePool (LanguageString);
LanguageString = AllocateZeroPool (BufferSize);
if (LanguageString == NULL) {
return NULL;
}
Status = mHiiStringProt->GetSecondaryLanguages (mHiiStringProt, HiiHandle, FirstLanguage, LanguageString, &BufferSize);
}
if (EFI_ERROR (Status)) {
LanguageString = NULL;
}
return LanguageString;
}

View File

@ -1,698 +0,0 @@
/** @file
HII Library implementation that uses DXE protocols and services.
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 "InternalHiiLib.h"
CONST EFI_HII_DATABASE_PROTOCOL *mHiiDatabaseProt = NULL;
CONST EFI_HII_STRING_PROTOCOL *mHiiStringProt = NULL;
/**
This function locate Hii relative protocols for later usage.
The constructor function caches the protocol pointer of HII Database Protocol
and Hii String Protocol.
It will ASSERT() if either of the protocol can't be located.
@param ImageHandle The firmware allocated handle for the EFI image.
@param SystemTable A pointer to the EFI System Table.
@retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
**/
EFI_STATUS
EFIAPI
HiiLibConstructor (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
Status = gBS->LocateProtocol (&gEfiHiiDatabaseProtocolGuid, NULL, (VOID **) &mHiiDatabaseProt);
ASSERT_EFI_ERROR (Status);
Status = gBS->LocateProtocol (&gEfiHiiStringProtocolGuid, NULL, (VOID **) &mHiiStringProt);
ASSERT_EFI_ERROR (Status);
return EFI_SUCCESS;
}
/**
This funciton build the package list based on the package number,
the GUID of the package list and the list of pointer which point to
package header that defined by UEFI VFR compiler and StringGather
tool.
#pragma pack (push, 1)
typedef struct {
UINT32 BinaryLength;
EFI_HII_PACKAGE_HEADER PackageHeader;
} EDKII_AUTOGEN_PACKAGES_HEADER;
#pragma pack (pop)
If there is not enough resource for the new package list,
the function will ASSERT.
@param NumberOfPackages The number of packages be
@param GuidId The GUID for the package list to be generated.
@param Marker The variable argument list. Each entry represent a specific package header that is
generated by VFR compiler and StrGather tool. The first 4 bytes is a UINT32 value
that indicate the overall length of the package.
@return The pointer to the package list header.
**/
EFI_HII_PACKAGE_LIST_HEADER *
InternalHiiLibPreparePackages (
IN UINTN NumberOfPackages,
IN CONST EFI_GUID *GuidId,
IN VA_LIST Marker
)
{
EFI_HII_PACKAGE_LIST_HEADER *PackageListHeader;
UINT8 *PackageListData;
UINT32 PackageListLength;
UINT32 PackageLength;
EFI_HII_PACKAGE_HEADER PackageHeader;
UINT8 *PackageArray;
UINTN Index;
VA_LIST MarkerBackup;
PackageListLength = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
MarkerBackup = Marker;
//
// Count the lenth of the final package list.
//
for (Index = 0; Index < NumberOfPackages; Index++) {
CopyMem (&PackageLength, VA_ARG (Marker, VOID *), sizeof (UINT32));
//
// Do not count the BinaryLength field.
//
PackageListLength += (PackageLength - sizeof (UINT32));
}
//
// Include the lenght of EFI_HII_PACKAGE_END
//
PackageListLength += sizeof (EFI_HII_PACKAGE_HEADER);
PackageListHeader = AllocateZeroPool (PackageListLength);
ASSERT (PackageListHeader != NULL);
CopyGuid (&PackageListHeader->PackageListGuid, GuidId);
PackageListHeader->PackageLength = PackageListLength;
PackageListData = ((UINT8 *) PackageListHeader) + sizeof (EFI_HII_PACKAGE_LIST_HEADER);
Marker = MarkerBackup;
//
// Prepare the final package list.
//
for (Index = 0; Index < NumberOfPackages; Index++) {
PackageArray = (UINT8 *) VA_ARG (Marker, VOID *);
//
// CopyMem is used for UINT32 to cover the unaligned address access.
//
CopyMem (&PackageLength, PackageArray, sizeof (UINT32));
PackageLength -= sizeof (UINT32);
PackageArray += sizeof (UINT32);
CopyMem (PackageListData, PackageArray, 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;
}
/**
Assemble EFI_HII_PACKAGE_LIST according to the passed in packages.
If GuidId is NULL, then ASSERT.
If not enough resource to complete the operation, then ASSERT.
@param NumberOfPackages Number of packages.
@param GuidId Package GUID.
@param ... Variable argument list for packages to be assembled.
@return Pointer of EFI_HII_PACKAGE_LIST_HEADER.
**/
EFI_HII_PACKAGE_LIST_HEADER *
EFIAPI
HiiLibPreparePackageList (
IN UINTN NumberOfPackages,
IN CONST EFI_GUID *GuidId,
...
)
{
EFI_HII_PACKAGE_LIST_HEADER *PackageListHeader;
VA_LIST Marker;
ASSERT (GuidId != NULL);
VA_START (Marker, GuidId);
PackageListHeader = InternalHiiLibPreparePackages (NumberOfPackages, GuidId, Marker);
VA_END (Marker);
return PackageListHeader;
}
/**
This function allocates pool for an EFI_HII_PACKAGE_LIST structure
with additional space that is big enough to host all packages described by the variable
argument list of package pointers. The allocated structure is initialized using NumberOfPackages,
GuidId, and the variable length argument list of package pointers.
Then, EFI_HII_PACKAGE_LIST will be register to the default System HII Database. The
Handle to the newly registered Package List is returned throught HiiHandle.
If HiiHandle is NULL, then ASSERT.
@param NumberOfPackages The number of HII packages to register.
@param GuidId Package List GUID ID.
@param DriverHandle Optional. If not NULL, the DriverHandle on which an instance of DEVICE_PATH_PROTOCOL is installed.
This DriverHandle uniquely defines the device that the added packages are associated with.
@param HiiHandle On output, the HiiHandle is update with the handle which can be used to retrieve the Package
List later. If the functions failed to add the package to the default HII database, this value will
be set to NULL.
@param ... The variable argument list describing all HII Package.
@return EFI_SUCCESS If the packages are successfully added to the default HII database.
@return EFI_OUT_OF_RESOURCE Not enough resource to complete the operation.
**/
EFI_STATUS
EFIAPI
HiiLibAddPackages (
IN UINTN NumberOfPackages,
IN CONST EFI_GUID *GuidId,
IN EFI_HANDLE DriverHandle, OPTIONAL
OUT EFI_HII_HANDLE *HiiHandle,
...
)
{
VA_LIST Args;
EFI_HII_PACKAGE_LIST_HEADER *PackageListHeader;
EFI_STATUS Status;
ASSERT (HiiHandle != NULL);
VA_START (Args, HiiHandle);
PackageListHeader = InternalHiiLibPreparePackages (NumberOfPackages, GuidId, Args);
Status = mHiiDatabaseProt->NewPackageList (mHiiDatabaseProt, PackageListHeader, DriverHandle, HiiHandle);
if (HiiHandle != NULL) {
if (EFI_ERROR (Status)) {
*HiiHandle = NULL;
}
}
FreePool (PackageListHeader);
VA_END (Args);
return Status;
}
/**
Removes a package list from the default HII database.
If HiiHandle is NULL, then ASSERT.
If HiiHandle is not a valid EFI_HII_HANDLE in the default HII database, then ASSERT.
@param HiiHandle The handle that was previously registered to the data base that is requested for removal.
List later.
**/
VOID
EFIAPI
HiiLibRemovePackages (
IN EFI_HII_HANDLE HiiHandle
)
{
EFI_STATUS Status;
ASSERT (IsHiiHandleRegistered (HiiHandle));
Status = mHiiDatabaseProt->RemovePackageList (mHiiDatabaseProt, HiiHandle);
ASSERT_EFI_ERROR (Status);
}
/**
Determines the handles that are currently active in the database.
It's the caller's responsibility to free handle buffer.
If HandleBufferLength is NULL, then ASSERT.
If HiiHandleBuffer is NULL, then ASSERT.
@param HandleBufferLength On input, a pointer to the length of the handle
buffer. On output, the length of the handle buffer
that is required for the handles found.
@param HiiHandleBuffer Pointer to an array of Hii Handles returned.
@retval EFI_SUCCESS Get an array of Hii Handles successfully.
**/
EFI_STATUS
EFIAPI
HiiLibGetHiiHandles (
IN OUT UINTN *HandleBufferLength,
OUT EFI_HII_HANDLE **HiiHandleBuffer
)
{
UINTN BufferLength;
EFI_STATUS Status;
ASSERT (HandleBufferLength != NULL);
ASSERT (HiiHandleBuffer != NULL);
BufferLength = 0;
//
// Try to find the actual buffer size for HiiHandle Buffer.
//
Status = mHiiDatabaseProt->ListPackageLists (
mHiiDatabaseProt,
EFI_HII_PACKAGE_TYPE_ALL,
NULL,
&BufferLength,
*HiiHandleBuffer
);
if (Status == EFI_BUFFER_TOO_SMALL) {
*HiiHandleBuffer = AllocateZeroPool (BufferLength);
ASSERT (*HiiHandleBuffer != NULL);
Status = mHiiDatabaseProt->ListPackageLists (
mHiiDatabaseProt,
EFI_HII_PACKAGE_TYPE_ALL,
NULL,
&BufferLength,
*HiiHandleBuffer
);
//
// we should not fail here.
//
ASSERT_EFI_ERROR (Status);
}
*HandleBufferLength = BufferLength;
return Status;
}
/**
Extract Hii package list GUID for given HII handle.
If HiiHandle could not be found in the default HII database, then ASSERT.
If Guid is NULL, then ASSERT.
@param Handle Hii handle
@param Guid Package list GUID
@retval EFI_SUCCESS Successfully extract GUID from Hii database.
**/
EFI_STATUS
EFIAPI
HiiLibExtractGuidFromHiiHandle (
IN EFI_HII_HANDLE Handle,
OUT EFI_GUID *Guid
)
{
EFI_STATUS Status;
UINTN BufferSize;
EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList;
ASSERT (Guid != NULL);
ASSERT (IsHiiHandleRegistered (Handle));
//
// Get HII PackageList
//
BufferSize = 0;
HiiPackageList = NULL;
Status = mHiiDatabaseProt->ExportPackageLists (mHiiDatabaseProt, Handle, &BufferSize, HiiPackageList);
ASSERT (Status != EFI_NOT_FOUND);
if (Status == EFI_BUFFER_TOO_SMALL) {
HiiPackageList = AllocatePool (BufferSize);
ASSERT (HiiPackageList != NULL);
Status = mHiiDatabaseProt->ExportPackageLists (mHiiDatabaseProt, Handle, &BufferSize, HiiPackageList);
}
if (EFI_ERROR (Status)) {
FreePool (HiiPackageList);
return Status;
}
//
// Extract GUID
//
CopyGuid (Guid, &HiiPackageList->PackageListGuid);
FreePool (HiiPackageList);
return EFI_SUCCESS;
}
/**
Find HII Handle in the default HII database associated with given Device Path.
If DevicePath is NULL, then ASSERT.
@param DevicePath Device Path associated with the HII package list
handle.
@retval Handle HII package list Handle associated with the Device
Path.
@retval NULL Hii Package list handle is not found.
**/
EFI_HII_HANDLE
EFIAPI
HiiLibDevicePathToHiiHandle (
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
{
EFI_STATUS Status;
EFI_DEVICE_PATH_PROTOCOL *TmpDevicePath;
UINTN BufferSize;
UINTN HandleCount;
UINTN Index;
EFI_HANDLE *Handles;
EFI_HANDLE Handle;
UINTN Size;
EFI_HANDLE DriverHandle;
EFI_HII_HANDLE *HiiHandles;
EFI_HII_HANDLE HiiHandle;
ASSERT (DevicePath != NULL);
//
// Locate Device Path Protocol handle buffer
//
Status = gBS->LocateHandleBuffer (
ByProtocol,
&gEfiDevicePathProtocolGuid,
NULL,
&HandleCount,
&Handles
);
if (EFI_ERROR (Status)) {
return NULL;
}
//
// Search Driver Handle by Device Path
//
DriverHandle = NULL;
BufferSize = GetDevicePathSize (DevicePath);
for(Index = 0; Index < HandleCount; Index++) {
Handle = Handles[Index];
gBS->HandleProtocol (Handle, &gEfiDevicePathProtocolGuid, (VOID **) &TmpDevicePath);
//
// Check whether DevicePath match
//
Size = GetDevicePathSize (TmpDevicePath);
if ((Size == BufferSize) && CompareMem (DevicePath, TmpDevicePath, Size) == 0) {
DriverHandle = Handle;
break;
}
}
FreePool (Handles);
if (DriverHandle == NULL) {
return NULL;
}
//
// Retrieve all Hii Handles from HII database
//
BufferSize = 0x1000;
HiiHandles = AllocatePool (BufferSize);
ASSERT (HiiHandles != NULL);
Status = mHiiDatabaseProt->ListPackageLists (
mHiiDatabaseProt,
EFI_HII_PACKAGE_TYPE_ALL,
NULL,
&BufferSize,
HiiHandles
);
if (Status == EFI_BUFFER_TOO_SMALL) {
FreePool (HiiHandles);
HiiHandles = AllocatePool (BufferSize);
ASSERT (HiiHandles != NULL);
Status = mHiiDatabaseProt->ListPackageLists (
mHiiDatabaseProt,
EFI_HII_PACKAGE_TYPE_ALL,
NULL,
&BufferSize,
HiiHandles
);
}
if (EFI_ERROR (Status)) {
FreePool (HiiHandles);
return NULL;
}
//
// Search Hii Handle by Driver Handle
//
HiiHandle = NULL;
HandleCount = BufferSize / sizeof (EFI_HII_HANDLE);
for (Index = 0; Index < HandleCount; Index++) {
Status = mHiiDatabaseProt->GetPackageListHandle (
mHiiDatabaseProt,
HiiHandles[Index],
&Handle
);
if (!EFI_ERROR (Status) && (Handle == DriverHandle)) {
HiiHandle = HiiHandles[Index];
break;
}
}
FreePool (HiiHandles);
return HiiHandle;
}
/**
Exports the contents of one or all package lists in the HII database into a buffer.
If Handle is not NULL and not a valid EFI_HII_HANDLE registered in the database,
then ASSERT.
If PackageListHeader is NULL, then ASSERT.
If PackageListSize is NULL, then ASSERT.
@param Handle The HII Handle.
@param PackageListHeader A pointer to a buffer that will contain the results of
the export function.
@param PackageListSize On output, the length of the buffer that is required for the exported data.
@retval EFI_SUCCESS Package exported.
@retval EFI_OUT_OF_RESOURCES Not enought memory to complete the operations.
**/
EFI_STATUS
EFIAPI
HiiLibExportPackageLists (
IN EFI_HII_HANDLE Handle,
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);
if (Handle != NULL) {
ASSERT (IsHiiHandleRegistered (Handle));
}
Size = 0;
PackageListHdr = NULL;
Status = mHiiDatabaseProt->ExportPackageLists (
mHiiDatabaseProt,
Handle,
&Size,
PackageListHdr
);
ASSERT_EFI_ERROR (Status != EFI_BUFFER_TOO_SMALL);
if (Status == EFI_BUFFER_TOO_SMALL) {
PackageListHdr = AllocateZeroPool (Size);
if (PackageListHeader == NULL) {
return EFI_OUT_OF_RESOURCES;
} else {
Status = mHiiDatabaseProt->ExportPackageLists (
mHiiDatabaseProt,
Handle,
&Size,
PackageListHdr
);
}
}
if (!EFI_ERROR (Status)) {
*PackageListHeader = PackageListHdr;
*PackageListSize = Size;
} else {
FreePool (PackageListHdr);
}
return Status;
}
/**
This function returns a list of the package handles of the
specified type that are currently active in the HII database. The
pseudo-type EFI_HII_PACKAGE_TYPE_ALL will cause all package
handles to be listed.
If HandleBufferLength is NULL, then ASSERT.
If HandleBuffer is NULL, the ASSERT.
If PackageType is EFI_HII_PACKAGE_TYPE_GUID and PackageGuid is
NULL, then ASSERT.
If PackageType is not EFI_HII_PACKAGE_TYPE_GUID and PackageGuid is not
NULL, then ASSERT.
@param PackageType Specifies the package type of the packages
to list or EFI_HII_PACKAGE_TYPE_ALL for
all packages to be listed.
@param PackageGuid If PackageType is
EFI_HII_PACKAGE_TYPE_GUID, then this is
the pointer to the GUID which must match
the Guid field of
EFI_HII_PACKAGE_GUID_HEADER. Otherwise, it
must be NULL.
@param HandleBufferLength On output, the length of the handle buffer
that is required for the handles found.
@param HandleBuffer On output, an array of EFI_HII_HANDLE instances returned.
The caller is responcible to free this pointer allocated.
@retval EFI_SUCCESS The matching handles are outputed successfully.
HandleBufferLength is updated with the actual length.
@retval EFI_OUT_OF_RESOURCES Not enough resource to complete the operation.
@retval EFI_NOT_FOUND No matching handle could not be found in database.
**/
EFI_STATUS
EFIAPI
HiiLibListPackageLists (
IN UINT8 PackageType,
IN CONST EFI_GUID *PackageGuid,
IN OUT UINTN *HandleBufferLength,
OUT EFI_HII_HANDLE **HandleBuffer
)
{
EFI_STATUS Status;
ASSERT (HandleBufferLength != NULL);
ASSERT (HandleBuffer != NULL);
*HandleBufferLength = 0;
*HandleBuffer = NULL;
if (PackageType == EFI_HII_PACKAGE_TYPE_GUID) {
ASSERT (PackageGuid != NULL);
} else {
ASSERT (PackageGuid == NULL);
}
Status = mHiiDatabaseProt->ListPackageLists (
mHiiDatabaseProt,
PackageType,
PackageGuid,
HandleBufferLength,
*HandleBuffer
);
if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
//
// No packages is registered to UEFI HII Database, just return.
//
//
return Status;
}
*HandleBuffer = AllocateZeroPool (*HandleBufferLength);
if (*HandleBuffer == NULL) {
return EFI_OUT_OF_RESOURCES;
}
return mHiiDatabaseProt->ListPackageLists (
mHiiDatabaseProt,
PackageType,
PackageGuid,
HandleBufferLength,
*HandleBuffer
);
}
/**
This function check if the Hii Handle is a valid handle registered
in the HII database.
@param HiiHandle The HII Handle.
@retval TRUE If it is a valid HII handle.
@retval FALSE If it is a invalid HII handle.
**/
BOOLEAN
IsHiiHandleRegistered (
EFI_HII_HANDLE HiiHandle
)
{
EFI_STATUS Status;
UINTN BufferSize;
EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList;
ASSERT (HiiHandle != NULL);
HiiPackageList = NULL;
BufferSize = 0;
Status = mHiiDatabaseProt->ExportPackageLists (
mHiiDatabaseProt,
HiiHandle,
&BufferSize,
HiiPackageList
);
return (BOOLEAN) (Status == EFI_BUFFER_TOO_SMALL);
}

View File

@ -1,602 +0,0 @@
/** @file
HII Library implementation that uses DXE protocols and services.
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 "InternalHiiLib.h"
//
// Lookup table of ISO639-2 3 character language codes to ISO 639-1 2 character language codes
// Each entry is 5 CHAR8 values long. The first 3 CHAR8 values are the ISO 639-2 code.
// The last 2 CHAR8 values are the ISO 639-1 code.
//
GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 Iso639ToRfc3066ConversionTable[] =
"\
aaraa\
abkab\
afraf\
amham\
araar\
asmas\
aymay\
azeaz\
bakba\
belbe\
benbn\
bihbh\
bisbi\
bodbo\
brebr\
bulbg\
catca\
cescs\
corkw\
cosco\
cymcy\
danda\
deude\
dzodz\
ellel\
engen\
epoeo\
estet\
euseu\
faofo\
fasfa\
fijfj\
finfi\
frafr\
fryfy\
gaiga\
gdhgd\
glggl\
grngn\
gujgu\
hauha\
hebhe\
hinhi\
hrvhr\
hunhu\
hyehy\
ikuiu\
ileie\
inaia\
indid\
ipkik\
islis\
itait\
jawjw\
jpnja\
kalkl\
kankn\
kasks\
katka\
kazkk\
khmkm\
kinrw\
kirky\
korko\
kurku\
laolo\
latla\
lavlv\
linln\
litlt\
ltzlb\
malml\
marmr\
mkdmk\
mlgmg\
mltmt\
molmo\
monmn\
mrimi\
msams\
myamy\
nauna\
nepne\
nldnl\
norno\
ocioc\
ormom\
panpa\
polpl\
porpt\
pusps\
quequ\
rohrm\
ronro\
runrn\
rusru\
sagsg\
sansa\
sinsi\
slksk\
slvsl\
smise\
smosm\
snasn\
sndsd\
somso\
sotst\
spaes\
sqisq\
srpsr\
sswss\
sunsu\
swasw\
swesv\
tamta\
tattt\
telte\
tgktg\
tgltl\
thath\
tsnts\
tuktk\
twitw\
uigug\
ukruk\
urdur\
uzbuz\
vievi\
volvo\
wolwo\
xhoxh\
yidyi\
zhaza\
zhozh\
zulzu\
";
/**
This function adds the string into String Package of each language
supported by the package list.
If String is NULL, then ASSERT.
If StringId is NULL, the ASSERT.
If PackageList could not be found in the default HII database, then ASSERT.
@param PackageList Handle of the package list where this string will
be added.
@param StringId On return, contains the new strings id, which is
unique within PackageList.
@param String Points to the new null-terminated string.
@retval EFI_SUCCESS The new string was added successfully.
@retval EFI_OUT_OF_RESOURCES Could not add the string due to lack of resources.
**/
EFI_STATUS
EFIAPI
HiiLibNewString (
IN EFI_HII_HANDLE PackageList,
OUT EFI_STRING_ID *StringId,
IN CONST EFI_STRING String
)
{
EFI_STATUS Status;
CHAR8 *Languages;
CHAR8 *LangStrings;
CHAR8 Lang[RFC_3066_ENTRY_SIZE];
ASSERT (String != NULL);
ASSERT (StringId != NULL);
Status = EFI_SUCCESS;
Languages = HiiLibGetSupportedLanguages (PackageList);
LangStrings = Languages;
while (*LangStrings != 0) {
HiiLibGetNextLanguage (&LangStrings, Lang);
//
// For each language supported by the package,
// a string token is created.
//
Status = mHiiStringProt->NewString (
mHiiStringProt,
PackageList,
StringId,
Lang,
NULL,
String,
NULL
);
if (EFI_ERROR (Status)) {
break;
}
}
FreePool (Languages);
return Status;
}
/**
This function update the specified string in String Package of each language
supported by the package list.
If String is NULL, then ASSERT.
If PackageList could not be found in the default HII database, then ASSERT.
If StringId is not found in PackageList, then ASSERT.
@param PackageList Handle of the package list where this string will
be added.
@param StringId Ths String Id to be updated.
@param String Points to the new null-terminated string.
@retval EFI_SUCCESS The new string was added successfully.
@retval EFI_OUT_OF_RESOURCES Could not add the string due to lack of resources.
**/
EFI_STATUS
EFIAPI
HiiLibSetString (
IN EFI_HII_HANDLE PackageList,
IN EFI_STRING_ID StringId,
IN CONST EFI_STRING String
)
{
EFI_STATUS Status;
CHAR8 *Languages;
CHAR8 *LangStrings;
CHAR8 Lang[RFC_3066_ENTRY_SIZE];
ASSERT (IsHiiHandleRegistered (PackageList));
Status = EFI_SUCCESS;
Languages = HiiLibGetSupportedLanguages (PackageList);
ASSERT (Languages != NULL);
LangStrings = Languages;
while (*LangStrings != 0) {
HiiLibGetNextLanguage (&LangStrings, Lang);
//
// For each language supported by the package,
// the string is updated.
//
Status = mHiiStringProt->SetString (
mHiiStringProt,
PackageList,
StringId,
Lang,
String,
NULL
);
if (EFI_ERROR (Status)) {
break;
}
}
FreePool (Languages);
return Status;
}
/**
Get the string given the StringId and String package Producer's Guid. The caller
is responsible to free the *String.
If PackageList with the matching ProducerGuid is not found, then ASSERT.
If PackageList with the matching ProducerGuid is found but no String is
specified by StringId is found, then ASSERT.
@param ProducerGuid The Guid of String package list.
@param StringId The String ID.
@param String The output string.
@retval EFI_SUCCESS Operation is successful.
@retval EFI_OUT_OF_RESOURCES There is not enought memory in the system.
**/
EFI_STATUS
EFIAPI
HiiLibGetStringFromToken (
IN EFI_GUID *ProducerGuid,
IN EFI_STRING_ID StringId,
OUT EFI_STRING *String
)
{
EFI_STATUS Status;
UINTN Index;
UINTN HandleBufferLen;
EFI_HII_HANDLE *HiiHandleBuffer;
EFI_GUID Guid;
Status = HiiLibGetHiiHandles (&HandleBufferLen, &HiiHandleBuffer);
if (EFI_ERROR(Status)) {
return Status;
}
for (Index = 0; Index < (HandleBufferLen / sizeof (EFI_HII_HANDLE)); Index++) {
Status = HiiLibExtractGuidFromHiiHandle (HiiHandleBuffer[Index], &Guid);
if (EFI_ERROR(Status)) {
return Status;
}
if (CompareGuid (&Guid, ProducerGuid)) {
break;
}
}
if (Index >= (HandleBufferLen / sizeof (EFI_HII_HANDLE))) {
//
// If PackageList with the matching ProducerGuid is not found, then ASSERT.
//
ASSERT (FALSE);
Status = EFI_NOT_FOUND;
goto Out;
}
Status = HiiLibGetStringFromHandle (HiiHandleBuffer[Index], StringId, String);
Out:
if (HiiHandleBuffer != NULL) {
FreePool (HiiHandleBuffer);
}
return Status;
}
/**
This function try to retrieve string from String package of current language.
If fails, it try to retrieve string from String package of first language it support.
If StringSize is NULL, then ASSERT.
If String is NULL and *StringSize is not 0, then ASSERT.
If PackageList could not be found in the default HII database, then ASSERT.
If StringId is not found in PackageList, then ASSERT.
@param PackageList The package list in the HII database to search for
the specified string.
@param StringId The string's id, which is unique within
PackageList.
@param String Points to the new null-terminated string.
@param StringSize On entry, points to the size of the buffer pointed
to by String, in bytes. On return, points to the
length of the string, in bytes.
@retval EFI_SUCCESS The string was returned successfully.
@retval EFI_NOT_FOUND The string specified by StringId is not available.
@retval EFI_BUFFER_TOO_SMALL The buffer specified by StringLength is too small
to hold the string.
**/
EFI_STATUS
EFIAPI
HiiLibGetString (
IN EFI_HII_HANDLE PackageList,
IN EFI_STRING_ID StringId,
OUT EFI_STRING String,
IN OUT UINTN *StringSize
)
{
EFI_STATUS Status;
CHAR8 *Languages;
CHAR8 *LangStrings;
CHAR8 Lang[RFC_3066_ENTRY_SIZE];
CHAR8 CurrentLang[RFC_3066_ENTRY_SIZE];
ASSERT (StringSize != NULL);
ASSERT (!(*StringSize != 0 && String == NULL));
ASSERT (IsHiiHandleRegistered (PackageList));
GetCurrentLanguage (CurrentLang);
Status = mHiiStringProt->GetString (
mHiiStringProt,
CurrentLang,
PackageList,
StringId,
String,
StringSize,
NULL
);
if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
Languages = HiiLibGetSupportedLanguages (PackageList);
ASSERT (Languages != NULL);
LangStrings = Languages;
HiiLibGetNextLanguage (&LangStrings, Lang);
FreePool (Languages);
Status = mHiiStringProt->GetString (
mHiiStringProt,
Lang,
PackageList,
StringId,
String,
StringSize,
NULL
);
}
return Status;
}
/**
Get string specified by StringId form the HiiHandle. The caller
is responsible to free the *String.
If String is NULL, then ASSERT.
If HiiHandle could not be found in the default HII database, then ASSERT.
If StringId is not found in PackageList, then ASSERT.
@param HiiHandle The HII handle of package list.
@param StringId The String ID.
@param String The output string.
@retval EFI_NOT_FOUND String is not found.
@retval EFI_SUCCESS Operation is successful.
@retval EFI_OUT_OF_RESOURCES There is not enought memory in the system.
**/
EFI_STATUS
EFIAPI
HiiLibGetStringFromHandle (
IN EFI_HII_HANDLE HiiHandle,
IN EFI_STRING_ID StringId,
OUT EFI_STRING *String
)
{
EFI_STATUS Status;
UINTN StringSize;
ASSERT (String != NULL);
StringSize = HII_LIB_DEFAULT_STRING_SIZE;
*String = AllocateZeroPool (StringSize);
if (*String == NULL) {
return EFI_OUT_OF_RESOURCES;
}
Status = HiiLibGetString (HiiHandle, StringId, *String, &StringSize);
if (Status == EFI_BUFFER_TOO_SMALL) {
FreePool (*String);
*String = AllocateZeroPool (StringSize);
if (*String == NULL) {
return EFI_OUT_OF_RESOURCES;
}
Status = HiiLibGetString (HiiHandle, StringId, *String, &StringSize);
}
return Status;
}
/**
Convert language code from RFC3066 to ISO639-2.
@param LanguageRfc3066 RFC3066 language code.
@param LanguageIso639 ISO639-2 language code.
@retval EFI_SUCCESS Language code converted.
@retval EFI_NOT_FOUND Language code not found.
**/
EFI_STATUS
EFIAPI
ConvertRfc3066LanguageToIso639Language (
IN CHAR8 *LanguageRfc3066,
OUT CHAR8 *LanguageIso639
)
{
UINTN Index;
if ((LanguageRfc3066[2] != '-') && (LanguageRfc3066[2] != 0)) {
CopyMem (LanguageIso639, LanguageRfc3066, 3);
return EFI_SUCCESS;
}
for (Index = 0; Iso639ToRfc3066ConversionTable[Index] != 0; Index += 5) {
if (CompareMem (LanguageRfc3066, &Iso639ToRfc3066ConversionTable[Index + 3], 2) == 0) {
CopyMem (LanguageIso639, &Iso639ToRfc3066ConversionTable[Index], 3);
return EFI_SUCCESS;
}
}
return EFI_NOT_FOUND;
}
/**
Convert language code from ISO639-2 to RFC3066.
LanguageIso639 contain a single ISO639-2 code such as
"eng" or "fra".
The LanguageRfc3066 must be a buffer large enough
for RFC_3066_ENTRY_SIZE characters.
If LanguageIso639 is NULL, then ASSERT.
If LanguageRfc3066 is NULL, then ASSERT.
@param LanguageIso639 ISO639-2 language code.
@param LanguageRfc3066 RFC3066 language code.
@retval EFI_SUCCESS Language code converted.
@retval EFI_NOT_FOUND Language code not found.
**/
EFI_STATUS
EFIAPI
ConvertIso639LanguageToRfc3066Language (
IN CONST CHAR8 *LanguageIso639,
OUT CHAR8 *LanguageRfc3066
)
{
UINTN Index;
for (Index = 0; Iso639ToRfc3066ConversionTable[Index] != 0; Index += 5) {
if (CompareMem (LanguageIso639, &Iso639ToRfc3066ConversionTable[Index], 3) == 0) {
CopyMem (LanguageRfc3066, &Iso639ToRfc3066ConversionTable[Index + 3], 2);
return EFI_SUCCESS;
}
}
return EFI_NOT_FOUND;
}
/**
Convert language code list from RFC3066 to ISO639-2, e.g. "en-US;fr-FR" will
be converted to "engfra".
@param SupportedLanguages The RFC3066 language list.
@return The ISO639-2 language list.
**/
CHAR8 *
EFIAPI
Rfc3066ToIso639 (
CHAR8 *SupportedLanguages
)
{
CHAR8 *Languages;
CHAR8 *ReturnValue;
CHAR8 *LangCodes;
CHAR8 LangRfc3066[RFC_3066_ENTRY_SIZE];
CHAR8 LangIso639[ISO_639_2_ENTRY_SIZE];
EFI_STATUS Status;
ReturnValue = AllocateZeroPool (AsciiStrSize (SupportedLanguages));
if (ReturnValue == NULL) {
return ReturnValue;
}
Languages = ReturnValue;
LangCodes = SupportedLanguages;
while (*LangCodes != 0) {
HiiLibGetNextLanguage (&LangCodes, LangRfc3066);
Status = ConvertRfc3066LanguageToIso639Language (LangRfc3066, LangIso639);
if (!EFI_ERROR (Status)) {
CopyMem (Languages, LangIso639, 3);
Languages = Languages + 3;
}
}
return ReturnValue;
}

View File

@ -1,53 +0,0 @@
/** @file
Internal include file for the HII Library instance.
Copyright (c) 2007, 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.
**/
#ifndef __INTERNAL_HII_LIB_H__
#define __INTERNAL_HII_LIB_H__
#include <Uefi.h>
#include <Protocol/HiiDatabase.h>
#include <Protocol/HiiString.h>
#include <Protocol/DevicePath.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/HiiLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/DevicePathLib.h>
#include <Library/UefiLib.h>
#define HII_LIB_DEFAULT_STRING_SIZE 0x200
extern CONST EFI_HII_DATABASE_PROTOCOL *mHiiDatabaseProt;
extern CONST EFI_HII_STRING_PROTOCOL *mHiiStringProt;
/**
This function check if the Hii Handle is a valid handle registered
in the HII database.
@param HiiHandle The HII Handle.
@retval TRUE If it is a valid HII handle.
@retval FALSE If it is a invalid HII handle.
**/
BOOLEAN
IsHiiHandleRegistered (
EFI_HII_HANDLE HiiHandle
);
#endif

View File

@ -1,59 +0,0 @@
#/** @file
# Instance of HII Library using DXE protocols and services.
#
# HII Library implementation that uses DXE protocols and services.
#
# 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.
#
#
#**/
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = UefiHiiLib
FILE_GUID = 3143687A-7C80-404e-B5FE-2D88980E1B1C
MODULE_TYPE = UEFI_DRIVER
VERSION_STRING = 1.0
LIBRARY_CLASS = HiiLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER
EDK_RELEASE_VERSION = 0x00020000
CONSTRUCTOR = HiiLibConstructor
#
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources.common]
HiiLib.c
HiiString.c
HiiLanguage.c
InternalHiiLib.h
[Packages]
MdePkg/MdePkg.dec
[LibraryClasses]
MemoryAllocationLib
BaseMemoryLib
BaseLib
DebugLib
UefiBootServicesTableLib
DevicePathLib
UefiLib
[Protocols]
gEfiHiiDatabaseProtocolGuid # ALWAYS_CONSUMED
gEfiHiiStringProtocolGuid # ALWAYS_CONSUMED
gEfiDevicePathProtocolGuid
[Depex]
gEfiHiiDatabaseProtocolGuid AND
gEfiHiiStringProtocolGuid

File diff suppressed because it is too large Load Diff

View File

@ -1,37 +0,0 @@
/** @file
Utility functions which helps in opcode creation, HII configuration string manipulations,
pop up window creations, setup browser persistence data set and get.
Copyright (c) 2007 - 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.
**/
#ifndef _IFRLIBRARY_INTERNAL_H_
#define _IFRLIBRARY_INTERNAL_H_
#include <Uefi.h>
#include <Protocol/DevicePath.h>
#include <Protocol/HiiConfigRouting.h>
#include <Protocol/FormBrowser2.h>
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/BaseLib.h>
#include <Library/DevicePathLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/IfrSupportLib.h>
#endif

View File

@ -1,891 +0,0 @@
/** @file
Library Routines to create IFR independent of string data - assume tokens already exist
Primarily to be used for exporting op-codes at a label in pre-defined forms.
Copyright (c) 2007, 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 "UefiIfrLibraryInternal.h"
/**
Check if the input question flags is a valid value.
The valid combination of question flags includes
EFI_IFR_FLAG_READ_ONLY | EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED | EFI_IFR_FLAG_OPTIONS_ONLY.
@param Flags The question flags to check.
@retval TRUE If the question flag is a valid combination.
@retval FALSE If the question flag is an invalid combination.
**/
BOOLEAN
IsValidQuestionFlags (
IN UINT8 Flags
)
{
return (BOOLEAN) (((Flags & (~QUESTION_FLAGS)) != 0) ? FALSE : TRUE);
}
/**
Check if the input value type is a valid type.
The valid value type is smaller or equal than EFI_IFR_TYPE_OTHER.
@param Type The value type to check.
@retval TRUE If the value type is valid.
@retval FALSE If the value type is invalid.
**/
BOOLEAN
IsValidValueType (
IN UINT8 Type
)
{
return (BOOLEAN) ((Type <= EFI_IFR_TYPE_OTHER) ? TRUE : FALSE);
}
/**
Check if the input numeric flags is a valid value.
@param Flags The numeric flags to check.
@retval TRUE If the numeric flags is valid.
@retval FALSE If the numeric flags is invalid.
**/
BOOLEAN
IsValidNumricFlags (
IN UINT8 Flags
)
{
if ((Flags & ~(EFI_IFR_NUMERIC_SIZE | EFI_IFR_DISPLAY)) != 0) {
return FALSE;
}
if ((Flags & EFI_IFR_DISPLAY) > EFI_IFR_DISPLAY_UINT_HEX) {
return FALSE;
}
return TRUE;
}
/**
Check if the checkbox flags is a valid value.
@param Flags The checkbox flags to check.
@retval TRUE If the checkbox flags is valid.
@retval FALSE If the checkbox flags is invalid.
**/
BOOLEAN
IsValidCheckboxFlags (
IN UINT8 Flags
)
{
return (BOOLEAN) ((Flags <= EFI_IFR_CHECKBOX_DEFAULT_MFG) ? TRUE : FALSE);
}
/**
Create EFI_IFR_END_OP opcode.
If Data is NULL or Data->Data is NULL, then ASSERT.
@param Data Destination for the created opcode binary
@retval EFI_SUCCESS Opcode is created successfully.
@retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
**/
EFI_STATUS
EFIAPI
CreateEndOpCode (
IN OUT EFI_HII_UPDATE_DATA *Data
)
{
EFI_IFR_END End;
UINT8 *LocalBuffer;
ASSERT (Data != NULL && Data->Data != NULL);
if (Data->Offset + sizeof (EFI_IFR_END) > Data->BufferSize) {
return EFI_BUFFER_TOO_SMALL;
}
End.Header.Length = sizeof (EFI_IFR_END);
End.Header.OpCode = EFI_IFR_END_OP;
End.Header.Scope = 0;
LocalBuffer = (UINT8 *) Data->Data + Data->Offset;
//
// CopyMem is used for EFI_IFR_END to cover the unaligned address access.
//
CopyMem (LocalBuffer, &End, sizeof (EFI_IFR_END));
Data->Offset += sizeof (EFI_IFR_END);
return EFI_SUCCESS;
}
/**
Create EFI_IFR_DEFAULT_OP opcode.
If Data is NULL or Data->Data is NULL, then ASSERT.
@param Value Value for the default
@param Type Type for the default
@param Data Destination for the created opcode binary
@retval EFI_SUCCESS Opcode is created successfully.
@retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
@retval EFI_INVALID_PARAMETER The type is not valid.
**/
EFI_STATUS
EFIAPI
CreateDefaultOpCode (
IN EFI_IFR_TYPE_VALUE *Value,
IN UINT8 Type,
IN OUT EFI_HII_UPDATE_DATA *Data
)
{
EFI_IFR_DEFAULT Default;
UINT8 *LocalBuffer;
ASSERT (Data != NULL && Data->Data != NULL);
if ((Value == NULL) || !IsValidValueType (Type)) {
return EFI_INVALID_PARAMETER;
}
if (Data->Offset + sizeof (EFI_IFR_DEFAULT) > Data->BufferSize) {
return EFI_BUFFER_TOO_SMALL;
}
Default.Header.OpCode = EFI_IFR_DEFAULT_OP;
Default.Header.Length = sizeof (EFI_IFR_DEFAULT);
Default.Header.Scope = 0;
Default.Type = Type;
Default.DefaultId = EFI_HII_DEFAULT_CLASS_STANDARD;
CopyMem (&Default.Value, Value, sizeof(EFI_IFR_TYPE_VALUE));
LocalBuffer = (UINT8 *) Data->Data + Data->Offset;
//
// CopyMem is used for EFI_IFR_DEFAULT to cover the unaligned address access.
//
CopyMem (LocalBuffer, &Default, sizeof (EFI_IFR_DEFAULT));
Data->Offset += sizeof (EFI_IFR_DEFAULT);
return EFI_SUCCESS;
}
/**
Create EFI_IFR_ACTION_OP opcode.
If Data is NULL or Data->Data is NULL, then ASSERT.
@param QuestionId Question ID
@param Prompt String ID for Prompt
@param Help String ID for Help
@param QuestionFlags Flags in Question Header
@param QuestionConfig String ID for configuration
@param Data Destination for the created opcode binary
@retval EFI_SUCCESS Opcode is created successfully.
@retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
@retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.
**/
EFI_STATUS
EFIAPI
CreateActionOpCode (
IN EFI_QUESTION_ID QuestionId,
IN EFI_STRING_ID Prompt,
IN EFI_STRING_ID Help,
IN UINT8 QuestionFlags,
IN EFI_STRING_ID QuestionConfig,
IN OUT EFI_HII_UPDATE_DATA *Data
)
{
EFI_IFR_ACTION Action;
UINT8 *LocalBuffer;
ASSERT (Data != NULL && Data->Data != NULL);
if (!IsValidQuestionFlags (QuestionFlags)) {
return EFI_INVALID_PARAMETER;
}
if (Data->Offset + sizeof (EFI_IFR_ACTION) > Data->BufferSize) {
return EFI_BUFFER_TOO_SMALL;
}
Action.Header.OpCode = EFI_IFR_ACTION_OP;
Action.Header.Length = sizeof (EFI_IFR_ACTION);
Action.Header.Scope = 0;
Action.Question.QuestionId = QuestionId;
Action.Question.Header.Prompt = Prompt;
Action.Question.Header.Help = Help;
Action.Question.VarStoreId = INVALID_VARSTORE_ID;
Action.Question.Flags = QuestionFlags;
Action.QuestionConfig = QuestionConfig;
LocalBuffer = (UINT8 *) Data->Data + Data->Offset;
//
// CopyMem is used for EFI_IFR_ACTION to cover the unaligned address access.
//
CopyMem (LocalBuffer, &Action, sizeof (EFI_IFR_ACTION));
Data->Offset += sizeof (EFI_IFR_ACTION);
return EFI_SUCCESS;
}
/**
Create EFI_IFR_SUBTITLE_OP opcode.
If Data is NULL or Data->Data is NULL, then ASSERT.
@param Prompt String ID for Prompt
@param Help String ID for Help
@param Flags Subtitle opcode flags
@param Scope Subtitle Scope bit
@param Data Destination for the created opcode binary
@retval EFI_SUCCESS Opcode is created successfully.
@retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
**/
EFI_STATUS
EFIAPI
CreateSubTitleOpCode (
IN EFI_STRING_ID Prompt,
IN EFI_STRING_ID Help,
IN UINT8 Flags,
IN UINT8 Scope,
IN OUT EFI_HII_UPDATE_DATA *Data
)
{
EFI_IFR_SUBTITLE Subtitle;
UINT8 *LocalBuffer;
ASSERT (Data != NULL && Data->Data != NULL);
if (Data->Offset + sizeof (EFI_IFR_SUBTITLE) > Data->BufferSize) {
return EFI_BUFFER_TOO_SMALL;
}
Subtitle.Header.OpCode = EFI_IFR_SUBTITLE_OP;
Subtitle.Header.Length = sizeof (EFI_IFR_SUBTITLE);
Subtitle.Header.Scope = Scope;
Subtitle.Statement.Prompt = Prompt;
Subtitle.Statement.Help = Help;
Subtitle.Flags = Flags;
LocalBuffer = (UINT8 *) Data->Data + Data->Offset;
//
// CopyMem is used for EFI_IFR_SUBTITLE to cover the unaligned address access.
//
CopyMem (LocalBuffer, &Subtitle, sizeof (EFI_IFR_SUBTITLE));
Data->Offset += sizeof (EFI_IFR_SUBTITLE);
return EFI_SUCCESS;
}
/**
Create EFI_IFR_TEXT_OP opcode.
If Data is NULL or Data->Data is NULL, then ASSERT.
@param Prompt String ID for Prompt
@param Help String ID for Help
@param TextTwo String ID for text two
@param Data Destination for the created opcode binary
@retval EFI_SUCCESS Opcode is created successfully.
@retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
**/
EFI_STATUS
EFIAPI
CreateTextOpCode (
IN EFI_STRING_ID Prompt,
IN EFI_STRING_ID Help,
IN EFI_STRING_ID TextTwo,
IN OUT EFI_HII_UPDATE_DATA *Data
)
{
EFI_IFR_TEXT Text;
UINT8 *LocalBuffer;
ASSERT (Data != NULL && Data->Data != NULL);
if (Data->Offset + sizeof (EFI_IFR_TEXT) > Data->BufferSize) {
return EFI_BUFFER_TOO_SMALL;
}
Text.Header.OpCode = EFI_IFR_TEXT_OP;
Text.Header.Length = sizeof (EFI_IFR_TEXT);
Text.Header.Scope = 0;
Text.Statement.Prompt = Prompt;
Text.Statement.Help = Help;
Text.TextTwo = TextTwo;
LocalBuffer = (UINT8 *) Data->Data + Data->Offset;
//
// CopyMem is used for EFI_IFR_TEXT to cover the unaligned address access.
//
CopyMem (LocalBuffer, &Text, sizeof (EFI_IFR_TEXT));
Data->Offset += sizeof (EFI_IFR_TEXT);
return EFI_SUCCESS;
}
/**
Create EFI_IFR_REF_OP opcode.
If Data is NULL or Data->Data is NULL, then ASSERT.
@param FormId Destination Form ID
@param Prompt String ID for Prompt
@param Help String ID for Help
@param QuestionFlags Flags in Question Header
@param QuestionId Question ID
@param Data Destination for the created opcode binary
@retval EFI_SUCCESS Opcode is created successfully.
@retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
@retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.
**/
EFI_STATUS
EFIAPI
CreateGotoOpCode (
IN EFI_FORM_ID FormId,
IN EFI_STRING_ID Prompt,
IN EFI_STRING_ID Help,
IN UINT8 QuestionFlags,
IN EFI_QUESTION_ID QuestionId,
IN OUT EFI_HII_UPDATE_DATA *Data
)
{
EFI_IFR_REF Goto;
UINT8 *LocalBuffer;
ASSERT (Data != NULL && Data->Data != NULL);
if (!IsValidQuestionFlags (QuestionFlags)) {
return EFI_INVALID_PARAMETER;
}
if (Data->Offset + sizeof (EFI_IFR_REF) > Data->BufferSize) {
return EFI_BUFFER_TOO_SMALL;
}
Goto.Header.OpCode = EFI_IFR_REF_OP;
Goto.Header.Length = sizeof (EFI_IFR_REF);
Goto.Header.Scope = 0;
Goto.Question.Header.Prompt = Prompt;
Goto.Question.Header.Help = Help;
Goto.Question.VarStoreId = INVALID_VARSTORE_ID;
Goto.Question.QuestionId = QuestionId;
Goto.Question.Flags = QuestionFlags;
Goto.FormId = FormId;
LocalBuffer = (UINT8 *) Data->Data + Data->Offset;
//
// CopyMem is used for EFI_IFR_REF to cover the unaligned address access.
//
CopyMem (LocalBuffer, &Goto, sizeof (EFI_IFR_REF));
Data->Offset += sizeof (EFI_IFR_REF);
return EFI_SUCCESS;
}
/**
Create EFI_IFR_ONE_OF_OPTION_OP opcode.
If Data is NULL or Data->Data is NULL, then ASSERT.
@param OptionCount The number of options.
@param OptionsList The list of Options.
@param Type The data type.
@param Data Destination for the created opcode binary
@retval EFI_SUCCESS Opcode is created successfully.
@retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
@retval EFI_INVALID_PARAMETER If OptionCount is not zero but OptionsList is NULL.
**/
EFI_STATUS
EFIAPI
CreateOneOfOptionOpCode (
IN UINTN OptionCount,
IN IFR_OPTION *OptionsList,
IN UINT8 Type,
IN OUT EFI_HII_UPDATE_DATA *Data
)
{
UINTN Index;
UINT8 *LocalBuffer;
EFI_IFR_ONE_OF_OPTION OneOfOption;
ASSERT (Data != NULL && Data->Data != NULL);
if ((OptionCount != 0) && (OptionsList == NULL)) {
return EFI_INVALID_PARAMETER;
}
if (Data->Offset + OptionCount * sizeof (EFI_IFR_ONE_OF_OPTION) > Data->BufferSize) {
return EFI_BUFFER_TOO_SMALL;
}
for (Index = 0; Index < OptionCount; Index++) {
OneOfOption.Header.OpCode = EFI_IFR_ONE_OF_OPTION_OP;
OneOfOption.Header.Length = sizeof (EFI_IFR_ONE_OF_OPTION);
OneOfOption.Header.Scope = 0;
OneOfOption.Option = OptionsList[Index].StringToken;
OneOfOption.Value = OptionsList[Index].Value;
OneOfOption.Flags = (UINT8) (OptionsList[Index].Flags & (EFI_IFR_OPTION_DEFAULT | EFI_IFR_OPTION_DEFAULT_MFG));
OneOfOption.Type = Type;
LocalBuffer = (UINT8 *) Data->Data + Data->Offset;
//
// CopyMem is used for EFI_IFR_ONF_OF_OPTION to cover the unaligned address access.
//
CopyMem (LocalBuffer, &OneOfOption, sizeof (EFI_IFR_ONE_OF_OPTION));
Data->Offset += sizeof (EFI_IFR_ONE_OF_OPTION);
}
return EFI_SUCCESS;
}
/**
Create EFI_IFR_ONE_OF_OP opcode.
If Data is NULL or Data->Data is NULL, then ASSERT.
@param QuestionId Question ID
@param VarStoreId Storage ID
@param VarOffset Offset in Storage
@param Prompt String ID for Prompt
@param Help String ID for Help
@param QuestionFlags Flags in Question Header
@param OneOfFlags Flags for oneof opcode
@param OptionsList List of options
@param OptionCount Number of options in option list
@param Data Destination for the created opcode binary
@retval EFI_SUCCESS Opcode is created successfully.
@retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
@retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.
**/
EFI_STATUS
EFIAPI
CreateOneOfOpCode (
IN EFI_QUESTION_ID QuestionId,
IN EFI_VARSTORE_ID VarStoreId,
IN UINT16 VarOffset,
IN EFI_STRING_ID Prompt,
IN EFI_STRING_ID Help,
IN UINT8 QuestionFlags,
IN UINT8 OneOfFlags,
IN IFR_OPTION *OptionsList,
IN UINTN OptionCount,
IN OUT EFI_HII_UPDATE_DATA *Data
)
{
UINTN Length;
EFI_IFR_ONE_OF OneOf;
UINT8 *LocalBuffer;
ASSERT (Data != NULL && Data->Data != NULL);
if (!IsValidNumricFlags (OneOfFlags) ||
!IsValidQuestionFlags (QuestionFlags) ||
((OptionCount != 0) && (OptionsList == NULL))) {
return EFI_INVALID_PARAMETER;
}
Length = sizeof (EFI_IFR_ONE_OF) + OptionCount * sizeof (EFI_IFR_ONE_OF_OPTION) + sizeof (EFI_IFR_END);
if (Data->Offset + Length > Data->BufferSize) {
return EFI_BUFFER_TOO_SMALL;
}
OneOf.Header.OpCode = EFI_IFR_ONE_OF_OP;
OneOf.Header.Length = sizeof (EFI_IFR_ONE_OF);
OneOf.Header.Scope = 1;
OneOf.Question.Header.Prompt = Prompt;
OneOf.Question.Header.Help = Help;
OneOf.Question.QuestionId = QuestionId;
OneOf.Question.VarStoreId = VarStoreId;
OneOf.Question.VarStoreInfo.VarOffset = VarOffset;
OneOf.Question.Flags = QuestionFlags;
OneOf.Flags = OneOfFlags;
ZeroMem ((VOID *) &OneOf.data, sizeof (MINMAXSTEP_DATA));
LocalBuffer = (UINT8 *) Data->Data + Data->Offset;
//
// CopyMem is used for EFI_IFR_ONF_OF to cover the unaligned address access.
//
CopyMem (LocalBuffer, &OneOf, sizeof (EFI_IFR_ONE_OF));
Data->Offset += sizeof (EFI_IFR_ONE_OF);
CreateOneOfOptionOpCode (OptionCount, OptionsList, (UINT8) (OneOfFlags & EFI_IFR_NUMERIC_SIZE), Data);
CreateEndOpCode (Data);
return EFI_SUCCESS;
}
/**
Create EFI_IFR_ORDERED_LIST_OP opcode.
If Data is NULL or Data->Data is NULL, then ASSERT.
@param QuestionId Question ID
@param VarStoreId Storage ID
@param VarOffset Offset in Storage
@param Prompt String ID for Prompt
@param Help String ID for Help
@param QuestionFlags Flags in Question Header
@param OrderedListFlags Flags for ordered list opcode
@param DataType Type for option value
@param MaxContainers Maximum count for options in this ordered list
@param OptionsList List of options
@param OptionCount Number of options in option list
@param Data Destination for the created opcode binary
@retval EFI_SUCCESS Opcode is created successfully.
@retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
@retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.
**/
EFI_STATUS
EFIAPI
CreateOrderedListOpCode (
IN EFI_QUESTION_ID QuestionId,
IN EFI_VARSTORE_ID VarStoreId,
IN UINT16 VarOffset,
IN EFI_STRING_ID Prompt,
IN EFI_STRING_ID Help,
IN UINT8 QuestionFlags,
IN UINT8 OrderedListFlags,
IN UINT8 DataType,
IN UINT8 MaxContainers,
IN IFR_OPTION *OptionsList,
IN UINTN OptionCount,
IN OUT EFI_HII_UPDATE_DATA *Data
)
{
UINTN Length;
EFI_IFR_ORDERED_LIST OrderedList;
UINT8 *LocalBuffer;
ASSERT (Data != NULL && Data->Data != NULL);
if (!IsValidQuestionFlags (QuestionFlags) ||
((OptionCount != 0) && (OptionsList == NULL))) {
return EFI_INVALID_PARAMETER;
}
if ((OrderedListFlags != 0) &&
(OrderedListFlags != EFI_IFR_UNIQUE_SET) &&
(OrderedListFlags != EFI_IFR_NO_EMPTY_SET)) {
return EFI_INVALID_PARAMETER;
}
Length = sizeof (EFI_IFR_ORDERED_LIST) + OptionCount * sizeof (EFI_IFR_ONE_OF_OPTION) + sizeof (EFI_IFR_END);
if (Data->Offset + Length > Data->BufferSize) {
return EFI_BUFFER_TOO_SMALL;
}
OrderedList.Header.OpCode = EFI_IFR_ORDERED_LIST_OP;
OrderedList.Header.Length = sizeof (EFI_IFR_ORDERED_LIST);
OrderedList.Header.Scope = 1;
OrderedList.Question.Header.Prompt = Prompt;
OrderedList.Question.Header.Help = Help;
OrderedList.Question.QuestionId = QuestionId;
OrderedList.Question.VarStoreId = VarStoreId;
OrderedList.Question.VarStoreInfo.VarOffset = VarOffset;
OrderedList.Question.Flags = QuestionFlags;
OrderedList.MaxContainers = MaxContainers;
OrderedList.Flags = OrderedListFlags;
LocalBuffer = (UINT8 *) Data->Data + Data->Offset;
//
// CopyMem is used for EFI_IFR_ORDERED_LIST to cover the unaligned address access.
//
CopyMem (LocalBuffer, &OrderedList, sizeof (EFI_IFR_ORDERED_LIST));
Data->Offset += sizeof (EFI_IFR_ORDERED_LIST);
CreateOneOfOptionOpCode (OptionCount, OptionsList, DataType, Data);
CreateEndOpCode (Data);
return EFI_SUCCESS;
}
/**
Create EFI_IFR_CHECKBOX_OP opcode.
If Data is NULL or Data->Data is NULL, then ASSERT.
@param QuestionId Question ID
@param VarStoreId Storage ID
@param VarOffset Offset in Storage
@param Prompt String ID for Prompt
@param Help String ID for Help
@param QuestionFlags Flags in Question Header
@param CheckBoxFlags Flags for checkbox opcode
@param Data Destination for the created opcode binary
@retval EFI_SUCCESS Opcode is created successfully.
@retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
@retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.
**/
EFI_STATUS
EFIAPI
CreateCheckBoxOpCode (
IN EFI_QUESTION_ID QuestionId,
IN EFI_VARSTORE_ID VarStoreId,
IN UINT16 VarOffset,
IN EFI_STRING_ID Prompt,
IN EFI_STRING_ID Help,
IN UINT8 QuestionFlags,
IN UINT8 CheckBoxFlags,
IN OUT EFI_HII_UPDATE_DATA *Data
)
{
EFI_IFR_CHECKBOX CheckBox;
UINT8 *LocalBuffer;
ASSERT (Data != NULL && Data->Data != NULL);
if (!IsValidQuestionFlags (QuestionFlags) || !IsValidCheckboxFlags (CheckBoxFlags)) {
return EFI_INVALID_PARAMETER;
}
if (Data->Offset + sizeof (EFI_IFR_CHECKBOX) > Data->BufferSize) {
return EFI_BUFFER_TOO_SMALL;
}
CheckBox.Header.OpCode = EFI_IFR_CHECKBOX_OP;
CheckBox.Header.Length = sizeof (EFI_IFR_CHECKBOX);
CheckBox.Header.Scope = 0;
CheckBox.Question.QuestionId = QuestionId;
CheckBox.Question.VarStoreId = VarStoreId;
CheckBox.Question.VarStoreInfo.VarOffset = VarOffset;
CheckBox.Question.Header.Prompt = Prompt;
CheckBox.Question.Header.Help = Help;
CheckBox.Question.Flags = QuestionFlags;
CheckBox.Flags = CheckBoxFlags;
LocalBuffer = (UINT8 *) Data->Data + Data->Offset;
//
// CopyMem is used for EFI_IFR_CHECKBOX to cover the unaligned address access.
//
CopyMem (LocalBuffer, &CheckBox, sizeof (EFI_IFR_CHECKBOX));
Data->Offset += sizeof (EFI_IFR_CHECKBOX);
return EFI_SUCCESS;
}
/**
Create EFI_IFR_NUMERIC_OP opcode.
If Data is NULL or Data->Data is NULL, then ASSERT.
@param QuestionId Question ID
@param VarStoreId Storage ID
@param VarOffset Offset in Storage
@param Prompt String ID for Prompt
@param Help String ID for Help
@param QuestionFlags Flags in Question Header
@param NumericFlags Flags for numeric opcode
@param Minimum Numeric minimum value
@param Maximum Numeric maximum value
@param Step Numeric step for edit
@param Default Numeric default value
@param Data Destination for the created opcode binary
@retval EFI_SUCCESS Opcode is created successfully.
@retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
@retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.
**/
EFI_STATUS
EFIAPI
CreateNumericOpCode (
IN EFI_QUESTION_ID QuestionId,
IN EFI_VARSTORE_ID VarStoreId,
IN UINT16 VarOffset,
IN EFI_STRING_ID Prompt,
IN EFI_STRING_ID Help,
IN UINT8 QuestionFlags,
IN UINT8 NumericFlags,
IN UINT64 Minimum,
IN UINT64 Maximum,
IN UINT64 Step,
IN UINT64 Default,
IN OUT EFI_HII_UPDATE_DATA *Data
)
{
EFI_STATUS Status;
EFI_IFR_NUMERIC Numeric;
MINMAXSTEP_DATA MinMaxStep;
EFI_IFR_TYPE_VALUE DefaultValue;
UINT8 *LocalBuffer;
ASSERT (Data != NULL && Data->Data != NULL);
if (!IsValidQuestionFlags (QuestionFlags) || !IsValidNumricFlags (NumericFlags)) {
return EFI_INVALID_PARAMETER;
}
if (Data->Offset + sizeof (EFI_IFR_CHECKBOX) > Data->BufferSize) {
return EFI_BUFFER_TOO_SMALL;
}
Numeric.Header.OpCode = EFI_IFR_NUMERIC_OP;
Numeric.Header.Length = sizeof (EFI_IFR_NUMERIC);
Numeric.Header.Scope = 1;
Numeric.Question.QuestionId = QuestionId;
Numeric.Question.VarStoreId = VarStoreId;
Numeric.Question.VarStoreInfo.VarOffset = VarOffset;
Numeric.Question.Header.Prompt = Prompt;
Numeric.Question.Header.Help = Help;
Numeric.Question.Flags = QuestionFlags;
Numeric.Flags = NumericFlags;
switch (NumericFlags & EFI_IFR_NUMERIC_SIZE) {
case EFI_IFR_NUMERIC_SIZE_1:
MinMaxStep.u8.MinValue = (UINT8) Minimum;
MinMaxStep.u8.MaxValue = (UINT8) Maximum;
MinMaxStep.u8.Step = (UINT8) Step;
break;
case EFI_IFR_NUMERIC_SIZE_2:
MinMaxStep.u16.MinValue = (UINT16) Minimum;
MinMaxStep.u16.MaxValue = (UINT16) Maximum;
MinMaxStep.u16.Step = (UINT16) Step;
break;
case EFI_IFR_NUMERIC_SIZE_4:
MinMaxStep.u32.MinValue = (UINT32) Minimum;
MinMaxStep.u32.MaxValue = (UINT32) Maximum;
MinMaxStep.u32.Step = (UINT32) Step;
break;
case EFI_IFR_NUMERIC_SIZE_8:
MinMaxStep.u64.MinValue = Minimum;
MinMaxStep.u64.MaxValue = Maximum;
MinMaxStep.u64.Step = Step;
break;
}
CopyMem (&Numeric.data, &MinMaxStep, sizeof (MINMAXSTEP_DATA));
LocalBuffer = (UINT8 *) Data->Data + Data->Offset;
//
// CopyMem is used for EFI_IFR_NUMERIC to cover the unaligned address access.
//
CopyMem (LocalBuffer, &Numeric, sizeof (EFI_IFR_NUMERIC));
Data->Offset += sizeof (EFI_IFR_NUMERIC);
DefaultValue.u64 = Default;
Status = CreateDefaultOpCode (&DefaultValue, (UINT8) (NumericFlags & EFI_IFR_NUMERIC_SIZE), Data);
if (EFI_ERROR(Status)) {
return Status;
}
CreateEndOpCode (Data);
return EFI_SUCCESS;
}
/**
Create EFI_IFR_STRING_OP opcode.
If Data is NULL or Data->Data is NULL, then ASSERT.
@param QuestionId Question ID
@param VarStoreId Storage ID
@param VarOffset Offset in Storage
@param Prompt String ID for Prompt
@param Help String ID for Help
@param QuestionFlags Flags in Question Header
@param StringFlags Flags for string opcode
@param MinSize String minimum length
@param MaxSize String maximum length
@param Data Destination for the created opcode binary
@retval EFI_SUCCESS Opcode is created successfully.
@retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
@retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.
**/
EFI_STATUS
EFIAPI
CreateStringOpCode (
IN EFI_QUESTION_ID QuestionId,
IN EFI_VARSTORE_ID VarStoreId,
IN UINT16 VarOffset,
IN EFI_STRING_ID Prompt,
IN EFI_STRING_ID Help,
IN UINT8 QuestionFlags,
IN UINT8 StringFlags,
IN UINT8 MinSize,
IN UINT8 MaxSize,
IN OUT EFI_HII_UPDATE_DATA *Data
)
{
EFI_IFR_STRING String;
UINT8 *LocalBuffer;
ASSERT (Data != NULL && Data->Data != NULL);
if (!IsValidQuestionFlags (QuestionFlags) || (StringFlags & ~EFI_IFR_STRING_MULTI_LINE) != 0) {
return EFI_INVALID_PARAMETER;
}
if (Data->Offset + sizeof (EFI_IFR_STRING) > Data->BufferSize) {
return EFI_BUFFER_TOO_SMALL;
}
String.Header.OpCode = EFI_IFR_STRING_OP;
String.Header.Length = sizeof (EFI_IFR_STRING);
String.Header.Scope = 0;
String.Question.Header.Prompt = Prompt;
String.Question.Header.Help = Help;
String.Question.QuestionId = QuestionId;
String.Question.VarStoreId = VarStoreId;
String.Question.VarStoreInfo.VarOffset = VarOffset;
String.Question.Flags = QuestionFlags;
String.MinSize = MinSize;
String.MaxSize = MaxSize;
String.Flags = StringFlags;
LocalBuffer = (UINT8 *) Data->Data + Data->Offset;
//
// CopyMem is used for EFI_IFR_STRING to cover the unaligned address access.
//
CopyMem (LocalBuffer, &String, sizeof (EFI_IFR_STRING));
Data->Offset += sizeof (EFI_IFR_STRING);
return EFI_SUCCESS;
}

View File

@ -1,56 +0,0 @@
#/** @file
# Instance of IFR Support Library.
#
# This library contains functions to do IFR opcode creation and utility
# functions to help module to interact with a UEFI Form Browser.
#
# Copyright (c) 2007 - 2008, Intel Corporation. All rights reserved.
#
# 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.
#
#
#**/
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = UefiIfrSupportLib
FILE_GUID = bf38668e-e231-4baa-99e4-8c0e4c35dca6
MODULE_TYPE = UEFI_DRIVER
VERSION_STRING = 1.0
LIBRARY_CLASS = IfrSupportLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER
EDK_RELEASE_VERSION = 0x00020000
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources.common]
UefiIfrForm.c
UefiIfrLibraryInternal.h
UefiIfrOpCodeCreation.c
[Packages]
MdePkg/MdePkg.dec
[LibraryClasses]
MemoryAllocationLib
DevicePathLib
BaseLib
UefiBootServicesTableLib
BaseMemoryLib
DebugLib
[Protocols]
gEfiDevicePathProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiHiiConfigRoutingProtocolGuid
gEfiFormBrowser2ProtocolGuid