]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Add FvbServiceLib, HiiLib & IfrSupportLib.h
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 13 Nov 2008 08:41:24 +0000 (08:41 +0000)
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 13 Nov 2008 08:41:24 +0000 (08:41 +0000)
They originate from MdePkg.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6502 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Include/Library/FvbServiceLib.h [new file with mode: 0644]
MdeModulePkg/Include/Library/HiiLib.h [new file with mode: 0644]
MdeModulePkg/Include/Library/IfrSupportLib.h [new file with mode: 0644]

diff --git a/MdeModulePkg/Include/Library/FvbServiceLib.h b/MdeModulePkg/Include/Library/FvbServiceLib.h
new file mode 100644 (file)
index 0000000..a87750a
--- /dev/null
@@ -0,0 +1,311 @@
+/** @file\r
+  Firmeware Volume BLock Service Library\r
+\r
+  Copyright (c) 2006 - 2007, 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
+#ifndef __FVB_SERVICE_LIB_H__\r
+#define __FVB_SERVICE_LIB_H__\r
+\r
+/**\r
+  Reads specified number of bytes into a buffer from the specified block.\r
+\r
+  The EfiFvbReadBlock() function reads the requested number of bytes from\r
+  the requested block in the specified firmware volume and stores them in\r
+  the provided buffer. Implementations should be mindful that the firmware\r
+  volume might be in the ReadDisabled state.  If it is in this state, the \r
+  EfiFvbReadBlock() function must return the status code EFI_ACCESS_DENIED\r
+  without modifying the contents of the buffer.\r
+  \r
+  The EfiFvbReadBlock() function must also prevent spanning block boundaries.\r
+  If a read is requested that would span a block boundary, the read must read\r
+  up to the boundary but not beyond.  The output parameter NumBytes must be\r
+  set to correctly indicate the number of bytes actually read.  \r
+  The caller must be aware that a read may be partially completed.\r
+\r
+  If NumBytes is NULL, then ASSERT().\r
+\r
+  If Buffer is NULL, then ASSERT().\r
+\r
+  @param[in]      Instance         The FV instance to be read from.\r
+  @param[in]      Lba              The logical block address to be read from\r
+  @param[in]      Offset           The offset relative to the block, at which to begin reading.\r
+  @param[in, out] NumBytes         Pointer to a UINTN. On input, *NumBytes contains the total\r
+                                   size of the buffer. On output, it contains the actual number\r
+                                   of bytes read.\r
+  @param[out]     Buffer           Pointer to a caller allocated buffer that will be\r
+                                   used to hold the data read.\r
+\r
+  @retval   EFI_SUCCESS            The firmware volume was read successfully and contents are in Buffer.\r
+  @retval   EFI_BAD_BUFFER_SIZE    Read attempted across an LBA boundary.  On output, NumBytes contains\r
+                                   the total number of bytes returned in Buffer.\r
+  @retval   EFI_ACCESS_DENIED      The firmware volume is in the ReadDisabled state.\r
+  @retval   EFI_DEVICE_ERROR       The block device is not functioning correctly and could not be read.\r
+  @retval   EFI_INVALID_PARAMETER  Invalid parameter, Instance is larger than the max FVB number. Lba index\r
+                                   is larger than the last block of the firmware volume. Offset is larger\r
+                                   than the block size.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiFvbReadBlock (\r
+  IN UINTN                                        Instance,\r
+  IN EFI_LBA                                      Lba,\r
+  IN UINTN                                        Offset,\r
+  IN OUT UINTN                                    *NumBytes,\r
+  OUT UINT8                                       *Buffer\r
+  );\r
+\r
+\r
+/**\r
+  Writes specified number of bytes from the input buffer to the block\r
+\r
+  The EfiFvbWriteBlock() function writes the specified number of bytes\r
+  from the provided buffer to the specified block and offset in the \r
+  requested firmware volume. \r
+\r
+  If the firmware volume is sticky write, the caller must ensure that\r
+  all the bits of the specified range to write are in the EFI_FVB_ERASE_POLARITY\r
+  state before calling the EfiFvbWriteBlock() function, or else the \r
+  result will be unpredictable.  This unpredictability arises because,\r
+  for a sticky-write firmware volume, a write may negate a bit in the \r
+  EFI_FVB_ERASE_POLARITY state but it cannot flip it back again. In \r
+  general, before calling the EfiFvbWriteBlock() function, the caller\r
+  should call the EfiFvbEraseBlock() function first to erase the specified\r
+  block to write. A block erase cycle will transition bits from the\r
+  (NOT)EFI_FVB_ERASE_POLARITY state back to the EFI_FVB_ERASE_POLARITY state.\r
+  Implementations should be mindful that the firmware volume might be \r
+  in the WriteDisabled state.  If it is in this state, the EfiFvbWriteBlock()\r
+  function must return the status code EFI_ACCESS_DENIED without modifying\r
+  the contents of the firmware volume.\r
+  \r
+  The EfiFvbWriteBlock() function must also prevent spanning block boundaries.\r
+  If a write is requested that spans a block boundary, the write must store\r
+  up to the boundary but not beyond. The output parameter NumBytes must be \r
+  set to correctly indicate the number of bytes actually written. The caller\r
+  must be aware that a write may be partially completed.\r
+  All writes, partial or otherwise, must be fully flushed to the hardware \r
+  before the EfiFvbWriteBlock() function returns. \r
+  \r
+  If NumBytes is NULL, then ASSERT().\r
+\r
+  @param Instance               The FV instance to be written to\r
+  @param Lba                    The starting logical block index to write to\r
+  @param Offset                 The offset relative to the block, at which to begin writting.\r
+  @param NumBytes               Pointer to a UINTN. On input, *NumBytes contains\r
+                                the total size of the buffer. On output, it contains\r
+                                the actual number of bytes written.\r
+  @param Buffer                 Pointer to a caller allocated buffer that contains\r
+                                the source for the write\r
+\r
+  @retval EFI_SUCCESS           The firmware volume was written successfully.\r
+  @retval EFI_BAD_BUFFER_SIZE   The write was attempted across an LBA boundary. \r
+                                On output, NumBytes contains the total number of bytes actually written.\r
+  @retval EFI_ACCESS_DENIED     The firmware volume is in the WriteDisabled state.\r
+  @retval EFI_DEVICE_ERROR      The block device is malfunctioning and could not be written.\r
+  @retval EFI_INVALID_PARAMETER Invalid parameter, Instance is larger than the max FVB number. \r
+                                Lba index is larger than the last block of the firmware volume.\r
+                                Offset is larger than the block size.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiFvbWriteBlock (\r
+  IN UINTN                                        Instance,\r
+  IN EFI_LBA                                      Lba,\r
+  IN UINTN                                        Offset,\r
+  IN OUT UINTN                                    *NumBytes,\r
+  IN UINT8                                        *Buffer\r
+  );\r
+\r
+\r
+/**\r
+  Erases and initializes a firmware volume block.\r
+\r
+  The EfiFvbEraseBlock() function erases one block specified by Lba.\r
+  Implementations should be mindful that the firmware volume might \r
+  be in the WriteDisabled state. If it is in this state, the EfiFvbEraseBlock()\r
+  function must return the status code EFI_ACCESS_DENIED without \r
+  modifying the contents of the firmware volume. If Instance is \r
+  larger than the max FVB number, or Lba index is larger than the\r
+  last block of the firmware volume, this function return the status\r
+  code EFI_INVALID_PARAMETER.\r
+  \r
+  All calls to EfiFvbEraseBlock() must be fully flushed to the \r
+  hardware before this function returns. \r
+\r
+  @param[in]     Instance    The FV instance to be erased.\r
+  @param[in]     Lba         The logical block index to be erased from.\r
+  \r
+  @retval EFI_SUCCESS            The erase request was successfully completed.\r
+  @retval EFI_ACCESS_DENIED      The firmware volume is in the WriteDisabled state.\r
+  @retval EFI_DEVICE_ERROR       The block device is not functioning correctly and\r
+                                 could not be written.  The firmware device may \r
+                                 have been partially erased.\r
+  @retval EFI_INVALID_PARAMETER  Invalid parameter. Instance is larger than the max\r
+                                 FVB number. Lba index is larger than the last block\r
+                                 of the firmware volume. \r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiFvbEraseBlock (\r
+  IN UINTN                                Instance,\r
+  IN EFI_LBA                              Lba\r
+  );\r
+\r
+\r
+/**\r
+  Retrieves the attributes and current settings of the specified block, \r
+  returns resulting attributes in output parameter.\r
+\r
+  The EfiFvbGetAttributes() function retrieves the attributes and current\r
+  settings of the block specified by Instance. If Instance is larger than\r
+  the max FVB number, this function returns the status code EFI_INVALID_PARAMETER.\r
+\r
+  If Attributes is NULL, then ASSERT().\r
+\r
+  @param[in]     Instance          The FV instance to be operated.\r
+  @param[out]    Attributes        Pointer to EFI_FVB_ATTRIBUTES_2 in which the\r
+                                   attributes and current settings are returned.\r
+\r
+  @retval   EFI_EFI_SUCCESS        The firmware volume attributes were returned.\r
+  @retval   EFI_INVALID_PARAMETER  Invalid parameter. Instance is larger than the max FVB number. \r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiFvbGetVolumeAttributes (\r
+  IN UINTN                                Instance,\r
+  OUT EFI_FVB_ATTRIBUTES_2                *Attributes\r
+  );\r
+\r
+\r
+/**\r
+  Modify the attributes and current settings of the specified block\r
+  according to the input parameter.\r
+\r
+  The EfiFvbSetAttributes() function sets configurable firmware volume\r
+  attributes and returns the new settings of the firmware volume specified\r
+  by Instance. If Instance is larger than the max FVB number, this function\r
+  returns the status code EFI_INVALID_PARAMETER.\r
+\r
+  If Attributes is NULL, then ASSERT().\r
+\r
+  @param[in]     Instance          The FV instance to be operated.\r
+  @param[in, out]Attributes        On input, Attributes is a pointer to EFI_FVB_ATTRIBUTES_2\r
+                                   that contains the desired firmware volume settings.  \r
+                                   On successful return, it contains the new settings of the firmware volume.\r
+\r
+  @retval   EFI_EFI_SUCCESS        The firmware volume attributes were modified successfully.\r
+  @retval   EFI_INVALID_PARAMETER  Invalid parameter. Instance is larger than the max FVB number.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiFvbSetVolumeAttributes (\r
+  IN     UINTN                                Instance,\r
+  IN OUT EFI_FVB_ATTRIBUTES_2                 *Attributes\r
+  );\r
+\r
+\r
+/**\r
+  Retrieves the physical address of the specified memory mapped FV.\r
+\r
+  Retrieve the base address of a memory-mapped firmware volume specified by Instance.\r
+  If Instance is larger than the max FVB number, this function returns the status \r
+  code EFI_INVALID_PARAMETER.\r
+  \r
+  If BaseAddress is NULL, then ASSERT().\r
+\r
+  @param[in]     Instance          The FV instance to be operated.\r
+  @param[out]    BaseAddress       Pointer to a caller allocated EFI_PHYSICAL_ADDRESS \r
+                                   that on successful return, contains the base address\r
+                                   of the firmware volume. \r
+\r
+  @retval   EFI_EFI_SUCCESS        The firmware volume base address is returned.\r
+  @retval   EFI_INVALID_PARAMETER  Invalid parameter. Instance is larger than the max FVB number. \r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiFvbGetPhysicalAddress (\r
+  IN UINTN                                Instance,\r
+  OUT EFI_PHYSICAL_ADDRESS                *BaseAddress\r
+  );\r
+\r
+\r
+/**\r
+  Retrieve the block size of the specified fv.\r
+  \r
+  The EfiFvbGetBlockSize() function retrieves the size of the requested block. \r
+  It also returns the number of additional blocks with the identical size. \r
+  If Instance is larger than the max FVB number, or Lba index is larger than\r
+  the last block of the firmware volume, this function return the status code\r
+  EFI_INVALID_PARAMETER.\r
+\r
+  If BlockSize  is NULL, then ASSERT().\r
+  \r
+  If NumOfBlocks  is NULL, then ASSERT().\r
+\r
+  @param[in]     Instance          The FV instance to be operated.\r
+  @param[in]     Lba               Indicates which block to return the size for.\r
+  @param[out]    BlockSize         Pointer to a caller-allocated UINTN in which the\r
+                                   size of the block is returned.\r
+  @param[out]    NumOfBlocks       Pointer to a caller-allocated UINTN in which the \r
+                                   number of consecutive blocks, starting with Lba, \r
+                                   is returned. All blocks in this range have a size of BlockSize.\r
+\r
+  @retval   EFI_EFI_SUCCESS        The firmware volume base address is returned.\r
+  @retval   EFI_INVALID_PARAMETER  Invalid parameter. Instance is larger than the max FVB number.\r
+                                   Lba index is larger than the last block of the firmware volume.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiFvbGetBlockSize (\r
+  IN UINTN                                        Instance,\r
+  IN EFI_LBA                                      Lba,\r
+  OUT UINTN                                       *BlockSize,\r
+  OUT UINTN                                       *NumOfBlocks\r
+  );\r
+\r
+\r
+/**\r
+  Erases and initializes a specified range of a firmware volume.\r
+\r
+  The EfiFvbEraseCustomBlockRange() function erases the specified range in the firmware\r
+  volume index by Instance. If Instance is larger than the max FVB number, StartLba or \r
+  LastLba  index is larger than the last block of the firmware volume, StartLba > LastLba\r
+  or StartLba equal to LastLba but OffsetStartLba > OffsetLastLba, this function return \r
+  the status code EFI_INVALID_PARAMETER.\r
+\r
+  @param[in]     Instance          The FV instance to be operated.\r
+  @param[in]     StartLba          The starting logical block index to be erased.\r
+  @param[in]     OffsetStartLba    Offset into the starting block at which to \r
+                                   begin erasing.    \r
+  @param[in]     LastLba           The last logical block index to be erased.\r
+  @param[in]     OffsetLastLba     Offset into the last block at which to end erasing.   \r
+\r
+  @retval   EFI_EFI_SUCCESS        Successfully erase custom block range\r
+  @retval   EFI_INVALID_PARAMETER  Invalid parameter. Instance is larger than the max FVB number. \r
+  @retval   EFI_UNSUPPORTED        Firmware volume block device has no this capability.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiFvbEraseCustomBlockRange (\r
+  IN UINTN                                Instance,\r
+  IN EFI_LBA                              StartLba,\r
+  IN UINTN                                OffsetStartLba,\r
+  IN EFI_LBA                              LastLba,\r
+  IN UINTN                                OffsetLastLba\r
+  );\r
+\r
+#endif\r
diff --git a/MdeModulePkg/Include/Library/HiiLib.h b/MdeModulePkg/Include/Library/HiiLib.h
new file mode 100644 (file)
index 0000000..a92431a
--- /dev/null
@@ -0,0 +1,500 @@
+/** @file\r
+  Public include file for the HII Library\r
+\r
+  Copyright (c) 2007 - 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 __HII_LIB_H__\r
+#define __HII_LIB_H__\r
+\r
+\r
+/**\r
+  Assemble EFI_HII_PACKAGE_LIST according to the passed in packages.\r
+\r
+  If GuidId is NULL, then ASSERT.\r
+  If not enough resource to complete the operation, then ASSERT.\r
+\r
+  @param  NumberOfPackages       Number of packages.\r
+  @param  GuidId                 Package GUID.\r
+  @param  ...                    Variable argument list for packages to be assembled.\r
+\r
+  @return Pointer of EFI_HII_PACKAGE_LIST_HEADER.\r
+\r
+**/\r
+EFI_HII_PACKAGE_LIST_HEADER *\r
+EFIAPI\r
+HiiLibPreparePackageList (\r
+  IN UINTN                    NumberOfPackages,\r
+  IN CONST EFI_GUID                 *GuidId,\r
+  ...\r
+  );\r
+\r
+/**\r
+  This function allocates pool for an EFI_HII_PACKAGE_LIST structure\r
+  with additional space that is big enough to host all packages described by the variable \r
+  argument list of package pointers.  The allocated structure is initialized using NumberOfPackages, \r
+  GuidId,  and the variable length argument list of package pointers.\r
+\r
+  Then, EFI_HII_PACKAGE_LIST will be register to the default System HII Database. The\r
+  Handle to the newly registered Package List is returned throught HiiHandle.\r
+\r
+  If HiiHandle is NULL, then ASSERT.\r
+\r
+  @param  NumberOfPackages    The number of HII packages to register.\r
+  @param  GuidId              Package List GUID ID.\r
+  @param  DriverHandle        Optional. If not NULL, the DriverHandle on which an instance of DEVICE_PATH_PROTOCOL is installed.\r
+                              This DriverHandle uniquely defines the device that the added packages are associated with.\r
+  @param  HiiHandle           On output, the HiiHandle is update with the handle which can be used to retrieve the Package \r
+                              List later. If the functions failed to add the package to the default HII database, this value will\r
+                              be set to NULL.\r
+  @param  ...                 The variable argument list describing all HII Package.\r
+\r
+  @return  EFI_SUCCESS         If the packages are successfully added to the default HII database.\r
+  @return  EFI_OUT_OF_RESOURCE Not enough resource to complete the operation.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+HiiLibAddPackages (\r
+  IN       UINTN               NumberOfPackages,\r
+  IN CONST EFI_GUID            *GuidId,\r
+  IN       EFI_HANDLE          DriverHandle, OPTIONAL\r
+  OUT      EFI_HII_HANDLE      *HiiHandle,\r
+  ...\r
+  );\r
+\r
+/**\r
+  Removes a package list from the default HII database.\r
+\r
+  If HiiHandle is NULL, then ASSERT.\r
+  If HiiHandle is not a valid EFI_HII_HANDLE in the default HII database, then ASSERT.\r
+\r
+  @param  HiiHandle                The handle that was previously registered to the data base that is requested for removal.\r
+                                             List later.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+HiiLibRemovePackages (\r
+  IN      EFI_HII_HANDLE      HiiHandle\r
+  );\r
+\r
+/**\r
+  This function adds the string into String Package of each language\r
+  supported by the package list.\r
+\r
+  If String is NULL, then ASSERT.\r
+  If StringId is NULL, the ASSERT.\r
+  If PackageList could not be found in the default HII database, then ASSERT.\r
+\r
+  @param  PackageList            Handle of the package list where this string will\r
+                                            be added.\r
+  @param  StringId               On return, contains the new strings id, which is\r
+                                          unique within PackageList.\r
+  @param  String                 Points to the new null-terminated string.\r
+\r
+  @retval EFI_SUCCESS             The new string was added successfully.\r
+  @retval EFI_OUT_OF_RESOURCES   Could not add the string due to lack of resources.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+HiiLibNewString (\r
+  IN  EFI_HII_HANDLE                  PackageList,\r
+  OUT EFI_STRING_ID                   *StringId,\r
+  IN  CONST EFI_STRING                String\r
+  );\r
+\r
+/**\r
+  This function update the specified string in String Package of each language\r
+  supported by the package list.\r
+\r
+  If String is NULL, then ASSERT.\r
+  If PackageList could not be found in the default HII database, then ASSERT.\r
+  If StringId is not found in PackageList, then ASSERT.\r
+\r
+  @param  PackageList            Handle of the package list where this string will\r
+                                            be added.\r
+  @param  StringId               Ths String Id to be updated.\r
+  @param  String                 Points to the new null-terminated string.\r
+\r
+  @retval EFI_SUCCESS            The new string was added successfully.\r
+  @retval EFI_OUT_OF_RESOURCES   Could not add the string due to lack of resources.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+HiiLibSetString (\r
+  IN  EFI_HII_HANDLE                  PackageList,\r
+  IN  EFI_STRING_ID                   StringId,\r
+  IN  CONST EFI_STRING                String\r
+  );\r
+\r
+/**\r
+  This function try to retrieve string from String package of current language.\r
+  If fails, it try to retrieve string from String package of first language it support.\r
+\r
+  If StringSize is NULL, then ASSERT.\r
+  If String is NULL and *StringSize is not 0, then ASSERT.\r
+  If PackageList could not be found in the default HII database, then ASSERT.\r
+  If StringId is not found in PackageList, then ASSERT.\r
+\r
+  @param  PackageList     The package list in the HII database to search for\r
+                                     the specified string.\r
+  @param  StringId          The string's id, which is unique within\r
+                                      PackageList.\r
+  @param  String             Points to the new null-terminated string.\r
+  @param  StringSize       On entry, points to the size of the buffer pointed\r
+                                 to by String, in bytes. On return, points to the\r
+                                 length of the string, in bytes.\r
+\r
+  @retval EFI_SUCCESS            The string was returned successfully.\r
+  @retval EFI_NOT_FOUND          The string specified by StringId is not available.\r
+  @retval EFI_BUFFER_TOO_SMALL   The buffer specified by StringLength is too small\r
+                                 to hold the string.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+HiiLibGetString (\r
+  IN  EFI_HII_HANDLE                  PackageList,\r
+  IN  EFI_STRING_ID                   StringId,\r
+  OUT EFI_STRING                      String,\r
+  IN  OUT UINTN                       *StringSize\r
+  );\r
+\r
+/**\r
+  Get string specified by StringId form the HiiHandle. The caller\r
+  is responsible to free the *String.\r
+\r
+  If String is NULL, then ASSERT.\r
+  If HiiHandle could not be found in the default HII database, then ASSERT.\r
+  If StringId is not found in PackageList, then ASSERT.\r
+\r
+  @param  HiiHandle              The HII handle of package list.\r
+  @param  StringId               The String ID.\r
+  @param  String                 The output string.\r
+\r
+  @retval EFI_NOT_FOUND          String is not found.\r
+  @retval EFI_SUCCESS            Operation is successful.\r
+  @retval EFI_OUT_OF_RESOURCES   There is not enought memory in the system.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+HiiLibGetStringFromHandle (\r
+  IN  EFI_HII_HANDLE                  HiiHandle,\r
+  IN  EFI_STRING_ID                   StringId,\r
+  OUT EFI_STRING                      *String\r
+  );\r
+\r
+/**\r
+  Get the string given the StringId and String package Producer's Guid. The caller\r
+  is responsible to free the *String.\r
+\r
+  If PackageList with the matching ProducerGuid is not found, then ASSERT.\r
+  If PackageList with the matching ProducerGuid is found but no String is\r
+  specified by StringId is found, then ASSERT.\r
+\r
+  @param  ProducerGuid           The Guid of String package list.\r
+  @param  StringId               The String ID.\r
+  @param  String                 The output string.\r
+\r
+  @retval EFI_SUCCESS            Operation is successful.\r
+  @retval EFI_OUT_OF_RESOURCES   There is not enought memory in the system.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+HiiLibGetStringFromToken (\r
+  IN  EFI_GUID                        *ProducerGuid,\r
+  IN  EFI_STRING_ID                   StringId,\r
+  OUT EFI_STRING                      *String\r
+  );\r
+\r
+/**\r
+  Determines the handles that are currently active in the database.\r
+  It's the caller's responsibility to free handle buffer.\r
+\r
+  If HandleBufferLength is NULL, then ASSERT.\r
+  If HiiHandleBuffer is NULL, then ASSERT.\r
+\r
+  @param  HandleBufferLength     On input, a pointer to the length of the handle\r
+                                 buffer. On output, the length of the handle buffer\r
+                                 that is required for the handles found.\r
+  @param  HiiHandleBuffer        Pointer to an array of Hii Handles returned.\r
+\r
+  @retval EFI_SUCCESS            Get an array of Hii Handles successfully.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+HiiLibGetHiiHandles (\r
+  IN OUT UINTN                     *HandleBufferLength,\r
+  OUT    EFI_HII_HANDLE            **HiiHandleBuffer\r
+  );\r
+\r
+/**\r
+  Extract Hii package list GUID for given HII handle.\r
+\r
+  If HiiHandle could not be found in the default HII database, then ASSERT.\r
+  If Guid is NULL, then ASSERT.\r
+\r
+  @param  Handle              Hii handle\r
+  @param  Guid                Package list GUID\r
+\r
+  @retval EFI_SUCCESS            Successfully extract GUID from Hii database.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+HiiLibExtractGuidFromHiiHandle (\r
+  IN      EFI_HII_HANDLE      Handle,\r
+  OUT     EFI_GUID            *Guid\r
+  );\r
+\r
+/**\r
+  Find HII Handle in the default HII database associated with given Device Path.\r
+\r
+  If DevicePath is NULL, then ASSERT.\r
+\r
+  @param  DevicePath             Device Path associated with the HII package list\r
+                                 handle.\r
+\r
+  @retval Handle                 HII package list Handle associated with the Device\r
+                                        Path.\r
+  @retval NULL                   Hii Package list handle is not found.\r
+\r
+**/\r
+EFI_HII_HANDLE\r
+EFIAPI\r
+HiiLibDevicePathToHiiHandle (\r
+  IN EFI_DEVICE_PATH_PROTOCOL   *DevicePath\r
+  );\r
+\r
+\r
+/**\r
+  Get next language from language code list (with separator ';').\r
+\r
+  If LangCode is NULL, then ASSERT.\r
+  If Lang is NULL, then ASSERT.\r
+\r
+  @param  LangCode    On input: point to first language in the list. On\r
+                                 output: point to next language in the list, or\r
+                                 NULL if no more language in the list.\r
+  @param  Lang           The first language in the list.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+HiiLibGetNextLanguage (\r
+  IN OUT CHAR8      **LangCode,\r
+  OUT CHAR8         *Lang\r
+  );\r
+\r
+/**\r
+  This function returns the list of supported languages, in the format specified\r
+  in UEFI specification Appendix M.\r
+\r
+  If HiiHandle is not a valid Handle in the default HII database, then ASSERT.\r
+\r
+  @param  HiiHandle              The HII package list handle.\r
+\r
+  @retval   !NULL  The supported languages.\r
+  @retval   NULL    If Supported Languages can not be retrived.\r
+\r
+**/\r
+CHAR8 *\r
+EFIAPI\r
+HiiLibGetSupportedLanguages (\r
+  IN EFI_HII_HANDLE           HiiHandle\r
+  );\r
+\r
+/**\r
+  This function returns the list of supported 2nd languages, in the format specified\r
+  in UEFI specification Appendix M.\r
+\r
+  If HiiHandle is not a valid Handle in the default HII database, then ASSERT.\r
+  If not enough resource to complete the operation, then ASSERT.\r
+\r
+  @param  HiiHandle              The HII package list handle.\r
+  @param  FirstLanguage          Pointer to language name buffer.\r
+  \r
+  @return The supported languages.\r
+\r
+**/\r
+CHAR8 *\r
+EFIAPI\r
+HiiLibGetSupportedSecondaryLanguages (\r
+  IN EFI_HII_HANDLE           HiiHandle,\r
+  IN CONST CHAR8              *FirstLanguage\r
+  );\r
+\r
+\r
+/**\r
+  This function returns the number of supported languages on HiiHandle.\r
+\r
+  If HiiHandle is not a valid Handle in the default HII database, then ASSERT.\r
+  If not enough resource to complete the operation, then ASSERT.\r
+\r
+  @param  HiiHandle              The HII package list handle.\r
+\r
+  @return The  number of supported languages.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+HiiLibGetSupportedLanguageNumber (\r
+  IN EFI_HII_HANDLE           HiiHandle\r
+  );\r
+\r
+/**\r
+  Exports the contents of one or all package lists in the HII database into a buffer.\r
+\r
+  If Handle is not NULL and not a valid EFI_HII_HANDLE registered in the database, \r
+  then ASSERT.\r
+  If PackageListHeader is NULL, then ASSERT.\r
+  If PackageListSize is NULL, then ASSERT.\r
+\r
+  @param  Handle                 The HII Handle.\r
+  @param  PackageListHeader      A pointer to a buffer that will contain the results of \r
+                                 the export function.\r
+  @param  PackageListSize        On output, the length of the buffer that is required for the exported data.\r
+\r
+  @retval EFI_SUCCESS            Package exported.\r
+\r
+  @retval EFI_OUT_OF_RESOURCES   Not enought memory to complete the operations.\r
+\r
+**/\r
+EFI_STATUS \r
+EFIAPI\r
+HiiLibExportPackageLists (\r
+  IN EFI_HII_HANDLE                    Handle,\r
+  OUT EFI_HII_PACKAGE_LIST_HEADER      **PackageListHeader,\r
+  OUT UINTN                            *PackageListSize\r
+  );\r
+\r
+/**\r
+  \r
+  This function returns a list of the package handles of the   \r
+  specified type that are currently active in the HII database. The   \r
+  pseudo-type EFI_HII_PACKAGE_TYPE_ALL will cause all package   \r
+  handles to be listed.\r
+\r
+  If HandleBufferLength is NULL, then ASSERT.\r
+  If HandleBuffer is NULL, the ASSERT.\r
+  If PackageType is EFI_HII_PACKAGE_TYPE_GUID and PackageGuid is\r
+  NULL, then ASSERT.\r
+  If PackageType is not EFI_HII_PACKAGE_TYPE_GUID and PackageGuid is not\r
+  NULL, then ASSERT.\r
+  \r
+  \r
+  @param PackageType          Specifies the package type of the packages\r
+                              to list or EFI_HII_PACKAGE_TYPE_ALL for\r
+                              all packages to be listed.\r
+  \r
+  @param PackageGuid          If PackageType is\r
+                              EFI_HII_PACKAGE_TYPE_GUID, then this is\r
+                              the pointer to the GUID which must match\r
+                              the Guid field of\r
+                              EFI_HII_PACKAGE_GUID_HEADER. Otherwise, it\r
+                              must be NULL.\r
+  \r
+  @param HandleBufferLength   On output, the length of the handle buffer\r
+                              that is required for the handles found.\r
+\r
+  @param HandleBuffer         On output, an array of EFI_HII_HANDLE  instances returned.\r
+                              The caller is responcible to free this pointer allocated.\r
+\r
+  @retval EFI_SUCCESS           The matching handles are outputed successfully.\r
+                                HandleBufferLength is updated with the actual length.\r
+  @retval EFI_OUT_OF_RESOURCES  Not enough resource to complete the operation.\r
+  @retval EFI_NOT_FOUND         No matching handle could not be found in database.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+HiiLibListPackageLists (\r
+  IN        UINT8                     PackageType,\r
+  IN CONST  EFI_GUID                  *PackageGuid,\r
+  IN OUT    UINTN                     *HandleBufferLength,\r
+  OUT       EFI_HII_HANDLE            **Handle\r
+  );\r
+\r
+/**\r
+  Convert language code from RFC3066 to ISO639-2.\r
+\r
+  LanguageRfc3066 contain a single RFC 3066 code such as\r
+  "en-US" or "fr-FR".\r
+\r
+  The LanguageRfc3066 must be a buffer large enough\r
+  for ISO_639_2_ENTRY_SIZE characters.\r
+\r
+  If LanguageRfc3066 is NULL, then ASSERT.\r
+  If LanguageIso639 is NULL, then ASSERT.\r
+\r
+  @param  LanguageRfc3066        RFC3066 language code.\r
+  @param  LanguageIso639         ISO639-2 language code.\r
+\r
+  @retval EFI_SUCCESS            Language code converted.\r
+  @retval EFI_NOT_FOUND          Language code not found.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ConvertRfc3066LanguageToIso639Language (\r
+  IN  CHAR8   *LanguageRfc3066,\r
+  OUT CHAR8   *LanguageIso639\r
+  );\r
+\r
+/**\r
+  Convert language code from ISO639-2 to RFC3066.\r
+\r
+  LanguageIso639 contain a single ISO639-2 code such as\r
+  "eng" or "fra".\r
+\r
+  The LanguageRfc3066 must be a buffer large enough\r
+  for RFC_3066_ENTRY_SIZE characters.\r
+\r
+  If LanguageIso639 is NULL, then ASSERT.\r
+  If LanguageRfc3066 is NULL, then ASSERT.\r
+\r
+  @param  LanguageIso639         ISO639-2 language code.\r
+  @param  LanguageRfc3066        RFC3066 language code.\r
+\r
+  @retval EFI_SUCCESS            Language code converted.\r
+  @retval EFI_NOT_FOUND          Language code not found.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ConvertIso639LanguageToRfc3066Language (\r
+  IN  CONST CHAR8   *LanguageIso639,\r
+  OUT CHAR8         *LanguageRfc3066\r
+  );\r
+\r
+/**\r
+  Convert language code list from RFC3066 to ISO639-2, e.g. "en-US;fr-FR" will\r
+  be converted to "engfra".\r
+\r
+  If SupportedLanguages is NULL, then ASSERT.\r
+\r
+  @param  SupportedLanguages     The RFC3066 language list.\r
+\r
+  @return The ISO639-2 language list.\r
+\r
+**/\r
+CHAR8 *\r
+EFIAPI\r
+Rfc3066ToIso639 (\r
+  CHAR8  *SupportedLanguages\r
+  );\r
+\r
+#endif\r
diff --git a/MdeModulePkg/Include/Library/IfrSupportLib.h b/MdeModulePkg/Include/Library/IfrSupportLib.h
new file mode 100644 (file)
index 0000000..3f686bd
--- /dev/null
@@ -0,0 +1,765 @@
+/** @file\r
+  This library contains functions to do IFR opcode creation and utility functions \r
+  to help module to interact with a UEFI Form Browser.\r
+\r
+  Copyright (c) 2007 - 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 _IFR_SUPPORT_LIBRARY_H_\r
+#define _IFR_SUPPORT_LIBRARY_H_\r
+\r
+\r
+#include <Protocol/HiiFont.h>\r
+#include <Protocol/HiiImage.h>\r
+#include <Protocol/HiiString.h>\r
+#include <Protocol/HiiDatabase.h>\r
+#include <Protocol/HiiConfigRouting.h>\r
+#include <Protocol/HiiConfigAccess.h>\r
+#include <Protocol/FormBrowser2.h>\r
+#include <Protocol/SimpleTextOut.h>\r
+\r
+#include <Guid/GlobalVariable.h>\r
+\r
+//\r
+// The architectural variable "Lang" and "LangCodes" are deprecated in UEFI\r
+// specification. While, UEFI specification also states that these deprecated\r
+// variables may be provided for backwards compatibility.\r
+\r
+#define EFI_LANGUAGE_VARIABLE           L"Lang"\r
+#define EFI_LANGUAGE_CODES_VARIABLE     L"LangCodes"\r
+\r
+#define UEFI_LANGUAGE_VARIABLE          L"PlatformLang"\r
+#define UEFI_LANGUAGE_CODES_VARIABLE    L"PlatformLangCodes"\r
+\r
+#define INVALID_VARSTORE_ID             0\r
+\r
+#define QUESTION_FLAGS              (EFI_IFR_FLAG_READ_ONLY | EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED | EFI_IFR_FLAG_OPTIONS_ONLY)\r
+#define QUESTION_FLAGS_MASK         (~QUESTION_FLAGS)\r
+\r
+#pragma pack(1)\r
+typedef struct {\r
+  EFI_STRING_ID       StringToken;\r
+  EFI_IFR_TYPE_VALUE  Value;\r
+  UINT8               Flags;\r
+} IFR_OPTION;\r
+#pragma pack()\r
+\r
+typedef struct {\r
+  ///\r
+  /// Buffer size allocated for Data.\r
+  ///\r
+  UINT32                BufferSize;\r
+\r
+  ///\r
+  /// Offset in Data to append the newly created opcode binary.\r
+  /// It will be adjusted automatically in Create***OpCode(), and should be\r
+  /// initialized to 0 before invocation of a serial of Create***OpCode()\r
+  ///\r
+  UINT32                Offset;\r
+\r
+  ///\r
+  /// The destination buffer for created op-codes\r
+  ///\r
+  UINT8                 *Data;\r
+} EFI_HII_UPDATE_DATA;\r
+\r
+\r
+/**\r
+  Create EFI_IFR_END_OP opcode.\r
+\r
+  If Data is NULL or Data->Data is NULL, then ASSERT.\r
+\r
+  @param  Data                   Destination for the created opcode binary\r
+\r
+  @retval EFI_SUCCESS            Opcode is created successfully.\r
+  @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CreateEndOpCode (\r
+  IN OUT EFI_HII_UPDATE_DATA *Data\r
+  )\r
+;\r
+\r
+/**\r
+  Create EFI_IFR_DEFAULT_OP opcode.\r
+\r
+  If Data is NULL or Data->Data is NULL, then ASSERT.\r
+\r
+  @param  Value                  Value for the default\r
+  @param  Type                   Type for the default\r
+  @param  Data                   Destination for the created opcode binary\r
+\r
+  @retval EFI_SUCCESS            Opcode is created successfully.\r
+  @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.\r
+  @retval EFI_INVALID_PARAMETER The type is not valid.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CreateDefaultOpCode (\r
+  IN     EFI_IFR_TYPE_VALUE  *Value,\r
+  IN     UINT8               Type,\r
+  IN OUT EFI_HII_UPDATE_DATA *Data\r
+  )\r
+;\r
+\r
+/**\r
+  Create EFI_IFR_ACTION_OP opcode.\r
+\r
+  If Data is NULL or Data->Data is NULL, then ASSERT.\r
+\r
+  @param  QuestionId             Question ID\r
+  @param  Prompt                 String ID for Prompt\r
+  @param  Help                   String ID for Help\r
+  @param  QuestionFlags          Flags in Question Header\r
+  @param  QuestionConfig         String ID for configuration\r
+  @param  Data                   Destination for the created opcode binary\r
+\r
+  @retval EFI_SUCCESS            Opcode is created successfully.\r
+  @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.\r
+  @retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CreateActionOpCode (\r
+  IN     EFI_QUESTION_ID      QuestionId,\r
+  IN     EFI_STRING_ID        Prompt,\r
+  IN     EFI_STRING_ID        Help,\r
+  IN     UINT8                QuestionFlags,\r
+  IN     EFI_STRING_ID        QuestionConfig,\r
+  IN OUT EFI_HII_UPDATE_DATA  *Data\r
+  )\r
+;\r
+\r
+/**\r
+  Create EFI_IFR_SUBTITLE_OP opcode.\r
+\r
+  If Data is NULL or Data->Data is NULL, then ASSERT.\r
+\r
+  @param  Prompt                 String ID for Prompt\r
+  @param  Help                   String ID for Help\r
+  @param  Flags                  Subtitle opcode flags\r
+  @param  Scope                  Subtitle Scope bit\r
+  @param  Data                   Destination for the created opcode binary\r
+\r
+  @retval EFI_SUCCESS            Opcode is created successfully.\r
+  @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.\r
+  \r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CreateSubTitleOpCode (\r
+  IN      EFI_STRING_ID       Prompt,\r
+  IN      EFI_STRING_ID       Help,\r
+  IN      UINT8               Flags,\r
+  IN      UINT8               Scope,\r
+  IN OUT EFI_HII_UPDATE_DATA  *Data\r
+  )\r
+;\r
+\r
+/**\r
+  Create EFI_IFR_TEXT_OP opcode.\r
+\r
+  If Data is NULL or Data->Data is NULL, then ASSERT.\r
+\r
+  @param  Prompt                 String ID for Prompt\r
+  @param  Help                   String ID for Help\r
+  @param  TextTwo                String ID for text two\r
+  @param  Data                   Destination for the created opcode binary\r
+\r
+  @retval EFI_SUCCESS            Opcode is created successfully.\r
+  @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CreateTextOpCode (\r
+  IN      EFI_STRING_ID       Prompt,\r
+  IN      EFI_STRING_ID       Help,\r
+  IN      EFI_STRING_ID       TextTwo,\r
+  IN OUT  EFI_HII_UPDATE_DATA *Data\r
+  )\r
+;\r
+\r
+/**\r
+  Create EFI_IFR_REF_OP opcode.\r
+\r
+  If Data is NULL or Data->Data is NULL, then ASSERT.\r
+\r
+  @param  FormId                 Destination Form ID\r
+  @param  Prompt                 String ID for Prompt\r
+  @param  Help                   String ID for Help\r
+  @param  QuestionFlags          Flags in Question Header\r
+  @param  QuestionId             Question ID\r
+  @param  Data                   Destination for the created opcode binary\r
+\r
+  @retval EFI_SUCCESS            Opcode is created successfully.\r
+  @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.\r
+  @retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CreateGotoOpCode (\r
+  IN      EFI_FORM_ID         FormId,\r
+  IN      EFI_STRING_ID       Prompt,\r
+  IN      EFI_STRING_ID       Help,\r
+  IN      UINT8               QuestionFlags,\r
+  IN      EFI_QUESTION_ID     QuestionId,\r
+  IN OUT  EFI_HII_UPDATE_DATA *Data\r
+  )\r
+;\r
+\r
+/**\r
+  Create EFI_IFR_ONE_OF_OPTION_OP opcode.\r
+\r
+  If Data is NULL or Data->Data is NULL, then ASSERT.\r
+\r
+  @param  OptionCount            The number of options.\r
+  @param  OptionsList            The list of Options.\r
+  @param  Type                   The data type.\r
+  @param  Data                   Destination for the created opcode binary\r
+\r
+  @retval EFI_SUCCESS            Opcode is created successfully.\r
+  @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.\r
+  @retval EFI_INVALID_PARAMETER If OptionCount is not zero but OptionsList is NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CreateOneOfOptionOpCode (\r
+  IN     UINTN                OptionCount,\r
+  IN     IFR_OPTION           *OptionsList,\r
+  IN     UINT8                Type,\r
+  IN OUT EFI_HII_UPDATE_DATA  *Data\r
+  )\r
+;\r
+\r
+/**\r
+  Create EFI_IFR_ONE_OF_OP opcode.\r
+\r
+  If Data is NULL or Data->Data is NULL, then ASSERT.\r
+\r
+  @param  QuestionId             Question ID\r
+  @param  VarStoreId             Storage ID\r
+  @param  VarOffset              Offset in Storage\r
+  @param  Prompt                 String ID for Prompt\r
+  @param  Help                   String ID for Help\r
+  @param  QuestionFlags          Flags in Question Header\r
+  @param  OneOfFlags             Flags for oneof opcode\r
+  @param  OptionsList            List of options\r
+  @param  OptionCount            Number of options in option list\r
+  @param  Data                   Destination for the created opcode binary\r
+\r
+  @retval EFI_SUCCESS            Opcode is created successfully.\r
+  @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.\r
+  @retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CreateOneOfOpCode (\r
+  IN     EFI_QUESTION_ID      QuestionId,\r
+  IN     EFI_VARSTORE_ID      VarStoreId,\r
+  IN     UINT16               VarOffset,\r
+  IN     EFI_STRING_ID        Prompt,\r
+  IN     EFI_STRING_ID        Help,\r
+  IN     UINT8                QuestionFlags,\r
+  IN     UINT8                OneOfFlags,\r
+  IN     IFR_OPTION           *OptionsList,\r
+  IN     UINTN                OptionCount,\r
+  IN OUT EFI_HII_UPDATE_DATA  *Data\r
+  )\r
+;\r
+\r
+/**\r
+  Create EFI_IFR_ORDERED_LIST_OP opcode.\r
+\r
+  If Data is NULL or Data->Data is NULL, then ASSERT.\r
+\r
+  @param  QuestionId             Question ID\r
+  @param  VarStoreId             Storage ID\r
+  @param  VarOffset              Offset in Storage\r
+  @param  Prompt                 String ID for Prompt\r
+  @param  Help                   String ID for Help\r
+  @param  QuestionFlags          Flags in Question Header\r
+  @param  OrderedListFlags       Flags for ordered list opcode\r
+  @param  DataType               Type for option value\r
+  @param  MaxContainers          Maximum count for options in this ordered list\r
+  @param  OptionsList            List of options\r
+  @param  OptionCount            Number of options in option list\r
+  @param  Data                   Destination for the created opcode binary\r
+\r
+  @retval EFI_SUCCESS            Opcode is created successfully.\r
+  @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.\r
+  @retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CreateOrderedListOpCode (\r
+  IN      EFI_QUESTION_ID     QuestionId,\r
+  IN      EFI_VARSTORE_ID     VarStoreId,\r
+  IN      UINT16              VarOffset,\r
+  IN      EFI_STRING_ID       Prompt,\r
+  IN      EFI_STRING_ID       Help,\r
+  IN      UINT8               QuestionFlags,\r
+  IN      UINT8               OrderedListFlags,\r
+  IN      UINT8               DataType,\r
+  IN      UINT8               MaxContainers,\r
+  IN      IFR_OPTION          *OptionsList,\r
+  IN      UINTN               OptionCount,\r
+  IN OUT  EFI_HII_UPDATE_DATA *Data\r
+  )\r
+;\r
+\r
+/**\r
+  Create EFI_IFR_CHECKBOX_OP opcode.\r
+\r
+  If Data is NULL or Data->Data is NULL, then ASSERT.\r
+\r
+  @param  QuestionId             Question ID\r
+  @param  VarStoreId             Storage ID\r
+  @param  VarOffset              Offset in Storage\r
+  @param  Prompt                 String ID for Prompt\r
+  @param  Help                   String ID for Help\r
+  @param  QuestionFlags          Flags in Question Header\r
+  @param  CheckBoxFlags          Flags for checkbox opcode\r
+  @param  Data                   Destination for the created opcode binary\r
+\r
+  @retval EFI_SUCCESS            Opcode is created successfully.\r
+  @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.\r
+  @retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CreateCheckBoxOpCode (\r
+  IN      EFI_QUESTION_ID     QuestionId,\r
+  IN      EFI_VARSTORE_ID     VarStoreId,\r
+  IN      UINT16              VarOffset,\r
+  IN      EFI_STRING_ID       Prompt,\r
+  IN      EFI_STRING_ID       Help,\r
+  IN      UINT8               QuestionFlags,\r
+  IN      UINT8               CheckBoxFlags,\r
+  IN OUT EFI_HII_UPDATE_DATA  *Data\r
+  )\r
+;\r
+\r
+/**\r
+  Create EFI_IFR_NUMERIC_OP opcode.\r
+\r
+  If Data is NULL or Data->Data is NULL, then ASSERT.\r
+\r
+  @param  QuestionId             Question ID\r
+  @param  VarStoreId             Storage ID\r
+  @param  VarOffset              Offset in Storage\r
+  @param  Prompt                 String ID for Prompt\r
+  @param  Help                   String ID for Help\r
+  @param  QuestionFlags          Flags in Question Header\r
+  @param  NumericFlags           Flags for numeric opcode\r
+  @param  Minimum                Numeric minimum value\r
+  @param  Maximum                Numeric maximum value\r
+  @param  Step                   Numeric step for edit\r
+  @param  Default                Numeric default value\r
+  @param  Data                   Destination for the created opcode binary\r
+\r
+  @retval EFI_SUCCESS            Opcode is created successfully.\r
+  @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.\r
+  @retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CreateNumericOpCode (\r
+  IN     EFI_QUESTION_ID     QuestionId,\r
+  IN     EFI_VARSTORE_ID     VarStoreId,\r
+  IN     UINT16              VarOffset,\r
+  IN     EFI_STRING_ID       Prompt,\r
+  IN     EFI_STRING_ID       Help,\r
+  IN     UINT8               QuestionFlags,\r
+  IN     UINT8               NumericFlags,\r
+  IN     UINT64              Minimum,\r
+  IN     UINT64              Maximum,\r
+  IN     UINT64              Step,\r
+  IN     UINT64              Default,\r
+  IN OUT EFI_HII_UPDATE_DATA *Data\r
+  )\r
+;\r
+\r
+/**\r
+  Create EFI_IFR_STRING_OP opcode.\r
+\r
+  If Data is NULL or Data->Data is NULL, then ASSERT.\r
+\r
+  @param  QuestionId             Question ID\r
+  @param  VarStoreId             Storage ID\r
+  @param  VarOffset              Offset in Storage\r
+  @param  Prompt                 String ID for Prompt\r
+  @param  Help                   String ID for Help\r
+  @param  QuestionFlags          Flags in Question Header\r
+  @param  StringFlags            Flags for string opcode\r
+  @param  MinSize                String minimum length\r
+  @param  MaxSize                String maximum length\r
+  @param  Data                   Destination for the created opcode binary\r
+\r
+  @retval EFI_SUCCESS            Opcode is created successfully.\r
+  @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.\r
+  @retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CreateStringOpCode (\r
+  IN      EFI_QUESTION_ID     QuestionId,\r
+  IN      EFI_VARSTORE_ID     VarStoreId,\r
+  IN      UINT16              VarOffset,\r
+  IN      EFI_STRING_ID       Prompt,\r
+  IN      EFI_STRING_ID       Help,\r
+  IN      UINT8               QuestionFlags,\r
+  IN      UINT8               StringFlags,\r
+  IN      UINT8               MinSize,\r
+  IN      UINT8               MaxSize,\r
+  IN OUT EFI_HII_UPDATE_DATA  *Data\r
+  )\r
+;\r
+/**\r
+    Construct <ConfigAltResp> for a buffer storage.\r
+\r
+    @param ConfigRequest           The Config request string. If set to NULL, all the\r
+                                   configurable elements will be extracted from BlockNameArray.\r
+    @param ConfigAltResp           The returned <ConfigAltResp>.\r
+    @param Progress                On return, points to a character in the Request.\r
+    @param Guid                    GUID of the buffer storage.\r
+    @param Name                    Name of the buffer storage.\r
+    @param DriverHandle            The DriverHandle which is used to invoke HiiDatabase\r
+                                   protocol interface NewPackageList().\r
+    @param BufferStorage           Content of the buffer storage.\r
+    @param BufferStorageSize       Length in bytes of the buffer storage.\r
+    @param BlockNameArray          Array generated by VFR compiler.\r
+    @param NumberAltCfg            Number of Default value array generated by VFR compiler.\r
+                                   The sequential input parameters will be number of\r
+                                   AltCfgId and DefaultValueArray pairs. When set to 0,\r
+                                   there will be no <AltResp>.\r
+\r
+    retval EFI_OUT_OF_RESOURCES  Run out of memory resource.\r
+    retval EFI_INVALID_PARAMETER ConfigAltResp is NULL.\r
+    retval EFI_SUCCESS           Operation successful.\r
+\r
+**/\r
+EFI_STATUS\r
+ConstructConfigAltResp (\r
+  IN  EFI_STRING                  ConfigRequest,  OPTIONAL\r
+  OUT EFI_STRING                  *Progress,\r
+  OUT EFI_STRING                  *ConfigAltResp,\r
+  IN  EFI_GUID                    *Guid,\r
+  IN  CHAR16                      *Name,\r
+  IN  EFI_HANDLE                  *DriverHandle,\r
+  IN  VOID                        *BufferStorage,\r
+  IN  UINTN                       BufferStorageSize,\r
+  IN  VOID                        *BlockNameArray, OPTIONAL\r
+  IN  UINTN                       NumberAltCfg,\r
+  ...\r
+//IN  UINT16                      AltCfgId,\r
+//IN  VOID                        *DefaultValueArray,\r
+  )\r
+;\r
+\r
+/**\r
+  Converts the unicode character of the string from uppercase to lowercase.\r
+\r
+  @param Str     String to be converted\r
+\r
\r
+**/\r
+VOID\r
+EFIAPI\r
+ToLower (\r
+  IN OUT CHAR16    *Str\r
+  )\r
+;\r
+\r
+/**\r
+  Converts binary buffer to a Unicode string. The byte buffer is in a reversed byte order \r
+  compared with the byte order defined in BufToHexString().\r
+\r
+  @param  Str                    String for output\r
+  @param  Buffer                 Binary buffer.\r
+  @param  BufferSize             Size of the buffer in bytes.\r
+\r
+  @retval EFI_SUCCESS            The function completed successfully.\r
+  @retval EFI_OUT_OF_RESOURCES   There is no enough available memory space.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BufInReverseOrderToHexString (\r
+  IN OUT CHAR16    *Str,\r
+  IN UINT8         *Buffer,\r
+  IN UINTN         BufferSize\r
+  )\r
+;\r
+\r
+/**\r
+  Converts Hex String to binary buffer in reversed byte order to HexStringToBuf().\r
+\r
+  @param  Buffer                 Pointer to buffer that receives the data.\r
+  @param  BufferSize             Length in bytes of the buffer to hold converted\r
+                                 data. If routine return with EFI_SUCCESS,\r
+                                 containing length of converted data. If routine\r
+                                 return with EFI_BUFFER_TOO_SMALL, containg length\r
+                                 of buffer desired.\r
+  @param  Str                    String to be converted from.\r
+\r
+  @retval EFI_SUCCESS            The function completed successfully.\r
+  @retval RETURN_BUFFER_TOO_SMALL   The input BufferSize is too small to hold the output. BufferSize\r
+                                   will be updated to the size required for the converstion.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+HexStringToBufInReverseOrder (\r
+  IN OUT UINT8         *Buffer,\r
+  IN OUT UINTN         *BufferSize,\r
+  IN CHAR16            *Str\r
+  )\r
+;\r
+\r
+/**\r
+  Convert binary representation Config string (e.g. "0041004200430044") to the\r
+  original string (e.g. "ABCD"). Config string appears in <ConfigHdr> (i.e.\r
+  "&NAME=<string>"), or Name/Value pair in <ConfigBody> (i.e. "label=<string>").\r
+\r
+  @param UnicodeString  Original Unicode string.\r
+  @param StrBufferLen   On input: Length in bytes of buffer to hold the Unicode string.\r
+                                    Includes tailing '\0' character.\r
+                                    On output:\r
+                                      containing length of Unicode string buffer when returning EFI_SUCCESS;\r
+                                      containg length of string buffer desired when returning EFI_BUFFER_TOO_SMALL.\r
+  @param ConfigString   Binary representation of Unicode String, <string> := (<HexCh>4)+\r
+\r
+  @retval EFI_SUCCESS          Operation completes successfully.\r
+  @retval EFI_BUFFER_TOO_SMALL The string buffer is too small.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ConfigStringToUnicode (\r
+  IN OUT CHAR16                *UnicodeString,\r
+  IN OUT UINTN                 *StrBufferLen,\r
+  IN CHAR16                    *ConfigString\r
+  )\r
+;\r
+\r
+/**\r
+  Convert Unicode string to binary representation Config string, e.g.\r
+  "ABCD" => "0041004200430044". Config string appears in <ConfigHdr> (i.e.\r
+  "&NAME=<string>"), or Name/Value pair in <ConfigBody> (i.e. "label=<string>").\r
+\r
+  @param ConfigString   Binary representation of Unicode String, <string> := (<HexCh>4)+\r
+  @param  StrBufferLen  On input: Length in bytes of buffer to hold the Unicode string.\r
+                                    Includes tailing '\0' character.\r
+                                    On output:\r
+                                      If return EFI_SUCCESS, containing length of Unicode string buffer.\r
+                                      If return EFI_BUFFER_TOO_SMALL, containg length of string buffer desired.\r
+  @param  UnicodeString  Original Unicode string.\r
+\r
+  @retval EFI_SUCCESS           Operation completes successfully.\r
+  @retval EFI_BUFFER_TOO_SMALL  The string buffer is too small.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UnicodeToConfigString (\r
+  IN OUT CHAR16                *ConfigString,\r
+  IN OUT UINTN                 *StrBufferLen,\r
+  IN CHAR16                    *UnicodeString\r
+  )\r
+;\r
+\r
+/**\r
+  Construct <ConfigHdr> using routing information GUID/NAME/PATH.\r
+\r
+  @param  ConfigHdr              Pointer to the ConfigHdr string.\r
+  @param  StrBufferLen           On input: Length in bytes of buffer to hold the\r
+                                 ConfigHdr string. Includes tailing '\0' character.\r
+                                 On output: If return EFI_SUCCESS, containing\r
+                                 length of ConfigHdr string buffer. If return\r
+                                 EFI_BUFFER_TOO_SMALL, containg length of string\r
+                                 buffer desired.\r
+  @param  Guid                   Routing information: GUID.\r
+  @param  Name                   Routing information: NAME.\r
+  @param  DriverHandle           Driver handle which contains the routing\r
+                                 information: PATH.\r
+\r
+  @retval EFI_SUCCESS            Operation completes successfully.\r
+  @retval EFI_BUFFER_TOO_SMALL   The ConfigHdr string buffer is too small.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ConstructConfigHdr (\r
+  IN OUT CHAR16                *ConfigHdr,\r
+  IN OUT UINTN                 *StrBufferLen,\r
+  IN CONST EFI_GUID            *Guid,\r
+  IN CHAR16                    *Name, OPTIONAL\r
+  IN EFI_HANDLE                *DriverHandle\r
+  )\r
+\r
+;\r
+\r
+/**\r
+  Determines if the Routing data (Guid and Name) is correct in <ConfigHdr>.\r
+\r
+  @param ConfigString  Either <ConfigRequest> or <ConfigResp>.\r
+  @param StorageGuid   GUID of the storage.\r
+  @param StorageName   Name of the stoarge.\r
+\r
+  @retval TRUE         Routing information is correct in ConfigString.\r
+  @retval FALSE        Routing information is incorrect in ConfigString.\r
+\r
+**/\r
+BOOLEAN\r
+IsConfigHdrMatch (\r
+  IN EFI_STRING                ConfigString,\r
+  IN EFI_GUID                  *StorageGuid, OPTIONAL\r
+  IN CHAR16                    *StorageName  OPTIONAL\r
+  )\r
+;\r
+\r
+/**\r
+  Search BlockName "&OFFSET=Offset&WIDTH=Width" in a string.\r
+\r
+  @param  String                 The string to be searched in.\r
+  @param  Offset                 Offset in BlockName.\r
+  @param  Width                  Width in BlockName.\r
+\r
+  @retval TRUE                   Block name found.\r
+  @retval FALSE                  Block name not found.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+FindBlockName (\r
+  IN OUT CHAR16                *String,\r
+  IN UINTN                     Offset,\r
+  IN UINTN                     Width\r
+  )\r
+;\r
+\r
+/**\r
+  This routine is invoked by ConfigAccess.Callback() to retrived uncommitted data from Form Browser.\r
+\r
+  @param  VariableGuid           An optional field to indicate the target variable\r
+                                 GUID name to use.\r
+  @param  VariableName           An optional field to indicate the target\r
+                                 human-readable variable name.\r
+  @param  BufferSize             On input: Length in bytes of buffer to hold\r
+                                 retrived data. On output: If return\r
+                                 EFI_BUFFER_TOO_SMALL, containg length of buffer\r
+                                 desired.\r
+  @param  Buffer                 Buffer to hold retrived data.\r
+\r
+  @retval EFI_SUCCESS            Operation completes successfully.\r
+  @retval EFI_BUFFER_TOO_SMALL   The intput buffer is too small.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GetBrowserData (\r
+  IN CONST EFI_GUID          *VariableGuid, OPTIONAL\r
+  IN CONST CHAR16            *VariableName, OPTIONAL\r
+  IN OUT UINTN               *BufferSize,\r
+  IN OUT UINT8               *Buffer\r
+  )\r
+;\r
+\r
+/**\r
+  This routine is invoked by ConfigAccess.Callback() to update uncommitted data of Form Browser.\r
+\r
+  @param  VariableGuid           An optional field to indicate the target variable\r
+                                 GUID name to use.\r
+  @param  VariableName           An optional field to indicate the target\r
+                                 human-readable variable name.\r
+  @param  BufferSize             Length in bytes of buffer to hold retrived data.\r
+  @param  Buffer                 Buffer to hold retrived data.\r
+  @param  RequestElement         An optional field to specify which part of the\r
+                                 buffer data will be send back to Browser. If NULL,\r
+                                 the whole buffer of data will be committed to\r
+                                 Browser. <RequestElement> ::=\r
+                                 &OFFSET=<Number>&WIDTH=<Number>*\r
+\r
+  @retval EFI_SUCCESS            Operation completes successfully.\r
+  @retval Other                  Updating Browser uncommitted data failed.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SetBrowserData (\r
+  IN CONST EFI_GUID          *VariableGuid, OPTIONAL\r
+  IN CONST CHAR16            *VariableName, OPTIONAL\r
+  IN UINTN                   BufferSize,\r
+  IN CONST UINT8             *Buffer,\r
+  IN CONST CHAR16            *RequestElement  OPTIONAL\r
+  )\r
+;\r
+\r
+/**\r
+  Draw a dialog and return the selected key.\r
+\r
+  @param  NumberOfLines          The number of lines for the dialog box\r
+  @param  KeyValue               The EFI_KEY value returned if HotKey is TRUE..\r
+  @param  String                 Pointer to the first string in the list\r
+  @param  ...                    A series of (quantity == NumberOfLines - 1) text\r
+                                 strings which will be used to construct the dialog\r
+                                 box\r
+\r
+  @retval EFI_SUCCESS            Displayed dialog and received user interaction\r
+  @retval EFI_INVALID_PARAMETER  One of the parameters was invalid.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+IfrLibCreatePopUp (\r
+  IN  UINTN                       NumberOfLines,\r
+  OUT EFI_INPUT_KEY               *KeyValue,\r
+  IN  CHAR16                      *String,\r
+  ...\r
+  )\r
+;\r
+\r
+/**\r
+  Draw a dialog and return the selected key using Variable Argument List.\r
+\r
+  @param  NumberOfLines          The number of lines for the dialog box\r
+  @param  KeyValue               The EFI_KEY value returned if HotKey is TRUE..\r
+  @param  Args                   VA_LIST marker for the variable argument list.\r
+                                 A series of (quantity == NumberOfLines - 1) text\r
+                                 strings which will be used to construct the dialog\r
+                                 box\r
+\r
+  @retval EFI_SUCCESS            Displayed dialog and received user interaction\r
+  @retval EFI_INVALID_PARAMETER  One of the parameters was invalid.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+IfrLibCreatePopUp2 (\r
+  IN  UINTN                       NumberOfLines,\r
+  OUT EFI_INPUT_KEY               *KeyValue,\r
+  IN  VA_LIST                     Args\r
+  )\r
+;\r
+\r
+#endif\r