summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MdeModulePkg/Library/ExtendedIfrSupportLib/Common.c180
-rw-r--r--MdeModulePkg/Library/ExtendedIfrSupportLib/ExtendedIfrSupportLib.inf66
-rw-r--r--MdeModulePkg/Library/ExtendedIfrSupportLib/Form.c527
-rw-r--r--MdeModulePkg/Library/ExtendedIfrSupportLib/IfrOpCodeCreation.c65
-rw-r--r--MdeModulePkg/Library/ExtendedIfrSupportLib/LibraryInternal.h39
-rw-r--r--MdeModulePkg/Library/UefiIfrSupportLib/UefiIfrForm.c1655
-rw-r--r--MdeModulePkg/Library/UefiIfrSupportLib/UefiIfrLibraryInternal.h41
-rw-r--r--MdeModulePkg/Library/UefiIfrSupportLib/UefiIfrOpCodeCreation.c891
-rw-r--r--MdeModulePkg/Library/UefiIfrSupportLib/UefiIfrSupportLib.inf58
-rw-r--r--MdeModulePkg/MdeModulePkg.dec10
10 files changed, 1 insertions, 3531 deletions
diff --git a/MdeModulePkg/Library/ExtendedIfrSupportLib/Common.c b/MdeModulePkg/Library/ExtendedIfrSupportLib/Common.c
deleted file mode 100644
index e9fc465..0000000
--- a/MdeModulePkg/Library/ExtendedIfrSupportLib/Common.c
+++ /dev/null
@@ -1,180 +0,0 @@
-/** @file
- Common Library Routines to assist handle HII elements.
-
-Copyright (c) 2007 - 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 "LibraryInternal.h"
-
-
-//
-// Hii relative protocols
-//
-
-EFI_HII_DATABASE_PROTOCOL *gIfrLibHiiDatabase;
-EFI_HII_STRING_PROTOCOL *gIfrLibHiiString;
-
-/**
- ExtendedIfrSupportLib's constructor. It locates the required protocol:
- gEfiHiiDatabaseProtocolGuid and gEfiHiiStringProtocolGuid.
-
- @param ImageHandle The firmware allocated handle for the EFI image.
-
- @param SystemTable A pointer to the EFI System Table.
-
- @retval EFI_SUCCESS This function always completes successfully.
-
-**/
-EFI_STATUS
-EFIAPI
-ExtendedIfrSupportLibConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
-
- Status = gBS->LocateProtocol (&gEfiHiiDatabaseProtocolGuid, NULL, (VOID **) &gIfrLibHiiDatabase);
- ASSERT_EFI_ERROR (Status);
-
- Status = gBS->LocateProtocol (&gEfiHiiStringProtocolGuid, NULL, (VOID **) &gIfrLibHiiString);
- ASSERT_EFI_ERROR (Status);
-
- return EFI_SUCCESS;
-}
-
-
-/**
- Extract formset class for given HII handle.
-
-
- @param Handle The HII handle.
- @param Class Class of the formset.
- @param FormSetTitle Formset title string.
- @param FormSetHelp Formset help string.
-
- @retval EFI_SUCCESS Successfully extract Class for specified Hii handle.
- @return Other values if failed to export packages for the given HII handle.
-
-**/
-EFI_STATUS
-EFIAPI
-IfrLibExtractClassFromHiiHandle (
- IN EFI_HII_HANDLE Handle,
- OUT UINT16 *Class,
- OUT EFI_STRING_ID *FormSetTitle,
- OUT EFI_STRING_ID *FormSetHelp
- )
-{
- EFI_STATUS Status;
- UINTN BufferSize;
- EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList;
- UINT8 *Package;
- UINT8 *OpCodeData;
- UINT32 Offset;
- UINT32 Offset2;
- UINT32 PackageListLength;
- EFI_HII_PACKAGE_HEADER PackageHeader;
-
- ASSERT (Handle != NULL);
- ASSERT (Class != NULL);
- ASSERT (FormSetTitle != NULL);
- ASSERT (FormSetHelp != NULL);
-
- *Class = EFI_NON_DEVICE_CLASS;
- *FormSetTitle = 0;
- *FormSetHelp = 0;
-
- //
- // Get HII PackageList
- //
- BufferSize = 0;
- HiiPackageList = NULL;
- Status = gIfrLibHiiDatabase->ExportPackageLists (gIfrLibHiiDatabase, Handle, &BufferSize, HiiPackageList);
- //
- // Handle is a invalid handle. Check if Handle is corrupted.
- //
- ASSERT (Status != EFI_NOT_FOUND);
- //
- // The return status should always be EFI_BUFFER_TOO_SMALL as input buffer's size is 0.
- //
- ASSERT (Status == EFI_BUFFER_TOO_SMALL);
-
- HiiPackageList = AllocatePool (BufferSize);
- ASSERT (HiiPackageList != NULL);
-
- Status = gIfrLibHiiDatabase->ExportPackageLists (gIfrLibHiiDatabase, Handle, &BufferSize, HiiPackageList);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Get Form package from this HII package List
- //
- Offset = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
- Offset2 = 0;
- PackageListLength = ReadUnaligned32 (&HiiPackageList->PackageLength);
-
- while (Offset < PackageListLength) {
- Package = ((UINT8 *) HiiPackageList) + Offset;
- CopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));
-
- if (PackageHeader.Type == EFI_HII_PACKAGE_FORMS) {
- //
- // Search Class Opcode in this Form Package
- //
- Offset2 = sizeof (EFI_HII_PACKAGE_HEADER);
- while (Offset2 < PackageHeader.Length) {
- OpCodeData = Package + Offset2;
-
- if (((EFI_IFR_OP_HEADER *) OpCodeData)->OpCode == EFI_IFR_FORM_SET_OP) {
- //
- // Find FormSet OpCode
- //
- CopyMem (FormSetTitle, &((EFI_IFR_FORM_SET *) OpCodeData)->FormSetTitle, sizeof (EFI_STRING_ID));
- CopyMem (FormSetHelp, &((EFI_IFR_FORM_SET *) OpCodeData)->Help, sizeof (EFI_STRING_ID));
- }
-
- if ((((EFI_IFR_OP_HEADER *) OpCodeData)->OpCode == EFI_IFR_GUID_OP) &&
- CompareGuid (&gEfiIfrTianoGuid, (EFI_GUID *)(OpCodeData + sizeof (EFI_IFR_OP_HEADER))) &&
- (((EFI_IFR_GUID_CLASS *) OpCodeData)->ExtendOpCode == EFI_IFR_EXTEND_OP_CLASS)
- ) {
- //
- // Find GUIDed Class OpCode
- //
- CopyMem (Class, &((EFI_IFR_GUID_CLASS *) OpCodeData)->Class, sizeof (UINT16));
-
- //
- // Till now, we ought to have found the formset Opcode
- //
- break;
- }
-
- Offset2 += ((EFI_IFR_OP_HEADER *) OpCodeData)->Length;
- }
-
- if (Offset2 < PackageHeader.Length) {
- //
- // Target formset found
- //
- break;
- }
- }
-
- Offset += PackageHeader.Length;
- }
-
- FreePool (HiiPackageList);
-
- return EFI_SUCCESS;
-}
-
-
diff --git a/MdeModulePkg/Library/ExtendedIfrSupportLib/ExtendedIfrSupportLib.inf b/MdeModulePkg/Library/ExtendedIfrSupportLib/ExtendedIfrSupportLib.inf
deleted file mode 100644
index 5502d85..0000000
--- a/MdeModulePkg/Library/ExtendedIfrSupportLib/ExtendedIfrSupportLib.inf
+++ /dev/null
@@ -1,66 +0,0 @@
-#/** @file
-# Library instance for ExtendedIfrSupportLib.
-#
-# This library instance implements the API which is
-# related to IFR operations but reference data structures
-# that are not defined in UEFI specification, for example EFI_IFR_GUID_LABEL.
-#
-# Copyright (c) 2007 - 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.
-#
-#**/
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = ExtendedIfrSupportLib
- FILE_GUID = A47B68BA-5177-4b2d-891E-4722FA5323F8
- MODULE_TYPE = DXE_DRIVER
- VERSION_STRING = 1.0
- LIBRARY_CLASS = ExtendedIfrSupportLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER
- EFI_SPECIFICATION_VERSION = 0x00020000
- CONSTRUCTOR = ExtendedIfrSupportLibConstructor
-
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC
-#
-
-[Sources.common]
- Common.c
- Form.c
- LibraryInternal.h
- IfrOpCodeCreation.c
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
-
-
-[LibraryClasses]
- MemoryAllocationLib
- DevicePathLib
- BaseLib
- UefiBootServicesTableLib
- UefiRuntimeServicesTableLib
- BaseMemoryLib
- DebugLib
- PcdLib
-
-[Guids]
- gEfiIfrTianoGuid ## CONSUMES ## GUID
-
-[Protocols]
- gEfiHiiDatabaseProtocolGuid ## CONSUMES
- gEfiHiiStringProtocolGuid ## CONSUMES
-
-[Depex]
- gEfiHiiDatabaseProtocolGuid AND
- gEfiHiiStringProtocolGuid
diff --git a/MdeModulePkg/Library/ExtendedIfrSupportLib/Form.c b/MdeModulePkg/Library/ExtendedIfrSupportLib/Form.c
deleted file mode 100644
index 4524a4e..0000000
--- a/MdeModulePkg/Library/ExtendedIfrSupportLib/Form.c
+++ /dev/null
@@ -1,527 +0,0 @@
-/** @file
- Common Library Routines to assist handle HII elements.
-
-Copyright (c) 2007 - 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 "LibraryInternal.h"
-
-extern EFI_HII_DATABASE_PROTOCOL *gIfrLibHiiDatabase;
-
-/**
- Get the specified package from a package list based on an index.
- The Buffer on output is updated to point to a package header in
- the HiiPackageList. This is an internal function.
-
- @param HiiPackageList The Package List Header.
- @param PackageIndex The index of the package to get.
- @param BufferLen The length of the package.
- @param Buffer The starting address of package.
-
- @retval EFI_SUCCESS This function completes successfully.
- @retval EFI_NOT_FOUND The package is not found.
-
-**/
-EFI_STATUS
-GetPackageDataFromPackageList (
- 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;
-
- PackageHeader.Length = 0;
- PackageHeader.Type = 0;
-
- ASSERT (HiiPackageList != NULL);
-
- if ((BufferLen == NULL) || (Buffer == NULL)) {
- return EFI_INVALID_PARAMETER;
- }
-
- Package = NULL;
- Index = 0;
- Offset = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
- PackageListLength = ReadUnaligned32 (&HiiPackageList->PackageLength);
- 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;
-}
-
-/**
- This is the internal worker function to update the data in
- a form specified by FormSetGuid, FormId and Label.
-
- @param FormSetGuid The optional Formset GUID.
- @param FormId The Form ID.
- @param Package The package header.
- @param PackageLength The package length.
- @param Label The label for the update.
- @param Insert True if inserting opcode to the form.
- @param Data The data payload.
- @param TempBuffer The resultant package.
- @param TempBufferSize The length of the resultant package.
-
- @retval EFI_OUT_OF_RESOURCES If there is not enough memory to complete the operation.
- @retval EFI_INVALID_PARAMETER If TempBuffer or TempBufferSize is NULL.
- @retval EFI_SUCCESS The function completes successfully.
-
-**/
-EFI_STATUS
-EFIAPI
-UpdateFormPackageData (
- IN EFI_GUID *FormSetGuid, OPTIONAL
- IN EFI_FORM_ID FormId,
- IN EFI_HII_PACKAGE_HEADER *Package,
- IN UINT32 PackageLength,
- IN UINT16 Label,
- IN BOOLEAN Insert,
- IN EFI_HII_UPDATE_DATA *Data,
- OUT UINT8 **TempBuffer,
- OUT UINT32 *TempBufferSize
- )
-{
- UINTN AddSize;
- UINT8 *BufferPos;
- EFI_HII_PACKAGE_HEADER PackageHeader;
- UINTN Offset;
- EFI_IFR_OP_HEADER *IfrOpHdr;
- BOOLEAN GetFormSet;
- BOOLEAN GetForm;
- UINT8 ExtendOpCode;
- UINT16 LabelNumber;
- BOOLEAN Updated;
- EFI_IFR_OP_HEADER *AddOpCode;
-
- if ((TempBuffer == NULL) || (TempBufferSize == NULL)) {
- return EFI_INVALID_PARAMETER;
- }
-
- *TempBufferSize = PackageLength;
- if (Data != NULL) {
- *TempBufferSize += Data->Offset;
- }
- *TempBuffer = AllocateZeroPool (*TempBufferSize);
- if (*TempBuffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- CopyMem (*TempBuffer, Package, sizeof (EFI_HII_PACKAGE_HEADER));
- *TempBufferSize = sizeof (EFI_HII_PACKAGE_HEADER);
- BufferPos = *TempBuffer + sizeof (EFI_HII_PACKAGE_HEADER);
-
- CopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));
- IfrOpHdr = (EFI_IFR_OP_HEADER *)((UINT8 *) Package + sizeof (EFI_HII_PACKAGE_HEADER));
- Offset = sizeof (EFI_HII_PACKAGE_HEADER);
- GetFormSet = (BOOLEAN) ((FormSetGuid == NULL) ? TRUE : FALSE);
- GetForm = FALSE;
- Updated = FALSE;
-
- while (Offset < PackageHeader.Length) {
- CopyMem (BufferPos, IfrOpHdr, IfrOpHdr->Length);
- BufferPos += IfrOpHdr->Length;
- *TempBufferSize += IfrOpHdr->Length;
-
- switch (IfrOpHdr->OpCode) {
- case EFI_IFR_FORM_SET_OP :
- if (FormSetGuid != NULL) {
- if (CompareGuid((GUID *)(VOID *)&((EFI_IFR_FORM_SET *) IfrOpHdr)->Guid, FormSetGuid)) {
- GetFormSet = TRUE;
- }
- }
- break;
-
- case EFI_IFR_FORM_OP:
- if (CompareMem (&((EFI_IFR_FORM *) IfrOpHdr)->FormId, &FormId, sizeof (EFI_FORM_ID)) == 0) {
- GetForm = TRUE;
- }
- break;
-
- case EFI_IFR_GUID_OP :
- if (!GetFormSet || !GetForm || Updated) {
- //
- // Go to the next Op-Code
- //
- Offset += IfrOpHdr->Length;
- IfrOpHdr = (EFI_IFR_OP_HEADER *) ((CHAR8 *) (IfrOpHdr) + IfrOpHdr->Length);
- continue;
- }
-
- ExtendOpCode = ((EFI_IFR_GUID_LABEL *) IfrOpHdr)->ExtendOpCode;
- LabelNumber = ReadUnaligned16 ((UINT16 *)(VOID *)&((EFI_IFR_GUID_LABEL *)IfrOpHdr)->Number);
- if ((ExtendOpCode != EFI_IFR_EXTEND_OP_LABEL) || (LabelNumber != Label)
- || !CompareGuid ((EFI_GUID *)(UINTN)(&((EFI_IFR_GUID_LABEL *)IfrOpHdr)->Guid), &gEfiIfrTianoGuid)) {
- //
- // Go to the next Op-Code
- //
- Offset += IfrOpHdr->Length;
- IfrOpHdr = (EFI_IFR_OP_HEADER *) ((CHAR8 *) (IfrOpHdr) + IfrOpHdr->Length);
- continue;
- }
-
- if (Insert && (Data != NULL)) {
- //
- // insert the DataCount amount of opcodes to TempBuffer if Data is NULL remove
- // DataCount amount of opcodes unless runing into a label.
- //
- AddOpCode = (EFI_IFR_OP_HEADER *)Data->Data;
- AddSize = 0;
- while (AddSize < Data->Offset) {
- CopyMem (BufferPos, AddOpCode, AddOpCode->Length);
- BufferPos += AddOpCode->Length;
- *TempBufferSize += AddOpCode->Length;
-
- AddSize += AddOpCode->Length;
- AddOpCode = (EFI_IFR_OP_HEADER *) ((CHAR8 *) (AddOpCode) + AddOpCode->Length);
- }
- } else {
- //
- // Search the next Label.
- //
- while (TRUE) {
- Offset += IfrOpHdr->Length;
- //
- // Search the next label and Fail if not label found.
- //
- if (Offset >= PackageHeader.Length) {
- goto Fail;
- }
- IfrOpHdr = (EFI_IFR_OP_HEADER *) ((CHAR8 *) (IfrOpHdr) + IfrOpHdr->Length);
- if (IfrOpHdr->OpCode == EFI_IFR_GUID_OP) {
- ExtendOpCode = ((EFI_IFR_GUID_LABEL *) IfrOpHdr)->ExtendOpCode;
- if ((ExtendOpCode == EFI_IFR_EXTEND_OP_LABEL) && CompareGuid ((EFI_GUID *)(UINTN)(&((EFI_IFR_GUID_LABEL *)IfrOpHdr)->Guid), &gEfiIfrTianoGuid)) {
- break;
- }
- }
- }
-
- if (Data != NULL) {
- AddOpCode = (EFI_IFR_OP_HEADER *)Data->Data;
- AddSize = 0;
- while (AddSize < Data->Offset) {
- CopyMem (BufferPos, AddOpCode, AddOpCode->Length);
- BufferPos += AddOpCode->Length;
- *TempBufferSize += AddOpCode->Length;
-
- AddSize += AddOpCode->Length;
- AddOpCode = (EFI_IFR_OP_HEADER *) ((CHAR8 *) (AddOpCode) + AddOpCode->Length);
- }
- }
-
- //
- // copy the next label
- //
- CopyMem (BufferPos, IfrOpHdr, IfrOpHdr->Length);
- BufferPos += IfrOpHdr->Length;
- *TempBufferSize += IfrOpHdr->Length;
- }
-
- Updated = TRUE;
- break;
- default :
- break;
- }
-
- //
- // Go to the next Op-Code
- //
- Offset += IfrOpHdr->Length;
- IfrOpHdr = (EFI_IFR_OP_HEADER *) ((CHAR8 *) (IfrOpHdr) + IfrOpHdr->Length);
- }
-
- //
- // Update the package length.
- //
- PackageHeader.Length = *TempBufferSize;
- CopyMem (*TempBuffer, &PackageHeader, sizeof (EFI_HII_PACKAGE_HEADER));
-
-Fail:
- if (!Updated) {
- FreePool (*TempBuffer);
- *TempBufferSize = 0;
- return EFI_NOT_FOUND;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- This function initialize the data structure for dynamic opcode.
-
- @param UpdateData The adding data;
- @param BufferSize Length of the buffer to fill dynamic opcodes.
-
- @retval EFI_SUCCESS Update data is initialized.
- @retval EFI_INVALID_PARAMETER UpdateData is NULL.
- @retval EFI_OUT_OF_RESOURCES No enough memory to allocate.
-
-**/
-EFI_STATUS
-IfrLibInitUpdateData (
- IN OUT EFI_HII_UPDATE_DATA *UpdateData,
- IN UINT32 BufferSize
- )
-{
- ASSERT (UpdateData != NULL);
-
- UpdateData->BufferSize = BufferSize;
- UpdateData->Offset = 0;
- UpdateData->Data = AllocatePool (BufferSize);
-
- return (UpdateData->Data != NULL) ? EFI_SUCCESS : EFI_OUT_OF_RESOURCES;
-}
-
-/**
-
- This function free the resource of update data.
-
- @param UpdateData The adding data;
-
-**/
-VOID
-IfrLibFreeUpdateData (
- IN EFI_HII_UPDATE_DATA *UpdateData
- )
-{
- ASSERT (UpdateData != NULL);
-
- FreePool (UpdateData->Data);
- UpdateData->Data = NULL;
-
-}
-
-/**
- This function allows the caller to update a form that has
- previously been registered with the EFI HII database.
-
- @param Handle Hii Handle
- @param FormSetGuid The formset should be updated.
- @param FormId The form should be updated.
- @param Label Update information starting immediately after this
- label in the IFR
- @param Insert If TRUE and Data is not NULL, insert data after
- Label. If FALSE, replace opcodes between two
- labels with Data
- @param Data The adding data; If NULL, remove opcodes between
- two Label.
-
- @retval EFI_SUCCESS Update success.
- @retval Other Update fail.
-
-**/
-EFI_STATUS
-EFIAPI
-IfrLibUpdateForm (
- IN EFI_HII_HANDLE Handle,
- IN EFI_GUID *FormSetGuid, OPTIONAL
- IN EFI_FORM_ID FormId,
- IN UINT16 Label,
- IN BOOLEAN Insert,
- IN EFI_HII_UPDATE_DATA *Data
- )
-{
- EFI_STATUS Status;
- EFI_HII_DATABASE_PROTOCOL *HiiDatabase;
- EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList;
- UINT32 Index;
- EFI_HII_PACKAGE_LIST_HEADER *UpdateBuffer;
- UINTN BufferSize;
- UINT8 *UpdateBufferPos;
- EFI_HII_PACKAGE_HEADER PackageHeader;
- EFI_HII_PACKAGE_HEADER *Package;
- UINT32 PackageLength;
- EFI_HII_PACKAGE_HEADER *TempBuffer;
- UINT32 TempBufferSize;
- BOOLEAN Updated;
-
- if (Data == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- HiiDatabase = gIfrLibHiiDatabase;
-
- //
- // Get the orginal package list
- //
- BufferSize = 0;
- HiiPackageList = NULL;
- Status = HiiDatabase->ExportPackageLists (HiiDatabase, Handle, &BufferSize, HiiPackageList);
- //
- // Handle is a invalid handle. Check if Handle is corrupted.
- //
- ASSERT (Status != EFI_NOT_FOUND);
- //
- // The return status should always be EFI_BUFFER_TOO_SMALL as input buffer's size is 0.
- //
- ASSERT (Status == EFI_BUFFER_TOO_SMALL);
- HiiPackageList = AllocatePool (BufferSize);
- ASSERT (HiiPackageList != NULL);
-
- Status = HiiDatabase->ExportPackageLists (HiiDatabase, Handle, &BufferSize, HiiPackageList);
- if (EFI_ERROR (Status)) {
- FreePool (HiiPackageList);
- return Status;
- }
-
- //
- // Calculate and allocate space for retrieval of IFR data
- //
- BufferSize += Data->Offset;
- UpdateBuffer = AllocateZeroPool (BufferSize);
- if (UpdateBuffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- UpdateBufferPos = (UINT8 *) UpdateBuffer;
-
- //
- // copy the package list header
- //
- CopyMem (UpdateBufferPos, HiiPackageList, sizeof (EFI_HII_PACKAGE_LIST_HEADER));
- UpdateBufferPos += sizeof (EFI_HII_PACKAGE_LIST_HEADER);
-
- Updated = FALSE;
- for (Index = 0; ; Index++) {
- Status = GetPackageDataFromPackageList (HiiPackageList, Index, &PackageLength, &Package);
- if (Status == EFI_SUCCESS) {
- CopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));
- if ((PackageHeader.Type == EFI_HII_PACKAGE_FORMS) && !Updated) {
- Status = UpdateFormPackageData (FormSetGuid, FormId, Package, PackageLength, Label, Insert, Data, (UINT8 **)&TempBuffer, &TempBufferSize);
- if (!EFI_ERROR(Status)) {
- if (FormSetGuid == NULL) {
- Updated = TRUE;
- }
- CopyMem (UpdateBufferPos, TempBuffer, TempBufferSize);
- UpdateBufferPos += TempBufferSize;
- FreePool (TempBuffer);
- continue;
- }
- }
-
- CopyMem (UpdateBufferPos, Package, PackageLength);
- UpdateBufferPos += PackageLength;
- } else if (Status == EFI_NOT_FOUND) {
- break;
- } else {
- FreePool (HiiPackageList);
- return Status;
- }
- }
-
- //
- // Update package list length
- //
- BufferSize = UpdateBufferPos - (UINT8 *) UpdateBuffer;
- WriteUnaligned32 (&UpdateBuffer->PackageLength, (UINT32)BufferSize);
-
- FreePool (HiiPackageList);
-
- return HiiDatabase->UpdatePackageList (HiiDatabase, Handle, UpdateBuffer);
-}
-
-
-/**
- Configure the buffer accrording to ConfigBody strings in the format of
- <Length:4 bytes>, <Offset: 2 bytes>, <Width:2 bytes>, <Data:n bytes>.
- This ConfigBody strings is generated by UEFI VfrCompiler for the default
- values in a Form Set. The name of the ConfigBody strings is VfrMyIfrNVDataDefault0000
- constructed following this rule:
- "Vfr" + varstore.name + "Default" + defaultstore.attributes.
- Check the generated C file in Output for details.
-
- @param Buffer The start address of buffer.
- @param BufferSize The size of buffer.
- @param Number The number of the strings.
- @param ... Variable argument list for default value in <AltResp> format
- generated by the tool.
-
- @retval EFI_BUFFER_TOO_SMALL the BufferSize is too small to operate.
- @retval EFI_INVALID_PARAMETER Buffer is NULL or BufferSize is 0.
- @retval EFI_SUCCESS Operation successful.
-
-**/
-EFI_STATUS
-EFIAPI
-IfrLibExtractDefault(
- IN VOID *Buffer,
- IN UINTN *BufferSize,
- UINTN Number,
- ...
- )
-{
- VA_LIST Args;
- UINTN Index;
- UINT32 TotalLen;
- UINT8 *BufCfgArray;
- UINT8 *BufferPos;
- UINT16 Offset;
- UINT16 Width;
- UINT8 *Value;
-
- if ((Buffer == NULL) || (BufferSize == NULL)) {
- return EFI_INVALID_PARAMETER;
- }
-
- Offset = 0;
- Width = 0;
- Value = NULL;
-
- VA_START (Args, Number);
- for (Index = 0; Index < Number; Index++) {
- BufCfgArray = (UINT8 *) VA_ARG (Args, VOID *);
- TotalLen = ReadUnaligned32 ((UINT32 *)BufCfgArray);
- BufferPos = BufCfgArray + sizeof (UINT32);
-
- while ((UINT32)(BufferPos - BufCfgArray) < TotalLen) {
- Offset = ReadUnaligned16 ((UINT16 *)BufferPos);
- BufferPos += sizeof (UINT16);
- Width = ReadUnaligned16 ((UINT16 *)BufferPos);
- BufferPos += sizeof (UINT16);
- Value = BufferPos;
- BufferPos += Width;
-
- if ((UINTN)(Offset + Width) > *BufferSize) {
- return EFI_BUFFER_TOO_SMALL;
- }
-
- CopyMem ((UINT8 *)Buffer + Offset, Value, Width);
- }
- }
- VA_END (Args);
-
- *BufferSize = (UINTN)Offset;
-
- return EFI_SUCCESS;
-}
-
-
diff --git a/MdeModulePkg/Library/ExtendedIfrSupportLib/IfrOpCodeCreation.c b/MdeModulePkg/Library/ExtendedIfrSupportLib/IfrOpCodeCreation.c
deleted file mode 100644
index 6851e5a..0000000
--- a/MdeModulePkg/Library/ExtendedIfrSupportLib/IfrOpCodeCreation.c
+++ /dev/null
@@ -1,65 +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 - 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 "LibraryInternal.h"
-
-/**
- Create GUIDed opcode for banner. Banner opcode
- EFI_IFR_EXTEND_OP_BANNER is extended opcode specific
- to Intel's implementation.
-
- @param Title String ID for title
- @param LineNumber Line number for this banner
- @param Alignment Alignment for this banner, left, center or right
- @param Data Destination for the created opcode binary
-
- @retval EFI_SUCCESS Opcode create success
- @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
-
-**/
-EFI_STATUS
-EFIAPI
-CreateBannerOpCode (
- IN EFI_STRING_ID Title,
- IN UINT16 LineNumber,
- IN UINT8 Alignment,
- IN OUT EFI_HII_UPDATE_DATA *Data
- )
-{
- EFI_IFR_GUID_BANNER Banner;
- UINT8 *LocalBuffer;
-
- ASSERT (Data != NULL && Data->Data != NULL);
-
- if (Data->Offset + sizeof (EFI_IFR_GUID_BANNER) > Data->BufferSize) {
- return EFI_BUFFER_TOO_SMALL;
- }
-
- Banner.Header.OpCode = EFI_IFR_GUID_OP;
- Banner.Header.Length = sizeof (EFI_IFR_GUID_BANNER);
- Banner.Header.Scope = 0;
- CopyMem (&Banner.Guid, &gEfiIfrTianoGuid, sizeof (EFI_IFR_GUID));
- Banner.ExtendOpCode = EFI_IFR_EXTEND_OP_BANNER;
- Banner.Title = Title;
- Banner.LineNumber = LineNumber;
- Banner.Alignment = Alignment;
-
- LocalBuffer = (UINT8 *) Data->Data + Data->Offset;
- CopyMem (LocalBuffer, &Banner, sizeof (EFI_IFR_GUID_BANNER));
- Data->Offset += sizeof (EFI_IFR_GUID_BANNER);
-
- return EFI_SUCCESS;
-}
-
diff --git a/MdeModulePkg/Library/ExtendedIfrSupportLib/LibraryInternal.h b/MdeModulePkg/Library/ExtendedIfrSupportLib/LibraryInternal.h
deleted file mode 100644
index 124eaef..0000000
--- a/MdeModulePkg/Library/ExtendedIfrSupportLib/LibraryInternal.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/** @file
- The file contain all library function for Ifr Operations.
-
-Copyright (c) 2007 - 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.
-
-**/
-
-#ifndef _IFRLIBRARY_INTERNAL_H_
-#define _IFRLIBRARY_INTERNAL_H_
-
-
-#include <Uefi.h>
-
-#include <Protocol/DevicePath.h>
-#include <Protocol/HiiDatabase.h>
-#include <Protocol/HiiString.h>
-
-#include <Library/DebugLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/BaseLib.h>
-#include <Library/DevicePathLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/IfrSupportLib.h>
-#include <Library/PcdLib.h>
-
-#include <Guid/MdeModuleHii.h>
-
-extern CONST EFI_GUID mIfrVendorGuid;
-
-#endif
diff --git a/MdeModulePkg/Library/UefiIfrSupportLib/UefiIfrForm.c b/MdeModulePkg/Library/UefiIfrSupportLib/UefiIfrForm.c
deleted file mode 100644
index 8f83c6c..0000000
--- a/MdeModulePkg/Library/UefiIfrSupportLib/UefiIfrForm.c
+++ /dev/null
@@ -1,1655 +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- 2009, 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"
-
-CONST EFI_FORM_BROWSER2_PROTOCOL *mFormBrowser2 = NULL;
-CONST EFI_HII_CONFIG_ROUTING_PROTOCOL *mIfrSupportLibHiiConfigRouting = NULL;
-GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 mIfrSupportLibHexStr[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
-
-//
-// Fake <ConfigHdr>
-//
-GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT16 mFakeConfigHdr[] = L"GUID=00000000000000000000000000000000&NAME=0000&PATH=0";
-
-/**
- This function locate FormBrowser2 protocols for later usage.
-
- @return Status the status to locate protocol.
-**/
-EFI_STATUS
-LocateFormBrowser2Protocols (
- VOID
- )
-{
- EFI_STATUS Status;
- //
- // Locate protocols for later usage
- //
- if (mFormBrowser2 == NULL) {
- Status = gBS->LocateProtocol (&gEfiFormBrowser2ProtocolGuid, NULL, (VOID **) &mFormBrowser2);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- }
-
- if (mIfrSupportLibHiiConfigRouting == NULL) {
- Status = gBS->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid, NULL, (VOID **) &mIfrSupportLibHiiConfigRouting);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Draw a dialog and return the selected key.
-
- @param NumberOfLines The number of lines for the dialog box
- @param KeyValue The EFI_KEY value returned if HotKey is TRUE..
- @param String The first String to be displayed in the Pop-Up.
- @param Marker A series of (quantity == NumberOfLines - 1) text
- strings which will be used to construct the dialog
- box
-
- @retval EFI_SUCCESS Displayed dialog and received user interaction
- @retval EFI_INVALID_PARAMETER One of the parameters was invalid.
- @retval EFI_OUT_OF_RESOURCES There is no enough available memory space.
-
-**/
-EFI_STATUS
-EFIAPI
-IfrLibCreatePopUp2 (
- IN UINTN NumberOfLines,
- OUT EFI_INPUT_KEY *KeyValue,
- IN CHAR16 *String,
- IN VA_LIST Marker
- )
-{
- UINTN Index;
- UINTN Count;
- UINTN Start;
- UINTN Top;
- CHAR16 *StringPtr;
- UINTN LeftColumn;
- UINTN RightColumn;
- UINTN TopRow;
- UINTN BottomRow;
- UINTN DimensionsWidth;
- UINTN DimensionsHeight;
- EFI_INPUT_KEY Key;
- UINTN LargestString;
- CHAR16 *StackString;
- EFI_STATUS Status;
- UINTN StringLen;
- CHAR16 *LineBuffer;
- CHAR16 **StringArray;
- EFI_EVENT TimerEvent;
- EFI_EVENT WaitList[2];
- UINTN CurrentAttribute;
- EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ConOut;
-
- if ((KeyValue == NULL) || (String == NULL)) {
- return EFI_INVALID_PARAMETER;
- }
-
- TopRow = 0;
- BottomRow = 0;
- LeftColumn = 0;
- RightColumn = 0;
-
- ConOut = gST->ConOut;
- ConOut->QueryMode (ConOut, ConOut->Mode->Mode, &RightColumn, &BottomRow);
-
- DimensionsWidth = RightColumn - LeftColumn;
- DimensionsHeight = BottomRow - TopRow;
-
- CurrentAttribute = ConOut->Mode->Attribute;
-
- LineBuffer = AllocateZeroPool (DimensionsWidth * sizeof (CHAR16));
- if (LineBuffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- //
- // Determine the largest string in the dialog box
- // Notice we are starting with 1 since String is the first string
- //
- StringArray = AllocateZeroPool (NumberOfLines * sizeof (CHAR16 *));
- if (StringArray == NULL) {
- FreePool (LineBuffer);
- return EFI_OUT_OF_RESOURCES;
- }
- LargestString = StrLen (String);
- StringArray[0] = String;
-
- for (Index = 1; Index < NumberOfLines; Index++) {
- StackString = VA_ARG (Marker, CHAR16 *);
-
- if (StackString == NULL) {
- FreePool (LineBuffer);
- FreePool (StringArray);
- return EFI_INVALID_PARAMETER;
- }
-
- StringArray[Index] = StackString;
- StringLen = StrLen (StackString);
- if (StringLen > LargestString) {
- LargestString = StringLen;
- }
- }
-
- if ((LargestString + 2) > DimensionsWidth) {
- LargestString = DimensionsWidth - 2;
- }
-
- //
- // Subtract the PopUp width from total Columns, allow for one space extra on
- // each end plus a border.
- //
- Start = (DimensionsWidth - LargestString - 2) / 2 + LeftColumn + 1;
-
- Top = ((DimensionsHeight - NumberOfLines - 2) / 2) + TopRow - 1;
-
- //
- // Disable cursor
- //
- ConOut->EnableCursor (ConOut, FALSE);
- ConOut->SetAttribute (ConOut, EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE);
-
- StringPtr = &LineBuffer[0];
- *StringPtr++ = BOXDRAW_DOWN_RIGHT;
- for (Index = 0; Index < LargestString; Index++) {
- *StringPtr++ = BOXDRAW_HORIZONTAL;
- }
- *StringPtr++ = BOXDRAW_DOWN_LEFT;
- *StringPtr = L'\0';
-
- ConOut->SetCursorPosition (ConOut, Start, Top);
- ConOut->OutputString (ConOut, LineBuffer);
-
- for (Index = 0; Index < NumberOfLines; Index++) {
- StringPtr = &LineBuffer[0];
- *StringPtr++ = BOXDRAW_VERTICAL;
-
- for (Count = 0; Count < LargestString; Count++) {
- StringPtr[Count] = L' ';
- }
-
- StringLen = StrLen (StringArray[Index]);
- if (StringLen > LargestString) {
- StringLen = LargestString;
- }
- CopyMem (
- StringPtr + ((LargestString - StringLen) / 2),
- StringArray[Index],
- StringLen * sizeof (CHAR16)
- );
- StringPtr += LargestString;
-
- *StringPtr++ = BOXDRAW_VERTICAL;
- *StringPtr = L'\0';
-
- ConOut->SetCursorPosition (ConOut, Start, Top + 1 + Index);
- ConOut->OutputString (ConOut, LineBuffer);
- }
-
- StringPtr = &LineBuffer[0];
- *StringPtr++ = BOXDRAW_UP_RIGHT;
- for (Index = 0; Index < LargestString; Index++) {
- *StringPtr++ = BOXDRAW_HORIZONTAL;
- }
- *StringPtr++ = BOXDRAW_UP_LEFT;
- *StringPtr = L'\0';
-
- ConOut->SetCursorPosition (ConOut, Start, Top + NumberOfLines + 1);
- ConOut->OutputString (ConOut, LineBuffer);
-
- do {
- Status = gBS->CreateEvent (EVT_TIMER, 0, NULL, NULL, &TimerEvent);
-
- //
- // Set a timer event of 1 second expiration
- //
- gBS->SetTimer (
- TimerEvent,
- TimerRelative,
- 10000000
- );
-
- //
- // Wait for the keystroke event or the timer
- //
- WaitList[0] = gST->ConIn->WaitForKey;
- WaitList[1] = TimerEvent;
- Status = gBS->WaitForEvent (2, WaitList, &Index);
-
- //
- // Check for the timer expiration
- //
- if (!EFI_ERROR (Status) && Index == 1) {
- Status = EFI_TIMEOUT;
- }
-
- gBS->CloseEvent (TimerEvent);
- } while (Status == EFI_TIMEOUT);
-
- Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
- CopyMem (KeyValue, &Key, sizeof (EFI_INPUT_KEY));
-
- ConOut->SetAttribute (ConOut, CurrentAttribute);
- ConOut->EnableCursor (ConOut, TRUE);
-
- FreePool (LineBuffer);
- FreePool (StringArray);
-
- return Status;
-}
-
-
-/**
- Draw a dialog and return the selected key.
-
- @param NumberOfLines The number of lines for the dialog box
- @param KeyValue The EFI_KEY value returned if HotKey is TRUE..
- @param String Pointer to the first string in the list
- @param ... A series of (quantity == NumberOfLines - 1) text
- strings which will be used to construct the dialog
- box
-
- @retval EFI_SUCCESS Displayed dialog and received user interaction
- @retval EFI_INVALID_PARAMETER One of the parameters was invalid.
-
-**/
-EFI_STATUS
-EFIAPI
-IfrLibCreatePopUp (
- IN UINTN NumberOfLines,
- OUT EFI_INPUT_KEY *KeyValue,
- IN CHAR16 *String,
- ...
- )
-{
- EFI_STATUS Status;
- VA_LIST Marker;
-
- VA_START (Marker, String);
-
- Status = IfrLibCreatePopUp2 (NumberOfLines, KeyValue, String, Marker);
-
- VA_END (Marker);
-
- return Status;
-}
-
-/**
- Extract block name from the array generated by VFR compiler. The name of
- this array is "Vfr + <StorageName> + BlockName", e.g. "VfrMyIfrNVDataBlockName".
- Format of this array is:
- Array length | 4-bytes
- Offset | 2-bytes
- Width | 2-bytes
- Offset | 2-bytes
- Width | 2-bytes
- ... ...
-
- @param Buffer Array generated by VFR compiler.
- @param BlockName The returned <BlockName>
-
- @retval EFI_OUT_OF_RESOURCES Run out of memory resource.
- @retval EFI_INVALID_PARAMETER Buffer is NULL or BlockName is NULL.
- @retval EFI_SUCCESS Operation successful.
-
-**/
-EFI_STATUS
-ExtractBlockName (
- IN UINT8 *Buffer,
- OUT CHAR16 **BlockName
- )
-
-{
- UINTN Index;
- UINT32 Length;
- UINT32 BlockNameNumber;
- UINTN HexStringBufferLen;
- CHAR16 *StringPtr;
-
- if ((Buffer == NULL) || (BlockName == NULL)) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // Calculate number of Offset/Width pair
- //
- CopyMem (&Length, Buffer, sizeof (UINT32));
- BlockNameNumber = (Length - sizeof (UINT32)) / (sizeof (UINT16) * 2);
-
- //
- // <BlockName> ::= &OFFSET=1234&WIDTH=1234
- // | 8 | 4 | 7 | 4 |
- //
- StringPtr = AllocateZeroPool ((BlockNameNumber * (8 + 4 + 7 + 4) + 1) * sizeof (CHAR16));
- if (StringPtr == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- *BlockName = StringPtr;
-
- Buffer += sizeof (UINT32);
- for (Index = 0; Index < BlockNameNumber; Index++) {
- StrCpy (StringPtr, L"&OFFSET=");
- StringPtr += 8;
-
- HexStringBufferLen = 5;
- BufToHexString (StringPtr, &HexStringBufferLen, Buffer, sizeof (UINT16));
- Buffer += sizeof (UINT16);
- StringPtr += 4;
-
- StrCpy (StringPtr, L"&WIDTH=");
- StringPtr += 7;
-
- HexStringBufferLen = 5;
- BufToHexString (StringPtr, &HexStringBufferLen, Buffer, sizeof (UINT16));
- Buffer += sizeof (UINT16);
- StringPtr += 4;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
-
- Extract block config from the array generated by VFR compiler. The name of
- this array is "Vfr + <StorageName> + Default<HexCh>4", e.g. "VfrMyIfrNVDataDefault0000".
-
- @param Buffer - Array generated by VFR compiler.
- @param BlockConfig - The returned <BlockConfig>
-
- @retval EFI_OUT_OF_RESOURCES - Run out of memory resource.
- @retval EFI_INVALID_PARAMETER - Buffer is NULL or BlockConfig is NULL.
- @retval EFI_SUCCESS - Operation successful.
-
-**/
-EFI_STATUS
-ExtractBlockConfig (
- IN UINT8 *Buffer,
- OUT CHAR16 **BlockConfig
- )
-{
- UINT32 Length;
- UINT16 Width;
- UINTN HexStringBufferLen;
- CHAR16 *StringPtr;
- UINT8 *BufferEnd;
- CHAR16 *StringEnd;
- EFI_STATUS Status;
-
- if ((Buffer == NULL) || (BlockConfig == NULL)) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // Calculate length of AltResp string
- // Format of Default value array is:
- // Array length | 4-bytes
- // Offset | 2-bytes
- // Width | 2-bytes
- // Value | Variable length
- // Offset | 2-bytes
- // Width | 2-bytes
- // Value | Variable length
- // ... ...
- // When value is 1 byte in length, overhead of AltResp string will be maximum,
- // BlockConfig ::= <&OFFSET=1234&WIDTH=1234&VALUE=12>+
- // | 8 | 4 | 7 | 4 | 7 |2|
- // so the maximum length of BlockConfig could be calculated as:
- // (ArrayLength / 5) * (8 + 4 + 7 + 4 + 7 + 2) = ArrayLength * 6.4 < ArrayLength * 7
- //
- CopyMem (&Length, Buffer, sizeof (UINT32));
- BufferEnd = Buffer + Length;
- StringPtr = AllocatePool (Length * 7 * sizeof (CHAR16));
- *BlockConfig = StringPtr;
- if (StringPtr == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- StringEnd = StringPtr + (Length * 7);
-
- Buffer += sizeof (UINT32);
- while (Buffer < BufferEnd) {
- StrCpy (StringPtr, L"&OFFSET=");
- StringPtr += 8;
-
- HexStringBufferLen = 5;
- BufToHexString (StringPtr, &HexStringBufferLen, Buffer, sizeof (UINT16));
- Buffer += sizeof (UINT16);
- StringPtr += 4;
-
- StrCpy (StringPtr, L"&WIDTH=");
- StringPtr += 7;
-
- HexStringBufferLen = 5;
- BufToHexString (StringPtr, &HexStringBufferLen, Buffer, sizeof (UINT16));
- CopyMem (&Width, Buffer, sizeof (UINT16));
- Buffer += sizeof (UINT16);
- StringPtr += 4;
-
- StrCpy (StringPtr, L"&VALUE=");
- StringPtr += 7;
-
- HexStringBufferLen = StringEnd - StringPtr;
- Status = BufToHexString (StringPtr, &HexStringBufferLen, Buffer, Width);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- Buffer += Width;
- StringPtr += (Width * 2);
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Construct <ConfigAltResp> for a buffer storage.
-
- @param ConfigRequest The Config request string. If set to NULL, all the
- configurable elements will be extracted from BlockNameArray.
- @param ConfigAltResp The returned <ConfigAltResp>.
- @param Progress On return, points to a character in the Request.
- @param Guid GUID of the buffer storage.
- @param Name Name of the buffer storage.
- @param DriverHandle The DriverHandle which is used to invoke HiiDatabase
- protocol interface NewPackageList().
- @param BufferStorage Content of the buffer storage.
- @param BufferStorageSize Length in bytes of the buffer storage.
- @param BlockNameArray Array generated by VFR compiler.
- @param NumberAltCfg Number of Default value array generated by VFR compiler.
- The sequential input parameters will be number of
- AltCfgId and DefaultValueArray pairs. When set to 0,
- there will be no <AltResp>.
-
- retval EFI_OUT_OF_RESOURCES Run out of memory resource.
- retval EFI_INVALID_PARAMETER ConfigAltResp is NULL.
- retval EFI_SUCCESS Operation successful.
-
-**/
-EFI_STATUS
-ConstructConfigAltResp (
- IN EFI_STRING ConfigRequest, OPTIONAL
- OUT EFI_STRING *Progress,
- OUT EFI_STRING *ConfigAltResp,
- IN EFI_GUID *Guid,
- IN CHAR16 *Name,
- IN EFI_HANDLE *DriverHandle,
- IN VOID *BufferStorage,
- IN UINTN BufferStorageSize,
- IN VOID *BlockNameArray, OPTIONAL
- IN UINTN NumberAltCfg,
- ...
-//IN UINT16 AltCfgId,
-//IN VOID *DefaultValueArray,
- )
-{
- EFI_STATUS Status;
- CHAR16 *ConfigHdr;
- CHAR16 *BlockName;
- CHAR16 *DescHdr;
- CHAR16 *StringPtr;
- CHAR16 **AltCfg;
- UINT16 AltCfgId;
- VOID *DefaultValueArray;
- UINTN StrBufferLen;
- EFI_STRING ConfigResp;
- EFI_STRING TempStr;
- VA_LIST Args;
- UINTN AltRespLen;
- UINTN Index;
- BOOLEAN NeedFreeConfigRequest;
- EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting;
- UINTN Len;
-
- if (ConfigAltResp == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- DescHdr = NULL;
- StringPtr = NULL;
- AltCfg = NULL;
- ConfigResp = NULL;
- BlockName = NULL;
- NeedFreeConfigRequest = FALSE;
-
- //
- // Construct <ConfigHdr> : "GUID=...&NAME=...&PATH=..."
- //
- ConfigHdr = NULL;
- StrBufferLen = 0;
- Status = ConstructConfigHdr (
- ConfigHdr,
- &StrBufferLen,
- Guid,
- Name,
- DriverHandle
- );
- ASSERT (Status == EFI_BUFFER_TOO_SMALL);
- ConfigHdr = AllocateZeroPool (StrBufferLen);
- if (ConfigHdr == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto Exit;
- }
- Status = ConstructConfigHdr (
- ConfigHdr,
- &StrBufferLen,
- Guid,
- Name,
- DriverHandle
- );
-
- if (EFI_ERROR (Status)) {
- goto Exit;
- }
-
- //
- // Construct <ConfigResp>
- //
- if (ConfigRequest == NULL) {
- //
- // If ConfigRequest is set to NULL, export all configurable elements in BlockNameArray
- //
- Status = ExtractBlockName (BlockNameArray, &BlockName);
- if (EFI_ERROR (Status)) {
- goto Exit;
- }
-
- Len = StrSize (ConfigHdr);
- ConfigRequest = AllocateZeroPool (Len + StrSize (BlockName) - sizeof (CHAR16));
- if (ConfigRequest == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto Exit;
- }
-
- StrCpy (ConfigRequest, ConfigHdr);
- StrCat (ConfigRequest, BlockName);
- NeedFreeConfigRequest = TRUE;
-
- }
-
- Status = gBS->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid, NULL, (VOID **) &HiiConfigRouting);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = HiiConfigRouting->BlockToConfig (
- HiiConfigRouting,
- ConfigRequest,
- BufferStorage,
- BufferStorageSize,
- &ConfigResp,
- (Progress == NULL) ? &TempStr : Progress
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- AltRespLen = 0;
- //
- // Construct <AltResp>
- //
- if (NumberAltCfg > 0) {
- DescHdr = AllocateZeroPool (NumberAltCfg * 16 * sizeof (CHAR16));
- if (DescHdr == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto Exit;
- }
-
- StringPtr = DescHdr;
- AltCfg = AllocateZeroPool (NumberAltCfg * sizeof (CHAR16 *));
- if (AltCfg == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto Exit;
- }
-
- VA_START (Args, NumberAltCfg);
- for (Index = 0; Index < NumberAltCfg; Index++) {
- AltCfgId = (UINT16) VA_ARG (Args, UINT16);
- DefaultValueArray = (UINT8 *) VA_ARG (Args, VOID *);
-
- //
- // '&' <ConfigHdr>
- //
- AltRespLen += (StrLen (ConfigHdr) + 1);
-
- StringPtr = DescHdr + Index * 16;
- StrCpy (StringPtr, L"&ALTCFG=");
- AltRespLen += (8 + sizeof (UINT16) * 2);
-
- StrBufferLen = 5;
- BufToHexString (StringPtr + 8, &StrBufferLen, (UINT8 *) &AltCfgId, sizeof (UINT16));
- Status = ExtractBlockConfig (DefaultValueArray, &AltCfg[Index]);
- if (EFI_ERROR (Status)) {
- goto Exit;
- }
- AltRespLen += StrLen (AltCfg[Index]);
- }
- VA_END (Args);
- }
-
- //
- // Generate the final <ConfigAltResp>
- //
- StrBufferLen = (StrLen ((CHAR16 *) ConfigResp) + AltRespLen + 1) * sizeof (CHAR16);
- TempStr = AllocateZeroPool (StrBufferLen);
- *ConfigAltResp = TempStr;
- if (TempStr == NULL) {
- goto Exit;
- }
-
- //
- // <ConfigAltResp> ::= <ConfigResp> ['&' <AltResp>]*
- //
- StrCpy (TempStr, ConfigResp);
- for (Index = 0; Index < NumberAltCfg; Index++) {
- StrCat (TempStr, L"&");
- StrCat (TempStr, ConfigHdr);
- StrCat (TempStr, DescHdr + Index * 16);
- StrCat (TempStr, AltCfg[Index]);
-
- FreePool (AltCfg[Index]);
- }
-
-Exit:
- if (NeedFreeConfigRequest) {
- FreePool (ConfigRequest);
- }
- FreePool (ConfigHdr);
- if (ConfigResp != NULL) {
- FreePool (ConfigResp);
- }
-
- if (BlockName != NULL) {
- FreePool (BlockName);
- }
-
- if (NumberAltCfg > 0) {
- FreePool (DescHdr);
- FreePool (AltCfg);
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Swap bytes in the buffer. This is a internal function.
-
- @param Buffer Binary buffer.
- @param BufferSize Size of the buffer in bytes.
-
- @return None.
-
-**/
-VOID
-SwapBuffer (
- IN OUT UINT8 *Buffer,
- IN UINTN BufferSize
- )
-{
- UINTN Index;
- UINT8 Temp;
- UINTN SwapCount;
-
- SwapCount = BufferSize / 2;
- for (Index = 0; Index < SwapCount; Index++) {
- Temp = Buffer[Index];
- Buffer[Index] = Buffer[BufferSize - 1 - Index];
- Buffer[BufferSize - 1 - Index] = Temp;
- }
-}
-
-/**
- Converts the unicode character of the string from uppercase to lowercase.
- This is a internal function.
-
- @param Str String to be converted
-
-**/
-VOID
-EFIAPI
-ToLower (
- IN OUT CHAR16 *Str
- )
-{
- CHAR16 *Ptr;
-
- for (Ptr = Str; *Ptr != L'\0'; Ptr++) {
- if (*Ptr >= L'A' && *Ptr <= L'Z') {
- *Ptr = (CHAR16) (*Ptr - L'A' + L'a');
- }
- }
-}
-
-
-/**
- Converts binary buffer to Unicode string in reversed byte order from BufToHexString().
-
- @param Str String for output
- @param Buffer Binary buffer.
- @param BufferSize Size of the buffer in bytes.
-
- @retval EFI_SUCCESS The function completed successfully.
- @retval EFI_OUT_OF_RESOURCES There is no enough available memory space.
-
-**/
-EFI_STATUS
-EFIAPI
-BufInReverseOrderToHexString (
- IN OUT CHAR16 *Str,
- IN UINT8 *Buffer,
- IN UINTN BufferSize
- )
-{
- EFI_STATUS Status;
- UINT8 *NewBuffer;
- UINTN StrBufferLen;
-
- NewBuffer = AllocateCopyPool (BufferSize, Buffer);
- if (NewBuffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- SwapBuffer (NewBuffer, BufferSize);
-
- StrBufferLen = BufferSize * sizeof (CHAR16) + 1;
- Status = BufToHexString (Str, &StrBufferLen, NewBuffer, BufferSize);
-
- FreePool (NewBuffer);
- //
- // Convert the uppercase to lowercase since <HexAf> is defined in lowercase format.
- //
- ToLower (Str);
-
- return Status;
-}
-
-
-/**
- Converts Hex String to binary buffer in reversed byte order from HexStringToBuf().
-
- @param Buffer Pointer to buffer that receives the data.
- @param BufferSize Length in bytes of the buffer to hold converted
- data. If routine return with EFI_SUCCESS,
- containing length of converted data. If routine
- return with EFI_BUFFER_TOO_SMALL, containg length
- of buffer desired.
- @param Str String to be converted from.
-
- @retval EFI_SUCCESS The function completed successfully.
- @retval RETURN_BUFFER_TOO_SMALL The input BufferSize is too small to hold the output. BufferSize
- will be updated to the size required for the converstion.
-
-**/
-EFI_STATUS
-EFIAPI
-HexStringToBufInReverseOrder (
- IN OUT UINT8 *Buffer,
- IN OUT UINTN *BufferSize,
- IN CHAR16 *Str
- )
-{
- EFI_STATUS Status;
- UINTN ConvertedStrLen;
-
- ConvertedStrLen = 0;
- Status = HexStringToBuf (Buffer, BufferSize, Str, &ConvertedStrLen);
- if (!EFI_ERROR (Status)) {
- SwapBuffer (Buffer, (ConvertedStrLen + 1) / 2);
- }
-
- return Status;
-}
-
-/**
- Convert binary representation Config string (e.g. "0041004200430044") to the
- original string (e.g. "ABCD"). Config string appears in <ConfigHdr> (i.e.
- "&NAME=<string>"), or Name/Value pair in <ConfigBody> (i.e. "label=<string>").
-
- @param UnicodeString Original Unicode string.
- @param StrBufferLen On input: Length in bytes of buffer to hold the Unicode string.
- Includes tailing '\0' character.
- On output:
- If return EFI_SUCCESS, containing length of Unicode string buffer.
- If return EFI_BUFFER_TOO_SMALL, containg length of string buffer desired.
- @param ConfigString Binary representation of Unicode String, <string> := (<HexCh>4)+
-
- @retval EFI_SUCCESS Operation completes successfully.
- @retval EFI_BUFFER_TOO_SMALL The string buffer is too small.
-
-**/
-EFI_STATUS
-EFIAPI
-ConfigStringToUnicode (
- IN OUT CHAR16 *UnicodeString,
- IN OUT UINTN *StrBufferLen,
- IN CHAR16 *ConfigString
- )
-{
- UINTN Index;
- UINTN Len;
- UINTN BufferSize;
- CHAR16 BackupChar;
-
- Len = StrLen (ConfigString) / 4;
- BufferSize = (Len + 1) * sizeof (CHAR16);
-
- if (*StrBufferLen < BufferSize) {
- *StrBufferLen = BufferSize;
- return EFI_BUFFER_TOO_SMALL;
- }
-
- *StrBufferLen = BufferSize;
-
- for (Index = 0; Index < Len; Index++) {
- BackupChar = ConfigString[4];
- ConfigString[4] = L'\0';
-
- HexStringToBuf ((UINT8 *) UnicodeString, &BufferSize, ConfigString, NULL);
-
- ConfigString[4] = BackupChar;
-
- ConfigString += 4;
- UnicodeString += 1;
- }
-
- //
- // Add tailing '\0' character
- //
- *UnicodeString = L'\0';
-
- return EFI_SUCCESS;
-}
-
-/**
- Convert Unicode string to binary representation Config string, e.g.
- "ABCD" => "0041004200430044". Config string appears in <ConfigHdr> (i.e.
- "&NAME=<string>"), or Name/Value pair in <ConfigBody> (i.e. "label=<string>").
-
- @param ConfigString Binary representation of Unicode String, <string> := (<HexCh>4)+
- @param StrBufferLen On input: Length in bytes of buffer to hold the Unicode string.
- Includes tailing '\0' character.
- On output:
- If return EFI_SUCCESS, containing length of Unicode string buffer.
- If return EFI_BUFFER_TOO_SMALL, containg length of string buffer desired.
- @param UnicodeString Original Unicode string.
-
- @retval EFI_SUCCESS Operation completes successfully.
- @retval EFI_BUFFER_TOO_SMALL The string buffer is too small.
-
-**/
-EFI_STATUS
-EFIAPI
-UnicodeToConfigString (
- IN OUT CHAR16 *ConfigString,
- IN OUT UINTN *StrBufferLen,
- IN CHAR16 *UnicodeString
- )
-{
- UINTN Index;
- UINTN Len;
- UINTN BufferSize;
- CHAR16 *String;
-
- Len = StrLen (UnicodeString);
- BufferSize = (Len * 4 + 1) * sizeof (CHAR16);
-
- if (*StrBufferLen < BufferSize) {
- *StrBufferLen = BufferSize;
- return EFI_BUFFER_TOO_SMALL;
- }
-
- *StrBufferLen = BufferSize;
- String = ConfigString;
-
- for (Index = 0; Index < Len; Index++) {
- BufToHexString (ConfigString, &BufferSize, (UINT8 *) UnicodeString, 2);
-
- ConfigString += 4;
- UnicodeString += 1;
- }
-
- //
- // Add tailing '\0' character
- //
- *ConfigString = L'\0';
-
- //
- // Convert the uppercase to lowercase since <HexAf> is defined in lowercase format.
- //
- ToLower (String);
- return EFI_SUCCESS;
-}
-
-/**
- Construct <ConfigHdr> using routing information GUID/NAME/PATH.
-
- @param ConfigHdr Pointer to the ConfigHdr string.
- @param StrBufferLen On input: Length in bytes of buffer to hold the
- ConfigHdr string. Includes tailing '\0' character.
- On output: If return EFI_SUCCESS, containing
- length of ConfigHdr string buffer. If return
- EFI_BUFFER_TOO_SMALL, containg length of string
- buffer desired.
- @param Guid Routing information: GUID.
- @param Name Routing information: NAME.
- @param DriverHandle Driver handle which contains the routing
- information: PATH.
-
- @retval EFI_SUCCESS Operation completes successfully.
- @retval EFI_BUFFER_TOO_SMALL The ConfigHdr string buffer is too small.
-
-**/
-EFI_STATUS
-EFIAPI
-ConstructConfigHdr (
- IN OUT CHAR16 *ConfigHdr,
- IN OUT UINTN *StrBufferLen,
- IN CONST EFI_GUID *Guid,
- IN CHAR16 *Name, OPTIONAL
- IN EFI_HANDLE *DriverHandle
- )
-{
- EFI_STATUS Status;
- UINTN NameStrLen;
- UINTN DevicePathSize;
- UINTN BufferSize;
- CHAR16 *StrPtr;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
-
- //
- // Make sure when ConfigHdr is NULL, StrBufferlen must be 0
- //
- ASSERT (!(ConfigHdr == NULL && *StrBufferLen != 0));
-
- if (Name == NULL) {
- //
- // There will be no "NAME" in <ConfigHdr> for Name/Value storage
- //
- NameStrLen = 0;
- } else {
- //
- // For buffer storage
- //
- NameStrLen = StrLen (Name);
- }
-
- //
- // Retrieve DevicePath Protocol associated with this HiiPackageList
- //
- Status = gBS->HandleProtocol (
- DriverHandle,
- &gEfiDevicePathProtocolGuid,
- (VOID **) &DevicePath
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- DevicePathSize = GetDevicePathSize (DevicePath);
-
- //
- // GUID=<HexCh>32&NAME=<Char>NameStrLen&PATH=<HexChar>DevicePathStrLen <NULL>
- // | 5 | 32 | 6 | NameStrLen*4 | 6 | DevicePathStrLen | 1 |
- //
- BufferSize = (5 + 32 + 6 + NameStrLen * 4 + 6 + DevicePathSize * 2 + 1) * sizeof (CHAR16);
- if ((*StrBufferLen == 0) || *StrBufferLen < BufferSize) {
- *StrBufferLen = BufferSize;
- return EFI_BUFFER_TOO_SMALL;
- }
-
- *StrBufferLen = BufferSize;
-
- StrPtr = ConfigHdr;
-
- StrCpy (StrPtr, L"GUID=");
- StrPtr += 5;
- BufInReverseOrderToHexString (StrPtr, (UINT8 *) Guid, sizeof (EFI_GUID));
- StrPtr += 32;
-
- //
- // Convert name string, e.g. name "ABCD" => "&NAME=0041004200430044"
- //
- StrCpy (StrPtr, L"&NAME=");
- StrPtr += 6;
- if (Name != NULL) {
- BufferSize = (NameStrLen * 4 + 1) * sizeof (CHAR16);
- UnicodeToConfigString (StrPtr, &BufferSize, Name);
- StrPtr += (NameStrLen * 4);
- }
-
- StrCpy (StrPtr, L"&PATH=");
- StrPtr += 6;
- BufInReverseOrderToHexString (StrPtr, (UINT8 *) DevicePath, DevicePathSize);
-
- return EFI_SUCCESS;
-}
-
-/**
- Determines if the Routing data (Guid and Name) is correct in <ConfigHdr>.
-
- @param ConfigString Either <ConfigRequest> or <ConfigResp>.
- @param StorageGuid GUID of the storage.
- @param StorageName Name of the stoarge.
-
- @retval TRUE Routing information is correct in ConfigString.
- @retval FALSE Routing information is incorrect in ConfigString.
-
-**/
-BOOLEAN
-EFIAPI
-IsConfigHdrMatch (
- IN EFI_STRING ConfigString,
- IN EFI_GUID *StorageGuid, OPTIONAL
- IN CHAR16 *StorageName OPTIONAL
- )
-{
- EFI_STATUS Status;
- BOOLEAN Match;
- EFI_GUID Guid;
- CHAR16 *Name;
- CHAR16 *StrPtr;
- UINTN BufferSize;
-
- //
- // <ConfigHdr> ::=
- // GUID=<HexCh>32&NAME=<Char>NameStrLen&PATH=<HexChar>DevicePathStrLen <NULL>
- // | 5 | 32 | 6 | NameStrLen*4 | 6 | DevicePathStrLen | 1 |
- //
- if (StrLen (ConfigString) <= (5 + 32 + 6)) {
- return FALSE;
- }
-
- //
- // Compare GUID
- //
- if (StorageGuid != NULL) {
-
- StrPtr = ConfigString + 5 + 32;
- if (*StrPtr != L'&') {
- return FALSE;
- }
- *StrPtr = L'\0';
-
- BufferSize = sizeof (EFI_GUID);
- Status = HexStringToBufInReverseOrder (
- (UINT8 *) &Guid,
- &BufferSize,
- ConfigString + 5
- );
- *StrPtr = L'&';
-
- if (EFI_ERROR (Status)) {
- return FALSE;
- }
-
- if (!CompareGuid (&Guid, StorageGuid)) {
- return FALSE;
- }
- }
-
- //
- // Compare Name
- //
- Match = TRUE;
- if (StorageName != NULL) {
- StrPtr = ConfigString + 5 + 32 + 6;
- while (*StrPtr != L'\0' && *StrPtr != L'&') {
- StrPtr++;
- }
- if (*StrPtr != L'&') {
- return FALSE;
- }
-
- *StrPtr = L'\0';
- BufferSize = (((UINTN) StrPtr) - ((UINTN) &ConfigString[5 + 32 + 6])) / 4 + sizeof (CHAR16);
- Name = AllocatePool (BufferSize);
- ASSERT (Name != NULL);
- Status = ConfigStringToUnicode (
- Name,
- &BufferSize,
- ConfigString + 5 + 32 + 6
- );
- *StrPtr = L'&';
-
- if (EFI_ERROR (Status) || (StrCmp (Name, StorageName) != 0)) {
- Match = FALSE;
- }
- FreePool (Name);
- }
-
- return Match;
-}
-
-/**
- Search BlockName "&OFFSET=Offset&WIDTH=Width" in a string.
-
- @param String The string to be searched in.
- @param Offset Offset in BlockName.
- @param Width Width in BlockName.
-
- @retval TRUE Block name found.
- @retval FALSE Block name not found.
-
-**/
-BOOLEAN
-EFIAPI
-FindBlockName (
- IN OUT CHAR16 *String,
- IN UINTN Offset,
- IN UINTN Width
- )
-{
- EFI_STATUS Status;
- UINTN Data;
- UINTN BufferSize;
- UINTN ConvertedStrLen;
-
- while ((String = StrStr (String, L"&OFFSET=")) != NULL) {
- //
- // Skip '&OFFSET='
- //
- String = String + 8;
-
- Data = 0;
- BufferSize = sizeof (UINTN);
- Status = HexStringToBuf ((UINT8 *) &Data, &BufferSize, String, &ConvertedStrLen);
- if (EFI_ERROR (Status)) {
- return FALSE;
- }
- String = String + ConvertedStrLen;
-
- if (Data != Offset) {
- continue;
- }
-
- if (StrnCmp (String, L"&WIDTH=", 7) != 0) {
- return FALSE;
- }
- String = String + 7;
-
- Data = 0;
- BufferSize = sizeof (UINTN);
- Status = HexStringToBuf ((UINT8 *) &Data, &BufferSize, String, &ConvertedStrLen);
- if (EFI_ERROR (Status)) {
- return FALSE;
- }
- if (Data == Width) {
- return TRUE;
- }
-
- String = String + ConvertedStrLen;
- }
-
- return FALSE;
-}
-
-
-/**
- This routine is invoked by ConfigAccess.Callback() to retrived uncommitted data from Form Browser.
-
- @param VariableGuid An optional field to indicate the target variable
- GUID name to use.
- @param VariableName An optional field to indicate the target
- human-readable variable name.
- @param BufferSize On input: Length in bytes of buffer to hold
- retrived data. On output: If return
- EFI_BUFFER_TOO_SMALL, containg length of buffer
- desired.
- @param Buffer Buffer to hold retrived data.
-
- @retval EFI_SUCCESS Operation completes successfully.
- @retval EFI_BUFFER_TOO_SMALL The intput buffer is too small.
- @retval EFI_OUT_OF_RESOURCES There is no enough available memory space.
-
-**/
-EFI_STATUS
-EFIAPI
-GetBrowserData (
- IN CONST EFI_GUID *VariableGuid, OPTIONAL
- IN CONST CHAR16 *VariableName, OPTIONAL
- IN OUT UINTN *BufferSize,
- IN OUT UINT8 *Buffer
- )
-{
- EFI_STATUS Status;
- CONST CHAR16 *ConfigHdr;
- CHAR16 *ConfigResp;
- CHAR16 *StringPtr;
- UINTN HeaderLen;
- UINTN BufferLen;
- CHAR16 *Progress;
-
- //
- // Locate protocols for use
- //
- Status = LocateFormBrowser2Protocols ();
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Retrive formset storage data from Form Browser
- //
- ConfigHdr = mFakeConfigHdr;
- HeaderLen = StrLen (ConfigHdr);
-
- //
- // First try allocate 0x4000 buffer for the formet storage data.
- //
- BufferLen = 0x4000;
- ConfigResp = AllocateZeroPool (BufferLen + HeaderLen);
- if (ConfigResp == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- StringPtr = ConfigResp + HeaderLen;
- *StringPtr = L'&';
- StringPtr++;
-
- Status = mFormBrowser2->BrowserCallback (
- mFormBrowser2,
- &BufferLen,
- StringPtr,
- TRUE,
- VariableGuid,
- VariableName
- );
- if (Status == EFI_BUFFER_TOO_SMALL) {
- FreePool (ConfigResp);
-
- ConfigResp = AllocateZeroPool (BufferLen + HeaderLen);
- if (ConfigResp == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- StringPtr = ConfigResp + HeaderLen;
- *StringPtr = L'&';
- StringPtr++;
-
- Status = mFormBrowser2->BrowserCallback (
- mFormBrowser2,
- &BufferLen,
- StringPtr,
- TRUE,
- VariableGuid,
- VariableName
- );
- }
- if (EFI_ERROR (Status)) {
- FreePool (ConfigResp);
- return Status;
- }
- CopyMem (ConfigResp, ConfigHdr, HeaderLen * sizeof (UINT16));
-
- //
- // Convert <ConfigResp> to buffer data
- //
- Status = mIfrSupportLibHiiConfigRouting->ConfigToBlock (
- mIfrSupportLibHiiConfigRouting,
- ConfigResp,
- Buffer,
- BufferSize,
- &Progress
- );
- FreePool (ConfigResp);
-
- return Status;
-}
-
-
-/**
- This routine is invoked by ConfigAccess.Callback() to update uncommitted data of Form Browser.
-
- @param VariableGuid An optional field to indicate the target variable
- GUID name to use.
- @param VariableName An optional field to indicate the target
- human-readable variable name.
- @param BufferSize Length in bytes of buffer to hold retrived data.
- @param Buffer Buffer to hold retrived data.
- @param RequestElement An optional field to specify which part of the
- buffer data will be send back to Browser. If NULL,
- the whole buffer of data will be committed to
- Browser. <RequestElement> ::=
- &OFFSET=<Number>&WIDTH=<Number>*
-
- @retval EFI_SUCCESS Operation completes successfully.
- @retval EFI_OUT_OF_RESOURCES There is no enough available memory space.
- @retval Other Updating Browser uncommitted data failed.
-
-**/
-EFI_STATUS
-EFIAPI
-SetBrowserData (
- IN CONST EFI_GUID *VariableGuid, OPTIONAL
- IN CONST CHAR16 *VariableName, OPTIONAL
- IN UINTN BufferSize,
- IN CONST UINT8 *Buffer,
- IN CONST CHAR16 *RequestElement OPTIONAL
- )
-{
- EFI_STATUS Status;
- CONST CHAR16 *ConfigHdr;
- CHAR16 *ConfigResp;
- CHAR16 *StringPtr;
- UINTN HeaderLen;
- UINTN BufferLen;
- CHAR16 *Progress;
- CHAR16 BlockName[33];
- CHAR16 *ConfigRequest;
- CONST CHAR16 *Request;
-
- //
- // Locate protocols for use
- //
- Status = LocateFormBrowser2Protocols ();
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Prepare <ConfigRequest>
- //
- ConfigHdr = mFakeConfigHdr;
- HeaderLen = StrLen (ConfigHdr);
-
- if (RequestElement == NULL) {
- //
- // RequestElement not specified, use "&OFFSET=0&WIDTH=<BufferSize>" as <BlockName>
- //
- BlockName[0] = L'\0';
- StrCpy (BlockName, L"&OFFSET=0&WIDTH=");
-
- //
- // String lenghth of L"&OFFSET=0&WIDTH=" is 16
- //
- StringPtr = BlockName + 16;
- BufferLen = sizeof (BlockName) - (16 * sizeof (CHAR16));
- BufToHexString (StringPtr, &BufferLen, (UINT8 *) &BufferSize, sizeof (UINTN));
-
- Request = BlockName;
- } else {
- Request = RequestElement;
- }
-
- BufferLen = HeaderLen * sizeof (CHAR16) + StrSize (Request);
- ConfigRequest = AllocateZeroPool (BufferLen);
- if (ConfigRequest == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- CopyMem (ConfigRequest, ConfigHdr, HeaderLen * sizeof (CHAR16));
- StringPtr = ConfigRequest + HeaderLen;
- StrCpy (StringPtr, Request);
-
- //
- // Convert buffer to <ConfigResp>
- //
- Status = mIfrSupportLibHiiConfigRouting->BlockToConfig (
- mIfrSupportLibHiiConfigRouting,
- ConfigRequest,
- Buffer,
- BufferSize,
- &ConfigResp,
- &Progress
- );
- if (EFI_ERROR (Status)) {
- FreePool (ConfigRequest);
- return Status;
- }
-
- //
- // Skip <ConfigHdr> and '&'
- //
- StringPtr = ConfigResp + HeaderLen + 1;
-
- //
- // Change uncommitted data in Browser
- //
- Status = mFormBrowser2->BrowserCallback (
- mFormBrowser2,
- &BufferSize,
- StringPtr,
- FALSE,
- VariableGuid,
- VariableName
- );
- FreePool (ConfigRequest);
- return Status;
-}
-
-/**
- Test if a Unicode character is a hexadecimal digit. If true, the input
- Unicode character is converted to a byte.
-
- This function tests if a Unicode character is a hexadecimal digit. If true, the input
- Unicode character is converted to a byte. For example, Unicode character
- L'A' will be converted to 0x0A.
-
- If Digit is NULL, then ASSERT.
-
- @param Digit The output hexadecimal digit.
-
- @param Char The input Unicode character.
-
- @retval TRUE Char is in the range of Hexadecimal number. Digit is updated
- to the byte value of the number.
- @retval FALSE Char is not in the range of Hexadecimal number. Digit is keep
- intact.
-
-**/
-BOOLEAN
-EFIAPI
-IsHexDigit (
- OUT UINT8 *Digit,
- IN CHAR16 Char
- )
-{
- ASSERT (Digit != NULL);
-
- if ((Char >= L'0') && (Char <= L'9')) {
- *Digit = (UINT8) (Char - L'0');
- return TRUE;
- }
-
- if ((Char >= L'A') && (Char <= L'F')) {
- *Digit = (UINT8) (Char - L'A' + 0x0A);
- return TRUE;
- }
-
- if ((Char >= L'a') && (Char <= L'f')) {
- *Digit = (UINT8) (Char - L'a' + 0x0A);
- return TRUE;
- }
-
- return FALSE;
-}
-
-/**
- Convert binary buffer to a Unicode String in a specified sequence.
-
- This function converts bytes in the memory block pointed by Buffer to a Unicode String Str.
- Each byte will be represented by two Unicode characters. For example, byte 0xA1 will
- be converted into two Unicode character L'A' and L'1'. In the output String, the Unicode Character
- for the Most Significant Nibble will be put before the Unicode Character for the Least Significant
- Nibble. The output string for the buffer containing a single byte 0xA1 will be L"A1".
- For a buffer with multiple bytes, the Unicode character produced by the first byte will be put into the
- the last character in the output string. The one next to first byte will be put into the
- character before the last character. This rules applies to the rest of the bytes. The Unicode
- character by the last byte will be put into the first character in the output string. For example,
- the input buffer for a 64-bits unsigned integer 0x12345678abcdef1234 will be converted to
- a Unicode string equal to L"12345678abcdef1234".
-
- @param String On input, String is pointed to the buffer allocated for the convertion.
- @param StringLen The Length of String buffer to hold the output String. The length must include the tailing '\0' character.
- The StringLen required to convert a N bytes Buffer will be a least equal to or greater
- than 2*N + 1.
- @param Buffer The pointer to a input buffer.
- @param BufferSizeInBytes Length in bytes of the input buffer.
-
-
- @retval EFI_SUCCESS The convertion is successful. All bytes in Buffer has been convert to the corresponding
- Unicode character and placed into the right place in String.
- @retval EFI_BUFFER_TOO_SMALL StringSizeInBytes is smaller than 2 * N + 1the number of bytes required to
- complete the convertion.
-**/
-RETURN_STATUS
-EFIAPI
-BufToHexString (
- IN OUT CHAR16 *String,
- IN OUT UINTN *StringLen,
- IN CONST UINT8 *Buffer,
- IN UINTN BufferSizeInBytes
- )
-{
- UINTN Idx;
- UINT8 Byte;
- UINTN StrLen;
-
- //
- // Make sure string is either passed or allocate enough.
- // It takes 2 Unicode characters (4 bytes) to represent 1 byte of the binary buffer.
- // Plus the Unicode termination character.
- //
- StrLen = BufferSizeInBytes * 2;
- if (StrLen > ((*StringLen) - 1)) {
- *StringLen = StrLen + 1;
- return RETURN_BUFFER_TOO_SMALL;
- }
-
- *StringLen = StrLen + 1;
- //
- // Ends the string.
- //
- String[StrLen] = L'\0';
-
- for (Idx = 0; Idx < BufferSizeInBytes; Idx++) {
- Byte = Buffer[Idx];
- String[StrLen - 1 - Idx * 2] = mIfrSupportLibHexStr [Byte & 0xF];
- String[StrLen - 2 - Idx * 2] = mIfrSupportLibHexStr [Byte >> 4];
- }
-
- return RETURN_SUCCESS;
-}
-
-
-/**
- Convert a Unicode string consisting of hexadecimal characters to a output byte buffer.
-
- This function converts a Unicode string consisting of characters in the range of Hexadecimal
- character (L'0' to L'9', L'A' to L'F' and L'a' to L'f') to a output byte buffer. The function will stop
- at the first non-hexadecimal character or the NULL character. The convertion process can be
- simply viewed as the reverse operations defined by BufToHexString. Two Unicode characters will be
- converted into one byte. The first Unicode character represents the Most Significant Nibble and the
- second Unicode character represents the Least Significant Nibble in the output byte.
- The first pair of Unicode characters represents the last byte in the output buffer. The second pair of Unicode
- characters represent the the byte preceding the last byte. This rule applies to the rest pairs of bytes.
- The last pair represent the first byte in the output buffer.
-
- For example, a Unciode String L"12345678" will be converted into a buffer wil the following bytes
- (first byte is the byte in the lowest memory address): "0x78, 0x56, 0x34, 0x12".
-
- If String has N valid hexadecimal characters for conversion, the caller must make sure Buffer is at least
- N/2 (if N is even) or (N+1)/2 (if N if odd) bytes.
-
- If either Buffer, BufferSizeInBytes or String is NULL, then ASSERT ().
-
- @param Buffer The output buffer allocated by the caller.
- @param BufferSizeInBytes On input, the size in bytes of Buffer. On output, it is updated to
- contain the size of the Buffer which is actually used for the converstion.
- For Unicode string with 2*N hexadecimal characters (not including the
- tailing NULL character), N bytes of Buffer will be used for the output.
- @param String The input hexadecimal string.
- @param ConvertedStrLen The number of hexadecimal characters used to produce content in output
- buffer Buffer.
-
- @retval RETURN_BUFFER_TOO_SMALL The input BufferSizeInBytes is too small to hold the output. BufferSizeInBytes
- will be updated to the size required for the converstion.
- @retval RETURN_SUCCESS The convertion is successful or the first Unicode character from String
- is hexadecimal. If ConvertedStrLen is not NULL, it is updated
- to the number of hexadecimal character used for the converstion.
-**/
-RETURN_STATUS
-EFIAPI
-HexStringToBuf (
- OUT UINT8 *Buffer,
- IN OUT UINTN *BufferSizeInBytes,
- IN CONST CHAR16 *String,
- OUT UINTN *ConvertedStrLen OPTIONAL
- )
-{
- UINTN HexCnt;
- UINTN Idx;
- UINTN BufferLength;
- UINT8 Digit;
- UINT8 Byte;
-
- ASSERT (Buffer != NULL);
- ASSERT (BufferSizeInBytes != NULL);
- ASSERT (String != NULL);
-
- //
- // Find out how many hex characters the string has.
- //
- for (Idx = 0, HexCnt = 0; IsHexDigit (&Digit, String[Idx]); Idx++, HexCnt++);
-
- if (HexCnt == 0) {
- *ConvertedStrLen = 0;
- return RETURN_SUCCESS;
- }
- //
- // Two Unicode characters make up 1 buffer byte. Round up.
- //
- BufferLength = (HexCnt + 1) / 2;
-
- //
- // Test if buffer is passed enough.
- //
- if (BufferLength > (*BufferSizeInBytes)) {
- *BufferSizeInBytes = BufferLength;
- return RETURN_BUFFER_TOO_SMALL;
- }
-
- *BufferSizeInBytes = BufferLength;
-
- for (Idx = 0; Idx < HexCnt; Idx++) {
-
- IsHexDigit (&Digit, String[HexCnt - 1 - Idx]);
-
- //
- // For odd charaters, write the lower nibble for each buffer byte,
- // and for even characters, the upper nibble.
- //
- if ((Idx & 1) == 0) {
- Byte = Digit;
- } else {
- Byte = Buffer[Idx / 2];
- Byte &= 0x0F;
- Byte = (UINT8) (Byte | Digit << 4);
- }
-
- Buffer[Idx / 2] = Byte;
- }
-
- if (ConvertedStrLen != NULL) {
- *ConvertedStrLen = HexCnt;
- }
-
- return RETURN_SUCCESS;
-}
diff --git a/MdeModulePkg/Library/UefiIfrSupportLib/UefiIfrLibraryInternal.h b/MdeModulePkg/Library/UefiIfrSupportLib/UefiIfrLibraryInternal.h
deleted file mode 100644
index 7abf9ce..0000000
--- a/MdeModulePkg/Library/UefiIfrSupportLib/UefiIfrLibraryInternal.h
+++ /dev/null
@@ -1,41 +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>
-
-#define INVALID_VARSTORE_ID 0
-
-#define QUESTION_FLAGS (EFI_IFR_FLAG_READ_ONLY | EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED | EFI_IFR_FLAG_OPTIONS_ONLY)
-#define QUESTION_FLAGS_MASK (~QUESTION_FLAGS)
-
-#endif
-
diff --git a/MdeModulePkg/Library/UefiIfrSupportLib/UefiIfrOpCodeCreation.c b/MdeModulePkg/Library/UefiIfrSupportLib/UefiIfrOpCodeCreation.c
deleted file mode 100644
index 026cc0f..0000000
--- a/MdeModulePkg/Library/UefiIfrSupportLib/UefiIfrOpCodeCreation.c
+++ /dev/null
@@ -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_MASK) != 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;
-}
-
-
diff --git a/MdeModulePkg/Library/UefiIfrSupportLib/UefiIfrSupportLib.inf b/MdeModulePkg/Library/UefiIfrSupportLib/UefiIfrSupportLib.inf
deleted file mode 100644
index 88d1c42..0000000
--- a/MdeModulePkg/Library/UefiIfrSupportLib/UefiIfrSupportLib.inf
+++ /dev/null
@@ -1,58 +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. 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
- EFI_SPECIFICATION_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
- MdeModulePkg/MdeModulePkg.dec
-
-[LibraryClasses]
- MemoryAllocationLib
- DevicePathLib
- BaseLib
- UefiBootServicesTableLib
- BaseMemoryLib
- DebugLib
-
-[Protocols]
- gEfiDevicePathProtocolGuid ## CONSUMES
- gEfiHiiConfigRoutingProtocolGuid ## CONSUMES
- gEfiFormBrowser2ProtocolGuid ## CONSUMES
-
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index af613b5..3517482 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -56,15 +56,7 @@
## @libraryclass Provides HII related functions.
HiiLib|Include/Library/HiiLib.h
-
- ## @libraryclass Provides a set of interfaces to do IFR opcode creation and interact with a UEFI Form Browser.
- IfrSupportLib|Include/Library/IfrSupportLib.h
-
- ## @libraryclass Defines APIs that is related to IFR operations but specific to EDK II
- # implementation.
- ##
- ExtendedIfrSupportLib|Include/Library/ExtendedIfrSupportLib.h
-
+
## @libraryclass Defines a set of interfaces on how to process capusle image update.
CapsuleLib|Include/Library/CapsuleLib.h