1) Cleanup HiiLib, IfrSupportLib.
authorqwang12 <qwang12@de2fecce-e211-0410-80a6-f3fac2684e05>
Sat, 2 Feb 2008 13:15:44 +0000 (13:15 +0000)
committerqwang12 <qwang12@de2fecce-e211-0410-80a6-f3fac2684e05>
Sat, 2 Feb 2008 13:15:44 +0000 (13:15 +0000)
2) Add ExtendedHiiLib and ExtendedIfrSupportLib which implement APIs that require the OPcode and Device Path which is specific to Intel's implementation.

git-svn-id: https://edk2.tianocore.org/svn/edk2/trunk@4662 de2fecce-e211-0410-80a6-f3fac2684e05

42 files changed:
edk2/MdeModulePkg/Core/Dxe/DxeMain.inf
edk2/MdeModulePkg/Include/Library/ExtendedHiiLib.h [new file with mode: 0644]
edk2/MdeModulePkg/Include/Library/ExtendedIfrSupportLib.h [new file with mode: 0644]
edk2/MdeModulePkg/Include/MdeModuleHii.h
edk2/MdeModulePkg/Library/ExtendedHiiLib/ExtendedHiiLib.c [new file with mode: 0644]
edk2/MdeModulePkg/Library/ExtendedHiiLib/ExtendedHiiLib.inf [new file with mode: 0644]
edk2/MdeModulePkg/Library/ExtendedHiiLib/ExtendedHiiLib.msa [new file with mode: 0644]
edk2/MdeModulePkg/Library/ExtendedIfrSupportLib/Common.c [new file with mode: 0644]
edk2/MdeModulePkg/Library/ExtendedIfrSupportLib/ExtendedIfrSupportLib.inf [moved from edk2/MdeModulePkg/Library/IfrSupportLib/IfrSupportLib.inf with 73% similarity]
edk2/MdeModulePkg/Library/ExtendedIfrSupportLib/ExtendedIfrSupportLib.msa [moved from edk2/MdeModulePkg/Library/IfrSupportLib/IfrSupportLib.msa with 100% similarity]
edk2/MdeModulePkg/Library/ExtendedIfrSupportLib/Form.c [new file with mode: 0644]
edk2/MdeModulePkg/Library/ExtendedIfrSupportLib/IfrOpCodeCreation.c [new file with mode: 0644]
edk2/MdeModulePkg/Library/ExtendedIfrSupportLib/LibraryInternal.h [moved from edk2/MdeModulePkg/Library/IfrSupportLib/UefiIfrLibraryInternal.h with 86% similarity]
edk2/MdeModulePkg/Library/ExtendedIfrSupportLib/R8Lib.c [moved from edk2/MdeModulePkg/Library/IfrSupportLib/R8Lib.c with 99% similarity]
edk2/MdeModulePkg/Library/ExtendedIfrSupportLib/R8Lib.h [moved from edk2/MdeModulePkg/Library/IfrSupportLib/R8Lib.h with 100% similarity]
edk2/MdeModulePkg/Library/IfrSupportLib/UefiIfrCommon.c [deleted file]
edk2/MdeModulePkg/Library/IfrSupportLib/UefiIfrForm.c [deleted file]
edk2/MdeModulePkg/Library/IfrSupportLib/UefiIfrOpCodeCreation.c [deleted file]
edk2/MdeModulePkg/Library/IfrSupportLib/UefiIfrString.c [deleted file]
edk2/MdeModulePkg/MdeModulePkg.dec
edk2/MdeModulePkg/MdeModulePkg.dsc
edk2/MdeModulePkg/Universal/BdsDxe/Bds.h
edk2/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
edk2/MdeModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c
edk2/MdeModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c
edk2/MdeModulePkg/Universal/BdsDxe/BootMaint/Variable.c
edk2/MdeModulePkg/Universal/BdsDxe/BootMngr/BootManager.c
edk2/MdeModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManager.c
edk2/MdeModulePkg/Universal/BdsDxe/FrontPage.c
edk2/MdeModulePkg/Universal/BdsDxe/Language.c
edk2/MdeModulePkg/Universal/BdsDxe/String.c
edk2/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c
edk2/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c
edk2/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h
edk2/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf
edk2/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c
edk2/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.h
edk2/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf
edk2/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
edk2/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h
edk2/MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf
edk2/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c

index a6b6df2..8f8a22f 100644 (file)
   gEfiMdePkgTokenSpaceGuid.PcdStatusCodeValueDxeDriverBegin | 0x3040002        # EFI_SOFTWARE_DXE_CORE | EFI_SW_PC_INIT_BEGIN\r
   gEfiMdePkgTokenSpaceGuid.PcdStatusCodeValueDxeDriverEnd | 0x3040003          # EFI_SOFTWARE_DXE_CORE | EFI_SW_PC_INIT_END\r
 \r
+[BuildOptions]\r
+  MSFT:*_*_*_CC_FLAGS     = /FAcs\r
+\r
diff --git a/edk2/MdeModulePkg/Include/Library/ExtendedHiiLib.h b/edk2/MdeModulePkg/Include/Library/ExtendedHiiLib.h
new file mode 100644 (file)
index 0000000..7396aef
--- /dev/null
@@ -0,0 +1,57 @@
+/** @file\r
+  This library includes the APIs that is specific to EDK II's implementation.\r
+  It extended the UEFI Specification to define GUIDed device path.\r
+\r
+  Copyright (c) 2008, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+**/\r
+\r
+#ifndef __EXTENDED_HII_LIB_H__\r
+#define __EXTENDED_HII_LIB_H__\r
+\r
+/**\r
+  The HII driver handle passed in for HiiDatabase.NewPackageList() requires\r
+  that there should be DevicePath Protocol installed on it.\r
+  This routine create a virtual Driver Handle by installing a vendor device\r
+  path on it, so as to use it to invoke HiiDatabase.NewPackageList().\r
+  The Device Path created is a Vendor Device Path specific to Intel's implemenation.\r
+\r
+  @param  DriverHandle           Handle to be returned\r
+\r
+  @retval EFI_SUCCESS            Handle destroy success.\r
+  @retval EFI_OUT_OF_RESOURCES   Not enough memory.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+HiiLibCreateHiiDriverHandle (\r
+  OUT EFI_HANDLE               *DriverHandle\r
+  )\r
+;\r
+\r
+/**\r
+  Destroy the Driver Handle created by CreateHiiDriverHandle().\r
+\r
+  If no Device Path protocol is installed on the DriverHandle, then ASSERT.\r
+  If this Device Path protocol is failed to be uninstalled, then ASSERT.\r
+\r
+  @param  DriverHandle           Handle returned by CreateHiiDriverHandle()\r
+\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+HiiLibDestroyHiiDriverHandle (\r
+  IN EFI_HANDLE                 DriverHandle\r
+  )\r
+;\r
+\r
+\r
+#endif\r
diff --git a/edk2/MdeModulePkg/Include/Library/ExtendedIfrSupportLib.h b/edk2/MdeModulePkg/Include/Library/ExtendedIfrSupportLib.h
new file mode 100644 (file)
index 0000000..e0e6233
--- /dev/null
@@ -0,0 +1,127 @@
+/** @file\r
+  Library header file defines APIs that is related to IFR operations but \r
+  specific to EDK II implementation.\r
+\r
+  Copyright (c) 2006 - 2007, Intel Corporation\r
+  All rights reserved. This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef __EXTENDED_IFR_SUPPORT_LIB_H__\r
+#define __EXTENDED_IFR_SUPPORT_LIB_H__\r
+\r
+/**\r
+  Create GUIDed opcode for banner. Banner opcode\r
+  EFI_IFR_EXTEND_OP_BANNER is extended opcode specific\r
+  to Intel's implementation.\r
+\r
+  @param  Title                  String ID for title\r
+  @param  LineNumber             Line number for this banner\r
+  @param  Alignment              Alignment for this banner, left, center or right\r
+  @param  Data                   Destination for the created opcode binary\r
+\r
+  @retval EFI_SUCCESS            Opcode create success\r
+  @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.\r
+\r
+**/\r
+EFI_STATUS\r
+CreateBannerOpCode (\r
+  IN      EFI_STRING_ID       Title,\r
+  IN      UINT16              LineNumber,\r
+  IN      UINT8               Alignment,\r
+  IN OUT  EFI_HII_UPDATE_DATA *Data\r
+  )\r
+;\r
+\r
+/**\r
+  This function allows the caller to update a form that has\r
+  previously been registered with the EFI HII database.\r
+  The update make use of a extended opcode EFI_IFR_EXTEND_OP_LABEL\r
+  specific to Intel's implementation to complete the operation.\r
+  \r
+\r
+  @param  Handle                 Hii Handle\r
+  @param  FormSetGuid            The formset should be updated.\r
+  @param  FormId                 The form should be updated.\r
+  @param  Label                  Update information starting immediately after this\r
+                                 label in the IFR\r
+  @param  Insert                 If TRUE and Data is not NULL, insert data after\r
+                                 Label. If FALSE, replace opcodes between two\r
+                                 labels with Data.\r
+  @param  Data                   The adding data; If NULL, remove opcodes between\r
+                                 two Label.\r
+\r
+  @retval EFI_SUCCESS            Update success.\r
+  @retval Other                  Update fail.\r
+\r
+**/\r
+EFI_STATUS\r
+IfrLibUpdateForm (\r
+  IN EFI_HII_HANDLE            Handle,\r
+  IN EFI_GUID                  *FormSetGuid, OPTIONAL\r
+  IN EFI_FORM_ID               FormId,\r
+  IN UINT16                    Label,\r
+  IN BOOLEAN                   Insert,\r
+  IN EFI_HII_UPDATE_DATA       *Data\r
+  )\r
+;\r
+\r
+/**\r
+  Extract formset class for given HII handle.\r
+\r
+  If Handle is not a valid EFI_HII_HANDLE in the default HII database, then\r
+  ASSERT.\r
+\r
+  If Class is NULL, then ASSERT.\r
+  IfFormSetTitle is NULL, then ASSERT.\r
+  If FormSetHelp is NULL, then ASSERT.\r
+\r
+  @param  HiiHandle              Hii handle\r
+  @param  Class                    On output, Class of the formset\r
+  @param  FormSetTitle          On output,  Formset title string\r
+  @param  FormSetHelp          On output,   Formset help string\r
+\r
+  @retval EFI_SUCCESS            Successfully extract Class for specified Hii\r
+                                 handle.\r
+\r
+**/\r
+EFI_STATUS\r
+IfrLibExtractClassFromHiiHandle (\r
+  IN      EFI_HII_HANDLE      Handle,\r
+  OUT     UINT16              *Class,\r
+  OUT     EFI_STRING_ID       *FormSetTitle,\r
+  OUT     EFI_STRING_ID       *FormSetHelp\r
+  )\r
+;\r
+\r
+/**\r
+  Configure the buffer accrording to ConfigBody strings in the format of\r
+  <Length:4 bytes>, <Offset: 2 bytes>, <Width:2 bytes>, <Data:n bytes>.\r
+\r
+  @param  Buffer                 the start address of buffer.\r
+  @param  BufferSize             the size of buffer.\r
+  @param  Number                 the number of the strings.\r
+\r
+  @retval EFI_BUFFER_TOO_SMALL   the BufferSize is too small to operate.\r
+  @retval EFI_INVALID_PARAMETER  Buffer is NULL or BufferSize is 0.\r
+  @retval EFI_SUCCESS            Operation successful.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+IfrLibExtractDefault(\r
+  IN VOID                         *Buffer,\r
+  IN UINTN                        *BufferSize,\r
+  UINTN                           Number,\r
+  ...\r
+  )\r
+;\r
+\r
+#endif\r
+\r
index 7f99ccd..7296f0d 100644 (file)
@@ -44,12 +44,6 @@ typedef struct {
 } HII_VENDOR_DEVICE_PATH;\r
 \r
 \r
-//\r
-// References to string tokens must use this macro to enable scanning for\r
-// token usages.\r
-//\r
-#define STRING_TOKEN(t) t\r
-\r
 //\r
 // GUIDed opcodes defined for Tiano\r
 //\r
diff --git a/edk2/MdeModulePkg/Library/ExtendedHiiLib/ExtendedHiiLib.c b/edk2/MdeModulePkg/Library/ExtendedHiiLib/ExtendedHiiLib.c
new file mode 100644 (file)
index 0000000..22b9763
--- /dev/null
@@ -0,0 +1,116 @@
+/** @file\r
+  HII Library implementation that uses DXE protocols and services.\r
+\r
+  Copyright (c) 2006, Intel Corporation<BR>\r
+  All rights reserved. This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+\r
+#include <PiDxe.h>\r
+\r
+#include <Protocol/DevicePath.h>\r
+\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <MdeModuleHii.h>\r
+\r
+\r
+//\r
+// Hii vendor device path template\r
+//\r
+HII_VENDOR_DEVICE_PATH  mHiiVendorDevicePathTemplate = {\r
+  {\r
+    {\r
+      {\r
+        HARDWARE_DEVICE_PATH,\r
+        HW_VENDOR_DP,\r
+        {\r
+          (UINT8) (sizeof (HII_VENDOR_DEVICE_PATH_NODE)),\r
+          (UINT8) ((sizeof (HII_VENDOR_DEVICE_PATH_NODE)) >> 8)\r
+        }\r
+      },\r
+      EFI_IFR_TIANO_GUID\r
+    },\r
+    0\r
+  },\r
+  {\r
+    END_DEVICE_PATH_TYPE,\r
+    END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
+    { \r
+      END_DEVICE_PATH_LENGTH\r
+    }\r
+  }\r
+};\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+HiiLibCreateHiiDriverHandle (\r
+  OUT EFI_HANDLE               *DriverHandle\r
+  )\r
+{\r
+  EFI_STATUS                   Status;\r
+  HII_VENDOR_DEVICE_PATH_NODE  *VendorDevicePath;\r
+  UINT64                       MonotonicCount;\r
+\r
+  VendorDevicePath = AllocateCopyPool (sizeof (HII_VENDOR_DEVICE_PATH), &mHiiVendorDevicePathTemplate);\r
+  if (VendorDevicePath == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  gBS->GetNextMonotonicCount (&MonotonicCount);\r
+  VendorDevicePath->MonotonicCount = (UINT32) MonotonicCount;\r
+\r
+  *DriverHandle = NULL;\r
+  Status = gBS->InstallProtocolInterface (\r
+                  DriverHandle,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  EFI_NATIVE_INTERFACE,\r
+                  VendorDevicePath\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+VOID\r
+EFIAPI\r
+HiiLibDestroyHiiDriverHandle (\r
+  IN EFI_HANDLE               DriverHandle\r
+  )\r
+{\r
+  EFI_STATUS                   Status;\r
+  EFI_DEVICE_PATH_PROTOCOL     *DevicePath;\r
+\r
+  Status = gBS->HandleProtocol (\r
+                  DriverHandle,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  (VOID **) &DevicePath\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  Status = gBS->UninstallProtocolInterface (\r
+                  DriverHandle,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  DevicePath\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  FreePool (DevicePath);\r
+\r
+}\r
+\r
+\r
+\r
diff --git a/edk2/MdeModulePkg/Library/ExtendedHiiLib/ExtendedHiiLib.inf b/edk2/MdeModulePkg/Library/ExtendedHiiLib/ExtendedHiiLib.inf
new file mode 100644 (file)
index 0000000..f7b8e34
--- /dev/null
@@ -0,0 +1,47 @@
+#/** @file\r
+# Library instance for HII common routines.\r
+#\r
+# This library instance implements the common HII routines.\r
+# Copyright (c) 2006, Intel Corporation\r
+#\r
+#  All rights reserved. This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+#**/\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = ExtendedHiiLib\r
+  FILE_GUID                      = 35961516-ABA1-4636-A4C0-608E62BE8BB0\r
+  MODULE_TYPE                    = DXE_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = ExtendedHiiLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER\r
+  EDK_RELEASE_VERSION            = 0x00020000\r
+  EFI_SPECIFICATION_VERSION      = 0x0002000A\r
+\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources.common]\r
+  ExtendedHiiLib.c\r
+\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
+\r
+[LibraryClasses]\r
+  MemoryAllocationLib\r
+  DebugLib\r
+  PcdLib\r
+  UefiRuntimeServicesTableLib\r
+\r
+[Protocols]\r
+  gEfiDevicePathProtocolGuid  \r
+  \r
diff --git a/edk2/MdeModulePkg/Library/ExtendedHiiLib/ExtendedHiiLib.msa b/edk2/MdeModulePkg/Library/ExtendedHiiLib/ExtendedHiiLib.msa
new file mode 100644 (file)
index 0000000..feedd21
--- /dev/null
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+  <MsaHeader>\r
+    <ModuleName>HiiLib</ModuleName>\r
+    <ModuleType>DXE_DRIVER</ModuleType>\r
+    <GuidValue>3143687A-7C80-404e-B5FE-2D88980E1B1C</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>Library instance for HII common routines.</Abstract>\r
+    <Description>This library instance implements the common HII routines.</Description>\r
+    <Copyright>Copyright (c) 2006, Intel Corporation</Copyright>\r
+    <License>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.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>HiiLib</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_PRODUCED" SupModuleList="DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER">\r
+      <Keyword>HiiLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DebugLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>MemoryAllocationLib</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename>HiiLib.c</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+  </PackageDependencies>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+  </Externs>\r
+</ModuleSurfaceArea>
\ No newline at end of file
diff --git a/edk2/MdeModulePkg/Library/ExtendedIfrSupportLib/Common.c b/edk2/MdeModulePkg/Library/ExtendedIfrSupportLib/Common.c
new file mode 100644 (file)
index 0000000..36bfb0f
--- /dev/null
@@ -0,0 +1,177 @@
+/** @file
+
+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.
+
+Module Name:
+
+  UefiIfrCommon.c
+
+Abstract:
+
+  Common Library Routines to assist handle HII elements.
+
+
+**/
+
+#include "LibraryInternal.h"
+
+
+//
+// Hii relative protocols
+//
+
+EFI_HII_DATABASE_PROTOCOL *gIfrLibHiiDatabase;
+EFI_HII_STRING_PROTOCOL   *gIfrLibHiiString;
+
+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;
+}
+
+
+
+STATIC EFI_GUID mIfrVendorGuid = EFI_IFR_TIANO_GUID;
+
+EFI_STATUS
+EFIAPI
+IfrLibExtractClassFromHiiHandle (
+  IN      EFI_HII_HANDLE      Handle,
+  OUT     UINT16              *Class,
+  OUT     EFI_STRING_ID       *FormSetTitle,
+  OUT     EFI_STRING_ID       *FormSetHelp
+  )
+/*++
+
+Routine Description:
+  Extract formset class for given HII handle.
+
+Arguments:
+  HiiHandle       - Hii handle
+  Class           - Class of the formset
+  FormSetTitle    - Formset title string
+  FormSetHelp     - Formset help string
+
+Returns:
+  EFI_SUCCESS     - Successfully extract Class for specified Hii handle.
+
+--*/
+{
+  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);
+  ASSERT (Status != EFI_NOT_FOUND);
+  
+  if (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;
+  CopyMem (&PackageListLength, &HiiPackageList->PackageLength, sizeof (UINT32));
+
+  while (Offset < PackageListLength) {
+    Package = ((UINT8 *) HiiPackageList) + Offset;
+    CopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));
+
+    if (PackageHeader.Type == EFI_HII_PACKAGE_FORM) {
+      //
+      // 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 (&mIfrVendorGuid, (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;
+  }
+
+  gBS->FreePool (HiiPackageList);
+
+  return EFI_SUCCESS;
+}
+
+
 \r
 [Defines]\r
   INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = IfrSupportLib\r
-  FILE_GUID                      = bf38668e-e231-4baa-99e4-8c0e4c35dca6\r
+  BASE_NAME                      = MdeModuleIfrSupportLib\r
+  FILE_GUID                      = A47B68BA-5177-4b2d-891E-4722FA5323F8\r
   MODULE_TYPE                    = DXE_DRIVER\r
   VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = IfrSupportLib\r
+  LIBRARY_CLASS                  = ExtendedIfrSupportLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER\r
   EDK_RELEASE_VERSION            = 0x00020000\r
   EFI_SPECIFICATION_VERSION      = 0x00020000\r
 \r
+  CONSTRUCTOR                    = ExtendedIfrSupportLibConstructor\r
+\r
 \r
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
 \r
 [Sources.common]\r
-  UefiIfrCommon.c\r
-  UefiIfrForm.c\r
-  UefiIfrLibraryInternal.h\r
-  UefiIfrOpCodeCreation.c\r
-  UefiIfrString.c\r
+  Common.c\r
+  Form.c\r
+  LibraryInternal.h\r
+  IfrOpCodeCreation.c\r
   R8Lib.h\r
   R8Lib.c\r
 \r
@@ -68,4 +69,4 @@
   gEfiFormBrowser2ProtocolGuid   \r
 \r
 [Pcd]\r
-  gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultPlatformLang
\ No newline at end of file
+  gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultPlatformLang\r
diff --git a/edk2/MdeModulePkg/Library/ExtendedIfrSupportLib/Form.c b/edk2/MdeModulePkg/Library/ExtendedIfrSupportLib/Form.c
new file mode 100644 (file)
index 0000000..d3a0faa
--- /dev/null
@@ -0,0 +1,441 @@
+/** @file
+
+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.
+
+Module Name:
+
+  UefiIfrForm.c
+
+Abstract:
+
+  Common Library Routines to assist handle HII elements.
+
+
+**/
+
+#include "LibraryInternal.h"
+
+STATIC
+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 = {0, 0};
+
+  ASSERT(HiiPackageList != NULL);
+
+  if ((BufferLen == NULL) || (Buffer == NULL)) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  Package = NULL;
+  Index   = 0;
+  Offset  = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
+  CopyMem (&PackageListLength, &HiiPackageList->PackageLength, sizeof (UINT32));
+  while (Offset < PackageListLength) {
+    Package = (EFI_HII_PACKAGE_HEADER *) (((UINT8 *) HiiPackageList) + Offset);
+    CopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));
+    if (Index == PackageIndex) {
+      break;
+    }
+    Offset += PackageHeader.Length;
+    Index++;
+  }
+  if (Offset >= PackageListLength) {
+    //
+    // no package found in this Package List
+    //
+    return EFI_NOT_FOUND;
+  }
+
+  *BufferLen = PackageHeader.Length;
+  *Buffer    = Package;
+  return EFI_SUCCESS;
+}
+
+STATIC
+EFI_STATUS
+EFIAPI
+UpdateFormPackageData (
+  IN  EFI_GUID               *FormSetGuid,
+  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 (CompareMem (&((EFI_IFR_FORM_SET *) IfrOpHdr)->Guid, FormSetGuid, sizeof (EFI_GUID)) == 0) {
+          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;
+      CopyMem (&LabelNumber, &((EFI_IFR_GUID_LABEL *)IfrOpHdr)->Number, sizeof (UINT16));
+      if ((ExtendOpCode != EFI_IFR_EXTEND_OP_LABEL) || (LabelNumber != Label)) {
+        //
+        // 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) {
+              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) {
+    gBS->FreePool (*TempBuffer);
+    *TempBufferSize = 0;
+    return EFI_NOT_FOUND;
+  }
+
+  return EFI_SUCCESS;
+}
+
+
+/**
+  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);
+  if (Status == EFI_BUFFER_TOO_SMALL) {
+    HiiPackageList = AllocatePool (BufferSize);
+    ASSERT (HiiPackageList != NULL);
+
+    Status = HiiDatabase->ExportPackageLists (HiiDatabase, Handle, &BufferSize, HiiPackageList);
+    if (EFI_ERROR (Status)) {
+      gBS->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_FORM) && !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;
+          gBS->FreePool (TempBuffer);
+          continue;
+        }
+      }
+
+      CopyMem (UpdateBufferPos, Package, PackageLength);
+      UpdateBufferPos += PackageLength;
+    } else if (Status == EFI_NOT_FOUND) {
+      break;
+    } else {
+      gBS->FreePool (HiiPackageList);
+      return Status;
+    }
+  }
+
+  //
+  // Update package list length
+  //
+  BufferSize = UpdateBufferPos - (UINT8 *) UpdateBuffer;
+  CopyMem (&UpdateBuffer->PackageLength, &BufferSize, sizeof (UINT32));
+
+  gBS->FreePool (HiiPackageList);
+
+  return HiiDatabase->UpdatePackageList (HiiDatabase, Handle, UpdateBuffer);
+}
+
+
+/**
+  Configure the buffer accrording to ConfigBody strings.
+
+  @param  DefaultId              the ID of default.
+  @param  Buffer                 the start address of buffer.
+  @param  BufferSize             the size of buffer.
+  @param  Number                 the number of the strings.
+
+  @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 *);
+    CopyMem (&TotalLen, BufCfgArray, sizeof (UINT32));
+    BufferPos = BufCfgArray + sizeof (UINT32);
+
+    while ((UINT32)(BufferPos - BufCfgArray) < TotalLen) {
+      CopyMem (&Offset, BufferPos, sizeof (UINT16));
+      BufferPos += sizeof (UINT16);
+      CopyMem (&Width, BufferPos, sizeof (UINT16));
+      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/edk2/MdeModulePkg/Library/ExtendedIfrSupportLib/IfrOpCodeCreation.c b/edk2/MdeModulePkg/Library/ExtendedIfrSupportLib/IfrOpCodeCreation.c
new file mode 100644 (file)
index 0000000..5a2995c
--- /dev/null
@@ -0,0 +1,63 @@
+/** @file
+
+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.
+
+Module Name:
+
+  UefiIfrOpCodeCreation.c
+
+Abstract:
+
+  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.
+
+Revision History:
+
+
+**/
+
+#include "LibraryInternal.h"
+
+STATIC EFI_GUID mIfrVendorGuid = EFI_IFR_TIANO_GUID;
+
+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, &mIfrVendorGuid, 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;
+}
+
@@ -43,22 +43,4 @@ Abstract:
 
 #include "R8Lib.h"
 
-VOID
-LocateHiiProtocols (
-  VOID
-  )
-/*++
-
-Routine Description:
-  This function locate Hii relative protocols for later usage.
-
-Arguments:
-  None.
-
-Returns:
-  None.
-
---*/
-;
-
 #endif
diff --git a/edk2/MdeModulePkg/Library/IfrSupportLib/UefiIfrCommon.c b/edk2/MdeModulePkg/Library/IfrSupportLib/UefiIfrCommon.c
deleted file mode 100644 (file)
index b2b92d1..0000000
+++ /dev/null
@@ -1,369 +0,0 @@
-/** @file
-
-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.
-
-Module Name:
-
-  UefiIfrCommon.c
-
-Abstract:
-
-  Common Library Routines to assist handle HII elements.
-
-
-**/
-
-#include "UefiIfrLibraryInternal.h"
-
-//
-// Hii relative protocols
-//
-BOOLEAN  mHiiProtocolsInitialized = FALSE;
-
-EFI_HII_DATABASE_PROTOCOL *gIfrLibHiiDatabase;
-EFI_HII_STRING_PROTOCOL   *gIfrLibHiiString;
-
-
-/**
-  This function locate Hii relative protocols for later usage.
-
-  None.
-
-  @return None.
-
-**/
-VOID
-LocateHiiProtocols (
-  VOID
-  )
-{
-  EFI_STATUS  Status;
-
-  if (mHiiProtocolsInitialized) {
-    return;
-  }
-
-  Status = gBS->LocateProtocol (&gEfiHiiDatabaseProtocolGuid, NULL, (VOID **) &gIfrLibHiiDatabase);
-  ASSERT_EFI_ERROR (Status);
-
-  Status = gBS->LocateProtocol (&gEfiHiiStringProtocolGuid, NULL, (VOID **) &gIfrLibHiiString);
-  ASSERT_EFI_ERROR (Status);
-
-  mHiiProtocolsInitialized = TRUE;
-}
-
-
-/**
-  Assemble EFI_HII_PACKAGE_LIST according to the passed in packages.
-
-  @param  NumberOfPackages       Number of packages.
-  @param  GuidId                 Package GUID.
-
-  @return Pointer of EFI_HII_PACKAGE_LIST_HEADER.
-
-**/
-EFI_HII_PACKAGE_LIST_HEADER *
-PreparePackageList (
-  IN UINTN                    NumberOfPackages,
-  IN EFI_GUID                 *GuidId,
-  ...
-  )
-{
-  VA_LIST                     Marker;
-  EFI_HII_PACKAGE_LIST_HEADER *PackageListHeader;
-  UINT8                       *PackageListData;
-  UINT32                      PackageListLength;
-  UINT32                      PackageLength;
-  EFI_HII_PACKAGE_HEADER      PackageHeader;
-  UINT8                       *PackageArray;
-  UINTN                       Index;
-
-  PackageListLength = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
-
-  VA_START (Marker, GuidId);
-  for (Index = 0; Index < NumberOfPackages; Index++) {
-    CopyMem (&PackageLength, VA_ARG (Marker, VOID *), sizeof (UINT32));
-    PackageListLength += (PackageLength - sizeof (UINT32));
-  }
-  VA_END (Marker);
-
-  //
-  // Include the lenght of EFI_HII_PACKAGE_END
-  //
-  PackageListLength += sizeof (EFI_HII_PACKAGE_HEADER);
-  PackageListHeader = AllocateZeroPool (PackageListLength);
-  ASSERT (PackageListHeader != NULL);
-  CopyMem (&PackageListHeader->PackageListGuid, GuidId, sizeof (EFI_GUID));
-  PackageListHeader->PackageLength = PackageListLength;
-
-  PackageListData = ((UINT8 *) PackageListHeader) + sizeof (EFI_HII_PACKAGE_LIST_HEADER);
-
-  VA_START (Marker, GuidId);
-  for (Index = 0; Index < NumberOfPackages; Index++) {
-    PackageArray = (UINT8 *) VA_ARG (Marker, VOID *);
-    CopyMem (&PackageLength, PackageArray, sizeof (UINT32));
-    PackageLength  -= sizeof (UINT32);
-    PackageArray += sizeof (UINT32);
-    CopyMem (PackageListData, PackageArray, PackageLength);
-    PackageListData += PackageLength;
-  }
-  VA_END (Marker);
-
-  //
-  // Append EFI_HII_PACKAGE_END
-  //
-  PackageHeader.Type = EFI_HII_PACKAGE_END;
-  PackageHeader.Length = sizeof (EFI_HII_PACKAGE_HEADER);
-  CopyMem (PackageListData, &PackageHeader, PackageHeader.Length);
-
-  return PackageListHeader;
-}
-
-
-/**
-  Find HII Handle associated with given Device Path.
-
-  @param  HiiDatabase            Point to EFI_HII_DATABASE_PROTOCOL instance.
-  @param  DevicePath             Device Path associated with the HII package list
-                                 handle.
-
-  @retval Handle                 HII package list Handle associated with the Device
-                                 Path.
-  @retval NULL                   Hii Package list handle is not found.
-
-**/
-EFI_HII_HANDLE
-DevicePathToHiiHandle (
-  IN EFI_HII_DATABASE_PROTOCOL  *HiiDatabase,
-  IN EFI_DEVICE_PATH_PROTOCOL   *DevicePath
-  )
-{
-  EFI_STATUS                  Status;
-  EFI_DEVICE_PATH_PROTOCOL    *TmpDevicePath;
-  UINTN                       BufferSize;
-  UINTN                       HandleCount;
-  UINTN                       Index;
-  EFI_HANDLE                  *Handles;
-  EFI_HANDLE                  Handle;
-  UINTN                       Size;
-  EFI_HANDLE                  DriverHandle;
-  EFI_HII_HANDLE              *HiiHandles;
-  EFI_HII_HANDLE              HiiHandle;
-
-  //
-  // Locate Device Path Protocol handle buffer
-  //
-  Status = gBS->LocateHandleBuffer (
-                  ByProtocol,
-                  &gEfiDevicePathProtocolGuid,
-                  NULL,
-                  &HandleCount,
-                  &Handles
-                  );
-  if (EFI_ERROR (Status)) {
-    return NULL;
-  }
-
-  //
-  // Search Driver Handle by Device Path
-  //
-  DriverHandle = NULL;
-  BufferSize = GetDevicePathSize (DevicePath);
-  for(Index = 0; Index < HandleCount; Index++) {
-    Handle = Handles[Index];
-    gBS->HandleProtocol (Handle, &gEfiDevicePathProtocolGuid, (VOID **) &TmpDevicePath);
-
-    //
-    // Check whether DevicePath match
-    //
-    Size = GetDevicePathSize (TmpDevicePath);
-    if ((Size == BufferSize) && CompareMem (DevicePath, TmpDevicePath, Size) == 0) {
-      DriverHandle = Handle;
-      break;
-    }
-  }
-  gBS->FreePool (Handles);
-
-  if (DriverHandle == NULL) {
-    return NULL;
-  }
-
-  //
-  // Retrieve all Hii Handles from HII database
-  //
-  BufferSize = 0x1000;
-  HiiHandles = AllocatePool (BufferSize);
-  ASSERT (HiiHandles != NULL);
-  Status = HiiDatabase->ListPackageLists (
-                          HiiDatabase,
-                          EFI_HII_PACKAGE_TYPE_ALL,
-                          NULL,
-                          &BufferSize,
-                          HiiHandles
-                          );
-  if (Status == EFI_BUFFER_TOO_SMALL) {
-    gBS->FreePool (HiiHandles);
-    HiiHandles = AllocatePool (BufferSize);
-    ASSERT (HiiHandles != NULL);
-
-    Status = HiiDatabase->ListPackageLists (
-                            HiiDatabase,
-                            EFI_HII_PACKAGE_TYPE_ALL,
-                            NULL,
-                            &BufferSize,
-                            HiiHandles
-                            );
-  }
-
-  if (EFI_ERROR (Status)) {
-    gBS->FreePool (HiiHandles);
-    return NULL;
-  }
-
-  //
-  // Search Hii Handle by Driver Handle
-  //
-  HiiHandle = NULL;
-  HandleCount = BufferSize / sizeof (EFI_HII_HANDLE);
-  for (Index = 0; Index < HandleCount; Index++) {
-    Status = HiiDatabase->GetPackageListHandle (
-                            HiiDatabase,
-                            HiiHandles[Index],
-                            &Handle
-                            );
-    if (!EFI_ERROR (Status) && (Handle == DriverHandle)) {
-      HiiHandle = HiiHandles[Index];
-      break;
-    }
-  }
-
-  gBS->FreePool (HiiHandles);
-  return HiiHandle;
-}
-
-
-/**
-  Determines the handles that are currently active in the database.
-  It's the caller's responsibility to free handle buffer.
-
-  @param  HiiDatabase            A pointer to the EFI_HII_DATABASE_PROTOCOL
-                                 instance.
-  @param  HandleBufferLength     On input, a pointer to the length of the handle
-                                 buffer. On output, the length of the handle buffer
-                                 that is required for the handles found.
-  @param  HiiHandleBuffer        Pointer to an array of Hii Handles returned.
-
-  @retval EFI_SUCCESS            Get an array of Hii Handles successfully.
-  @retval EFI_INVALID_PARAMETER  Hii is NULL.
-  @retval EFI_NOT_FOUND          Database not found.
-
-**/
-EFI_STATUS
-GetHiiHandles (
-  IN OUT UINTN                     *HandleBufferLength,
-  OUT    EFI_HII_HANDLE            **HiiHandleBuffer
-  )
-{
-  UINTN       BufferLength;
-  EFI_STATUS  Status;
-
-  BufferLength = 0;
-
-  LocateHiiProtocols ();
-
-  //
-  // Try to find the actual buffer size for HiiHandle Buffer.
-  //
-  Status = gIfrLibHiiDatabase->ListPackageLists (
-                                 gIfrLibHiiDatabase,
-                                 EFI_HII_PACKAGE_TYPE_ALL,
-                                 NULL,
-                                 &BufferLength,
-                                 *HiiHandleBuffer
-                                 );
-
-  if (Status == EFI_BUFFER_TOO_SMALL) {
-      *HiiHandleBuffer = AllocateZeroPool (BufferLength);
-      Status = gIfrLibHiiDatabase->ListPackageLists (
-                                     gIfrLibHiiDatabase,
-                                     EFI_HII_PACKAGE_TYPE_ALL,
-                                     NULL,
-                                     &BufferLength,
-                                     *HiiHandleBuffer
-                                     );
-      //
-      // we should not fail here.
-      //
-      ASSERT_EFI_ERROR (Status);
-  }
-
-  *HandleBufferLength = BufferLength;
-
-  return Status;
-}
-
-
-/**
-  Extract Hii package list GUID for given HII handle.
-
-  @param  HiiHandle              Hii handle
-  @param  Guid                   Package list GUID
-
-  @retval EFI_SUCCESS            Successfully extract GUID from Hii database.
-
-**/
-EFI_STATUS
-ExtractGuidFromHiiHandle (
-  IN      EFI_HII_HANDLE      Handle,
-  OUT     EFI_GUID            *Guid
-  )
-{
-  EFI_STATUS                   Status;
-  UINTN                        BufferSize;
-  EFI_HII_DATABASE_PROTOCOL    *HiiDatabase;
-  EFI_HII_PACKAGE_LIST_HEADER  *HiiPackageList;
-
-  //
-  // Locate HII Database protocol
-  //
-  Status = gBS->LocateProtocol (
-                  &gEfiHiiDatabaseProtocolGuid,
-                  NULL,
-                  (VOID **) &HiiDatabase
-                  );
-  if (EFI_ERROR (Status)) {
-    return Status;
-  }
-
-  //
-  // Get HII PackageList
-  //
-  BufferSize = 0;
-  HiiPackageList = NULL;
-  Status = HiiDatabase->ExportPackageLists (HiiDatabase, Handle, &BufferSize, HiiPackageList);
-  if (Status == EFI_BUFFER_TOO_SMALL) {
-    HiiPackageList = AllocatePool (BufferSize);
-    ASSERT (HiiPackageList != NULL);
-
-    Status = HiiDatabase->ExportPackageLists (HiiDatabase, Handle, &BufferSize, HiiPackageList);
-  }
-  if (EFI_ERROR (Status)) {
-    return Status;
-  }
-
-  //
-  // Extract GUID
-  //
-  CopyMem (Guid, &HiiPackageList->PackageListGuid, sizeof (EFI_GUID));
-
-  gBS->FreePool (HiiPackageList);
-
-  return EFI_SUCCESS;
-}
diff --git a/edk2/MdeModulePkg/Library/IfrSupportLib/UefiIfrForm.c b/edk2/MdeModulePkg/Library/IfrSupportLib/UefiIfrForm.c
deleted file mode 100644 (file)
index 362978a..0000000
+++ /dev/null
@@ -1,1121 +0,0 @@
-/** @file
-
-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.
-
-Module Name:
-
-  UefiIfrForm.c
-
-Abstract:
-
-  Common Library Routines to assist handle HII elements.
-
-
-**/
-
-#include "UefiIfrLibraryInternal.h"
-
-//
-// Fake <ConfigHdr>
-//
-UINT16 mFakeConfigHdr[] = L"GUID=00000000000000000000000000000000&NAME=0000&PATH=0";
-
-STATIC
-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 = {0, 0};
-
-  ASSERT(HiiPackageList != NULL);
-
-  if ((BufferLen == NULL) || (Buffer == NULL)) {
-    return EFI_INVALID_PARAMETER;
-  }
-
-  Package = NULL;
-  Index   = 0;
-  Offset  = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
-  CopyMem (&PackageListLength, &HiiPackageList->PackageLength, sizeof (UINT32));
-  while (Offset < PackageListLength) {
-    Package = (EFI_HII_PACKAGE_HEADER *) (((UINT8 *) HiiPackageList) + Offset);
-    CopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));
-    if (Index == PackageIndex) {
-      break;
-    }
-    Offset += PackageHeader.Length;
-    Index++;
-  }
-  if (Offset >= PackageListLength) {
-    //
-    // no package found in this Package List
-    //
-    return EFI_NOT_FOUND;
-  }
-
-  *BufferLen = PackageHeader.Length;
-  *Buffer    = Package;
-  return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-UpdateFormPackageData (
-  IN  EFI_GUID               *FormSetGuid,
-  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 (CompareMem (&((EFI_IFR_FORM_SET *) IfrOpHdr)->Guid, FormSetGuid, sizeof (EFI_GUID)) == 0) {
-          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;
-      CopyMem (&LabelNumber, &((EFI_IFR_GUID_LABEL *)IfrOpHdr)->Number, sizeof (UINT16));
-      if ((ExtendOpCode != EFI_IFR_EXTEND_OP_LABEL) || (LabelNumber != Label)) {
-        //
-        // 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) {
-              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) {
-    gBS->FreePool (*TempBuffer);
-    *TempBufferSize = 0;
-    return EFI_NOT_FOUND;
-  }
-
-  return EFI_SUCCESS;
-}
-
-
-/**
-  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
-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;
-  }
-
-  LocateHiiProtocols ();
-  HiiDatabase = gIfrLibHiiDatabase;
-
-  //
-  // Get the orginal package list
-  //
-  BufferSize = 0;
-  HiiPackageList   = NULL;
-  Status = HiiDatabase->ExportPackageLists (HiiDatabase, Handle, &BufferSize, HiiPackageList);
-  if (Status == EFI_BUFFER_TOO_SMALL) {
-    HiiPackageList = AllocatePool (BufferSize);
-    ASSERT (HiiPackageList != NULL);
-
-    Status = HiiDatabase->ExportPackageLists (HiiDatabase, Handle, &BufferSize, HiiPackageList);
-    if (EFI_ERROR (Status)) {
-      gBS->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_FORM) && !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;
-          gBS->FreePool (TempBuffer);
-          continue;
-        }
-      }
-
-      CopyMem (UpdateBufferPos, Package, PackageLength);
-      UpdateBufferPos += PackageLength;
-    } else if (Status == EFI_NOT_FOUND) {
-      break;
-    } else {
-      gBS->FreePool (HiiPackageList);
-      return Status;
-    }
-  }
-
-  //
-  // Update package list length
-  //
-  BufferSize = UpdateBufferPos - (UINT8 *) UpdateBuffer;
-  CopyMem (&UpdateBuffer->PackageLength, &BufferSize, sizeof (UINT32));
-
-  gBS->FreePool (HiiPackageList);
-
-  return HiiDatabase->UpdatePackageList (HiiDatabase, Handle, UpdateBuffer);
-}
-
-
-/**
-  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) 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
-IfrLibCreatePopUp (
-  IN  UINTN                       NumberOfLines,
-  OUT EFI_INPUT_KEY               *KeyValue,
-  IN  CHAR16                      *String,
-  ...
-  )
-{
-  UINTN                         Index;
-  UINTN                         Count;
-  UINTN                         Start;
-  UINTN                         Top;
-  CHAR16                        *StringPtr;
-  UINTN                         LeftColumn;
-  UINTN                         RightColumn;
-  UINTN                         TopRow;
-  UINTN                         BottomRow;
-  UINTN                         DimensionsWidth;
-  UINTN                         DimensionsHeight;
-  VA_LIST                       Marker;
-  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));
-  ASSERT (LineBuffer != NULL);
-
-  //
-  // 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 *));
-  LargestString = StrLen (String);
-  StringArray[0] = String;
-
-  VA_START (Marker, String);
-  for (Index = 1; Index < NumberOfLines; Index++) {
-    StackString = VA_ARG (Marker, CHAR16 *);
-
-    if (StackString == NULL) {
-      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);
-
-  return Status;
-}
-
-
-/**
-  Configure the buffer accrording to ConfigBody strings.
-
-  @param  DefaultId              the ID of default.
-  @param  Buffer                 the start address of buffer.
-  @param  BufferSize             the size of buffer.
-  @param  Number                 the number of the strings.
-
-  @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
-ExtractDefault(
-  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 *);
-    CopyMem (&TotalLen, BufCfgArray, sizeof (UINT32));
-    BufferPos = BufCfgArray + sizeof (UINT32);
-
-    while ((UINT32)(BufferPos - BufCfgArray) < TotalLen) {
-      CopyMem (&Offset, BufferPos, sizeof (UINT16));
-      BufferPos += sizeof (UINT16);
-      CopyMem (&Width, BufferPos, sizeof (UINT16));
-      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;
-}
-
-
-/**
-  Swap bytes in the buffer.
-
-  @param  Buffer                 Binary buffer.
-  @param  BufferSize             Size of the buffer in bytes.
-
-  @return None.
-
-**/
-STATIC
-VOID
-SwapBuffer (
-  IN OUT UINT8     *Buffer,
-  IN UINTN         BufferSize
-  )
-{
-  UINTN  Index;
-  UINT8  Temp;
-  UINTN  SwapCount;
-
-  SwapCount = (BufferSize - 1) / 2;
-  for (Index = 0; Index < SwapCount; Index++) {
-    Temp = Buffer[Index];
-    Buffer[Index] = Buffer[BufferSize - 1 - Index];
-    Buffer[BufferSize - 1 - Index] = Temp;
-  }
-}
-
-
-/**
-  Converts binary buffer to Unicode string in reversed byte order from R8_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.
-
-**/
-EFI_STATUS
-BufferToHexString (
-  IN OUT CHAR16    *Str,
-  IN UINT8         *Buffer,
-  IN UINTN         BufferSize
-  )
-{
-  EFI_STATUS  Status;
-  UINT8       *NewBuffer;
-  UINTN       StrBufferLen;
-
-  NewBuffer = AllocateCopyPool (BufferSize, Buffer);
-  SwapBuffer (NewBuffer, BufferSize);
-
-  StrBufferLen = (BufferSize + 1) * sizeof (CHAR16);
-  Status = R8_BufToHexString (Str, &StrBufferLen, NewBuffer, BufferSize);
-
-  gBS->FreePool (NewBuffer);
-
-  return Status;
-}
-
-
-/**
-  Converts Hex String to binary buffer in reversed byte order from R8_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.
-
-**/
-EFI_STATUS
-HexStringToBuffer (
-  IN OUT UINT8         *Buffer,
-  IN OUT UINTN         *BufferSize,
-  IN CHAR16            *Str
-  )
-{
-  EFI_STATUS  Status;
-  UINTN       ConvertedStrLen;
-
-  ConvertedStrLen = 0;
-  Status = R8_HexStringToBuf (Buffer, BufferSize, Str, &ConvertedStrLen);
-  if (!EFI_ERROR (Status)) {
-    SwapBuffer (Buffer, ConvertedStrLen);
-  }
-
-  return Status;
-}
-
-
-/**
-  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            Routine success.
-  @retval EFI_BUFFER_TOO_SMALL   The ConfigHdr string buffer is too small.
-
-**/
-EFI_STATUS
-ConstructConfigHdr (
-  IN OUT CHAR16                *ConfigHdr,
-  IN OUT UINTN                 *StrBufferLen,
-  IN 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;
-
-  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=<Alpha>NameStrLen&PATH=<HexChar>DevicePathStrLen <NULL>
-  // | 5  |   32   |  6  |   NameStrLen   |  6  |    DevicePathStrLen   |
-  //
-  BufferSize = (5 + 32 + 6 + NameStrLen + 6 + DevicePathSize * 2 + 1) * sizeof (CHAR16);
-  if (*StrBufferLen < BufferSize) {
-    *StrBufferLen = BufferSize;
-    return EFI_BUFFER_TOO_SMALL;
-  }
-
-  *StrBufferLen = BufferSize;
-
-  StrPtr = ConfigHdr;
-
-  StrCpy (StrPtr, L"GUID=");
-  StrPtr += 5;
-  BufferToHexString (StrPtr, (UINT8 *) Guid, sizeof (EFI_GUID));
-  StrPtr += 32;
-
-  StrCpy (StrPtr, L"&NAME=");
-  StrPtr += 6;
-  if (Name != NULL) {
-    StrCpy (StrPtr, Name);
-    StrPtr += NameStrLen;
-  }
-
-  StrCpy (StrPtr, L"&PATH=");
-  StrPtr += 6;
-  BufferToHexString (StrPtr, (UINT8 *) DevicePath, DevicePathSize);
-
-  return EFI_SUCCESS;
-}
-
-
-/**
-  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
-FindBlockName (
-  IN OUT CHAR16                *String,
-  UINTN                        Offset,
-  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 = R8_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 = R8_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            Routine success.
-  @retval EFI_BUFFER_TOO_SMALL   The intput buffer is too small.
-
-**/
-EFI_STATUS
-GetBrowserData (
-  EFI_GUID                   *VariableGuid, OPTIONAL
-  CHAR16                     *VariableName, OPTIONAL
-  UINTN                      *BufferSize,
-  UINT8                      *Buffer
-  )
-{
-  EFI_STATUS                      Status;
-  CHAR16                          *ConfigHdr;
-  CHAR16                          *ConfigResp;
-  CHAR16                          *StringPtr;
-  UINTN                           HeaderLen;
-  UINTN                           BufferLen;
-  CHAR16                          *Progress;
-  EFI_FORM_BROWSER2_PROTOCOL      *FormBrowser2;
-  EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting;
-
-  //
-  // Locate protocols for use
-  //
-  Status = gBS->LocateProtocol (&gEfiFormBrowser2ProtocolGuid, NULL, (VOID **) &FormBrowser2);
-  if (EFI_ERROR (Status)) {
-    return Status;
-  }
-
-  Status = gBS->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid, NULL, (VOID **) &HiiConfigRouting);
-  if (EFI_ERROR (Status)) {
-    return Status;
-  }
-
-  //
-  // Retrive formset storage data from Form Browser
-  //
-  ConfigHdr = mFakeConfigHdr;
-  HeaderLen = StrLen (ConfigHdr);
-
-  BufferLen = 0x4000;
-  ConfigResp = AllocateZeroPool (BufferLen + HeaderLen);
-
-  StringPtr = ConfigResp + HeaderLen;
-  *StringPtr = L'&';
-  StringPtr++;
-
-  Status = FormBrowser2->BrowserCallback (
-                           FormBrowser2,
-                           &BufferLen,
-                           StringPtr,
-                           TRUE,
-                           VariableGuid,
-                           VariableName
-                           );
-  if (Status == EFI_BUFFER_TOO_SMALL) {
-    gBS->FreePool (ConfigResp);
-    ConfigResp = AllocateZeroPool (BufferLen + HeaderLen);
-
-    StringPtr = ConfigResp + HeaderLen;
-    *StringPtr = L'&';
-    StringPtr++;
-
-    Status = FormBrowser2->BrowserCallback (
-                             FormBrowser2,
-                             &BufferLen,
-                             StringPtr,
-                             TRUE,
-                             VariableGuid,
-                             VariableName
-                             );
-  }
-  if (EFI_ERROR (Status)) {
-    gBS->FreePool (ConfigResp);
-    return Status;
-  }
-  CopyMem (ConfigResp, ConfigHdr, HeaderLen * sizeof (UINT16));
-
-  //
-  // Convert <ConfigResp> to buffer data
-  //
-  Status = HiiConfigRouting->ConfigToBlock (
-                               HiiConfigRouting,
-                               ConfigResp,
-                               Buffer,
-                               BufferSize,
-                               &Progress
-                               );
-  gBS->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            Routine success.
-  @retval Other                  Updating Browser uncommitted data failed.
-
-**/
-EFI_STATUS
-SetBrowserData (
-  EFI_GUID                   *VariableGuid, OPTIONAL
-  CHAR16                     *VariableName, OPTIONAL
-  UINTN                      BufferSize,
-  UINT8                      *Buffer,
-  CHAR16                     *RequestElement  OPTIONAL
-  )
-{
-  EFI_STATUS                      Status;
-  CHAR16                          *ConfigHdr;
-  CHAR16                          *ConfigResp;
-  CHAR16                          *StringPtr;
-  UINTN                           HeaderLen;
-  UINTN                           BufferLen;
-  CHAR16                          *Progress;
-  EFI_FORM_BROWSER2_PROTOCOL      *FormBrowser2;
-  EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting;
-  CHAR16                          BlockName[33];
-  CHAR16                          *ConfigRequest;
-  CHAR16                          *Request;
-
-  //
-  // Locate protocols for use
-  //
-  Status = gBS->LocateProtocol (&gEfiFormBrowser2ProtocolGuid, NULL, (VOID **) &FormBrowser2);
-  if (EFI_ERROR (Status)) {
-    return Status;
-  }
-
-  Status = gBS->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid, NULL, (VOID **) &HiiConfigRouting);
-  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));
-    R8_BufToHexString (StringPtr, &BufferLen, (UINT8 *) &BufferSize, sizeof (UINTN));
-
-    Request = BlockName;
-  } else {
-    Request = RequestElement;
-  }
-
-  BufferLen = HeaderLen * sizeof (CHAR16) + StrSize (Request);
-  ConfigRequest = AllocateZeroPool (BufferLen);
-
-  CopyMem (ConfigRequest, ConfigHdr, HeaderLen * sizeof (CHAR16));
-  StringPtr = ConfigRequest + HeaderLen;
-  StrCpy (StringPtr, Request);
-
-  //
-  // Convert buffer to <ConfigResp>
-  //
-  Status = HiiConfigRouting->BlockToConfig (
-                                HiiConfigRouting,
-                                ConfigRequest,
-                                Buffer,
-                                BufferSize,
-                                &ConfigResp,
-                                &Progress
-                                );
-  if (EFI_ERROR (Status)) {
-    gBS->FreePool (ConfigResp);
-    return Status;
-  }
-
-  //
-  // Skip <ConfigHdr> and '&'
-  //
-  StringPtr = ConfigResp + HeaderLen + 1;
-
-  //
-  // Change uncommitted data in Browser
-  //
-  Status = FormBrowser2->BrowserCallback (
-                           FormBrowser2,
-                           &BufferSize,
-                           StringPtr,
-                           FALSE,
-                           NULL,
-                           NULL
-                           );
-  gBS->FreePool (ConfigResp);
-  return Status;
-}
diff --git a/edk2/MdeModulePkg/Library/IfrSupportLib/UefiIfrOpCodeCreation.c b/edk2/MdeModulePkg/Library/IfrSupportLib/UefiIfrOpCodeCreation.c
deleted file mode 100644 (file)
index 240f020..0000000
+++ /dev/null
@@ -1,639 +0,0 @@
-/** @file
-
-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.
-
-Module Name:
-
-  UefiIfrOpCodeCreation.c
-
-Abstract:
-
-  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.
-
-Revision History:
-
-
-**/
-
-#include "UefiIfrLibraryInternal.h"
-
-STATIC EFI_GUID mIfrVendorGuid = EFI_IFR_TIANO_GUID;
-
-STATIC
-BOOLEAN
-IsValidQuestionFlags (
-  IN UINT8                   Flags
-  )
-{
-  return (BOOLEAN) ((Flags & (~QUESTION_FLAGS)) ? FALSE : TRUE);
-}
-
-STATIC
-BOOLEAN
-IsValidValueType (
-  IN UINT8                   Type
-  )
-{
-  return (BOOLEAN) ((Type <= EFI_IFR_TYPE_OTHER) ? TRUE : FALSE);
-}
-
-STATIC
-BOOLEAN
-IsValidNumricFlags (
-  IN UINT8                   Flags
-  )
-{
-  if (Flags & ~(EFI_IFR_NUMERIC_SIZE | EFI_IFR_DISPLAY)) {
-    return FALSE;
-  }
-
-  if ((Flags & EFI_IFR_DISPLAY) > EFI_IFR_DISPLAY_UINT_HEX) {
-    return FALSE;
-  }
-
-  return TRUE;
-}
-
-STATIC
-BOOLEAN
-IsValidCheckboxFlags (
-  IN UINT8                   Flags
-  )
-{
-  return (BOOLEAN) ((Flags <= EFI_IFR_CHECKBOX_DEFAULT_MFG) ? TRUE : FALSE);
-}
-
-EFI_STATUS
-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 (LocalBuffer, &End, sizeof (EFI_IFR_END));
-  Data->Offset += sizeof (EFI_IFR_END);
-
-  return EFI_SUCCESS;
-}
-
-EFI_STATUS
-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 (LocalBuffer, &Default, sizeof (EFI_IFR_DEFAULT));
-  Data->Offset += sizeof (EFI_IFR_DEFAULT);
-
-  return EFI_SUCCESS;
-}
-
-EFI_STATUS
-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 (LocalBuffer, &Action, sizeof (EFI_IFR_ACTION));
-  Data->Offset += sizeof (EFI_IFR_ACTION);
-
-  return EFI_SUCCESS;
-}
-
-EFI_STATUS
-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 (LocalBuffer, &Subtitle, sizeof (EFI_IFR_SUBTITLE));
-  Data->Offset += sizeof (EFI_IFR_SUBTITLE);
-
-  return EFI_SUCCESS;
-}
-
-
-EFI_STATUS
-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 (LocalBuffer, &Text, sizeof (EFI_IFR_TEXT));
-  Data->Offset += sizeof (EFI_IFR_TEXT);
-
-  return EFI_SUCCESS;
-}
-
-EFI_STATUS
-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 (LocalBuffer, &Goto, sizeof (EFI_IFR_REF));
-  Data->Offset += sizeof (EFI_IFR_REF);
-
-  return EFI_SUCCESS;
-}
-
-EFI_STATUS
-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 (LocalBuffer, &OneOfOption, sizeof (EFI_IFR_ONE_OF_OPTION));
-    Data->Offset += sizeof (EFI_IFR_ONE_OF_OPTION);
-  }
-
-  return EFI_SUCCESS;
-}
-
-EFI_STATUS
-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 (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;
-}
-
-EFI_STATUS
-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 (LocalBuffer, &OrderedList, sizeof (EFI_IFR_ORDERED_LIST));
-  Data->Offset += sizeof (EFI_IFR_ORDERED_LIST);
-
-  CreateOneOfOptionOpCode (OptionCount, OptionsList, DataType, Data);
-
-  CreateEndOpCode (Data);
-
-  return EFI_SUCCESS;
-}
-
-EFI_STATUS
-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 (LocalBuffer, &CheckBox, sizeof (EFI_IFR_CHECKBOX));
-  Data->Offset += sizeof (EFI_IFR_CHECKBOX);
-
-  return EFI_SUCCESS;
-}
-
-EFI_STATUS
-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 (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;
-}
-
-EFI_STATUS
-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))) {
-    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 (LocalBuffer, &String, sizeof (EFI_IFR_STRING));
-  Data->Offset += sizeof (EFI_IFR_STRING);
-
-  return EFI_SUCCESS;
-}
-
-EFI_STATUS
-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, &mIfrVendorGuid, 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/edk2/MdeModulePkg/Library/IfrSupportLib/UefiIfrString.c b/edk2/MdeModulePkg/Library/IfrSupportLib/UefiIfrString.c
deleted file mode 100644 (file)
index 2536940..0000000
+++ /dev/null
@@ -1,681 +0,0 @@
-/** @file
-
-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.
-
-Module Name:
-
-  UefiIfrString.c
-
-Abstract:
-
-  Common Library Routines to assist to handle String and Language.
-
-
-**/
-
-#include "UefiIfrLibraryInternal.h"
-
-//
-// Lookup table of ISO639-2 3 character language codes to ISO 639-1 2 character language codes
-// Each entry is 5 CHAR8 values long.  The first 3 CHAR8 values are the ISO 639-2 code.
-// The last 2 CHAR8 values are the ISO 639-1 code.
-//
-CHAR8 Iso639ToRfc3066ConversionTable[] =
-"\
-aaraa\
-abkab\
-afraf\
-amham\
-araar\
-asmas\
-aymay\
-azeaz\
-bakba\
-belbe\
-benbn\
-bihbh\
-bisbi\
-bodbo\
-brebr\
-bulbg\
-catca\
-cescs\
-corkw\
-cosco\
-cymcy\
-danda\
-deude\
-dzodz\
-ellel\
-engen\
-epoeo\
-estet\
-euseu\
-faofo\
-fasfa\
-fijfj\
-finfi\
-frafr\
-fryfy\
-gaiga\
-gdhgd\
-glggl\
-grngn\
-gujgu\
-hauha\
-hebhe\
-hinhi\
-hrvhr\
-hunhu\
-hyehy\
-ikuiu\
-ileie\
-inaia\
-indid\
-ipkik\
-islis\
-itait\
-jawjw\
-jpnja\
-kalkl\
-kankn\
-kasks\
-katka\
-kazkk\
-khmkm\
-kinrw\
-kirky\
-korko\
-kurku\
-laolo\
-latla\
-lavlv\
-linln\
-litlt\
-ltzlb\
-malml\
-marmr\
-mkdmk\
-mlgmg\
-mltmt\
-molmo\
-monmn\
-mrimi\
-msams\
-myamy\
-nauna\
-nepne\
-nldnl\
-norno\
-ocioc\
-ormom\
-panpa\
-polpl\
-porpt\
-pusps\
-quequ\
-rohrm\
-ronro\
-runrn\
-rusru\
-sagsg\
-sansa\
-sinsi\
-slksk\
-slvsl\
-smise\
-smosm\
-snasn\
-sndsd\
-somso\
-sotst\
-spaes\
-sqisq\
-srpsr\
-sswss\
-sunsu\
-swasw\
-swesv\
-tamta\
-tattt\
-telte\
-tgktg\
-tgltl\
-thath\
-tsnts\
-tuktk\
-twitw\
-uigug\
-ukruk\
-urdur\
-uzbuz\
-vievi\
-volvo\
-wolwo\
-xhoxh\
-yidyi\
-zhaza\
-zhozh\
-zulzu\
-";
-
-
-/**
-  Convert language code from RFC3066 to ISO639-2.
-
-  @param  LanguageRfc3066        RFC3066 language code.
-  @param  LanguageIso639         ISO639-2 language code.
-
-  @retval EFI_SUCCESS            Language code converted.
-  @retval EFI_NOT_FOUND          Language code not found.
-
-**/
-EFI_STATUS
-ConvertRfc3066LanguageToIso639Language (
-  CHAR8   *LanguageRfc3066,
-  CHAR8   *LanguageIso639
-  )
-{
-  UINTN  Index;
-
-  if ((LanguageRfc3066[2] != '-') && (LanguageRfc3066[2] != 0)) {
-    CopyMem (LanguageIso639, LanguageRfc3066, 3);
-    return EFI_SUCCESS;
-  }
-
-  for (Index = 0; Iso639ToRfc3066ConversionTable[Index] != 0; Index += 5) {
-    if (CompareMem (LanguageRfc3066, &Iso639ToRfc3066ConversionTable[Index + 3], 2) == 0) {
-      CopyMem (LanguageIso639, &Iso639ToRfc3066ConversionTable[Index], 3);
-      return EFI_SUCCESS;
-    }
-  }
-
-  return EFI_NOT_FOUND;
-}
-
-
-/**
-  Convert language code list from RFC3066 to ISO639-2, e.g. "en-US;fr-FR" will
-  be converted to "engfra".
-
-  @param  SupportedLanguages     The RFC3066 language list.
-
-  @return The ISO639-2 language list.
-
-**/
-CHAR8 *
-Rfc3066ToIso639 (
-  CHAR8  *SupportedLanguages
-  )
-{
-  CHAR8       *Languages;
-  CHAR8       *ReturnValue;
-  CHAR8       *LangCodes;
-  CHAR8       LangRfc3066[RFC_3066_ENTRY_SIZE];
-  CHAR8       LangIso639[ISO_639_2_ENTRY_SIZE];
-  EFI_STATUS  Status;
-
-  ReturnValue = AllocateZeroPool (AsciiStrSize (SupportedLanguages));
-  if (ReturnValue == NULL) {
-    return ReturnValue;
-  }
-
-  Languages = ReturnValue;
-  LangCodes = SupportedLanguages;
-  while (*LangCodes != 0) {
-    GetNextLanguage (&LangCodes, LangRfc3066);
-
-    Status = ConvertRfc3066LanguageToIso639Language (LangRfc3066, LangIso639);
-    if (!EFI_ERROR (Status)) {
-      CopyMem (Languages, LangIso639, 3);
-      Languages = Languages + 3;
-    }
-  }
-
-  return ReturnValue;
-}
-
-
-/**
-  Determine what is the current language setting
-
-  @param  Lang                   Pointer of system language
-
-  @return Status code
-
-**/
-EFI_STATUS
-GetCurrentLanguage (
-  OUT     CHAR8               *Lang
-  )
-{
-  EFI_STATUS  Status;
-  UINTN       Size;
-
-  //
-  // Get current language setting
-  //
-  Size = RFC_3066_ENTRY_SIZE;
-  Status = gRT->GetVariable (
-                  L"PlatformLang",
-                  &gEfiGlobalVariableGuid,
-                  NULL,
-                  &Size,
-                  Lang
-                  );
-
-  if (EFI_ERROR (Status)) {
-    AsciiStrCpy (Lang, (CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLang));
-  }
-
-  return Status;
-}
-
-
-/**
-  Get next language from language code list (with separator ';').
-
-  @param  LangCode               On input: point to first language in the list. On
-                                 output: point to next language in the list, or
-                                 NULL if no more language in the list.
-  @param  Lang                   The first language in the list.
-
-  @return None.
-
-**/
-VOID
-GetNextLanguage (
-  IN OUT CHAR8      **LangCode,
-  OUT CHAR8         *Lang
-  )
-{
-  UINTN  Index;
-  CHAR8  *StringPtr;
-
-  if (LangCode == NULL || *LangCode == NULL) {
-    *Lang = 0;
-    return;
-  }
-
-  Index = 0;
-  StringPtr = *LangCode;
-  while (StringPtr[Index] != 0 && StringPtr[Index] != ';') {
-    Index++;
-  }
-
-  CopyMem (Lang, StringPtr, Index);
-  Lang[Index] = 0;
-
-  if (StringPtr[Index] == ';') {
-    Index++;
-  }
-  *LangCode = StringPtr + Index;
-}
-
-
-/**
-  This function returns the list of supported languages, in the format specified
-  in UEFI specification Appendix¬†M.
-
-  @param  HiiHandle              The HII package list handle.
-
-  @return The supported languages.
-
-**/
-CHAR8 *
-GetSupportedLanguages (
-  IN EFI_HII_HANDLE           HiiHandle
-  )
-{
-  EFI_STATUS  Status;
-  UINTN       BufferSize;
-  CHAR8       *LanguageString;
-
-  LocateHiiProtocols ();
-
-  //
-  // Collect current supported Languages for given HII handle
-  //
-  BufferSize = 0x1000;
-  LanguageString = AllocatePool (BufferSize);
-  Status = gIfrLibHiiString->GetLanguages (gIfrLibHiiString, HiiHandle, LanguageString, &BufferSize);
-  if (Status == EFI_BUFFER_TOO_SMALL) {
-    gBS->FreePool (LanguageString);
-    LanguageString = AllocatePool (BufferSize);
-    Status = gIfrLibHiiString->GetLanguages (gIfrLibHiiString, HiiHandle, LanguageString, &BufferSize);
-  }
-
-  if (EFI_ERROR (Status)) {
-    LanguageString = NULL;
-  }
-
-  return LanguageString;
-}
-
-
-/**
-  This function returns the number of supported languages
-
-  @param  HiiHandle              The HII package list handle.
-
-  @return The  number of supported languages.
-
-**/
-UINT16
-GetSupportedLanguageNumber (
-  IN EFI_HII_HANDLE           HiiHandle
-  )
-{
-  CHAR8   *Languages;
-  CHAR8   *LanguageString;
-  UINT16  LangNumber;
-  CHAR8   Lang[RFC_3066_ENTRY_SIZE];
-
-  Languages = GetSupportedLanguages (HiiHandle);
-  if (Languages == NULL) {
-    return 0;
-  }
-
-  LangNumber = 0;
-  LanguageString = Languages;
-  while (*LanguageString != 0) {
-    GetNextLanguage (&LanguageString, Lang);
-    LangNumber++;
-  }
-  gBS->FreePool (Languages);
-
-  return LangNumber;
-}
-
-
-/**
-  Get string specified by StringId form the HiiHandle.
-
-  @param  HiiHandle              The HII handle of package list.
-  @param  StringId               The String ID.
-  @param  String                 The output string.
-
-  @retval EFI_NOT_FOUND          String is not found.
-  @retval EFI_SUCCESS            Operation is successful.
-  @retval EFI_OUT_OF_RESOURCES   There is not enought memory in the system.
-  @retval EFI_INVALID_PARAMETER  The String is NULL.
-
-**/
-EFI_STATUS
-GetStringFromHandle (
-  IN  EFI_HII_HANDLE                  HiiHandle,
-  IN  EFI_STRING_ID                   StringId,
-  OUT EFI_STRING                      *String
-  )
-{
-  EFI_STATUS                          Status;
-  UINTN                               StringSize;
-
-  if (String == NULL) {
-    return EFI_INVALID_PARAMETER;
-  }
-
-  StringSize = IFR_LIB_DEFAULT_STRING_SIZE;
-  *String    = AllocateZeroPool (StringSize);
-  if (*String == NULL) {
-    return EFI_OUT_OF_RESOURCES;
-  }
-
-  Status = IfrLibGetString (HiiHandle, StringId, *String, &StringSize);
-  if (Status == EFI_BUFFER_TOO_SMALL) {
-    gBS->FreePool (*String);
-    *String = AllocateZeroPool (StringSize);
-    if (*String == NULL) {
-      return EFI_OUT_OF_RESOURCES;
-    }
-    Status = IfrLibGetString (HiiHandle, StringId, *String, &StringSize);
-  }
-
-  return Status;
-}
-
-
-/**
-  Get the string given the StringId and String package Producer's Guid.
-
-  @param  ProducerGuid           The Guid of String package list.
-  @param  StringId               The String ID.
-  @param  String                 The output string.
-
-  @retval EFI_NOT_FOUND          String is not found.
-  @retval EFI_SUCCESS            Operation is successful.
-  @retval EFI_OUT_OF_RESOURCES   There is not enought memory in the system.
-
-**/
-EFI_STATUS
-GetStringFromToken (
-  IN  EFI_GUID                        *ProducerGuid,
-  IN  EFI_STRING_ID                   StringId,
-  OUT EFI_STRING                      *String
-  )
-{
-  EFI_STATUS      Status;
-  UINTN           Index;
-  UINTN           HandleBufferLen;
-  EFI_HII_HANDLE  *HiiHandleBuffer;
-  EFI_GUID        Guid;
-
-  Status = GetHiiHandles (&HandleBufferLen, &HiiHandleBuffer);
-  if (EFI_ERROR(Status)) {
-    return Status;
-  }
-  for (Index = 0; Index < (HandleBufferLen / sizeof (EFI_HII_HANDLE)); Index++) {
-    Status = ExtractGuidFromHiiHandle (HiiHandleBuffer[Index], &Guid);
-    if (EFI_ERROR(Status)) {
-      return Status;
-    }
-    if (CompareGuid (&Guid, ProducerGuid) == TRUE) {
-      break;
-    }
-  }
-
-  if (Index >= (HandleBufferLen / sizeof (EFI_HII_HANDLE))) {
-    Status = EFI_NOT_FOUND;
-    goto Out;
-  }
-
-  Status = GetStringFromHandle (HiiHandleBuffer[Index], StringId, String);
-
-Out:
-  if (HiiHandleBuffer != NULL) {
-    gBS->FreePool (HiiHandleBuffer);
-  }
-  return Status;
-}
-
-
-/**
-  This function adds the string into String Package of each language.
-
-  @param  PackageList            Handle of the package list where this string will
-                                 be added.
-  @param  StringId               On return, contains the new strings id, which is
-                                 unique within PackageList.
-  @param  String                 Points to the new null-terminated string.
-
-  @retval EFI_SUCCESS            The new string was added successfully.
-  @retval EFI_NOT_FOUND          The specified PackageList could not be found in
-                                 database.
-  @retval EFI_OUT_OF_RESOURCES   Could not add the string due to lack of resources.
-  @retval EFI_INVALID_PARAMETER  String is NULL or StringId is NULL is NULL.
-
-**/
-EFI_STATUS
-IfrLibNewString (
-  IN  EFI_HII_HANDLE                  PackageList,
-  OUT EFI_STRING_ID                   *StringId,
-  IN  CONST EFI_STRING                String
-  )
-{
-  EFI_STATUS  Status;
-  CHAR8       *Languages;
-  CHAR8       *LangStrings;
-  CHAR8       Lang[RFC_3066_ENTRY_SIZE];
-
-  Status = EFI_SUCCESS;
-
-  LocateHiiProtocols ();
-
-  Languages = GetSupportedLanguages (PackageList);
-
-  LangStrings = Languages;
-  while (*LangStrings != 0) {
-    GetNextLanguage (&LangStrings, Lang);
-
-    Status = gIfrLibHiiString->NewString (
-                                 gIfrLibHiiString,
-                                 PackageList,
-                                 StringId,
-                                 Lang,
-                                 NULL,
-                                 String,
-                                 NULL
-                                 );
-    if (EFI_ERROR (Status)) {
-      break;
-    }
-  }
-
-  gBS->FreePool (Languages);
-
-  return Status;
-}
-
-
-/**
-  This function try to retrieve string from String package of current language.
-  If fail, it try to retrieve string from String package of first language it support.
-
-  @param  PackageList            The package list in the HII database to search for
-                                 the specified string.
-  @param  StringId               The string's id, which is unique within
-                                 PackageList.
-  @param  String                 Points to the new null-terminated string.
-  @param  StringSize             On entry, points to the size of the buffer pointed
-                                 to by String, in bytes. On return, points to the
-                                 length of the string, in bytes.
-
-  @retval EFI_SUCCESS            The string was returned successfully.
-  @retval EFI_NOT_FOUND          The string specified by StringId is not available.
-  @retval EFI_BUFFER_TOO_SMALL   The buffer specified by StringLength is too small
-                                 to hold the string.
-  @retval EFI_INVALID_PARAMETER  The String or StringSize was NULL.
-
-**/
-EFI_STATUS
-IfrLibGetString (
-  IN  EFI_HII_HANDLE                  PackageList,
-  IN  EFI_STRING_ID                   StringId,
-  OUT EFI_STRING                      String,
-  IN  OUT UINTN                       *StringSize
-  )
-{
-  EFI_STATUS  Status;
-  CHAR8       *Languages;
-  CHAR8       *LangStrings;
-  CHAR8       Lang[RFC_3066_ENTRY_SIZE];
-  CHAR8       CurrentLang[RFC_3066_ENTRY_SIZE];
-
-  LocateHiiProtocols ();
-
-  GetCurrentLanguage (CurrentLang);
-
-  Status = gIfrLibHiiString->GetString (
-                               gIfrLibHiiString,
-                               CurrentLang,
-                               PackageList,
-                               StringId,
-                               String,
-                               StringSize,
-                               NULL
-                               );
-
-  if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
-    Languages = GetSupportedLanguages (PackageList);
-    LangStrings = Languages;
-    GetNextLanguage (&LangStrings, Lang);
-    gBS->FreePool (Languages);
-
-    Status = gIfrLibHiiString->GetString (
-                                 gIfrLibHiiString,
-                                 Lang,
-                                 PackageList,
-                                 StringId,
-                                 String,
-                                 StringSize,
-                                 NULL
-                                 );
-  }
-
-  return Status;
-}
-
-
-/**
-  This function updates the string in String package of each language.
-
-  @param  PackageList            The package list containing the strings.
-  @param  StringId               The string's id, which is unique within
-                                 PackageList.
-  @param  String                 Points to the new null-terminated string.
-
-  @retval EFI_SUCCESS            The string was updated successfully.
-  @retval EFI_NOT_FOUND          The string specified by StringId is not in the
-                                 database.
-  @retval EFI_INVALID_PARAMETER  The String was NULL.
-  @retval EFI_OUT_OF_RESOURCES   The system is out of resources to accomplish the
-                                 task.
-
-**/
-EFI_STATUS
-IfrLibSetString (
-  IN EFI_HII_HANDLE                   PackageList,
-  IN EFI_STRING_ID                    StringId,
-  IN CONST EFI_STRING                 String
-  )
-{
-  EFI_STATUS  Status;
-  CHAR8       *Languages;
-  CHAR8       *LangStrings;
-  CHAR8       Lang[RFC_3066_ENTRY_SIZE];
-
-  Status = EFI_SUCCESS;
-
-  LocateHiiProtocols ();
-
-  Languages = GetSupportedLanguages (PackageList);
-
-  LangStrings = Languages;
-  while (*LangStrings != 0) {
-    GetNextLanguage (&LangStrings, Lang);
-
-    Status = gIfrLibHiiString->SetString (
-                                 gIfrLibHiiString,
-                                 PackageList,
-                                 StringId,
-                                 Lang,
-                                 String,
-                                 NULL
-                                 );
-    if (EFI_ERROR (Status)) {
-      break;
-    }
-  }
-
-  gBS->FreePool (Languages);
-
-  return Status;
-}
-
index 907a06d..dbe8720 100644 (file)
@@ -35,6 +35,8 @@
   RecoveryLib|Include/Library/RecoveryLib.h\r
   GenericBdsLib.h|Include/Library/GenericBdsLib.h\r
   PlatDriOverLib|Include/Library/PlatDriOverLib.h\r
+  ExtendedHiiLib|Include/Library/ExtendedHiiLib.h\r
+  ExtendedIfrSupportLib|Include/Library/ExtendedIfrSupportLib.h\r
 \r
 [Guids.common]\r
 \r
index 4845262..a19a85b 100644 (file)
@@ -63,6 +63,7 @@
   FvbServiceLib|MdeModulePkg/Library/EdkFvbServiceLib/EdkFvbServiceLib.inf\r
   ScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf\r
   HiiLib|MdePkg/Library/HiiLib/HiiLib.inf\r
+  ExtendedHiiLib|MdeModulePkg/Library/ExtendedHiiLib/ExtendedHiiLib.inf\r
   UsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf\r
   NetLib|MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf\r
   IpIoLib|MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.inf\r
   DpcLib|MdeModulePkg/Library/DxeDpcLib/DxeDpcLib.inf\r
   PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
   GraphicsLib|MdeModulepkg/Library/GraphicsLib/GraphicsLib.inf\r
-  IfrSupportLib|MdeModulePkg/Library/IfrSupportLib/IfrSupportLib.inf\r
+  IfrSupportLib|MdePkg/Library/IfrSupportLib/IfrSupportLib.inf\r
+  ExtendedIfrSupportLib|MdeModulePkg/Library/ExtendedIfrSupportLib/ExtendedIfrSupportLib.inf\r
   CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf\r
   DxePiLib|MdePkg/Library/DxePiLib/DxePiLib.inf\r
   PlatformBdsLib|MdeModulePkg/Library/PlatformBdsLibNull/PlatformBdsLibNull.inf\r
   GenericBdsLib|MdeModulePkg/Library/GenericBdsLib/GenericBdsLib.inf  \r
   GraphicsLib|MdeModulepkg/Library/GraphicsLib/GraphicsLib.inf\r
-  IfrSupportLib|MdeModulePkg/Library/IfrSupportLib/IfrSupportLib.inf\r
   DxePiLib|MdePkg/Library/DxePiLib/DxePiLib.inf\r
   PlatformBdsLib|MdeModulePkg/Library/PlatformBdsLibNull/PlatformBdsLibNull.inf\r
   GenericBdsLib|MdeModulePkg/Library/GenericBdsLib/GenericBdsLib.inf  \r
   MdeModulePkg/Library/PeiS3LibNull/PeiS3LibNull.inf\r
   MdeModulePkg/Library/PeiRecoveryLibNull/PeiRecoveryLibNull.inf\r
 \r
-  MdeModulePkg/Library/IfrSupportLib/IfrSupportLib.inf\r
   MdeModulePkg/Library/GenericBdsLib/GenericBdsLib.inf\r
   MdeModulepkg/Library/GraphicsLib/GraphicsLib.inf\r
+  MdeModulePkg/Library/ExtendedHiiLib/ExtendedHiiLib.inf\r
+  MdeModulePkg/Library/ExtendedIfrSupportLib/ExtendedIfrSupportLib.inf\r
 \r
   MdeModulePkg/Library/PlatformBdsLibNull/PlatformBdsLibNull.inf\r
 \r
index fbfa965..7c76120 100644 (file)
@@ -70,6 +70,7 @@ Revision History
 #include <Library/PerformanceLib.h>\r
 #include <Library/ReportStatusCodeLib.h>\r
 #include <Library/IfrSupportLib.h>\r
+#include <Library/ExtendedIfrSupportLib.h>\r
 #include <Library/UefiRuntimeServicesTableLib.h>\r
 #include <Library/HobLib.h>\r
 #include <Library/BaseLib.h>\r
@@ -77,6 +78,8 @@ Revision History
 #include <Library/PcdLib.h>\r
 #include <Library/CapsuleLib.h>\r
 #include <Library/HiiLib.h>\r
+#include <Library/ExtendedHiiLib.h>\r
+\r
 \r
 #include <Library/GenericBdsLib.h>\r
 #include <Library/PlatformBdsLib.h>\r
index c4c6b7f..f7358f0 100644 (file)
@@ -88,6 +88,7 @@
   HobLib\r
   UefiRuntimeServicesTableLib\r
   IfrSupportLib\r
+  ExtendedIfrSupportLib\r
   GenericBdsLib\r
   ReportStatusCodeLib\r
   PerformanceLib\r
   DebugLib\r
   PrintLib\r
   HiiLib\r
+  ExtendedHiiLib\r
   UefiDriverEntryPoint\r
   PlatformBdsLib\r
   CapsuleLib\r
index 9cf2a9d..63724dc 100644 (file)
@@ -68,7 +68,7 @@ Returns:
   for (Index = 0; Index < MenuOption->MenuNumber; Index++) {\r
     NewMenuEntry = BOpt_GetMenuEntry (MenuOption, Index);\r
 \r
-    IfrLibNewString (\r
+    HiiLibNewString (\r
       HiiHandle,\r
       &NewMenuEntry->DisplayStringToken,\r
       NewMenuEntry->DisplayString\r
@@ -77,7 +77,7 @@ Returns:
     if (NULL == NewMenuEntry->HelpString) {\r
       NewMenuEntry->HelpStringToken = NewMenuEntry->DisplayStringToken;\r
     } else {\r
-      IfrLibNewString (\r
+      HiiLibNewString (\r
         HiiHandle,\r
         &NewMenuEntry->HelpStringToken,\r
         NewMenuEntry->HelpString\r
@@ -885,7 +885,7 @@ Returns:
   //\r
   // Post our Boot Maint VFR binnary to the HII database.\r
   //\r
-  PackageList = PreparePackageList (2, &mBootMaintGuid, BmBin, BdsStrings);\r
+  PackageList = HiiLibPreparePackageList (2, &mBootMaintGuid, BmBin, BdsStrings);\r
   ASSERT (PackageList != NULL);\r
 \r
   Status = gHiiDatabase->NewPackageList (\r
@@ -899,7 +899,7 @@ Returns:
   //\r
   // Post our File Explorer VFR binary to the HII database.\r
   //\r
-  PackageList = PreparePackageList (2, &mFileExplorerGuid, FEBin, BdsStrings);\r
+  PackageList = HiiLibPreparePackageList (2, &mFileExplorerGuid, FEBin, BdsStrings);\r
   ASSERT (PackageList != NULL);\r
 \r
   Status = gHiiDatabase->NewPackageList (\r
@@ -1124,7 +1124,7 @@ Returns:
     //\r
     NextListNode = EfiAllocateZeroPool (sizeof (STRING_LIST_NODE));\r
 \r
-    IfrLibNewString (CallbackData->BmmHiiHandle, &(NextListNode->StringToken), L" ");\r
+    HiiLibNewString (CallbackData->BmmHiiHandle, &(NextListNode->StringToken), L" ");\r
     ASSERT (NextListNode->StringToken != 0);\r
 \r
     StringDepository->TotalNodeNumber++;\r
index d1608bf..06a879a 100644 (file)
@@ -688,7 +688,7 @@ Returns:
     UnicodeValueToString (RowString, 0, Row, 0);\r
     StrCat (ModeString, RowString);\r
 \r
-    IfrLibNewString (CallbackData->BmmHiiHandle, &ModeToken[Index], ModeString);\r
+    HiiLibNewString (CallbackData->BmmHiiHandle, &ModeToken[Index], ModeString);\r
 \r
     IfrOptionList[Index].StringToken  = ModeToken[Index];\r
     IfrOptionList[Index].Value.u16    = (UINT16) Mode;\r
@@ -1142,11 +1142,11 @@ UpdateSetLegacyDeviceOrderPage (
       //\r
       UnicodeSPrint (String, sizeof (String), TypeStr, Index);\r
       StrRef = 0;\r
-      IfrLibNewString (CallbackData->BmmHiiHandle, &StrRef, String);\r
+      HiiLibNewString (CallbackData->BmmHiiHandle, &StrRef, String);\r
 \r
       UnicodeSPrint (String, sizeof (String), TypeStrHelp, Index);\r
       StrRefHelp = 0;\r
-      IfrLibNewString (CallbackData->BmmHiiHandle, &StrRefHelp, String);\r
+      HiiLibNewString (CallbackData->BmmHiiHandle, &StrRefHelp, String);\r
 \r
       CreateOneOfOpCode (\r
         (EFI_QUESTION_ID) (Key + Index),\r
index f5a1038..cd18c03 100644 (file)
@@ -601,13 +601,13 @@ Var_UpdateDriverOption (
                                       CallbackData,\r
                                       DriverOptionStrDepository\r
                                       );\r
-  IfrLibNewString (HiiHandle, &NewMenuEntry->DisplayStringToken, NewMenuEntry->DisplayString);\r
+  HiiLibNewString (HiiHandle, &NewMenuEntry->DisplayStringToken, NewMenuEntry->DisplayString);\r
 \r
   NewMenuEntry->HelpStringToken = GetStringTokenFromDepository (\r
                                     CallbackData,\r
                                     DriverOptionHelpStrDepository\r
                                     );\r
-  IfrLibNewString (HiiHandle, &NewMenuEntry->HelpStringToken, NewMenuEntry->HelpString);\r
+  HiiLibNewString (HiiHandle, &NewMenuEntry->HelpStringToken, NewMenuEntry->HelpString);\r
 \r
   if (OptionalDataExist) {\r
     Ptr += (UINT8) GetDevicePathSize (CallbackData->LoadContext->FilePathList);\r
@@ -759,13 +759,13 @@ Var_UpdateBootOption (
                                       CallbackData,\r
                                       BootOptionStrDepository\r
                                       );\r
-  IfrLibNewString (CallbackData->FeHiiHandle, &NewMenuEntry->DisplayStringToken, NewMenuEntry->DisplayString);\r
+  HiiLibNewString (CallbackData->FeHiiHandle, &NewMenuEntry->DisplayStringToken, NewMenuEntry->DisplayString);\r
 \r
   NewMenuEntry->HelpStringToken = GetStringTokenFromDepository (\r
                                     CallbackData,\r
                                     BootOptionHelpStrDepository\r
                                     );\r
-  IfrLibNewString (CallbackData->FeHiiHandle, &NewMenuEntry->HelpStringToken, NewMenuEntry->HelpString);\r
+  HiiLibNewString (CallbackData->FeHiiHandle, &NewMenuEntry->HelpStringToken, NewMenuEntry->HelpString);\r
 \r
   if (OptionalDataExist) {\r
     Ptr += (UINT8) GetDevicePathSize (CallbackData->LoadContext->FilePathList);\r
index fdf39ca..fec8740 100644 (file)
@@ -151,7 +151,7 @@ Returns:
   //\r
   // Publish our HII data\r
   //\r
-  PackageList = PreparePackageList (2, &mBootManagerGuid, BootManagerVfrBin, BdsStrings);\r
+  PackageList = HiiLibPreparePackageList (2, &mBootManagerGuid, BootManagerVfrBin, BdsStrings);\r
   ASSERT (PackageList != NULL);\r
 \r
   Status = gHiiDatabase->NewPackageList (\r
@@ -246,7 +246,7 @@ Returns:
       continue;\r
     }\r
 \r
-    IfrLibNewString (HiiHandle, &Token, Option->Description);\r
+    HiiLibNewString (HiiHandle, &Token, Option->Description);\r
 \r
     TempStr = DevicePathToStr (Option->DevicePath);\r
     TempSize = StrSize (TempStr);\r
@@ -254,7 +254,7 @@ Returns:
     StrCat (HelpString, L"Device Path : ");\r
     StrCat (HelpString, TempStr);\r
 \r
-    IfrLibNewString (HiiHandle, &HelpToken, HelpString);\r
+    HiiLibNewString (HiiHandle, &HelpToken, HelpString);\r
 \r
     CreateActionOpCode (\r
       mKeyInput,\r
index 0ec274d..febde95 100644 (file)
@@ -162,7 +162,7 @@ Returns:
   //\r
   // Publish our HII data\r
   //\r
-  PackageList = PreparePackageList (2, &mDeviceManagerGuid, DeviceManagerVfrBin, BdsStrings);\r
+  PackageList = HiiLibPreparePackageList (2, &mDeviceManagerGuid, DeviceManagerVfrBin, BdsStrings);\r
   ASSERT (PackageList != NULL);\r
 \r
   Status = gHiiDatabase->NewPackageList (\r
@@ -251,7 +251,7 @@ Returns:
   //\r
   // Get all the Hii handles\r
   //\r
-  Status = GetHiiHandles (&HandleBufferLength, &HiiHandles);\r
+  Status = HiiLibGetHiiHandles (&HandleBufferLength, &HiiHandles);\r
   ASSERT_EFI_ERROR (Status);\r
 \r
   HiiHandle = gDeviceManagerPrivate.HiiHandle;\r
@@ -265,7 +265,7 @@ Returns:
   //\r
   NumberOfHiiHandles = HandleBufferLength / sizeof (EFI_HII_HANDLE);\r
   for (Index = 0; Index < NumberOfHiiHandles; Index++) {\r
-    HiiLibExtractClassFromHiiHandle (HiiHandles[Index], &FormSetClass, &FormSetTitle, &FormSetHelp);\r
+    IfrLibExtractClassFromHiiHandle (HiiHandles[Index], &FormSetClass, &FormSetTitle, &FormSetHelp);\r
 \r
     if (FormSetClass == EFI_NON_DEVICE_CLASS) {\r
       continue;\r
@@ -274,14 +274,14 @@ Returns:
     Token = 0;\r
     *String = 0;\r
     StringLength = 0x1000;\r
-    IfrLibGetString (HiiHandles[Index], FormSetTitle, String, &StringLength);\r
-    IfrLibNewString (HiiHandle, &Token, String);\r
+    HiiLibGetString (HiiHandles[Index], FormSetTitle, String, &StringLength);\r
+    HiiLibNewString (HiiHandle, &Token, String);\r
 \r
     TokenHelp = 0;\r
     *String = 0;\r
     StringLength = 0x1000;\r
-    IfrLibGetString (HiiHandles[Index], FormSetHelp, String, &StringLength);\r
-    IfrLibNewString (HiiHandle, &TokenHelp, String);\r
+    HiiLibGetString (HiiHandles[Index], FormSetHelp, String, &StringLength);\r
+    HiiLibNewString (HiiHandle, &TokenHelp, String);\r
 \r
     for (Count = 0; Count < MENU_ITEM_NUM; Count++) {\r
       if (FormSetClass & mDeviceManagerMenuItemTable[Count].Class) {\r
@@ -413,7 +413,7 @@ Returns:
   // Cleanup dynamic created strings in HII database by reinstall the packagelist\r
   //\r
   gHiiDatabase->RemovePackageList (gHiiDatabase, HiiHandle);\r
-  PackageList = PreparePackageList (2, &mDeviceManagerGuid, DeviceManagerVfrBin, BdsStrings);\r
+  PackageList = HiiLibPreparePackageList (2, &mDeviceManagerGuid, DeviceManagerVfrBin, BdsStrings);\r
   ASSERT (PackageList != NULL);\r
   Status = gHiiDatabase->NewPackageList (\r
                            gHiiDatabase,\r
index b82b40f..1d364bf 100644 (file)
@@ -174,13 +174,13 @@ FrontPageCallback (
     //\r
     // Collect the languages from what our current Language support is based on our VFR\r
     //\r
-    LanguageString = GetSupportedLanguages (gFrontPagePrivate.HiiHandle);\r
+    LanguageString = HiiLibGetSupportedLanguages (gFrontPagePrivate.HiiHandle);\r
     ASSERT (LanguageString != NULL);\r
 \r
     Index = 0;\r
     LangCode = LanguageString;\r
     while (*LangCode != 0) {\r
-      GetNextLanguage (&LangCode, Lang);\r
+      HiiLibGetNextLanguage (&LangCode, Lang);\r
 \r
       if (Index == Value->u8) {\r
         break;\r
@@ -335,7 +335,7 @@ Returns:
     //\r
     // Publish our HII data\r
     //\r
-    PackageList = PreparePackageList (2, &mFrontPageGuid, FrontPageVfrBin, BdsStrings);\r
+    PackageList = HiiLibPreparePackageList (2, &mFrontPageGuid, FrontPageVfrBin, BdsStrings);\r
     ASSERT (PackageList != NULL);\r
 \r
     Status = gHiiDatabase->NewPackageList (\r
@@ -353,7 +353,7 @@ Returns:
   //\r
   // Get current language setting\r
   //\r
-  GetCurrentLanguage (CurrentLang);\r
+  HiiLibGetCurrentLanguage (CurrentLang);\r
 \r
   //\r
   // Allocate space for creation of UpdateData Buffer\r
@@ -369,13 +369,13 @@ Returns:
   // Collect the languages from what our current Language support is based on our VFR\r
   //\r
   HiiHandle = gFrontPagePrivate.HiiHandle;\r
-  LanguageString = GetSupportedLanguages (HiiHandle);\r
+  LanguageString = HiiLibGetSupportedLanguages (HiiHandle);\r
   ASSERT (LanguageString != NULL);\r
 \r
   OptionCount = 0;\r
   LangCode = LanguageString;\r
   while (*LangCode != 0) {\r
-    GetNextLanguage (&LangCode, Lang);\r
+    HiiLibGetNextLanguage (&LangCode, Lang);\r
 \r
     if (gFrontPagePrivate.LanguageToken == NULL) {\r
       //\r
@@ -409,7 +409,7 @@ Returns:
       ASSERT_EFI_ERROR (Status);\r
 \r
       Token = 0;\r
-      Status = IfrLibNewString (HiiHandle, &Token, StringBuffer);\r
+      Status = HiiLibNewString (HiiHandle, &Token, StringBuffer);\r
       FreePool (StringBuffer);\r
     } else {\r
       Token = gFrontPagePrivate.LanguageToken[OptionCount];\r
@@ -542,7 +542,7 @@ Returns:
 {\r
   EFI_STATUS      Status;\r
 \r
-  Status = GetStringFromToken (ProducerGuid, Token, String);\r
+  Status = HiiLibGetStringFromToken (ProducerGuid, Token, String);\r
   if (EFI_ERROR (Status)) {\r
     *String = GetStringById (STRING_TOKEN (STR_MISSING_STRING));\r
   }\r
@@ -677,7 +677,7 @@ Returns:
         BiosVendor = (EFI_MISC_BIOS_VENDOR_DATA *) (DataHeader + 1);\r
         GetProducerString (&Record->ProducerName, BiosVendor->BiosVersion, &NewString);\r
         TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION);\r
-        IfrLibSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString);\r
+        HiiLibSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString);\r
         FreePool (NewString);\r
         Find[0] = TRUE;\r
       }\r
@@ -688,7 +688,7 @@ Returns:
         SystemManufacturer = (EFI_MISC_SYSTEM_MANUFACTURER_DATA *) (DataHeader + 1);\r
         GetProducerString (&Record->ProducerName, SystemManufacturer->SystemProductName, &NewString);\r
         TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL);\r
-        IfrLibSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString);\r
+        HiiLibSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString);\r
         FreePool (NewString);\r
         Find[1] = TRUE;\r
       }\r
@@ -699,7 +699,7 @@ Returns:
         ProcessorVersion = (EFI_PROCESSOR_VERSION_DATA *) (DataHeader + 1);\r
         GetProducerString (&Record->ProducerName, *ProcessorVersion, &NewString);\r
         TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL);\r
-        IfrLibSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString);\r
+        HiiLibSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString);\r
         FreePool (NewString);\r
         Find[2] = TRUE;\r
       }\r
@@ -710,7 +710,7 @@ Returns:
         ProcessorFrequency = (EFI_PROCESSOR_CORE_FREQUENCY_DATA *) (DataHeader + 1);\r
         ConvertProcessorToString (ProcessorFrequency, &NewString);\r
         TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED);\r
-        IfrLibSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString);\r
+        HiiLibSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString);\r
         FreePool (NewString);\r
         Find[3] = TRUE;\r
       }\r
@@ -724,7 +724,7 @@ Returns:
           &NewString\r
           );\r
         TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_MEMORY_SIZE);\r
-        IfrLibSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString);\r
+        HiiLibSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString);\r
         FreePool (NewString);\r
         Find[4] = TRUE;\r
       }\r
index 8a99e9b..907bb61 100644 (file)
@@ -33,7 +33,7 @@ EFI_GUID  mFontPackageGuid = {
 \r
 typedef struct {\r
   //\r
-  // This 4-bytes total array length is required by PreparePackageList()\r
+  // This 4-bytes total array length is required by HiiLibPreparePackageList()\r
   //\r
   UINT32                 Length;\r
 \r
@@ -288,7 +288,7 @@ Returns:
     return ;\r
   }\r
 \r
-  PackageList = PreparePackageList (1, &mFontPackageGuid, &mFontBin);\r
+  PackageList = HiiLibPreparePackageList (1, &mFontPackageGuid, &mFontBin);\r
   ASSERT (PackageList != NULL);\r
 \r
   gHiiDatabase->NewPackageList (gHiiDatabase, PackageList, DriverHandle, &HiiHandle);\r
index 84f9f96..6cb109d 100644 (file)
@@ -63,7 +63,7 @@ Returns:
     return Status;\r
   }\r
 \r
-  PackageList = PreparePackageList (1, &mBdsStringPackGuid, &BdsStrings);\r
+  PackageList = HiiLibPreparePackageList (1, &mBdsStringPackGuid, &BdsStrings);\r
   ASSERT (PackageList != NULL);\r
 \r
   Status = gHiiDatabase->NewPackageList (\r
@@ -98,7 +98,7 @@ Returns:
   CHAR16 *String;\r
 \r
   String = NULL;\r
-  GetStringFromHandle (gStringPackHandle, Id, &String);\r
+  HiiLibGetStringFromHandle (gStringPackHandle, Id, &String);\r
 \r
   return String;\r
 }\r
index 77a209e..ff4b0c2 100644 (file)
@@ -619,10 +619,8 @@ GraphicsConsoleControllerDriverStop (
     // Remove the font pack\r
     //\r
 #if 1\r
-    Status = HiiLibRemovePackagesFromHiiDatabase (Private->HiiHandle);\r
-    if (!EFI_ERROR (Status)) {\r
-      mFirstAccessFlag = TRUE;\r
-    }\r
+    HiiLibRemovePackages (Private->HiiHandle);\r
+    mFirstAccessFlag = TRUE;\r
 #else    \r
     mHii->RemovePack (mHii, Private->HiiHandle);\r
 #endif\r
index f18e311..4cdbe5f 100644 (file)
@@ -111,7 +111,7 @@ ValidatePassword (
   Password = AllocateZeroPool (BufferSize);\r
   ASSERT (Password != NULL);\r
 \r
-  Status = IfrLibGetString (PrivateData->HiiHandle[0], StringId, Password, &BufferSize);\r
+  Status = HiiLibGetString (PrivateData->HiiHandle[0], StringId, Password, &BufferSize);\r
   if (EFI_ERROR (Status)) {\r
     gBS->FreePool (Password);\r
     return Status;\r
@@ -169,7 +169,7 @@ SetPassword (
   //\r
   Password = &PrivateData->Configuration.WhatIsThePassword2[0];\r
   ZeroMem (Password, 20 * sizeof (CHAR16));\r
-  Status = IfrLibGetString (PrivateData->HiiHandle[0], StringId, Password, &BufferSize);\r
+  Status = HiiLibGetString (PrivateData->HiiHandle[0], StringId, Password, &BufferSize);\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
@@ -646,7 +646,7 @@ DriverSampleInit (
   //\r
   // Publish our HII data\r
   //\r
-  PackageList = PreparePackageList (\r
+  PackageList = HiiLibPreparePackageList (\r
                   2,\r
                   &mFormSetGuid,\r
                   DriverSampleStrings,\r
@@ -677,7 +677,7 @@ DriverSampleInit (
   }\r
   PrivateData->DriverHandle[1] = DriverHandle[1];\r
 \r
-  PackageList = PreparePackageList (\r
+  PackageList = HiiLibPreparePackageList (\r
                   2,\r
                   &mInventoryGuid,\r
                   DriverSampleStrings,\r
@@ -705,7 +705,7 @@ DriverSampleInit (
   //\r
   NewString = L"700 Mhz";\r
 \r
-  Status = IfrLibSetString (HiiHandle[0], STRING_TOKEN (STR_CPU_STRING2), NewString);\r
+  Status = HiiLibSetString (HiiHandle[0], STRING_TOKEN (STR_CPU_STRING2), NewString);\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
@@ -732,7 +732,7 @@ DriverSampleInit (
     // based on default values stored in IFR\r
     //\r
     BufferSize = sizeof (DRIVER_SAMPLE_CONFIGURATION);\r
-    Status = ExtractDefault (Configuration, &BufferSize, 1, VfrMyIfrNVDataDefault0000);\r
+    Status = IfrLibExtractDefault (Configuration, &BufferSize, 1, VfrMyIfrNVDataDefault0000);\r
 \r
     if (!EFI_ERROR (Status)) {\r
       gRT->SetVariable(\r
index 9f19258..60fa280 100644 (file)
@@ -39,7 +39,9 @@ Revision History
 #include <Library/UefiBootServicesTableLib.h>
 #include <Library/MemoryAllocationLib.h>
 #include <Library/IfrSupportLib.h>
+#include <Library/ExtendedIfrSupportLib.h>
 #include <Library/HiiLib.h>
+#include <Library/ExtendedHiiLib.h>
 
 #include <MdeModuleHii.h>
 
@@ -53,7 +55,7 @@ extern UINT8 VfrMyIfrNVDataDefault0000[];
 
 //
 // This is the generated IFR binary data for each formset defined in VFR.
-// This data array is ready to be used as input of PreparePackageList() to
+// This data array is ready to be used as input of HiiLibPreparePackageList() to
 // create a packagelist (which contains Form packages, String packages, etc).
 //
 extern UINT8  VfrBin[];
@@ -61,7 +63,7 @@ extern UINT8  InventoryBin[];
 
 //
 // This is the generated String package data for all .UNI files.
-// This data array is ready to be used as input of PreparePackageList() to
+// This data array is ready to be used as input of HiiLibPreparePackageList() to
 // create a packagelist (which contains Form packages, String packages, etc).
 //
 extern UINT8  DriverSampleStrings[];
index 42a3317..c36eb06 100644 (file)
@@ -56,6 +56,8 @@
   DebugLib\r
   HiiLib\r
   IfrSupportLib\r
+  ExtendedHiiLib\r
+  ExtendedIfrSupportLib\r
   BaseLib\r
 \r
 \r
index 14e42e3..9f3c4fe 100644 (file)
@@ -700,7 +700,7 @@ IScsiFormCallback (
 \r
       UnicodeSPrint (PortString, (UINTN) 128, L"Port %s", ConfigFormEntry->MacString);\r
       DeviceFormTitleToken = (STRING_REF) STR_ISCSI_DEVICE_FORM_TITLE;\r
-      IfrLibSetString (Private->RegisteredHandle, DeviceFormTitleToken, PortString);\r
+      HiiLibSetString (Private->RegisteredHandle, DeviceFormTitleToken, PortString);\r
 \r
       IScsiConvertDeviceConfigDataToIfrNvData (ConfigFormEntry, IfrNvData);\r
 \r
@@ -832,13 +832,13 @@ Returns:
       // Compose the Port string and create a new STRING_REF.\r
       //\r
       UnicodeSPrint (PortString, 128, L"Port %s", ConfigFormEntry->MacString);\r
-      IfrLibNewString (mCallbackInfo->RegisteredHandle, &ConfigFormEntry->PortTitleToken, PortString);\r
+      HiiLibNewString (mCallbackInfo->RegisteredHandle, &ConfigFormEntry->PortTitleToken, PortString);\r
 \r
       //\r
       // Compose the help string of this port and create a new STRING_REF.\r
       //\r
       UnicodeSPrint (PortString, 128, L"Set the iSCSI parameters on port %s", ConfigFormEntry->MacString);\r
-      IfrLibNewString (mCallbackInfo->RegisteredHandle, &ConfigFormEntry->PortTitleHelpToken, PortString);\r
+      HiiLibNewString (mCallbackInfo->RegisteredHandle, &ConfigFormEntry->PortTitleHelpToken, PortString);\r
 \r
       NetListInsertTail (&mIScsiConfigFormList, &ConfigFormEntry->Link);\r
       mNumberOfIScsiDevices++;\r
@@ -958,7 +958,7 @@ Returns:
   //\r
   // Publish our HII data\r
   //\r
-  PackageList = PreparePackageList (2, &mVendorGuid, IScsiDxeStrings, IScsiConfigDxeBin);\r
+  PackageList = HiiLibPreparePackageList (2, &mVendorGuid, IScsiDxeStrings, IScsiConfigDxeBin);\r
   ASSERT (PackageList != NULL);\r
   \r
   Status = HiiDatabase->NewPackageList (\r
index 7fb98a7..e9311b6 100644 (file)
@@ -22,7 +22,9 @@ Abstract:
 #define _ISCSI_CONFIG_H_\r
 \r
 #include <Library/HiiLib.h>\r
+#include <Library/ExtendedHiiLib.h>\r
 #include <Library/IfrSupportLib.h>\r
+#include <Library/ExtendedIfrSupportLib.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/BaseLib.h>\r
 #include <Library/NetLib.h>\r
index 95aa242..0dc07d8 100644 (file)
@@ -79,6 +79,8 @@
   PrintLib\r
   HiiLib\r
   IfrSupportLib\r
+  ExtendedHiiLib\r
+  ExtendedIfrSupportLib\r
   NetLib\r
 \r
 [Protocols]\r
@@ -93,4 +95,4 @@
   gEfiPciIoProtocolGuid\r
   gEfiAcpiSupportProtocolGuid\r
   gEfiDhcp4ProtocolGuid\r
-  gEfiDhcp4ServiceBindingProtocolGuid
\ No newline at end of file
+  gEfiDhcp4ServiceBindingProtocolGuid\r
index d14dac0..4ec9e6e 100644 (file)
@@ -568,7 +568,7 @@ InitializeSetup (
   Status = HiiLibCreateHiiDriverHandle (&HiiDriverHandle);
   ASSERT_EFI_ERROR (Status);
 
-  PackageList = PreparePackageList (1, &gSetupBrowserGuid, SetupBrowserStrings);
+  PackageList = HiiLibPreparePackageList (1, &gSetupBrowserGuid, SetupBrowserStrings);
   ASSERT (PackageList != NULL);
   Status = mHiiDatabase->NewPackageList (
                            mHiiDatabase,
@@ -631,7 +631,7 @@ NewString (
   EFI_STATUS     Status;
 
   StringId = 0;
-  Status = IfrLibNewString (HiiHandle, &StringId, String);
+  Status = HiiLibNewString (HiiHandle, &StringId, String);
   ASSERT_EFI_ERROR (Status);
 
   return StringId;
@@ -656,7 +656,7 @@ DeleteString (
   CHAR16  NullChar;
 
   NullChar = CHAR_NULL;
-  return IfrLibSetString (HiiHandle, StringId, &NullChar);
+  return HiiLibSetString (HiiHandle, StringId, &NullChar);
 }
 
 
@@ -687,14 +687,14 @@ GetToken (
   String = AllocateZeroPool (BufferLength);
   ASSERT (String != NULL);
 
-  Status = IfrLibGetString (HiiHandle, Token, String, &BufferLength);
+  Status = HiiLibGetString (HiiHandle, Token, String, &BufferLength);
 
   if (Status == EFI_BUFFER_TOO_SMALL) {
     gBS->FreePool (String);
     String = AllocateZeroPool (BufferLength);
     ASSERT (String != NULL);
 
-    Status = IfrLibGetString (HiiHandle, Token, String, &BufferLength);
+    Status = HiiLibGetString (HiiHandle, Token, String, &BufferLength);
   }
   ASSERT_EFI_ERROR (Status);
 
index 3ade4da..647c448 100644 (file)
@@ -50,7 +50,9 @@ Revision History
 #include <Library/BaseLib.h>
 #include <Library/MemoryAllocationLib.h>
 #include <Library/IfrSupportLib.h>
+#include <Library/ExtendedIfrSupportLib.h>
 #include <Library/HiiLib.h>
+#include <Library/ExtendedHiiLib.h>
 
 #include "R8Lib.h"
 
index 807076e..c594749 100644 (file)
@@ -67,6 +67,7 @@
   GraphicsLib\r
   IfrSupportLib\r
   HiiLib\r
+  ExtendedHiiLib\r
 \r
 [Protocols]\r
   gEfiPrintProtocolGuid                         # PROTOCOL ALWAYS_CONSUMED\r
index 34ec526..06479c7 100644 (file)
@@ -2259,7 +2259,7 @@ UiDisplayMenu (
           DevicePath = AllocatePool (BufferSize);
 
           HexStringToBuffer ((UINT8 *) DevicePath, &BufferSize, StringPtr);
-          Selection->Handle = DevicePathToHiiHandle (mHiiDatabase, DevicePath);
+          Selection->Handle = HiiLibDevicePathToHiiHandle (DevicePath);
           if (Selection->Handle == NULL) {
             //
             // If target Hii Handle not found, exit