]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Update UefiHiiLib to support new defined IFR related HII APIs.
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 13 Apr 2009 06:05:15 +0000 (06:05 +0000)
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 13 Apr 2009 06:05:15 +0000 (06:05 +0000)
Apply new defined IFR related HII APIs in PlatOverMngr, DriverSample, IScsiDxe and Setup drivers.

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

25 files changed:
MdeModulePkg/Application/PlatOverMngr/PlatOverMngr.c
MdeModulePkg/Application/PlatOverMngr/PlatOverMngr.h
MdeModulePkg/Application/PlatOverMngr/PlatOverMngr.inf
MdeModulePkg/Application/PlatOverMngr/Vfr.vfr
MdeModulePkg/Include/Library/HiiLib.h
MdeModulePkg/Include/Library/NewHiiLib.h
MdeModulePkg/Library/NewHiiLib/HiiLib.c
MdeModulePkg/Library/UefiHiiLib/HiiLanguage.c
MdeModulePkg/Library/UefiHiiLib/HiiLib.c
MdeModulePkg/Library/UefiHiiLib/HiiString.c
MdeModulePkg/Library/UefiHiiLib/InternalHiiLib.h
MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf
MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c
MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h
MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf
MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h
MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr
MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c
MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.h
MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfigDxe.vfr
MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfigNVDataStruc.h
MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf
MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
MdeModulePkg/Universal/SetupBrowserDxe/Setup.h
MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf

index d9a530296e8a80b4143b5328c5d8cd148d6b509c..64a26c66657529c73c69011a5cb8f7e9094b7499 100644 (file)
@@ -38,6 +38,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Protocol/DriverBinding.h>\r
 #include <Protocol/DevicePathToText.h>\r
 #include <Protocol/DevicePath.h>\r
+#include <Guid/MdeModuleHii.h>\r
 \r
 #include <Library/DevicePathLib.h>\r
 #include <Library/BaseLib.h>\r
@@ -46,12 +47,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/UefiApplicationEntryPoint.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/PlatformDriverOverrideLib.h>\r
-#include <Library/HiiLib.h>\r
-#include <Library/IfrSupportLib.h>\r
-#include <Library/ExtendedIfrSupportLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/DevicePathLib.h>\r
+#include <Library/HiiLib.h>\r
+\r
 #include "PlatOverMngr.h"\r
 \r
 #define EFI_CALLBACK_INFO_SIGNATURE SIGNATURE_32 ('C', 'l', 'b', 'k')\r
@@ -88,6 +88,7 @@ extern UINT8  PlatOverMngrStrings[];
 // module global data\r
 //\r
 EFI_GUID                     mPlatformOverridesManagerGuid = PLAT_OVER_MNGR_GUID;\r
+CHAR16                       mVariableName[] = L"Data";\r
 LIST_ENTRY                   mMappingDataBase = INITIALIZE_LIST_HEAD_VARIABLE (mMappingDataBase);\r
 \r
 EFI_HANDLE                   *mDevicePathHandleBuffer;\r
@@ -103,6 +104,7 @@ EFI_DEVICE_PATH_PROTOCOL     *mControllerDevicePathProtocol[MAX_CHOICE_NUM];
 UINTN                        mSelectedDriverImageNum;\r
 UINTN                        mLastSavedDriverImageNum;\r
 UINT16                       mCurrentPage;\r
+EFI_CALLBACK_INFO           *mCallbackInfo;\r
 \r
 HII_VENDOR_DEVICE_PATH  mHiiVendorDevicePath = {\r
   {\r
@@ -114,10 +116,7 @@ HII_VENDOR_DEVICE_PATH  mHiiVendorDevicePath = {
         (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)\r
       }\r
     },\r
-    //\r
-    // {99936717-BF3D-4b04-9787-76CEE324D76F}\r
-    //\r
-    { 0x99936717, 0xbf3d, 0x4b04, { 0x97, 0x87, 0x76, 0xce, 0xe3, 0x24, 0xd7, 0x6f } }\r
+    EFI_CALLER_ID_GUID\r
   },\r
   {\r
     END_DEVICE_PATH_TYPE,\r
@@ -345,7 +344,6 @@ UpdateDeviceSelectPage (
   IN PLAT_OVER_MNGR_DATA              *FakeNvData\r
   )\r
 {\r
-  EFI_HII_UPDATE_DATA                       UpdateData;\r
   EFI_STATUS                                Status;\r
   UINTN                                     Index;\r
   UINTN                                     DevicePathHandleCount;\r
@@ -356,9 +354,13 @@ UpdateDeviceSelectPage (
   EFI_PCI_IO_PROTOCOL                       *PciIo;\r
   EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL *BusSpecificDriverOverride;\r
   UINTN                                     Len;\r
-  \r
+  VOID                                      *StartOpCodeHandle;\r
+  VOID                                      *EndOpCodeHandle;\r
+  EFI_IFR_GUID_LABEL                        *StartLabel;\r
+  EFI_IFR_GUID_LABEL                        *EndLabel;  \r
+\r
   //\r
-  // set current page form ID.\r
+  // Set current page form ID.\r
   //\r
   mCurrentPage = FORM_ID_DEVICE;  \r
   \r
@@ -366,25 +368,40 @@ UpdateDeviceSelectPage (
   // Initial the mapping database in memory\r
   //\r
   FreeMappingDatabase (&mMappingDataBase);\r
-  Status = InitOverridesMapping (&mMappingDataBase);\r
+  InitOverridesMapping (&mMappingDataBase);\r
+\r
+  //\r
+  // Init OpCode Handle\r
+  //\r
+  StartOpCodeHandle = HiiAllocateOpCodeHandle ();\r
+  ASSERT (StartOpCodeHandle != NULL);\r
 \r
+  EndOpCodeHandle = HiiAllocateOpCodeHandle ();\r
+  ASSERT (EndOpCodeHandle != NULL);\r
+\r
+  //\r
+  // Create Hii Extend Label OpCode as the start opcode\r
   //\r
-  // Clear all the content in the first page\r
+  StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));\r
+  StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
+  StartLabel->Number = FORM_ID_DEVICE;\r
+\r
   //\r
-  UpdateData.BufferSize = UPDATE_DATA_SIZE;\r
-  UpdateData.Offset = 0;\r
-  UpdateData.Data = AllocateZeroPool (UPDATE_DATA_SIZE);\r
-  ASSERT (UpdateData.Data != NULL);\r
+  // Create Hii Extend Label OpCode as the end opcode\r
+  //\r
+  EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (EndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));\r
+  EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
+  EndLabel->Number       = LABEL_END;\r
+\r
   //\r
   // Clear first page form\r
   //\r
-  IfrLibUpdateForm (\r
+  HiiUpdateForm (\r
     Private->RegisteredHandle,\r
     &mPlatformOverridesManagerGuid,\r
     FORM_ID_DEVICE,\r
-    FORM_ID_DEVICE,\r
-    FALSE,\r
-    &UpdateData\r
+    StartOpCodeHandle, // Label FORM_ID_DEVICE\r
+    EndOpCodeHandle    // LABEL_END\r
     );\r
 \r
   //\r
@@ -499,30 +516,31 @@ UpdateDeviceSelectPage (
     // Save the device path string toke for next access use\r
     //\r
     mControllerToken[Index] = NewStringToken;\r
-\r
-    CreateGotoOpCode (\r
+      \r
+    HiiCreateGotoOpCode (\r
+      StartOpCodeHandle,\r
       FORM_ID_DRIVER,\r
       NewStringToken,\r
       STRING_TOKEN (STR_GOTO_HELP_DRIVER),\r
       EFI_IFR_FLAG_CALLBACK,\r
-      (UINT16) (Index + KEY_VALUE_DEVICE_OFFSET),\r
-      &UpdateData\r
+      (UINT16) (Index + KEY_VALUE_DEVICE_OFFSET)\r
       );\r
   }\r
 \r
   //\r
   // Update first page form\r
   //\r
-  IfrLibUpdateForm (\r
+  HiiUpdateForm (\r
     Private->RegisteredHandle,\r
     &mPlatformOverridesManagerGuid,\r
     FORM_ID_DEVICE,\r
-    FORM_ID_DEVICE,\r
-    FALSE,\r
-    &UpdateData\r
+    StartOpCodeHandle, // Label FORM_ID_DEVICE\r
+    EndOpCodeHandle    // LABEL_END\r
     );\r
 \r
-  FreePool (UpdateData.Data);\r
+  HiiFreeOpCodeHandle (StartOpCodeHandle);\r
+  HiiFreeOpCodeHandle (EndOpCodeHandle);\r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -613,7 +631,6 @@ UpdateBindingDriverSelectPage (
   IN PLAT_OVER_MNGR_DATA              *FakeNvData\r
   )\r
 {\r
-  EFI_HII_UPDATE_DATA                       UpdateData;\r
   EFI_STATUS                                Status;\r
   UINTN                                     Index;\r
   CHAR16                                    *NewString;\r
@@ -626,6 +643,10 @@ UpdateBindingDriverSelectPage (
   EFI_DEVICE_PATH_PROTOCOL                  *LoadedImageDevicePath;\r
   EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL *BusSpecificDriverOverride;\r
   EFI_HANDLE                                DriverBindingHandle;\r
+  VOID                                      *StartOpCodeHandle;\r
+  VOID                                      *EndOpCodeHandle;\r
+  EFI_IFR_GUID_LABEL                        *StartLabel;\r
+  EFI_IFR_GUID_LABEL                        *EndLabel;\r
 \r
   //\r
   // If user select a controller item in the first page  the following code will be run.\r
@@ -641,26 +662,42 @@ UpdateBindingDriverSelectPage (
   // Switch the item callback key value to its NO. in mDevicePathHandleBuffer\r
   //\r
   mSelectedCtrIndex = KeyValue - KEY_VALUE_DEVICE_OFFSET;\r
-  ASSERT (mSelectedCtrIndex > 0 && mSelectedCtrIndex < MAX_CHOICE_NUM);\r
+  ASSERT (mSelectedCtrIndex < MAX_CHOICE_NUM);\r
 \r
   mLastSavedDriverImageNum = 0;\r
+\r
   //\r
-  // Clear all the content in dynamic page\r
+  // Init OpCode Handle\r
   //\r
-  UpdateData.BufferSize = UPDATE_DATA_SIZE;\r
-  UpdateData.Offset = 0;\r
-  UpdateData.Data = AllocateZeroPool (UPDATE_DATA_SIZE);\r
-  ASSERT (UpdateData.Data != NULL);\r
+  StartOpCodeHandle = HiiAllocateOpCodeHandle ();\r
+  ASSERT (StartOpCodeHandle != NULL);\r
+\r
+  EndOpCodeHandle = HiiAllocateOpCodeHandle ();\r
+  ASSERT (EndOpCodeHandle != NULL);\r
+\r
+  //\r
+  // Create Hii Extend Label OpCode as the start opcode\r
+  //\r
+  StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));\r
+  StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
+  StartLabel->Number       = FORM_ID_DRIVER;\r
+\r
+  //\r
+  // Create Hii Extend Label OpCode as the end opcode\r
+  //\r
+  EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (EndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));\r
+  EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
+  EndLabel->Number       = LABEL_END;\r
+\r
   //\r
   // Clear second page form\r
   //\r
-  IfrLibUpdateForm (\r
+  HiiUpdateForm (\r
     Private->RegisteredHandle,\r
     &mPlatformOverridesManagerGuid,\r
     FORM_ID_DRIVER,\r
-    FORM_ID_DRIVER,\r
-    FALSE,\r
-    &UpdateData\r
+    StartOpCodeHandle,\r
+    EndOpCodeHandle\r
     );\r
 \r
   //\r
@@ -816,7 +853,8 @@ UpdateBindingDriverSelectPage (
     FreePool (NewString);\r
     FreePool (DriverName);\r
 \r
-    CreateCheckBoxOpCode (\r
+    HiiCreateCheckBoxOpCode (\r
+      StartOpCodeHandle,\r
       (UINT16) (DRIVER_SELECTION_QUESTION_ID + Index),\r
       VARSTORE_ID_PLAT_OVER_MNGR,\r
       (UINT16) (DRIVER_SELECTION_VAR_OFFSET + Index),\r
@@ -824,23 +862,23 @@ UpdateBindingDriverSelectPage (
       NewStringHelpToken,\r
       0,\r
       0,\r
-      &UpdateData\r
+      NULL\r
       );\r
   }\r
 \r
   //\r
   // Update second page form\r
   //\r
-  IfrLibUpdateForm (\r
+  HiiUpdateForm (\r
     Private->RegisteredHandle,\r
     &mPlatformOverridesManagerGuid,\r
     FORM_ID_DRIVER,\r
-    FORM_ID_DRIVER,\r
-    FALSE,\r
-    &UpdateData\r
+    StartOpCodeHandle, // Label FORM_ID_DRIVER\r
+    EndOpCodeHandle    // LABEL_END\r
     );\r
 \r
-  FreePool (UpdateData.Data);\r
+  HiiFreeOpCodeHandle (StartOpCodeHandle);\r
+  HiiFreeOpCodeHandle (EndOpCodeHandle);\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -862,15 +900,19 @@ UpdatePrioritySelectPage (
   IN PLAT_OVER_MNGR_DATA              *FakeNvData\r
   )\r
 {\r
-  EFI_HII_UPDATE_DATA                       UpdateData;\r
   UINTN                                     Index;\r
   EFI_DEVICE_PATH_PROTOCOL                  *LoadedImageDevicePath;\r
-  IFR_OPTION                                *IfrOptionList;\r
   UINTN                                     SelectedDriverImageNum;\r
   UINT32                                    DriverImageNO;\r
   UINTN                                     MinNO;\r
   UINTN                                     Index1;\r
   UINTN                                     TempNO[100];\r
+  UINTN                                     OrderNO[100];\r
+  VOID                                      *StartOpCodeHandle;\r
+  VOID                                      *EndOpCodeHandle;\r
+  VOID                                      *OptionsOpCodeHandle;\r
+  EFI_IFR_GUID_LABEL                        *StartLabel;\r
+  EFI_IFR_GUID_LABEL                        *EndLabel;\r
 \r
   //\r
   // Following code will be run if user select 'order ... priority' item in second page\r
@@ -878,20 +920,38 @@ UpdatePrioritySelectPage (
   //\r
   mCurrentPage = FORM_ID_ORDER;\r
 \r
-  UpdateData.BufferSize = UPDATE_DATA_SIZE;\r
-  UpdateData.Offset = 0;\r
-  UpdateData.Data = AllocateZeroPool (UPDATE_DATA_SIZE);\r
-  ASSERT (UpdateData.Data != NULL);\r
+  //\r
+  // Init OpCode Handle\r
+  //\r
+  StartOpCodeHandle = HiiAllocateOpCodeHandle ();\r
+  ASSERT (StartOpCodeHandle != NULL);\r
+\r
+  EndOpCodeHandle = HiiAllocateOpCodeHandle ();\r
+  ASSERT (EndOpCodeHandle != NULL);\r
+\r
+  //\r
+  // Create Hii Extend Label OpCode as the start opcode\r
+  //\r
+  StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));\r
+  StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
+  StartLabel->Number       = FORM_ID_ORDER;\r
+\r
+  //\r
+  // Create Hii Extend Label OpCode as the end opcode\r
+  //\r
+  EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (EndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));\r
+  EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
+  EndLabel->Number       = LABEL_END;\r
+\r
   //\r
   // Clear third page form\r
   //\r
-  IfrLibUpdateForm (\r
+  HiiUpdateForm (\r
     Private->RegisteredHandle,\r
     &mPlatformOverridesManagerGuid,\r
     FORM_ID_ORDER,\r
-    FORM_ID_ORDER,\r
-    FALSE,\r
-    &UpdateData\r
+    StartOpCodeHandle,\r
+    EndOpCodeHandle\r
     );\r
 \r
   //\r
@@ -908,21 +968,26 @@ UpdatePrioritySelectPage (
   if (SelectedDriverImageNum == 0) {\r
     return EFI_SUCCESS;\r
   }\r
-  \r
-  IfrOptionList = AllocateZeroPool (sizeof (IFR_OPTION) * mSelectedDriverImageNum);\r
-  ASSERT (IfrOptionList != NULL);\r
+\r
+  OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();\r
+  ASSERT (OptionsOpCodeHandle != NULL);\r
+\r
   //\r
   // Create order list for those selected drivers\r
   //\r
   SelectedDriverImageNum = 0;\r
   for (Index = 0; Index < mDriverImageHandleCount; Index++) {\r
     if (FakeNvData->DriSelection[Index] != 0) {\r
-      IfrOptionList[SelectedDriverImageNum].StringToken = mDriverImageToken[Index];\r
       //\r
       // Use the NO. in driver binding buffer as value, will use it later\r
       //\r
-      IfrOptionList[SelectedDriverImageNum].Value.u8 = (UINT8) (Index + 1);\r
-      IfrOptionList[SelectedDriverImageNum].Flags = 0;\r
+      HiiCreateOneOfOptionOpCode (\r
+        OptionsOpCodeHandle,\r
+        mDriverImageToken[Index],\r
+        0,\r
+        EFI_IFR_NUMERIC_SIZE_1,\r
+        Index + 1\r
+        );\r
 \r
       //\r
       // Get the EFI Loaded Image Device Path Protocol\r
@@ -951,6 +1016,7 @@ UpdatePrioritySelectPage (
         mLastSavedDriverImageNum++;\r
       }\r
       TempNO[SelectedDriverImageNum] = DriverImageNO;\r
+      OrderNO[SelectedDriverImageNum] = Index + 1;\r
       SelectedDriverImageNum ++;\r
     }\r
   }\r
@@ -978,11 +1044,15 @@ UpdatePrioritySelectPage (
     //\r
     // the IfrOptionList[MinNO].Value = the driver NO. in driver binding buffer\r
     //\r
-    FakeNvData->DriOrder[Index] =IfrOptionList[MinNO].Value.u8;\r
+    FakeNvData->DriOrder[Index] = (UINT8) OrderNO[MinNO];\r
     TempNO[MinNO] = MAX_CHOICE_NUM + 1;\r
   }\r
-\r
-  CreateOrderedListOpCode (\r
+  \r
+  //\r
+  // Create Order List OpCode\r
+  //\r
+  HiiCreateOrderedListOpCode (\r
+    StartOpCodeHandle,\r
     (UINT16) DRIVER_ORDER_QUESTION_ID,\r
     VARSTORE_ID_PLAT_OVER_MNGR,\r
     (UINT16) DRIVER_ORDER_VAR_OFFSET,\r
@@ -992,25 +1062,25 @@ UpdatePrioritySelectPage (
     0,\r
     EFI_IFR_NUMERIC_SIZE_1,\r
     (UINT8) MAX_CHOICE_NUM,\r
-    IfrOptionList,\r
-    SelectedDriverImageNum,\r
-    &UpdateData\r
+    OptionsOpCodeHandle,\r
+    NULL\r
     );\r
 \r
   //\r
   // Update third page form\r
   //\r
-  IfrLibUpdateForm (\r
+  HiiUpdateForm (\r
     Private->RegisteredHandle,\r
     &mPlatformOverridesManagerGuid,\r
     FORM_ID_ORDER,\r
-    FORM_ID_ORDER,\r
-    FALSE,\r
-    &UpdateData\r
+    StartOpCodeHandle, // Label FORM_ID_ORDER\r
+    EndOpCodeHandle    // LABEL_END\r
     );\r
 \r
-  FreePool (IfrOptionList);\r
-  FreePool (UpdateData.Data);\r
+  HiiFreeOpCodeHandle (StartOpCodeHandle);\r
+  HiiFreeOpCodeHandle (EndOpCodeHandle);\r
+  HiiFreeOpCodeHandle (OptionsOpCodeHandle);\r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -1102,7 +1172,7 @@ PlatOverMngrExtractConfig (
   EFI_STATUS                       Status;\r
   EFI_CALLBACK_INFO                *Private;\r
   EFI_HII_CONFIG_ROUTING_PROTOCOL  *HiiConfigRouting;\r
-\r
+  \r
   if (Request == NULL) {\r
     return EFI_NOT_FOUND;\r
   }\r
@@ -1148,18 +1218,13 @@ PlatOverMngrRouteConfig (
   )\r
 {\r
   EFI_CALLBACK_INFO                         *Private;\r
-  EFI_STATUS                                Status;\r
   UINT16                                    KeyValue;\r
-  UINTN                                     BufferSize;\r
   PLAT_OVER_MNGR_DATA                       *FakeNvData;\r
 \r
-  Private     = EFI_CALLBACK_INFO_FROM_THIS (This);\r
-\r
-  FakeNvData = &Private->FakeNvData;\r
-  BufferSize = sizeof (PLAT_OVER_MNGR_DATA);\r
-  Status = GetBrowserData (NULL, NULL, &BufferSize, (UINT8 *) FakeNvData);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
+  Private    = EFI_CALLBACK_INFO_FROM_THIS (This);\r
+  FakeNvData = (PLAT_OVER_MNGR_DATA *) HiiGetBrowserData (&mPlatformOverridesManagerGuid, mVariableName, sizeof (PLAT_OVER_MNGR_DATA));\r
+  if (FakeNvData == NULL) {\r
+    return EFI_NOT_FOUND;\r
   }\r
 \r
   if (mCurrentPage == FORM_ID_DRIVER) {\r
@@ -1178,6 +1243,11 @@ PlatOverMngrRouteConfig (
     KeyValue = KEY_VALUE_ORDER_SAVE_AND_EXIT;\r
     CommintChanges (Private, KeyValue, FakeNvData);\r
   }\r
+\r
+  if (FakeNvData != NULL) {\r
+    FreePool (FakeNvData);\r
+  }\r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -1216,17 +1286,13 @@ PlatOverMngrCallback (
   EFI_CALLBACK_INFO                         *Private;\r
   EFI_STATUS                                Status;\r
   EFI_STRING_ID                             NewStringToken;\r
-  UINTN                                     BufferSize;\r
-  PLAT_OVER_MNGR_DATA                       *FakeNvData;\r
   EFI_INPUT_KEY                             Key;\r
-\r
+  PLAT_OVER_MNGR_DATA                       *FakeNvData;\r
+  \r
   Private = EFI_CALLBACK_INFO_FROM_THIS (This);\r
-\r
-  FakeNvData = &Private->FakeNvData;\r
-  BufferSize = sizeof (PLAT_OVER_MNGR_DATA);\r
-  Status = GetBrowserData (NULL, NULL, &BufferSize, (UINT8 *) FakeNvData);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
+  FakeNvData = (PLAT_OVER_MNGR_DATA *) HiiGetBrowserData (&mPlatformOverridesManagerGuid, mVariableName, sizeof (PLAT_OVER_MNGR_DATA));\r
+  if (FakeNvData == NULL) {\r
+    return EFI_NOT_FOUND;\r
   }\r
 \r
   if (KeyValue == KEY_VALUE_DEVICE_REFRESH ||\r
@@ -1285,8 +1351,15 @@ PlatOverMngrCallback (
   //\r
   // Pass changed uncommitted data back to Form Browser\r
   //\r
-  BufferSize = sizeof (PLAT_OVER_MNGR_DATA);\r
-  Status = SetBrowserData (NULL, NULL, BufferSize, (UINT8 *) FakeNvData, NULL);\r
+  HiiSetBrowserData (&mPlatformOverridesManagerGuid, mVariableName, sizeof (PLAT_OVER_MNGR_DATA), (UINT8 *) FakeNvData, NULL);\r
+  \r
+  //\r
+  // Update local configuration buffer.\r
+  //\r
+  CopyMem (&Private->FakeNvData, FakeNvData, sizeof (PLAT_OVER_MNGR_DATA));\r
+  if (FakeNvData != NULL) {\r
+    FreePool (FakeNvData);\r
+  }\r
 \r
   return EFI_SUCCESS;\r
 }\r
@@ -1312,7 +1385,6 @@ PlatOverMngrInit (
   EFI_STATUS                  Status;\r
   EFI_HII_DATABASE_PROTOCOL   *HiiDatabase;\r
   EFI_HII_PACKAGE_LIST_HEADER *PackageList;\r
-  EFI_CALLBACK_INFO           *CallbackInfo;\r
   EFI_FORM_BROWSER2_PROTOCOL  *FormBrowser2;\r
   \r
   //\r
@@ -1339,25 +1411,25 @@ PlatOverMngrInit (
     return Status;\r
   }\r
 \r
-  CallbackInfo = AllocateZeroPool (sizeof (EFI_CALLBACK_INFO));\r
-  if (CallbackInfo == NULL) {\r
+  mCallbackInfo = AllocateZeroPool (sizeof (EFI_CALLBACK_INFO));\r
+  if (mCallbackInfo == NULL) {\r
     return EFI_BAD_BUFFER_SIZE;\r
   }\r
 \r
-  CallbackInfo->Signature = EFI_CALLBACK_INFO_SIGNATURE;\r
-  CallbackInfo->ConfigAccess.ExtractConfig = PlatOverMngrExtractConfig;\r
-  CallbackInfo->ConfigAccess.RouteConfig   = PlatOverMngrRouteConfig;\r
-  CallbackInfo->ConfigAccess.Callback      = PlatOverMngrCallback;\r
+  mCallbackInfo->Signature = EFI_CALLBACK_INFO_SIGNATURE;\r
+  mCallbackInfo->ConfigAccess.ExtractConfig = PlatOverMngrExtractConfig;\r
+  mCallbackInfo->ConfigAccess.RouteConfig   = PlatOverMngrRouteConfig;\r
+  mCallbackInfo->ConfigAccess.Callback      = PlatOverMngrCallback;\r
 \r
   //\r
   // Install Device Path Protocol and Config Access protocol to driver handle\r
   //\r
   Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &CallbackInfo->DriverHandle,\r
+                  &mCallbackInfo->DriverHandle,\r
                   &gEfiDevicePathProtocolGuid,\r
                   &mHiiVendorDevicePath,\r
                   &gEfiHiiConfigAccessProtocolGuid,\r
-                  &CallbackInfo->ConfigAccess,\r
+                  &mCallbackInfo->ConfigAccess,\r
                   NULL\r
                   );\r
   if (EFI_ERROR (Status)) {\r
@@ -1378,8 +1450,8 @@ PlatOverMngrInit (
   Status = HiiDatabase->NewPackageList (\r
                            HiiDatabase,\r
                            PackageList,\r
-                           CallbackInfo->DriverHandle,\r
-                           &CallbackInfo->RegisteredHandle\r
+                           mCallbackInfo->DriverHandle,\r
+                           &mCallbackInfo->RegisteredHandle\r
                            );\r
   FreePool (PackageList);\r
 \r
@@ -1393,7 +1465,7 @@ PlatOverMngrInit (
   Status = gBS->LocateProtocol (\r
                   &gEfiHiiConfigRoutingProtocolGuid,\r
                   NULL,\r
-                  (VOID **) &CallbackInfo->HiiConfigRouting\r
+                  (VOID **) &mCallbackInfo->HiiConfigRouting\r
                   );\r
   if (EFI_ERROR (Status)) {\r
     goto Finish;\r
@@ -1414,37 +1486,34 @@ PlatOverMngrInit (
   //\r
   Status = FormBrowser2->SendForm (\r
                            FormBrowser2,\r
-                           &CallbackInfo->RegisteredHandle,\r
+                           &mCallbackInfo->RegisteredHandle,\r
                            1,\r
                            NULL,\r
                            0,\r
                            NULL,\r
                            NULL\r
                            );\r
-  if (EFI_ERROR (Status)) {\r
-    goto Finish;\r
-  }\r
 \r
-  Status = HiiDatabase->RemovePackageList (HiiDatabase, CallbackInfo->RegisteredHandle);\r
+  HiiDatabase->RemovePackageList (HiiDatabase, mCallbackInfo->RegisteredHandle);\r
+\r
   if (EFI_ERROR (Status)) {\r
     goto Finish;\r
   }\r
-  \r
-  return EFI_SUCCESS;\r
 \r
 Finish:\r
-  if (CallbackInfo->DriverHandle != NULL) {\r
+  if (mCallbackInfo->DriverHandle != NULL) {\r
     gBS->UninstallMultipleProtocolInterfaces (\r
-           CallbackInfo->DriverHandle,\r
+           mCallbackInfo->DriverHandle,\r
            &gEfiDevicePathProtocolGuid,\r
            &mHiiVendorDevicePath,\r
            &gEfiHiiConfigAccessProtocolGuid,\r
-           &CallbackInfo->ConfigAccess,\r
+           &mCallbackInfo->ConfigAccess,\r
            NULL\r
            );\r
   }\r
-  if (CallbackInfo != NULL) {\r
-    FreePool (CallbackInfo);\r
+\r
+  if (mCallbackInfo != NULL) {\r
+    FreePool (mCallbackInfo);\r
   }\r
 \r
   return Status;\r
index 12bbf6a3b3fc9fe982662b5afa5fffdf8aa4495c..2d73d0ee6fe4196bf1fce53bd6083f9dede7c66a 100644 (file)
@@ -47,6 +47,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #define VARSTORE_ID_PLAT_OVER_MNGR     0x1000\r
 \r
+#define LABEL_END                      0xffff\r
+\r
 typedef struct {\r
   UINT8   DriSelection[MAX_CHOICE_NUM];\r
   UINT8   DriOrder[MAX_CHOICE_NUM];\r
index 6b42f05bdf946bfa2753652301036b0c14b98c8e..0d5ea888bbfa0fd9dda81733037d1360b7acfa31 100644 (file)
@@ -57,8 +57,6 @@
   UefiBootServicesTableLib\r
   PlatformDriverOverrideLib\r
   HiiLib\r
-  IfrSupportLib\r
-  ExtendedIfrSupportLib\r
   BaseMemoryLib\r
   MemoryAllocationLib\r
   DevicePathLib\r
@@ -67,6 +65,7 @@
 ##  This GUID C Name is not required for build since it is from UefiLib and not directly used by this module source.\r
 ##  gEfiGlobalVariableGuid                      ## SOMETIMES_CONSUMED ## Variable:L"PlatformLang" this variable specifies the platform supported language string (RFC 4646 format)\r
 ##  gEfiGlobalVariableGuid                      ## SOMETIMES_CONSUMED ## Variable:L"Lang" this variable specifies the platform supported language string (ISO 639-2 format)\r
+  gEfiIfrTianoGuid                              ## CONSUMES ## Guid\r
 \r
 [Protocols]\r
   gEfiComponentName2ProtocolGuid                ## SOMETIMES_CONSUMED (Get Driver Name if ComponentName2Protocol exists)\r
index b3cd0387f01186906961166d8c1339be44833054..a68073fa05a3b3af9d50b2e94c1912bd0e9eec16 100644 (file)
@@ -23,7 +23,6 @@
 #include "PlatOverMngr.h"\r
 \r
 #define EFI_DISK_DEVICE_CLASS          0x01\r
-#define LABEL_END                      0xffff\r
 \r
 formset\r
   guid     = PLAT_OVER_MNGR_GUID,\r
index e5c33d857af35d57f725f4b8ebd5a35389fa49b1..fa1963b27735d31deac4ea5bd4b36ed132c27321 100644 (file)
@@ -512,4 +512,943 @@ Rfc3066ToIso639 (
   )\r
 ;\r
 \r
+\r
+////////////////////////////////////////////////////////\r
+////////////////////////////////////////////////////////\r
+// HiiLib Functions\r
+////////////////////////////////////////////////////////\r
+////////////////////////////////////////////////////////\r
+\r
+/**\r
+  Registers a list of packages in the HII Database and returns the HII Handle\r
+  associated with that registration.  If an HII Handle has already been registered\r
+  with the same PackageListGuid, then NULL is returned.  If there are not enough \r
+  resources to perform the registration, then NULL is returned.  If an empty list \r
+  of packages is passed in, then NULL is returned.  If the size of the list of \r
+  package is 0, then NULL is returned.\r
+\r
+  @param[in]  PackageListGuid  An optional parameter that is used to identify \r
+                               the GUID of the package list.  If this parameter \r
+                               is NULL, then gEfiCallerIdGuid is used.\r
+  @param[in]  DeviceHandle     Optional. If not NULL, the Device Handle on which \r
+                               an instance of DEVICE_PATH_PROTOCOL is installed.\r
+                               This Device Handle uniquely defines the device that \r
+                               the added packages are associated with.\r
+  @param[in]  ...              The variable argument list that contains pointers \r
+                               to packages terminated by a NULL.\r
+\r
+  @retval NULL   A HII Handle has already been registered in the HII Database with\r
+                 the same PackageListGuid.\r
+  @retval NULL   The HII Handle could not be created.\r
+  @retval Other  The HII Handle associated with the newly registered package list.\r
+\r
+**/\r
+EFI_HII_HANDLE\r
+EFIAPI\r
+HiiAddPackages (\r
+  IN CONST EFI_GUID    *PackageListGuid,  OPTIONAL\r
+  IN       EFI_HANDLE  DeviceHandle,      OPTIONAL\r
+  ...\r
+  );\r
+\r
+/**\r
+  Removes a package list from the HII Database.\r
+\r
+  If HiiHandle is NULL, then ASSERT().\r
+  If HiiHandle is not a valid EFI_HII_HANDLE in the HII Database, then ASSERT().\r
+\r
+  @param[in]  HiiHandle  A handle that was previously registered in the HII Database.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+HiiRemovePackages (\r
+  IN EFI_HII_HANDLE  HiiHandle\r
+  );\r
+\r
+/**\r
+  Retrieves the array of all the HII Handles in the HII Database.\r
+  This array is terminated with a NULL HII Handle.\r
+  This function allocates the returned array using AllocatePool().\r
+  The caller is responsible for freeing the array with FreePool().\r
+\r
+  @param[in]  PackageListGuid  An optional parameter that is used to request \r
+                               an HII Handle that is associatd with a specific\r
+                               Package List GUID.  If this parameter is NULL\r
+                               then all the HII Handles in the HII Database\r
+                               are returned.  If this parameter is not NULL\r
+                               then at most 1 HII Handle is returned.\r
+\r
+  @retval NULL   There are no HII handles in the HII database\r
+  @retval NULL   The array of HII Handles could not be retrieved\r
+  @retval Other  A pointer to the NULL terminated array of HII Handles\r
+\r
+**/\r
+EFI_HII_HANDLE *\r
+EFIAPI\r
+HiiGetHiiHandles (\r
+  IN CONST EFI_GUID  *PackageListGuid  OPTIONAL\r
+  );\r
+\r
+/**\r
+  Retrieves a pointer to the a Null-terminated ASCII string containing the list \r
+  of languages that an HII handle in the HII Database supports.  The returned \r
+  string is allocated using AllocatePool().  The caller is responsible for freeing\r
+  the returned string using FreePool().  The format of the returned string follows\r
+  the language format assumed the HII Database.\r
+  \r
+  If HiiHandle is NULL, then ASSERT().\r
+\r
+  @param[in]  HiiHandle  A handle that was previously registered in the HII Database.\r
+\r
+  @retval NULL   HiiHandle is not registered in the HII database\r
+  @retval NULL   There are not enough resources available to retrieve the suported \r
+                 languages.\r
+  @retval NULL   The list of suported languages could not be retrieved.\r
+  @retval Other  A pointer to the Null-terminated ASCII string of supported languages.\r
+\r
+**/\r
+CHAR8 *\r
+EFIAPI\r
+HiiGetSupportedLanguages (\r
+  IN EFI_HII_HANDLE  HiiHandle\r
+  );\r
+\r
+/**\r
+  Retrieves a string from a string package in a specific language.  If the language\r
+  is not specified, then a string from a string package in the current platform \r
+  language is retrieved.  If the string can not be retrieved using the specified \r
+  language or the current platform language, then the string is retrieved from \r
+  the string package in the first language the string package supports.  The \r
+  returned string is allocated using AllocatePool().  The caller is responsible \r
+  for freeing the allocated buffer using FreePool().\r
+  \r
+  If HiiHandle is NULL, then ASSERT().\r
+  If StringId is 0, then ASSET.\r
+\r
+  @param[in]  HiiHandle  A handle that was previously registered in the HII Database.\r
+  @param[in]  StringId   The identifier of the string to retrieved from the string \r
+                         package associated with HiiHandle.\r
+  @param[in]  Language   The language of the string to retrieve.  If this parameter \r
+                         is NULL, then the current platform language is used.  The \r
+                         format of Language must follow the language format assumed \r
+                         the HII Database.\r
+\r
+  @retval NULL   The string specified by StringId is not present in the string package.\r
+  @retval Other  The string was returned.\r
+\r
+**/\r
+EFI_STRING\r
+EFIAPI\r
+HiiGetString (\r
+  IN EFI_HII_HANDLE  HiiHandle,\r
+  IN EFI_STRING_ID   StringId,\r
+  IN CONST CHAR8     *Language  OPTIONAL\r
+  );\r
+\r
+/**\r
+  Retrieves a string from a string package names by GUID in a specific language.  \r
+  If the language is not specified, then a string from a string package in the \r
+  current platform  language is retrieved.  If the string can not be retrieved \r
+  using the specified language or the current platform language, then the string \r
+  is retrieved from the string package in the first language the string package \r
+  supports.  The returned string is allocated using AllocatePool().  The caller \r
+  is responsible for freeing the allocated buffer using FreePool().\r
+  \r
+  If PackageListGuid is NULL, then ASSERT().\r
+  If StringId is 0, then ASSET.\r
+\r
+  @param[in]  PackageListGuid  The GUID of a package list that was previously \r
+                               registered in the HII Database.\r
+  @param[in]  StringId         The identifier of the string to retrieved from the \r
+                               string package associated with PackageListGuid.\r
+  @param[in]  Language         The language of the string to retrieve.  If this \r
+                               parameter is NULL, then the current platform \r
+                               language is used.  The format of Language must \r
+                               follow the language format assumed the HII Database.\r
+\r
+  @retval NULL   The package list specified by PackageListGuid is not present in the\r
+                 HII Database.\r
+  @retval NULL   The string specified by StringId is not present in the string package.\r
+  @retval Other  The string was returned.\r
+\r
+**/\r
+EFI_STRING\r
+EFIAPI\r
+HiiGetPackageString (\r
+  IN CONST EFI_GUID  *PackageListGuid,\r
+  IN EFI_STRING_ID   StringId,\r
+  IN CONST CHAR8     *Language  OPTIONAL\r
+  );\r
+\r
+/**\r
+  This function create a new string in String Package or updates an existing \r
+  string in a String Package.  If StringId is 0, then a new string is added to\r
+  a String Package.  If StringId is not zero, then a string in String Package is\r
+  updated.  If SupportedLanguages is NULL, then the string is added or updated\r
+  for all the languages that the String Package supports.  If SupportedLanguages\r
+  is not NULL, then the string is added or updated for the set of languages \r
+  specified by SupportedLanguages.\r
+    \r
+  If HiiHandle is NULL, then ASSERT().\r
+  If String is NULL, then ASSERT().\r
+\r
+  @param[in]  HiiHandle           A handle that was previously registered in the \r
+                                  HII Database.\r
+  @param[in]  StringId            If zero, then a new string is created in the \r
+                                  String Package associated with HiiHandle.  If \r
+                                  non-zero, then the string specified by StringId \r
+                                  is updated in the String Package  associated \r
+                                  with HiiHandle. \r
+  @param[in]  String              A pointer to the Null-terminated Unicode string \r
+                                  to add or update in the String Package associated \r
+                                  with HiiHandle.\r
+  @param[in]  SupportedLanguages  A pointer to a Null-terminated ASCII string of \r
+                                  language codes.  If this parameter is NULL, then \r
+                                  String is added or updated in the String Package \r
+                                  associated with HiiHandle for all the languages \r
+                                  that the String Package supports.  If this \r
+                                  parameter is not NULL, then then String is added \r
+                                  or updated in the String Package associated with \r
+                                  HiiHandle for the set oflanguages specified by \r
+                                  SupportedLanguages.  The format of \r
+                                  SupportedLanguages must follow the language \r
+                                  format assumed the HII Database.\r
+\r
+  @retval 0      The string could not be added or updated in the String Package.\r
+  @retval Other  The EFI_STRING_ID of the newly added or updated string.\r
+\r
+**/\r
+EFI_STRING_ID\r
+EFIAPI\r
+HiiSetString (\r
+  IN EFI_HII_HANDLE    HiiHandle,\r
+  IN EFI_STRING_ID     StringId,            OPTIONAL\r
+  IN CONST EFI_STRING  String,\r
+  IN CONST CHAR8       *SupportedLanguages  OPTIONAL\r
+  );\r
+\r
+/**\r
+  Validates the config data associated with an HII handle in the HII Database.\r
+    \r
+  If HiiHandle is NULL, then ASSERT().\r
+\r
+  @param[in]  HiiHandle  A handle that was previously registered in the HII Database.\r
+\r
+  @retval TRUE   The config data associated with HiiHandle passes all validation\r
+                 checks.\r
+  @retval FALSE  The config data associated with HiiHandle failed one or more \r
+                 validation checks.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+HiiValidateDataFromHiiHandle (\r
+  IN EFI_HII_HANDLE  HiiHandle\r
+  );\r
+\r
+/**\r
+  Allocates and returns a Null-terminated Unicode <ConfigHdr> string using routing \r
+  information that includes a GUID, an optional Unicode string name, and a device\r
+  path.  The string returned is allocated with AllocatePool().  The caller is \r
+  responsible for freeing the allocated string with FreePool().\r
+  \r
+  The format of a <ConfigHdr> is as follows:\r
+\r
+    GUID=<HexCh>32&NAME=<Char>NameLength&PATH=<HexChar>DevicePathSize<Null>\r
+\r
+  @param[in]  Guid          Pointer to an EFI_GUID that is the routing information\r
+                            GUID.  Each of the 16 bytes in Guid is converted to \r
+                            a 2 Unicode character hexidecimal string.  This is \r
+                            an optional parameter that may be NULL.\r
+  @param[in]  Name          Pointer to a Null-terminated Unicode string that is \r
+                            the routing information NAME.  This is an optional \r
+                            parameter that may be NULL.  Each 16-bit Unicode \r
+                            character in Name is converted to a 4 character Unicode \r
+                            hexidecimal string.                        \r
+  @param[in]  DriverHandle  The driver handle which supports a Device Path Protocol\r
+                            that is the routing information PATH.  Each byte of\r
+                            the Device Path associated with DriverHandle is converted\r
+                            to a 2 Unicode character hexidecimal string.\r
+\r
+  @retval NULL   DriverHandle does not support the Device Path Protocol.\r
+  @retval NULL   DriverHandle does not support the Device Path Protocol.\r
+  @retval Other  A pointer to the Null-terminate Unicode <ConfigHdr> string\r
+\r
+**/\r
+EFI_STRING\r
+EFIAPI\r
+HiiConstructConfigHdr (\r
+  IN CONST EFI_GUID  *Guid,  OPTIONAL\r
+  IN CONST CHAR16    *Name,  OPTIONAL\r
+  IN EFI_HANDLE      DriverHandle\r
+  );\r
+\r
+/**\r
+  Allocates and returns a Null-terminated Unicode <ConfigAltResp> string.\r
+\r
+  If Guid is NULL, then ASSERT().\r
+  If Name is NULL, then ASSERT().\r
+  If BlockNameArray is NULL, then ASSERT().\r
+\r
+  @param[in] Guid               GUID of the buffer storage.\r
+  @param[in] Name               Name of the buffer storage.\r
+  @param[in] DriverHandle       The DriverHandle that support a Device Path\r
+                                Protocol.    \r
+  @param[in] BufferStorage      Content of the buffer storage.\r
+  @param[in] BufferStorageSize  Length in bytes of the buffer storage.\r
+  @param[in] BlockNameArray     Array generated by VFR compiler.  This array\r
+                                contains a UINT32 value that is the length\r
+                                of BlockNameArray in bytes, followed by pairs\r
+                                of 16-bit values that are the offset and length\r
+                                values used to contruct a <ConfigRequest> string.\r
+  @param[in]  ...               A variable argument list that contains pairs of 16-bit\r
+                                ALTCFG identifiers and pointers to DefaultValueArrays.\r
+                                The variable argument list is terminated by a NULL \r
+                                DefaultValueArray pointer.  A DefaultValueArray \r
+                                contains a UINT32 value that is the length, in bytes,\r
+                                of the DefaultValueArray.  The UINT32 length value \r
+                                is followed by a series of records that contain\r
+                                a 16-bit WIDTH value followed by a byte array with \r
+                                WIDTH entries.  The records must be parsed from\r
+                                beginning to end until the UINT32 length limit\r
+                                is reached.  \r
+\r
+  @retval NULL          There are not enough resources to process the request.\r
+  @retval NULL          A <ConfigResp> could not be retrieved from the Config \r
+                        Routing Protocol.\r
+  @retval Other         A pointer to the Null-terminate Unicode <ConfigAltResp>\r
+                        string.\r
+\r
+**/\r
+EFI_STRING\r
+EFIAPI\r
+HiiConstructConfigAltResp (\r
+  IN CONST EFI_GUID  *Guid,\r
+  IN CONST CHAR16    *Name,\r
+  IN EFI_HANDLE      DriverHandle,\r
+  IN CONST VOID      *BufferStorage,\r
+  IN UINTN           BufferStorageSize,\r
+  IN CONST VOID      *BlockNameArray, \r
+  ...\r
+  );\r
+\r
+/**\r
+  Determines if the routing data specified by GUID and NAME match a <ConfigHdr>.\r
+\r
+  If ConfigHdr is NULL, then ASSERT().\r
+\r
+  @param[in] ConfigHdr  Either <ConfigRequest> or <ConfigResp>.\r
+  @param[in] Guid       GUID of the storage.\r
+  @param[in] Name       NAME of the storage.\r
+\r
+  @retval TRUE   Routing information matches <ConfigHdr>.\r
+  @retval FALSE  Routing information does not match <ConfigHdr>.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+HiiIsConfigHdrMatch (\r
+  IN CONST EFI_STRING  ConfigHdr,\r
+  IN CONST EFI_GUID    *Guid,     OPTIONAL\r
+  IN CONST CHAR16      *Name      OPTIONAL\r
+  );\r
+\r
+/**\r
+  Retrieves uncommited data from the Form Browser and converts it to a binary\r
+  buffer.  The returned buffer is allocated using AllocatePool().  The caller\r
+  is responsible for freeing the returned buffer using FreePool().\r
+\r
+  @param[in]  VariableName  Pointer to a Null-terminated Unicode string.  This \r
+                            is an optional parameter that may be NULL.\r
+  @param[in]  VariableGuid  Pointer to an EFI_GUID structure.  This is an optional \r
+                            parameter that may be NULL.\r
+  @param[in]  BufferSize    Length in bytes of buffer to hold retrived data. \r
+\r
+  @retval NULL   The uncommitted data could not be retrieved.\r
+  @retval Other  A pointer to a buffer containing the uncommitted data.\r
+\r
+**/\r
+UINT8 *\r
+EFIAPI\r
+HiiGetBrowserData (\r
+  IN CONST EFI_GUID  *VariableGuid,  OPTIONAL\r
+  IN CONST CHAR16    *VariableName,  OPTIONAL\r
+  IN UINTN           BlockSize\r
+  );\r
+\r
+/**\r
+  Updates uncommitted data in the Form Browser.\r
+\r
+  If Buffer is NULL, then ASSERT().\r
+\r
+  @param[in]  VariableName    Pointer to a Null-terminated Unicode string.  This\r
+                              is an optional parameter that may be NULL.\r
+  @param[in]  VariableGuid    Pointer to an EFI_GUID structure.  This is an optional\r
+                              parameter that may be NULL.\r
+  @param[in]  BufferSize      Length, in bytes, of Buffer.\r
+  @param[in]  Buffer          Buffer of data to commit.\r
+  @param[in]  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. \r
+                              <RequestElement> ::= &OFFSET=<Number>&WIDTH=<Number>*\r
+\r
+  @retval FALSE  The uncommitted data could not be updated.\r
+  @retval TRUE   The uncommitted data was updated.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+HiiSetBrowserData (\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
+/// IFR Functions\r
+/////////////////////////////////////////\r
+/////////////////////////////////////////\r
+\r
+/**\r
+  Returns a UINT64 value that contains bitfields for Hour, Minute, and Second.\r
+  The lower 8-bits of Hour are placed in bits 0..7.  The lower 8-bits of Minute \r
+  are placed in bits 8..15, and the lower 8-bits of Second are placed in bits \r
+  16..23.  This format is selected because it can be easily translated to \r
+  an EFI_HII_TIME structure in an EFI_IFR_TYPE_VALUE union.\r
+\r
+  @param  Hour    The hour value to be encoded.\r
+  @param  Minute  The miniute value to be encoded.\r
+  @param  Second  The second value to be encoded.\r
+\r
+  @return A 64-bit containing Hour, Minute, and Second.\r
+**/\r
+#define EFI_HII_TIME_UINT64(Hour, Minute, Second) \\r
+  (UINT64)((Hour & 0xff) | ((Minute & 0xff) << 8) | ((Second & 0xff) << 16))\r
+\r
+/**\r
+  Returns a UINT64 value that contains bitfields for Year, Month, and Day.\r
+  The lower 16-bits of Year are placed in bits 0..15.  The lower 8-bits of Month \r
+  are placed in bits 16..23, and the lower 8-bits of Day are placed in bits \r
+  24..31.  This format is selected because it can be easily translated to \r
+  an EFI_HII_DATE structure in an EFI_IFR_TYPE_VALUE union.\r
+\r
+  @param  Year   The year value to be encoded.\r
+  @param  Month  The month value to be encoded.\r
+  @param  Day    The day value to be encoded.\r
+\r
+  @return A 64-bit containing Year, Month, and Day.\r
+**/\r
+#define EFI_HII_DATE_UINT64(Year, Month, Day) \\r
+  (UINT64)((Year & 0xffff) | ((Month & 0xff) << 16) | ((Day & 0xff) << 24))\r
+\r
+/**\r
+  Allocates and returns a new OpCode Handle.  OpCode Handles must be freed with \r
+  HiiFreeOpCodeHandle().\r
+\r
+  @retval NULL   There are not enough resources to allocate a new OpCode Handle.\r
+  @retval Other  A new OpCode handle.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+HiiAllocateOpCodeHandle (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Frees an OpCode Handle that was peviously allocated with HiiAllocateOpCodeHandle().\r
+  When an OpCode Handle is freed, all of the opcodes associated with the OpCode\r
+  Handle are also freed.\r
+\r
+  If OpCodeHandle is NULL, then ASSERT().\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+HiiFreeOpCodeHandle (\r
+  VOID  *OpCodeHandle\r
+  );\r
+\r
+/**\r
+  Create EFI_IFR_END_OP opcode.\r
+\r
+  If OpCodeHandle is NULL, then ASSERT().\r
+\r
+  @param[in]  OpCodeHandle  Handle to the buffer of opcodes.\r
+\r
+  @retval NULL   There is not enough space left in Buffer to add the opcode.\r
+  @retval Other  A pointer to the created opcode.\r
+\r
+**/\r
+UINT8 *\r
+EFIAPI\r
+HiiCreateEndOpCode (\r
+  IN VOID  *OpCodeHandle\r
+  );\r
+\r
+/**\r
+  Create EFI_IFR_ONE_OF_OPTION_OP opcode.\r
+\r
+  If OpCodeHandle is NULL, then ASSERT().\r
+  If Type is invalid, then ASSERT().\r
+  If Flags is invalid, then ASSERT().\r
+\r
+  @param[in]  OpCodeHandle  Handle to the buffer of opcodes.\r
+  @param[in]  StringId      StringId for the option\r
+  @param[in]  Flags         Flags for the option\r
+  @param[in]  Type          Type for the option\r
+  @param[in]  Value         Value for the option\r
+\r
+  @retval NULL   There is not enough space left in Buffer to add the opcode.\r
+  @retval Other  A pointer to the created opcode.\r
+\r
+**/\r
+UINT8 *\r
+EFIAPI\r
+HiiCreateOneOfOptionOpCode (\r
+  IN VOID    *OpCodeHandle,\r
+  IN UINT16  StringId,\r
+  IN UINT8   Flags,\r
+  IN UINT8   Type,\r
+  IN UINT64  Value\r
+  );\r
+\r
+/**\r
+  Create EFI_IFR_DEFAULT_OP opcode.\r
+\r
+  If OpCodeHandle is NULL, then ASSERT().\r
+  If Type is invalid, then ASSERT().\r
+\r
+  @param[in]  OpCodeHandle  Handle to the buffer of opcodes.\r
+  @param[in]  DefaultId     DefaultId for the default\r
+  @param[in]  Type          Type for the default\r
+  @param[in]  Value         Value for the default\r
+\r
+  @retval NULL   There is not enough space left in Buffer to add the opcode.\r
+  @retval Other  A pointer to the created opcode.\r
+\r
+**/\r
+UINT8 *\r
+EFIAPI\r
+HiiCreateDefaultOpCode (\r
+  IN VOID    *OpCodeHandle,\r
+  IN UINT16  DefaultId,\r
+  IN UINT8   Type,\r
+  IN UINT64  Value\r
+  );\r
+\r
+/**\r
+  Create EFI_IFR_GUID opcode.\r
+\r
+  If OpCodeHandle is NULL, then ASSERT().\r
+  If Guid is NULL, then ASSERT().\r
+  If OpCodeSize < sizeof (EFI_IFR_GUID), then ASSERT().\r
+\r
+  @param[in]  OpCodeHandle  Handle to the buffer of opcodes.\r
+  @param[in]  Guid          Pointer to EFI_GUID of this guided opcode.\r
+  @param[in]  GuidOpCode    Pointer to an EFI_IFR_GUID opcode.  This is an \r
+                            optional parameter that may be NULL.  If this\r
+                            parameter is NULL, then the GUID extension \r
+                            region of the created opcode is filled with zeros.\r
+                            If this parameter is not NULL, then the GUID \r
+                            extension region of GuidData will be copied to \r
+                            the GUID extension region of the created opcode.\r
+  @param[in]  OpCodeSize    The size, in bytes, of created opcode.  This value \r
+                            must be >= sizeof(EFI_IFR_GUID).\r
+\r
+  @retval NULL   There is not enough space left in Buffer to add the opcode.\r
+  @retval Other  A pointer to the created opcode.\r
+\r
+**/\r
+UINT8 *\r
+EFIAPI\r
+HiiCreateGuidOpCode (\r
+  IN VOID            *OpCodeHandle,\r
+  IN CONST EFI_GUID  *Guid,\r
+  IN CONST VOID      *GuidOpCode,    OPTIONAL\r
+  IN UINTN           OpCodeSize\r
+  );\r
+\r
+/**\r
+  Create EFI_IFR_ACTION_OP opcode.\r
+\r
+  If OpCodeHandle is NULL, then ASSERT().\r
+  If any reserved bits are set in QuestionFlags, then ASSERT().\r
+\r
+  @param[in]  OpCodeHandle  Handle to the buffer of opcodes.\r
+  @param[in]  QuestionId      Question ID\r
+  @param[in]  Prompt          String ID for Prompt\r
+  @param[in]  Help            String ID for Help\r
+  @param[in]  QuestionFlags   Flags in Question Header\r
+  @param[in]  QuestionConfig  String ID for configuration\r
+\r
+  @retval NULL   There is not enough space left in Buffer to add the opcode.\r
+  @retval Other  A pointer to the created opcode.\r
+\r
+**/\r
+UINT8 *\r
+EFIAPI\r
+HiiCreateActionOpCode (\r
+  IN VOID             *OpCodeHandle,\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
+  );\r
+\r
+/**\r
+  Create EFI_IFR_SUBTITLE_OP opcode.\r
+\r
+  If OpCodeHandle is NULL, then ASSERT().\r
+  If any reserved bits are set in Flags, then ASSERT().\r
+  If Scope > 1, then ASSERT().\r
+\r
+  @param[in]  OpCodeHandle  Handle to the buffer of opcodes.\r
+  @param[in]  Prompt      String ID for Prompt\r
+  @param[in]  Help        String ID for Help\r
+  @param[in]  Flags       Subtitle opcode flags\r
+  @param[in]  Scope       1 if this opcpde is the beginning of a new scope.\r
+                          0 if this opcode is within the current scope.\r
+\r
+  @retval NULL   There is not enough space left in Buffer to add the opcode.\r
+  @retval Other  A pointer to the created opcode.\r
+\r
+**/\r
+UINT8 *\r
+EFIAPI\r
+HiiCreateSubTitleOpCode (\r
+  IN VOID           *OpCodeHandle,\r
+  IN EFI_STRING_ID  Prompt,\r
+  IN EFI_STRING_ID  Help,\r
+  IN UINT8          Flags,\r
+  IN UINT8          Scope\r
+  );\r
+\r
+/**\r
+  Create EFI_IFR_REF_OP opcode.\r
+\r
+  If OpCodeHandle is NULL, then ASSERT().\r
+  If any reserved bits are set in QuestionFlags, then ASSERT().\r
+\r
+  @param[in]  OpCodeHandle   Handle to the buffer of opcodes.\r
+  @param[in]  FormId         Destination Form ID\r
+  @param[in]  Prompt         String ID for Prompt\r
+  @param[in]  Help           String ID for Help\r
+  @param[in]  QuestionFlags  Flags in Question Header\r
+  @param[in]  QuestionId     Question ID\r
+\r
+  @retval NULL   There is not enough space left in Buffer to add the opcode.\r
+  @retval Other  A pointer to the created opcode.\r
+\r
+**/\r
+UINT8 *\r
+EFIAPI\r
+HiiCreateGotoOpCode (\r
+  IN VOID             *OpCodeHandle,\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
+  );\r
+\r
+/**\r
+  Create EFI_IFR_CHECKBOX_OP opcode.\r
+\r
+  If OpCodeHandle is NULL, then ASSERT().\r
+  If any reserved bits are set in QuestionFlags, then ASSERT().\r
+  If any reserved bits are set in CheckBoxFlags, then ASSERT().\r
+\r
+  @param[in]  OpCodeHandle          Handle to the buffer of opcodes.\r
+  @param[in]  QuestionId            Question ID\r
+  @param[in]  VarStoreId            Storage ID\r
+  @param[in]  VarOffset             Offset in Storage\r
+  @param[in]  Prompt                String ID for Prompt\r
+  @param[in]  Help                  String ID for Help\r
+  @param[in]  QuestionFlags         Flags in Question Header\r
+  @param[in]  CheckBoxFlags         Flags for checkbox opcode\r
+  @param[in]  DefaultsOpCodeHandle  Handle for a buffer of DEFAULT opcodes.  This\r
+                                    is an optional parameter that may be NULL.\r
+\r
+  @retval NULL   There is not enough space left in Buffer to add the opcode.\r
+  @retval Other  A pointer to the created opcode.\r
+\r
+**/\r
+UINT8 *\r
+EFIAPI\r
+HiiCreateCheckBoxOpCode (\r
+  IN VOID             *OpCodeHandle,\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 VOID             *DefaultsOpCodeHandle  OPTIONAL\r
+  );\r
+\r
+/**\r
+  Create EFI_IFR_NUMERIC_OP opcode.\r
+\r
+  If OpCodeHandle is NULL, then ASSERT().\r
+  If any reserved bits are set in QuestionFlags, then ASSERT().\r
+  If any reserved bits are set in NumericFlags, then ASSERT().\r
+\r
+  @param[in]  OpCodeHandle          Handle to the buffer of opcodes.\r
+  @param[in]  QuestionId            Question ID\r
+  @param[in]  VarStoreId            Storage ID\r
+  @param[in]  VarOffset             Offset in Storage\r
+  @param[in]  Prompt                String ID for Prompt\r
+  @param[in]  Help                  String ID for Help\r
+  @param[in]  QuestionFlags         Flags in Question Header\r
+  @param[in]  NumericFlags          Flags for numeric opcode\r
+  @param[in]  Minimum               Numeric minimum value\r
+  @param[in]  Maximum               Numeric maximum value\r
+  @param[in]  Step                  Numeric step for edit\r
+  @param[in]  DefaultsOpCodeHandle  Handle for a buffer of DEFAULT opcodes.  This\r
+                                    is an optional parameter that may be NULL.\r
+\r
+  @retval NULL   There is not enough space left in Buffer to add the opcode.\r
+  @retval Other  A pointer to the created opcode.\r
+\r
+**/\r
+UINT8 *\r
+EFIAPI\r
+HiiCreateNumericOpCode (\r
+  IN VOID             *OpCodeHandle,\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 VOID             *DefaultsOpCodeHandle  OPTIONAL\r
+  );\r
+\r
+/**\r
+  Create EFI_IFR_STRING_OP opcode.\r
+\r
+  If OpCodeHandle is NULL, then ASSERT().\r
+  If any reserved bits are set in QuestionFlags, then ASSERT().\r
+  If any reserved bits are set in StringFlags, then ASSERT().\r
+\r
+  @param[in]  OpCodeHandle          Handle to the buffer of opcodes.\r
+  @param[in]  QuestionId            Question ID\r
+  @param[in]  VarStoreId            Storage ID\r
+  @param[in]  VarOffset             Offset in Storage\r
+  @param[in]  Prompt                String ID for Prompt\r
+  @param[in]  Help                  String ID for Help\r
+  @param[in]  QuestionFlags         Flags in Question Header\r
+  @param[in]  StringFlags           Flags for string opcode\r
+  @param[in]  MinSize               String minimum length\r
+  @param[in]  MaxSize               String maximum length\r
+  @param[in]  DefaultsOpCodeHandle  Handle for a buffer of DEFAULT opcodes.  This\r
+                                    is an optional parameter that may be NULL.\r
+\r
+  @retval NULL   There is not enough space left in Buffer to add the opcode.\r
+  @retval Other  A pointer to the created opcode.\r
+\r
+**/\r
+UINT8 *\r
+EFIAPI\r
+HiiCreateStringOpCode (\r
+  IN VOID             *OpCodeHandle,\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 VOID             *DefaultsOpCodeHandle  OPTIONAL\r
+  );\r
+\r
+/**\r
+  Create EFI_IFR_ONE_OF_OP opcode.\r
+\r
+  If OpCodeHandle is NULL, then ASSERT().\r
+  If any reserved bits are set in QuestionFlags, then ASSERT().\r
+  If any reserved bits are set in OneOfFlags, then ASSERT().\r
+\r
+  @param[in]  OpCodeHandle          Handle to the buffer of opcodes.\r
+  @param[in]  QuestionId            Question ID\r
+  @param[in]  VarStoreId            Storage ID\r
+  @param[in]  VarOffset             Offset in Storage\r
+  @param[in]  Prompt                String ID for Prompt\r
+  @param[in]  Help                  String ID for Help\r
+  @param[in]  QuestionFlags         Flags in Question Header\r
+  @param[in]  OneOfFlags            Flags for oneof opcode\r
+  @param[in]  OptionsOpCodeHandle   Handle for a buffer of ONE_OF_OPTION opcodes.\r
+  @param[in]  DefaultsOpCodeHandle  Handle for a buffer of DEFAULT opcodes.  This\r
+                                    is an optional parameter that may be NULL.\r
+\r
+  @retval NULL   There is not enough space left in Buffer to add the opcode.\r
+  @retval Other  A pointer to the created opcode.\r
+\r
+**/\r
+UINT8 *\r
+EFIAPI\r
+HiiCreateOneOfOpCode (\r
+  IN VOID             *OpCodeHandle,\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 VOID             *OptionsOpCodeHandle,\r
+  IN VOID             *DefaultsOpCodeHandle  OPTIONAL\r
+  );\r
+\r
+/**\r
+  Create EFI_IFR_ORDERED_LIST_OP opcode.\r
+\r
+  If OpCodeHandle is NULL, then ASSERT().\r
+  If any reserved bits are set in QuestionFlags, then ASSERT().\r
+  If any reserved bits are set in OrderedListFlags, then ASSERT().\r
+\r
+  @param[in]  OpCodeHandle          Handle to the buffer of opcodes.\r
+  @param[in]  QuestionId            Question ID\r
+  @param[in]  VarStoreId            Storage ID\r
+  @param[in]  VarOffset             Offset in Storage\r
+  @param[in]  Prompt                String ID for Prompt\r
+  @param[in]  Help                  String ID for Help\r
+  @param[in]  QuestionFlags         Flags in Question Header\r
+  @param[in]  OrderedListFlags      Flags for ordered list opcode\r
+  @param[in]  DataType              Type for option value\r
+  @param[in]  MaxContainers         Maximum count for options in this ordered list\r
+  @param[in]  OptionsOpCodeHandle   Handle for a buffer of ONE_OF_OPTION opcodes.\r
+  @param[in]  DefaultsOpCodeHandle  Handle for a buffer of DEFAULT opcodes.  This\r
+                                    is an optional parameter that may be NULL.\r
+\r
+  @retval NULL   There is not enough space left in Buffer to add the opcode.\r
+  @retval Other  A pointer to the created opcode.\r
+\r
+**/\r
+UINT8 *\r
+EFIAPI\r
+HiiCreateOrderedListOpCode (\r
+  IN VOID             *OpCodeHandle,\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 VOID             *OptionsOpCodeHandle,\r
+  IN VOID             *DefaultsOpCodeHandle  OPTIONAL\r
+  );\r
+\r
+/**\r
+  This function updates a form that has previously been registered with the HII \r
+  Database.  This function will perform at most one update operation.\r
+    \r
+  The form to update is specified by Handle, FormSetGuid, and FormId.  Binary \r
+  comparisons of IFR opcodes are performed from the beginning of the form being \r
+  updated until an IFR opcode is found that exactly matches the first IFR opcode \r
+  specifed by StartOpCodeHandle.  The following rules are used to determine if\r
+  an insert, replace, or delete operation is performed.\r
+  \r
+  1) If no matches are found, then NULL is returned.  \r
+  2) If a match is found, and EndOpCodeHandle is NULL, then all of the IFR opcodes\r
+     from StartOpcodeHandle except the first opcode are inserted immediately after \r
+     the matching IFR opcode in the form beng updated.\r
+  3) If a match is found, and EndOpCodeHandle is not NULL, then a search is made \r
+     from the matching IFR opcode until an IFR opcode exatly matches the first \r
+     IFR opcode specified by EndOpCodeHandle.  If no match is found for the first\r
+     IFR opcode specified by EndOpCodeHandle, then NULL is returned.  If a match\r
+     is found, then all of the IFR opcodes between the start match and the end \r
+     match are deleted from the form being updated and all of the IFR opcodes\r
+     from StartOpcodeHandle except the first opcode are inserted immediately after \r
+     the matching start IFR opcode.  If StartOpCcodeHandle only contains one\r
+     IFR instruction, then the result of ths operation will delete all of the IFR\r
+     opcodes between the start end matches.\r
+\r
+  If HiiHandle is NULL, then ASSERT().\r
+  If StartOpCodeHandle is NULL, then ASSERT().\r
+\r
+  @param[in]  HiiHandle          The HII Handle of the form to update.\r
+  @param[in]  FormSetGuid        The Formset GUID of the form to update.  This\r
+                                 is an optional parameter that may be NULL.\r
+                                 If it is NULL, all FormSet will be updated.\r
+  @param[in]  FormId             The ID of the form to update.\r
+  @param[in]  StartOpCodeHandle  An OpCode Handle that contains the set of IFR \r
+                                 opcodes to be inserted or replaced in the form.\r
+                                 The first IFR instruction in StartOpCodeHandle \r
+                                 is used to find matching IFR opcode in the \r
+                                 form. \r
+  @param[in]  EndOpCodeHandle    An OpCcode Handle that contains the IFR opcode\r
+                                 that marks the end of a replace operation in\r
+                                 the form.  This is an optional parameter that\r
+                                 may be NULL.  If it is NULL, then an the IFR\r
+                                 opcodes specified by StartOpCodeHandle are \r
+                                 inserted into the form.\r
+  \r
+  @retval EFI_OUT_OF_RESOURCES   No enough memory resource is allocated.\r
+  @retval EFI_NOT_FOUND          The following cases will return EFI_NOT_FOUND.\r
+                                 1) The form specified by HiiHandle, FormSetGuid, \r
+                                 and FormId could not be found in the HII Database.\r
+                                 2) No IFR opcodes in the target form match the first\r
+                                 IFR opcode in StartOpCodeHandle.\r
+                                 3) EndOpCOde is not NULL, and no IFR opcodes in the \r
+                                 target form following a matching start opcode match \r
+                                 the first IFR opcode in EndOpCodeHandle.\r
+  @retval EFI_SUCCESS            The matched form is updated by StartOpcode.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+HiiUpdateForm (\r
+  IN EFI_HII_HANDLE  HiiHandle,\r
+  IN EFI_GUID        *FormSetGuid,        OPTIONAL\r
+  IN EFI_FORM_ID     FormId,\r
+  IN VOID            *StartOpcodeHandle,\r
+  IN VOID            *EndOpcodeHandle     OPTIONAL\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
+  This ConfigBody strings is generated by EDKII UEFI VfrCompiler for the default\r
+  values in a Form Set. The name of the ConfigBody strings is VfrMyIfrNVDataDefault0000\r
+  constructed following this rule: \r
+   "Vfr" + varstore.name + "Default" + defaultstore.attributes.\r
+  Check the generated C file in Output for details.\r
+\r
+  @param  Buffer                 the start address of buffer.\r
+  @param  BufferSize             the size of buffer.\r
+  @param  Number                 the number of the ConfigBody strings.\r
+  @param  ...                    the ConfigBody 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
 #endif\r
index 388a95134c1feba80aad0eaf6477a92260a1c994..1983a65f9d98e0604968ac143890b49b44babb95 100644 (file)
@@ -925,4 +925,32 @@ HiiUpdateForm (
   IN VOID            *EndOpcodeHandle     OPTIONAL\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
+  This ConfigBody strings is generated by EDKII UEFI VfrCompiler for the default\r
+  values in a Form Set. The name of the ConfigBody strings is VfrMyIfrNVDataDefault0000\r
+  constructed following this rule: \r
+   "Vfr" + varstore.name + "Default" + defaultstore.attributes.\r
+  Check the generated C file in Output for details.\r
+\r
+  @param  Buffer                 the start address of buffer.\r
+  @param  BufferSize             the size of buffer.\r
+  @param  Number                 the number of the ConfigBody strings.\r
+  @param  ...                    the ConfigBody 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
 #endif\r
index 099ef5441204568c05a54fe3cb9bf4d1e182c505..06d51fa29d355737c8ee35e49706ec66a3318500 100644 (file)
@@ -794,7 +794,7 @@ InternalHiiLowerConfigString (
   EFI_STRING  String;\r
   BOOLEAN     Lower;\r
 \r
-  ASSERT (String != NULL);\r
+  ASSERT (ConfigString != NULL);\r
 \r
   //\r
   // Convert all hex digits in range [A-F] in the configuration header to [a-f]\r
@@ -2938,3 +2938,77 @@ Finish:
 \r
   return Status; \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
+  This ConfigBody strings is generated by UEFI VfrCompiler for the default\r
+  values in a Form Set. The name of the ConfigBody strings is VfrMyIfrNVDataDefault0000\r
+  constructed following this rule: \r
+   "Vfr" + varstore.name + "Default" + defaultstore.attributes.\r
+  Check the generated C file in Output for details.\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
+  @param  ...                    Variable argument list for default value in <AltResp> format \r
+                                 generated by the tool.\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
+  VA_LIST                         Args;\r
+  UINTN                           Index;\r
+  UINT32                          TotalLen;\r
+  UINT8                           *BufCfgArray;\r
+  UINT8                           *BufferPos;\r
+  UINT16                          Offset;\r
+  UINT16                          Width;\r
+  UINT8                           *Value;\r
+\r
+  if ((Buffer == NULL) || (BufferSize == NULL)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Offset = 0;\r
+  Width  = 0;\r
+  Value  = NULL;\r
+\r
+  VA_START (Args, Number);\r
+  for (Index = 0; Index < Number; Index++) {\r
+    BufCfgArray = (UINT8 *) VA_ARG (Args, VOID *);\r
+    TotalLen = ReadUnaligned32 ((UINT32 *)BufCfgArray);\r
+    BufferPos = BufCfgArray + sizeof (UINT32);\r
+\r
+    while ((UINT32)(BufferPos - BufCfgArray) < TotalLen) {\r
+      Offset = ReadUnaligned16 ((UINT16 *)BufferPos);\r
+      BufferPos += sizeof (UINT16);\r
+      Width = ReadUnaligned16 ((UINT16 *)BufferPos);\r
+      BufferPos += sizeof (UINT16);\r
+      Value = BufferPos;\r
+      BufferPos += Width;\r
+\r
+      if ((UINTN)(Offset + Width) > *BufferSize) {\r
+        return EFI_BUFFER_TOO_SMALL;\r
+      }\r
+\r
+      CopyMem ((UINT8 *)Buffer + Offset, Value, Width);\r
+    }\r
+  }\r
+  VA_END (Args);\r
+\r
+  *BufferSize = (UINTN)Offset;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
index 3aef7126e03812a3ab73e753dfedc53a3c432e44..21173296ba90a7158be4c8005d0c03fd95fdf30b 100644 (file)
@@ -90,7 +90,7 @@ HiiLibGetSupportedLanguages (
     return NULL;\r
   }\r
 \r
-  Status = mHiiStringProt->GetLanguages (mHiiStringProt, HiiHandle, LanguageString, &BufferSize);\r
+  Status = gHiiString->GetLanguages (gHiiString, HiiHandle, LanguageString, &BufferSize);\r
   \r
   if (Status == EFI_BUFFER_TOO_SMALL) {\r
     FreePool (LanguageString);\r
@@ -99,7 +99,7 @@ HiiLibGetSupportedLanguages (
       return NULL;\r
     }\r
 \r
-    Status = mHiiStringProt->GetLanguages (mHiiStringProt, HiiHandle, LanguageString, &BufferSize);\r
+    Status = gHiiString->GetLanguages (gHiiString, HiiHandle, LanguageString, &BufferSize);\r
   }\r
 \r
   if (EFI_ERROR (Status)) {\r
@@ -189,7 +189,7 @@ HiiLibGetSupportedSecondaryLanguages (
     return NULL;\r
   }\r
 \r
-  Status = mHiiStringProt->GetSecondaryLanguages (mHiiStringProt, HiiHandle, FirstLanguage, LanguageString, &BufferSize);\r
+  Status = gHiiString->GetSecondaryLanguages (gHiiString, HiiHandle, FirstLanguage, LanguageString, &BufferSize);\r
   \r
   if (Status == EFI_BUFFER_TOO_SMALL) {\r
     FreePool (LanguageString);\r
@@ -198,7 +198,7 @@ HiiLibGetSupportedSecondaryLanguages (
       return NULL;\r
     }\r
 \r
-    Status = mHiiStringProt->GetSecondaryLanguages (mHiiStringProt, HiiHandle, FirstLanguage, LanguageString, &BufferSize);\r
+    Status = gHiiString->GetSecondaryLanguages (gHiiString, HiiHandle, FirstLanguage, LanguageString, &BufferSize);\r
   }\r
 \r
   if (EFI_ERROR (Status)) {\r
index 83e33d2a6ee67b7501df037fe0a83ab93dba2a27..a3e2498e78607f4a13eb9bebe826671951ededb3 100644 (file)
 \r
 #include "InternalHiiLib.h"\r
 \r
-CONST EFI_HII_DATABASE_PROTOCOL   *mHiiDatabaseProt = NULL;\r
-CONST EFI_HII_STRING_PROTOCOL     *mHiiStringProt = NULL;\r
-\r
-/**\r
-  This function locate Hii relative protocols for later usage.\r
-    \r
-  The constructor function caches the protocol pointer of HII Database Protocol\r
-  and Hii String Protocol.\r
-  \r
-  It will ASSERT() if either of the protocol can't be located.\r
-\r
-  @param  ImageHandle   The firmware allocated handle for the EFI image.\r
-  @param  SystemTable   A pointer to the EFI System Table.\r
-\r
-  @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-HiiLibConstructor (\r
-  IN EFI_HANDLE        ImageHandle,\r
-  IN EFI_SYSTEM_TABLE  *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  Status = gBS->LocateProtocol (&gEfiHiiDatabaseProtocolGuid, NULL, (VOID **) &mHiiDatabaseProt);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  Status = gBS->LocateProtocol (&gEfiHiiStringProtocolGuid, NULL, (VOID **) &mHiiStringProt);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
+//\r
+// <ConfigHdr> Template\r
+//\r
+GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR16 mConfigHdrTemplate[] = L"GUID=00000000000000000000000000000000&NAME=0000&PATH=00";\r
 \r
+//\r
+// Form Browser2 Protocol\r
+//\r
+EFI_FORM_BROWSER2_PROTOCOL  *mFormBrowser2 = NULL;\r
 \r
 /**\r
   This funciton build the package list based on the package number,\r
@@ -222,7 +195,7 @@ HiiLibAddPackages (
   VA_START (Args, HiiHandle);\r
   PackageListHeader = InternalHiiLibPreparePackages (NumberOfPackages, GuidId, Args);\r
 \r
-  Status      = mHiiDatabaseProt->NewPackageList (mHiiDatabaseProt, PackageListHeader, DriverHandle, HiiHandle);\r
+  Status      = gHiiDatabase->NewPackageList (gHiiDatabase, PackageListHeader, DriverHandle, HiiHandle);\r
   if (HiiHandle != NULL) {\r
     if (EFI_ERROR (Status)) {\r
       *HiiHandle = NULL;\r
@@ -254,7 +227,7 @@ HiiLibRemovePackages (
   EFI_STATUS Status;\r
   ASSERT (IsHiiHandleRegistered (HiiHandle));\r
 \r
-  Status = mHiiDatabaseProt->RemovePackageList (mHiiDatabaseProt, HiiHandle);\r
+  Status = gHiiDatabase->RemovePackageList (gHiiDatabase, HiiHandle);\r
   ASSERT_EFI_ERROR (Status);\r
 }\r
 \r
@@ -292,8 +265,8 @@ HiiLibGetHiiHandles (
   //\r
   // Try to find the actual buffer size for HiiHandle Buffer.\r
   //\r
-  Status = mHiiDatabaseProt->ListPackageLists (\r
-                                 mHiiDatabaseProt,\r
+  Status = gHiiDatabase->ListPackageLists (\r
+                                 gHiiDatabase,\r
                                  EFI_HII_PACKAGE_TYPE_ALL,\r
                                  NULL,\r
                                  HandleBufferLength,\r
@@ -303,8 +276,8 @@ HiiLibGetHiiHandles (
   if (Status == EFI_BUFFER_TOO_SMALL) {\r
       *HiiHandleBuffer = AllocateZeroPool (*HandleBufferLength);\r
       ASSERT (*HiiHandleBuffer != NULL);\r
-      Status = mHiiDatabaseProt->ListPackageLists (\r
-                                     mHiiDatabaseProt,\r
+      Status = gHiiDatabase->ListPackageLists (\r
+                                     gHiiDatabase,\r
                                      EFI_HII_PACKAGE_TYPE_ALL,\r
                                      NULL,\r
                                      HandleBufferLength,\r
@@ -352,14 +325,14 @@ HiiLibExtractGuidFromHiiHandle (
   BufferSize = 0;\r
   HiiPackageList = NULL;\r
 \r
-  Status = mHiiDatabaseProt->ExportPackageLists (mHiiDatabaseProt, Handle, &BufferSize, HiiPackageList);\r
+  Status = gHiiDatabase->ExportPackageLists (gHiiDatabase, Handle, &BufferSize, HiiPackageList);\r
   ASSERT (Status != EFI_NOT_FOUND);\r
   \r
   if (Status == EFI_BUFFER_TOO_SMALL) {\r
     HiiPackageList = AllocatePool (BufferSize);\r
     ASSERT (HiiPackageList != NULL);\r
 \r
-    Status = mHiiDatabaseProt->ExportPackageLists (mHiiDatabaseProt, Handle, &BufferSize, HiiPackageList);\r
+    Status = gHiiDatabase->ExportPackageLists (gHiiDatabase, Handle, &BufferSize, HiiPackageList);\r
   }\r
   if (EFI_ERROR (Status)) {\r
     FreePool (HiiPackageList);\r
@@ -453,8 +426,8 @@ HiiLibDevicePathToHiiHandle (
   BufferSize = 0x1000;\r
   HiiHandles = AllocatePool (BufferSize);\r
   ASSERT (HiiHandles != NULL);\r
-  Status = mHiiDatabaseProt->ListPackageLists (\r
-                          mHiiDatabaseProt,\r
+  Status = gHiiDatabase->ListPackageLists (\r
+                          gHiiDatabase,\r
                           EFI_HII_PACKAGE_TYPE_ALL,\r
                           NULL,\r
                           &BufferSize,\r
@@ -465,8 +438,8 @@ HiiLibDevicePathToHiiHandle (
     HiiHandles = AllocatePool (BufferSize);\r
     ASSERT (HiiHandles != NULL);\r
 \r
-    Status = mHiiDatabaseProt->ListPackageLists (\r
-                            mHiiDatabaseProt,\r
+    Status = gHiiDatabase->ListPackageLists (\r
+                            gHiiDatabase,\r
                             EFI_HII_PACKAGE_TYPE_ALL,\r
                             NULL,\r
                             &BufferSize,\r
@@ -485,8 +458,8 @@ HiiLibDevicePathToHiiHandle (
   HiiHandle = NULL;\r
   HandleCount = BufferSize / sizeof (EFI_HII_HANDLE);\r
   for (Index = 0; Index < HandleCount; Index++) {\r
-    Status = mHiiDatabaseProt->GetPackageListHandle (\r
-                            mHiiDatabaseProt,\r
+    Status = gHiiDatabase->GetPackageListHandle (\r
+                            gHiiDatabase,\r
                             HiiHandles[Index],\r
                             &Handle\r
                             );\r
@@ -539,8 +512,8 @@ HiiLibExportPackageLists (
 \r
   Size = 0;\r
   PackageListHdr = NULL;\r
-  Status = mHiiDatabaseProt->ExportPackageLists (\r
-                                      mHiiDatabaseProt,\r
+  Status = gHiiDatabase->ExportPackageLists (\r
+                                      gHiiDatabase,\r
                                       Handle,\r
                                       &Size,\r
                                       PackageListHdr\r
@@ -553,8 +526,8 @@ HiiLibExportPackageLists (
     if (PackageListHeader == NULL) {\r
       return EFI_OUT_OF_RESOURCES;\r
     } else {\r
-      Status = mHiiDatabaseProt->ExportPackageLists (\r
-                                          mHiiDatabaseProt,\r
+      Status = gHiiDatabase->ExportPackageLists (\r
+                                          gHiiDatabase,\r
                                           Handle,\r
                                           &Size,\r
                                           PackageListHdr\r
@@ -632,8 +605,8 @@ HiiLibListPackageLists (
     ASSERT (PackageGuid == NULL);\r
   }\r
 \r
-  Status = mHiiDatabaseProt->ListPackageLists (\r
-                            mHiiDatabaseProt,\r
+  Status = gHiiDatabase->ListPackageLists (\r
+                            gHiiDatabase,\r
                             PackageType,\r
                             PackageGuid,\r
                             HandleBufferLength,\r
@@ -653,8 +626,8 @@ HiiLibListPackageLists (
     return EFI_OUT_OF_RESOURCES;\r
   }\r
   \r
-  return mHiiDatabaseProt->ListPackageLists (\r
-                            mHiiDatabaseProt,\r
+  return gHiiDatabase->ListPackageLists (\r
+                            gHiiDatabase,\r
                             PackageType,\r
                             PackageGuid,\r
                             HandleBufferLength,\r
@@ -685,8 +658,8 @@ IsHiiHandleRegistered (
   HiiPackageList = NULL;\r
   BufferSize = 0;\r
 \r
-  Status = mHiiDatabaseProt->ExportPackageLists (\r
-             mHiiDatabaseProt,\r
+  Status = gHiiDatabase->ExportPackageLists (\r
+             gHiiDatabase,\r
              HiiHandle,\r
              &BufferSize,\r
              HiiPackageList\r
@@ -695,3 +668,2242 @@ IsHiiHandleRegistered (
   return (BOOLEAN) (Status == EFI_BUFFER_TOO_SMALL);\r
 }\r
 \r
+\r
+/**\r
+  Converts all hex dtring characters in range ['A'..'F'] to ['a'..'f'] for \r
+  hex digits that appear between a '=' and a '&' in a config string.\r
+\r
+  If String is NULL, then ASSERT().\r
+\r
+  @param[in] String  Pointer to a Null-terminated Unicode string.\r
+\r
+  @return  Pointer to the Null-terminated Unicode result string.\r
+\r
+**/\r
+EFI_STRING\r
+EFIAPI\r
+InternalHiiLowerConfigString (\r
+  IN EFI_STRING  ConfigString\r
+  )\r
+{\r
+  EFI_STRING  String;\r
+  BOOLEAN     Lower;\r
+\r
+  ASSERT (ConfigString != NULL);\r
+\r
+  //\r
+  // Convert all hex digits in range [A-F] in the configuration header to [a-f]\r
+  //\r
+  for (String = ConfigString, Lower = FALSE; *String != L'\0'; String++) {\r
+    if (*String == L'=') {\r
+      Lower = TRUE;\r
+    } else if (*String == L'&') {\r
+      Lower = FALSE;\r
+    } else if (Lower && *String > L'A' && *String <= L'F') {\r
+      *String = *String - L'A' + L'a';\r
+    }\r
+  }\r
+\r
+  return ConfigString;\r
+}\r
+\r
+/**\r
+  Uses the BlockToConfig() service of the Config Routing Protocol to \r
+  convert <ConfigRequest> and a buffer to a <ConfigResp>\r
+\r
+  If ConfigRequest is NULL, then ASSERT().\r
+  If Block is NULL, then ASSERT().\r
+\r
+  @param[in] ConfigRequest  Pointer to a Null-terminated Unicode string.\r
+  @param[in] Block          Pointer to a block of data.\r
+  @param[in] BlockSize      The zie, in bytes, of Block.\r
+\r
+  @retval NULL   The <ConfigResp> string could not be generated.\r
+  @retval Other  Pointer to the Null-terminated Unicode <ConfigResp> string.\r
+\r
+**/\r
+EFI_STRING\r
+EFIAPI\r
+InternalHiiBlockToConfig (\r
+  IN CONST EFI_STRING  ConfigRequest,\r
+  IN CONST UINT8       *Block,\r
+  IN UINTN             BlockSize\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+  EFI_STRING  ConfigResp;\r
+  CHAR16      *Progress;\r
+\r
+  ASSERT (ConfigRequest != NULL);\r
+  ASSERT (Block != NULL);\r
+\r
+  //\r
+  // Convert <ConfigRequest> to <ConfigResp>\r
+  //\r
+  Status = gHiiConfigRouting->BlockToConfig (\r
+                                gHiiConfigRouting,\r
+                                ConfigRequest,\r
+                                Block,\r
+                                BlockSize,\r
+                                &ConfigResp,\r
+                                &Progress\r
+                                );\r
+  if (EFI_ERROR (Status)) {\r
+    return NULL;\r
+  }\r
+  return ConfigResp;\r
+}\r
+\r
+/**\r
+  Uses the ConfigToBlock() service of the Config Routing Protocol to \r
+  convert <ConfigResp> to a block.  The block is allocated using\r
+  AllocatePool().  The caller is responsible for freeing the block\r
+  using FreePool().\r
+\r
+  If ConfigResp is NULL, then ASSERT().\r
+\r
+  @param[in] ConfigResp  Pointer to a Null-terminated Unicode string.\r
+  @param[in] BufferSize  Length in bytes of buffer to hold retrived data. \r
+\r
+  @retval NULL   The block could not be generated..\r
+  @retval Other  Pointer to the allocated block.\r
+\r
+**/\r
+UINT8 *\r
+EFIAPI\r
+InternalHiiConfigToBlock (\r
+  IN  EFI_STRING  ConfigResp,\r
+  IN  UINTN       BlockSize\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+  CHAR16      *Progress;\r
+  UINT8       *Block;\r
+\r
+  ASSERT (ConfigResp != NULL);\r
+\r
+  //\r
+  // Allocate a buffer to hold the <ConfigResp> conversion\r
+  //\r
+  Block = AllocateZeroPool (BlockSize);\r
+  if (Block == NULL) {\r
+    return NULL;\r
+  }\r
+\r
+  //\r
+  // Convert <ConfigResp> to a buffer\r
+  //\r
+  Status = gHiiConfigRouting->ConfigToBlock (\r
+                                gHiiConfigRouting,\r
+                                ConfigResp,\r
+                                Block,\r
+                                &BlockSize,\r
+                                &Progress\r
+                                );\r
+  if (EFI_ERROR (Status)) {\r
+    FreePool (Block);\r
+    return NULL;\r
+  }\r
+\r
+  //\r
+  // Return converted buffer\r
+  //\r
+  return Block;\r
+}\r
+\r
+/**\r
+  Uses the BrowserCallback() service of the Form Browser Protocol to retrieve \r
+  or set uncommitted data.  If sata i being retrieved, then the buffer is \r
+  allocated using AllocatePool().  The caller is then responsible for freeing \r
+  the buffer using FreePool().\r
+\r
+  @param[in]  VariableName    Pointer to a Null-terminated Unicode string.  This \r
+                              is an optional parameter that may be NULL.\r
+  @param[in]  VariableGuid    Pointer to an EFI_GUID structure.  This is an optional \r
+                              parameter that may be NULL.\r
+  @param[in]  SetResultsData  If not NULL, then this parameter specified the buffer\r
+                              of uncommited data to set.  If this parameter is NULL,\r
+                              then the caller is requesting to get the uncommited data\r
+                              from the Form Browser.\r
+\r
+  @retval NULL   The uncommitted data could not be retrieved.\r
+  @retval Other  A pointer to a buffer containing the uncommitted data.\r
+\r
+**/\r
+EFI_STRING\r
+EFIAPI\r
+InternalHiiBrowserCallback (\r
+  IN CONST EFI_GUID    *VariableGuid,  OPTIONAL\r
+  IN CONST CHAR16      *VariableName,  OPTIONAL\r
+  IN CONST EFI_STRING  SetResultsData  OPTIONAL\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+  UINTN       ResultsDataSize;\r
+  EFI_STRING  ResultsData;\r
+  CHAR16      TempResultsData;\r
+\r
+  //\r
+  // Locate protocols\r
+  //\r
+  if (mFormBrowser2 == NULL) {\r
+    Status = gBS->LocateProtocol (&gEfiFormBrowser2ProtocolGuid, NULL, (VOID **) &mFormBrowser2);\r
+    if (EFI_ERROR (Status) || mFormBrowser2 == NULL) {\r
+      return NULL;\r
+    }\r
+  }\r
+\r
+  ResultsDataSize = 0;\r
+\r
+  if (SetResultsData != NULL) {\r
+    //\r
+    // Request to to set data in the uncommitted browser state information\r
+    //\r
+    ResultsData = SetResultsData;\r
+  } else {\r
+    //\r
+    // Retrieve the length of the buffer required ResultsData from the Browser Callback\r
+    //\r
+    Status = mFormBrowser2->BrowserCallback (\r
+                              mFormBrowser2,\r
+                              &ResultsDataSize,\r
+                              &TempResultsData,\r
+                              TRUE,\r
+                              VariableGuid,\r
+                              VariableName\r
+                              );\r
+    if (Status != EFI_BUFFER_TOO_SMALL) {\r
+      return NULL;\r
+    }\r
+\r
+    //\r
+    // Allocate the ResultsData buffer\r
+    //\r
+    ResultsData = AllocateZeroPool (ResultsDataSize);\r
+    if (ResultsData == NULL) {\r
+      return NULL;\r
+    }\r
+  }\r
+\r
+  //\r
+  // Retrieve or set the ResultsData from the Browser Callback\r
+  //\r
+  Status = mFormBrowser2->BrowserCallback (\r
+                            mFormBrowser2,\r
+                            &ResultsDataSize,\r
+                            ResultsData,\r
+                            (BOOLEAN)(SetResultsData == NULL),\r
+                            VariableGuid,\r
+                            VariableName\r
+                            );\r
+  if (EFI_ERROR (Status)) {\r
+    return NULL;\r
+  }\r
+\r
+  return ResultsData;\r
+}\r
+\r
+/**\r
+  Allocates and returns a Null-terminated Unicode <ConfigHdr> string using routing \r
+  information that includes a GUID, an optional Unicode string name, and a device\r
+  path.  The string returned is allocated with AllocatePool().  The caller is \r
+  responsible for freeing the allocated string with FreePool().\r
+  \r
+  The format of a <ConfigHdr> is as follows:\r
+\r
+    GUID=<HexCh>32&NAME=<Char>NameLength&PATH=<HexChar>DevicePathSize<Null>\r
+\r
+  @param[in]  Guid          Pointer to an EFI_GUID that is the routing information\r
+                            GUID.  Each of the 16 bytes in Guid is converted to \r
+                            a 2 Unicode character hexidecimal string.  This is \r
+                            an optional parameter that may be NULL.\r
+  @param[in]  Name          Pointer to a Null-terminated Unicode string that is \r
+                            the routing information NAME.  This is an optional \r
+                            parameter that may be NULL.  Each 16-bit Unicode \r
+                            character in Name is converted to a 4 character Unicode \r
+                            hexidecimal string.                        \r
+  @param[in]  DriverHandle  The driver handle which supports a Device Path Protocol\r
+                            that is the routing information PATH.  Each byte of\r
+                            the Device Path associated with DriverHandle is converted\r
+                            to a 2 Unicode character hexidecimal string.\r
+\r
+  @retval NULL   DriverHandle does not support the Device Path Protocol.\r
+  @retval NULL   DriverHandle does not support the Device Path Protocol.\r
+  @retval Other  A pointer to the Null-terminate Unicode <ConfigHdr> string\r
+\r
+**/\r
+EFI_STRING\r
+EFIAPI\r
+HiiConstructConfigHdr (\r
+  IN CONST EFI_GUID  *Guid,  OPTIONAL\r
+  IN CONST CHAR16    *Name,  OPTIONAL\r
+  IN EFI_HANDLE      DriverHandle\r
+  )\r
+{\r
+  UINTN                     NameLength;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+  UINTN                     DevicePathSize;\r
+  CHAR16                    *String;\r
+  CHAR16                    *ReturnString;\r
+  UINTN                     Index;\r
+  UINT8                     *Buffer;\r
+\r
+  //\r
+  // Compute the length of Name in Unicode characters.  \r
+  // If Name is NULL, then the length is 0.\r
+  //\r
+  NameLength = 0;\r
+  if (Name != NULL) {\r
+    NameLength = StrLen (Name);\r
+  }\r
+\r
+  //\r
+  // Retrieve DevicePath Protocol associated with DriverHandle\r
+  //\r
+  DevicePath = DevicePathFromHandle (DriverHandle);\r
+  if (DevicePath == NULL) {\r
+    return NULL;\r
+  }\r
+\r
+  //\r
+  // Compute the size of the device path in bytes\r
+  //\r
+  DevicePathSize = GetDevicePathSize (DevicePath);\r
+\r
+  //\r
+  // GUID=<HexCh>32&NAME=<Char>NameLength&PATH=<HexChar>DevicePathSize <Null>\r
+  // | 5 | sizeof (EFI_GUID) * 2 | 6 | NameStrLen*4 | 6 | DevicePathSize * 2 | 1 |\r
+  //\r
+  String = AllocateZeroPool ((5 + sizeof (EFI_GUID) * 2 + 6 + NameLength * 4 + 6 + DevicePathSize * 2 + 1) * sizeof (CHAR16));\r
+  if (String == NULL) {\r
+    return NULL;\r
+  }\r
+\r
+  //\r
+  // Start with L"GUID="\r
+  //\r
+  ReturnString = StrCpy (String, L"GUID=");\r
+  String += StrLen (String);\r
+\r
+  if (Guid != NULL) {\r
+    //\r
+    // Append Guid converted to <HexCh>32\r
+    //\r
+    for (Index = 0, Buffer = (UINT8 *)Guid; Index < sizeof (EFI_GUID); Index++) {\r
+      String += UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, *(Buffer++), 2);\r
+    }\r
+  }\r
+  \r
+  //\r
+  // Append L"&NAME="\r
+  //\r
+  StrCpy (String, L"&NAME=");\r
+  String += StrLen (String);\r
+\r
+  if (Name != NULL) {\r
+    //\r
+    // Append Name converted to <Char>NameLength\r
+    //\r
+    for (; *Name != L'\0'; Name++) {\r
+      String += UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, *Name, 4);\r
+    }\r
+  }\r
+\r
+  //\r
+  // Append L"&PATH="\r
+  //\r
+  StrCpy (String, L"&PATH=");\r
+  String += StrLen (String);\r
+\r
+  //\r
+  // Append the device path associated with DriverHandle converted to <HexChar>DevicePathSize\r
+  //\r
+  for (Index = 0, Buffer = (UINT8 *)DevicePath; Index < DevicePathSize; Index++) {\r
+    String += UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, *(Buffer++), 2);\r
+  }\r
+\r
+  //\r
+  // Null terminate the Unicode string\r
+  //\r
+  *String = L'\0';\r
+\r
+  //\r
+  // Convert all hex digits in range [A-F] in the configuration header to [a-f]\r
+  //\r
+  return InternalHiiLowerConfigString (ReturnString);\r
+}\r
+\r
+/**\r
+  Allocates and returns a Null-terminated Unicode <ConfigAltResp> string.\r
+\r
+  If Guid is NULL, then ASSERT().\r
+  If Name is NULL, then ASSERT().\r
+  If BlockNameArray is NULL, then ASSERT().\r
+\r
+  @param[in] Guid               GUID of the buffer storage.\r
+  @param[in] Name               Name of the buffer storage.\r
+  @param[in] DriverHandle       The DriverHandle that support a Device Path\r
+                                Protocol.    \r
+  @param[in] BufferStorage      Content of the buffer storage.\r
+  @param[in] BufferStorageSize  Length in bytes of the buffer storage.\r
+  @param[in] BlockNameArray     Array generated by VFR compiler.  This array\r
+                                contains a UINT32 value that is the length\r
+                                of BlockNameArray in bytes, followed by pairs\r
+                                of 16-bit values that are the offset and length\r
+                                values used to contruct a <ConfigRequest> string.\r
+  @param[in]  ...               A variable argument list that contains pairs of 16-bit\r
+                                ALTCFG identifiers and pointers to DefaultValueArrays.\r
+                                The variable argument list is terminated by a NULL \r
+                                DefaultValueArray pointer.  A DefaultValueArray \r
+                                contains a UINT32 value that is the length, in bytes,\r
+                                of the DefaultValueArray.  The UINT32 length value \r
+                                is followed by a series of records that contain\r
+                                a 16-bit WIDTH value followed by a byte array with \r
+                                WIDTH entries.  The records must be parsed from\r
+                                beginning to end until the UINT32 length limit\r
+                                is reached.  \r
+\r
+  @retval NULL          There are not enough resources to process the request.\r
+  @retval NULL          A <ConfigResp> could not be retrieved from the Config \r
+                        Routing Protocol.\r
+  @retval Other         A pointer to the Null-terminate Unicode <ConfigAltResp>\r
+                        string.\r
+\r
+**/\r
+EFI_STRING\r
+EFIAPI\r
+HiiConstructConfigAltResp (\r
+  IN CONST EFI_GUID  *Guid,\r
+  IN CONST CHAR16    *Name,\r
+  IN EFI_HANDLE      DriverHandle,\r
+  IN CONST VOID      *BufferStorage,\r
+  IN UINTN           BufferStorageSize,\r
+  IN CONST VOID      *BlockNameArray, \r
+  ...\r
+  )\r
+{\r
+  UINTN         Length;\r
+  CHAR16        *String;\r
+  CHAR16        *ConfigHdr;\r
+  UINT8         *Buffer;\r
+  UINT8         *BufferEnd;\r
+  CHAR16        *ConfigRequest;\r
+  EFI_STRING    ConfigResp;\r
+  EFI_STRING    ConfigAltResp;\r
+  VA_LIST       Args;\r
+  UINTN         AltCfgId;\r
+  UINT16        Width;\r
+\r
+  ASSERT (Guid != NULL);\r
+  ASSERT (Name != NULL);\r
+  ASSERT (BlockNameArray != NULL);\r
+\r
+  //\r
+  // Initialize local variables\r
+  //\r
+  ConfigHdr     = NULL;\r
+  ConfigRequest = NULL; \r
+  ConfigResp    = NULL;\r
+\r
+  //\r
+  // Construct <ConfigHdr> : "GUID=...&NAME=...&PATH=..."\r
+  //\r
+  ConfigHdr = HiiConstructConfigHdr (Guid, Name, DriverHandle);\r
+  if (ConfigHdr == NULL) {\r
+    goto Exit;\r
+  }\r
+\r
+  //\r
+  // Compute the length of the entire request starting with <ConfigHdr> and a \r
+  // Null-terminator\r
+  //\r
+  Length = StrLen (ConfigHdr) + 1;\r
+\r
+  //\r
+  // Determine the size <BlockName> Offset/Width pairs\r
+  //\r
+  Buffer = (UINT8 *)BlockNameArray;\r
+  BufferEnd = Buffer + ReadUnaligned32 ((UINT32 *)Buffer);\r
+  Buffer += sizeof (UINT32);\r
+\r
+  //\r
+  // Add <BlockName> length that is composed of one or more Offset/Width pairs\r
+  //\r
+  // <BlockName> ::= &OFFSET=1234&WIDTH=1234\r
+  //                 |  8   | 4 |   7  | 4 |\r
+  //\r
+  Length += (((BufferEnd - Buffer) / (sizeof (UINT16) + sizeof (UINT16))) * (8 + 4 + 7 + 4));\r
+\r
+  //\r
+  // Allocate buffer for the entire <ConfigRequest>\r
+  //\r
+  ConfigRequest = AllocateZeroPool (Length * sizeof (CHAR16));\r
+  if (ConfigRequest == NULL) {\r
+    goto Exit;\r
+  }\r
+  String = ConfigRequest;\r
+\r
+  //\r
+  // Start with <ConfigHdr>\r
+  //\r
+  StrCpy (String, ConfigHdr);\r
+  String += StrLen (String);\r
+\r
+  //\r
+  // Loop through all the Offset/Width pairs and append them to ConfigRequest\r
+  //\r
+  while (Buffer < BufferEnd) {\r
+    //\r
+    // Append &OFFSET=XXXX&WIDTH=YYYY\r
+    //\r
+    UnicodeSPrint (\r
+      String, \r
+      (8 + 4 + 7 + 4) * sizeof (CHAR16), \r
+      L"&OFFSET=%04X&WIDTH=%04X", \r
+      ReadUnaligned16 ((UINT16 *)Buffer), \r
+      ReadUnaligned16 ((UINT16 *)(Buffer + sizeof (UINT16)))\r
+      );\r
+    String += StrLen (String);\r
+    Buffer += (sizeof (UINT16) + sizeof (UINT16));\r
+  }\r
+\r
+  //\r
+  // Get the <ConfigResp>\r
+  //\r
+  ConfigResp = InternalHiiBlockToConfig (ConfigRequest, BufferStorage, BufferStorageSize);\r
+  if (ConfigResp == NULL) {\r
+    goto Exit;\r
+  }\r
+\r
+  //\r
+  // Compute the length of the entire response starting with <ConfigResp> and a \r
+  // Null-terminator\r
+  //\r
+  Length = StrLen (ConfigResp) + 1;\r
+\r
+  //\r
+  // Add the length associated with each pair of variable argument parameters\r
+  //\r
+  VA_START (Args, BlockNameArray);\r
+  while (TRUE) {\r
+    AltCfgId = VA_ARG (Args, UINT16);\r
+    Buffer   = VA_ARG (Args, UINT8 *);\r
+    if (Buffer == NULL) {\r
+      break;\r
+    }\r
+\r
+    //\r
+    // Add length for "&<ConfigHdr>&ALTCFG=XXXX"\r
+    //                |1| StrLen (ConfigHdr) | 8 | 4 |\r
+    //\r
+    Length += (1 + StrLen (ConfigHdr) + 8 + 4);\r
+\r
+    BufferEnd = Buffer + ReadUnaligned32 ((UINT32 *)Buffer);\r
+    Buffer += sizeof (UINT32);\r
+    while (Buffer < BufferEnd) {\r
+      //\r
+      // Extract Width field\r
+      //\r
+      Width = ReadUnaligned16 ((UINT16 *)(Buffer + sizeof (UINT16)));\r
+\r
+      //\r
+      // Add length for "&OFFSET=XXXX&WIDTH=YYYY&VALUE=zzzzzzzzzzzz"\r
+      //                |    8  | 4 |   7  | 4 |   7  | Width * 2 |\r
+      //\r
+      Length += (8 + 4 + 7 + 4 + 7 + Width * 2);\r
+\r
+      //\r
+      // Update Buffer to the next record\r
+      //\r
+      Buffer += (sizeof (UINT16) + sizeof (UINT16) + Width);\r
+    }\r
+  }\r
+  VA_END (Args);\r
+\r
+  //\r
+  // Allocate a buffer for the entire response\r
+  //\r
+  ConfigAltResp = AllocateZeroPool (Length * sizeof (CHAR16));\r
+  if (ConfigAltResp == NULL) {\r
+    goto Exit;\r
+  }\r
+  String = ConfigAltResp;\r
+\r
+  //\r
+  // Add <ConfigResp>\r
+  //\r
+  StrCpy (String, ConfigResp);\r
+  String += StrLen (String);\r
+\r
+  //\r
+  // Add <AltResp> for each pair of variable argument parameters\r
+  //\r
+  VA_START (Args, BlockNameArray);\r
+  while (TRUE) {\r
+    AltCfgId = VA_ARG (Args, UINT16);\r
+    Buffer   = VA_ARG (Args, UINT8 *);\r
+    if (Buffer == NULL) {\r
+      break;\r
+    }\r
+\r
+    //\r
+    // Add <AltConfigHdr> of the form "&<ConfigHdr>&ALTCFG=XXXX"\r
+    //                                |1| StrLen (ConfigHdr) | 8 | 4 |\r
+    //\r
+    UnicodeSPrint (\r
+      String, \r
+      (1 + StrLen (ConfigHdr) + 8 + 4) * sizeof (CHAR16), \r
+      L"&%s&ALTCFG=%04X", \r
+      ConfigHdr, \r
+      AltCfgId\r
+      );\r
+    String += StrLen (String);\r
+\r
+    //\r
+    // Add <ConfigBody> ::= <ConfigElement>*\r
+    //\r
+    BufferEnd = Buffer + ReadUnaligned32 ((UINT32 *)Buffer);\r
+    Buffer += sizeof (UINT32);\r
+    while (Buffer < BufferEnd) {\r
+      //\r
+      // Extract Width field\r
+      //\r
+      Width = ReadUnaligned16 ((UINT16 *)(Buffer + sizeof (UINT16)));\r
+\r
+      //\r
+      // Add <BlockConfig>\r
+      //\r
+      UnicodeSPrint (\r
+        String, \r
+        (8 + 4 + 7 + 4 + 7 + Width * 2) * sizeof (CHAR16),\r
+        L"&OFFSET=%04X&WIDTH=%04X&VALUE=", \r
+        ReadUnaligned16 ((UINT16 *)Buffer), \r
+        Width\r
+        );\r
+      String += StrLen (String);\r
+\r
+      //\r
+      // Update Buffer to point to the value in the current record\r
+      //\r
+      Buffer += (sizeof (UINT16) + sizeof (UINT16));\r
+\r
+      //\r
+      // Convert Value to a hex string in "%x" format\r
+      //   NOTE: This is in the opposite byte that GUID and PATH use\r
+      //\r
+      for (; Width > 0; Width--) {\r
+        String += UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, Buffer[Width - 1], 2);\r
+      }\r
+      //\r
+      // Update Buffer to the next record\r
+      //\r
+      Buffer += Width;\r
+    }\r
+  }\r
+  VA_END (Args);\r
+\r
+  //\r
+  // Convert all hex digits in range [A-F] in the configuration header to [a-f]\r
+  //\r
+  return InternalHiiLowerConfigString (ConfigAltResp);\r
+\r
+Exit:\r
+  if (ConfigHdr != NULL) {\r
+    FreePool (ConfigHdr);\r
+  }\r
+  if (ConfigRequest != NULL) {\r
+    FreePool (ConfigRequest);\r
+  }\r
+  if (ConfigResp != NULL) {\r
+    FreePool (ConfigResp);\r
+  }\r
+\r
+  return NULL;\r
+}\r
+\r
+/**\r
+  Determines if two values in config strings match.\r
+\r
+  Compares the substring between StartSearchString and StopSearchString in \r
+  FirstString to the substring between StartSearchString and StopSearchString \r
+  in SecondString.  If the two substrings match, then TRUE is returned.  If the\r
+  two substrings do not match, then FALSE is returned.\r
+\r
+  If FirstString is NULL, then ASSERT().\r
+  If SecondString is NULL, then ASSERT().\r
+  If StartSearchString is NULL, then ASSERT().\r
+  If StopSearchString is NULL, then ASSERT().\r
+\r
+  @param FirstString        Pointer to the first Null-terminated Unicode string.\r
+  @param SecondString       Pointer to the second Null-terminated Unicode string.\r
+  @param StartSearchString  Pointer to the Null-terminated Unicode string that \r
+                            marks the start of the value string to compare.\r
+  @param StopSearchString   Pointer to the Null-terminated Unicode string that \r
+                            marks the end of the vakue string to compare.\r
+\r
+  @retval FALSE             StartSearchString is not present in FirstString. \r
+  @retval FALSE             StartSearchString is not present in SecondString.\r
+  @retval FALSE             StopSearchString is not present in FirstString. \r
+  @retval FALSE             StopSearchString is not present in SecondString.\r
+  @retval FALSE             The length of the substring in FirstString is not the \r
+                            same length as the substring in SecondString.\r
+  @retval FALSE             The value string in FirstString does not matche the \r
+                            value string in SecondString.\r
+  @retval TRUE              The value string in FirstString matches the value \r
+                            string in SecondString.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+InternalHiiCompareSubString (\r
+  IN CHAR16  *FirstString,\r
+  IN CHAR16  *SecondString,\r
+  IN CHAR16  *StartSearchString,\r
+  IN CHAR16  *StopSearchString\r
+  )\r
+{\r
+  CHAR16  *EndFirstString;\r
+  CHAR16  *EndSecondString;\r
+\r
+  ASSERT (FirstString != NULL);\r
+  ASSERT (SecondString != NULL);\r
+  ASSERT (StartSearchString != NULL);\r
+  ASSERT (StopSearchString != NULL);\r
+\r
+  FirstString = StrStr (FirstString, StartSearchString);\r
+  if (FirstString == NULL) {\r
+    return FALSE;\r
+  }\r
+\r
+  SecondString = StrStr (SecondString, StartSearchString);\r
+  if (SecondString == NULL) {\r
+    return FALSE;\r
+  }\r
+\r
+  EndFirstString = StrStr (FirstString, StopSearchString);\r
+  if (EndFirstString == NULL) {\r
+    return FALSE;\r
+  }\r
+\r
+  EndSecondString = StrStr (SecondString, StopSearchString);\r
+  if (EndSecondString == NULL) {\r
+    return FALSE;\r
+  }\r
+\r
+  if ((EndFirstString - FirstString) != (EndSecondString - SecondString)) {\r
+    return FALSE;\r
+  }\r
+\r
+  return (BOOLEAN)(StrnCmp (FirstString, SecondString, EndFirstString - FirstString) == 0);\r
+}\r
+\r
+/**\r
+  Determines if the routing data specified by GUID and NAME match a <ConfigHdr>.\r
+\r
+  If ConfigHdr is NULL, then ASSERT().\r
+\r
+  @param[in] ConfigHdr  Either <ConfigRequest> or <ConfigResp>.\r
+  @param[in] Guid       GUID of the storage.\r
+  @param[in] Name       NAME of the storage.\r
+\r
+  @retval TRUE   Routing information matches <ConfigHdr>.\r
+  @retval FALSE  Routing information does not match <ConfigHdr>.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+HiiIsConfigHdrMatch (\r
+  IN CONST EFI_STRING  ConfigHdr,\r
+  IN CONST EFI_GUID    *Guid,     OPTIONAL\r
+  IN CONST CHAR16      *Name      OPTIONAL\r
+  )\r
+{\r
+  EFI_STRING  CompareConfigHdr;\r
+  BOOLEAN     Result;\r
+\r
+  ASSERT (ConfigHdr != NULL);\r
+\r
+  //\r
+  // Use Guid and Name to generate a <ConfigHdr> string\r
+  //\r
+  CompareConfigHdr = HiiConstructConfigHdr (Guid, Name, NULL);\r
+  if (CompareConfigHdr == NULL) {\r
+    return FALSE;\r
+  }\r
+\r
+  Result = TRUE;\r
+  if (Guid != NULL) {\r
+    //\r
+    // Compare GUID value strings\r
+    //\r
+    Result = InternalHiiCompareSubString (ConfigHdr, CompareConfigHdr, L"GUID=", L"&NAME=");\r
+  }\r
+\r
+  if (Result && Name != NULL) {\r
+    //\r
+    // Compare NAME value strings\r
+    //\r
+    Result = InternalHiiCompareSubString (ConfigHdr, CompareConfigHdr, L"&NAME=", L"&PATH=");\r
+  }\r
+\r
+  //\r
+  // Free the <ConfigHdr> string\r
+  //\r
+  FreePool (CompareConfigHdr);\r
+\r
+  return Result;\r
+}\r
+\r
+/**\r
+  Retrieves uncommited data from the Form Browser and converts it to a binary\r
+  buffer.  The returned buffer is allocated using AllocatePool().  The caller\r
+  is responsible for freeing the returned buffer using FreePool().\r
+\r
+  @param[in]  VariableName  Pointer to a Null-terminated Unicode string.  This \r
+                            is an optional parameter that may be NULL.\r
+  @param[in]  VariableGuid  Pointer to an EFI_GUID structure.  This is an optional \r
+                            parameter that may be NULL.\r
+  @param[in]  BufferSize    Length in bytes of buffer to hold retrived data. \r
+\r
+  @retval NULL   The uncommitted data could not be retrieved.\r
+  @retval Other  A pointer to a buffer containing the uncommitted data.\r
+\r
+**/\r
+UINT8 *\r
+EFIAPI\r
+HiiGetBrowserData (\r
+  IN CONST EFI_GUID  *VariableGuid,  OPTIONAL\r
+  IN CONST CHAR16    *VariableName,  OPTIONAL\r
+  IN UINTN           BlockSize\r
+  )\r
+{\r
+  EFI_STRING  ResultsData;\r
+  UINTN       Size;\r
+  EFI_STRING  ConfigResp;\r
+  UINT8       *Block;\r
+\r
+  //\r
+  // Retrieve the results data from the Browser Callback\r
+  //\r
+  ResultsData = InternalHiiBrowserCallback (VariableGuid, VariableName, NULL);\r
+  if (ResultsData == NULL) {\r
+    return NULL;\r
+  }\r
+\r
+  //\r
+  // Construct <ConfigResp>\r
+  //\r
+  Size = (StrLen (mConfigHdrTemplate) + 1 + StrLen (ResultsData) + 1) * sizeof (CHAR16);\r
+  ConfigResp = AllocateZeroPool (Size);\r
+  UnicodeSPrint (ConfigResp, Size, L"%s&%s", mConfigHdrTemplate, ResultsData);\r
+  \r
+  //\r
+  // Free the allocated buffer\r
+  //\r
+  FreePool (ResultsData);\r
+  if (ConfigResp == NULL) {\r
+    return NULL;\r
+  }\r
+\r
+  //\r
+  // Convert <ConfigResp> to a buffer\r
+  //\r
+  Block = InternalHiiConfigToBlock (ConfigResp, BlockSize);\r
+  FreePool (ConfigResp);\r
+\r
+  return Block;\r
+}\r
+\r
+/**\r
+  Updates uncommitted data in the Form Browser.\r
+\r
+  If Buffer is NULL, then ASSERT().\r
+\r
+  @param[in]  VariableName    Pointer to a Null-terminated Unicode string.  This\r
+                              is an optional parameter that may be NULL.\r
+  @param[in]  VariableGuid    Pointer to an EFI_GUID structure.  This is an optional\r
+                              parameter that may be NULL.\r
+  @param[in]  BufferSize      Length, in bytes, of Buffer.\r
+  @param[in]  Buffer          Buffer of data to commit.\r
+  @param[in]  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. \r
+                              <RequestElement> ::= &OFFSET=<Number>&WIDTH=<Number>*\r
+\r
+  @retval FALSE  The uncommitted data could not be updated.\r
+  @retval TRUE   The uncommitted data was updated.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+HiiSetBrowserData (\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
+  UINTN       Size;\r
+  EFI_STRING  ConfigRequest;\r
+  EFI_STRING  ConfigResp;\r
+  EFI_STRING  ResultsData;\r
+\r
+  ASSERT (Buffer != NULL);\r
+\r
+  //\r
+  // Construct <ConfigRequest>\r
+  //\r
+  if (RequestElement == NULL) {\r
+    //\r
+    // Allocate and fill a buffer large enough to hold the <ConfigHdr> template \r
+    // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator\r
+    //\r
+    Size = (StrLen (mConfigHdrTemplate) + 32 + 1) * sizeof (CHAR16);\r
+    ConfigRequest = AllocateZeroPool (Size);\r
+    UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", mConfigHdrTemplate, (UINT64)BufferSize);\r
+  } else {\r
+    //\r
+    // Allocate and fill a buffer large enough to hold the <ConfigHdr> template \r
+    // followed by <RequestElement> followed by a Null-terminator\r
+    //\r
+    Size = (StrLen (mConfigHdrTemplate) + StrLen (RequestElement) + 1) * sizeof (CHAR16);\r
+    ConfigRequest = AllocateZeroPool (Size);\r
+    UnicodeSPrint (ConfigRequest, Size, L"%s%s", mConfigHdrTemplate, RequestElement);\r
+  }\r
+  if (ConfigRequest == NULL) {\r
+    return FALSE;\r
+  }\r
+\r
+  //\r
+  // Convert <ConfigRequest> to <ConfigResp>\r
+  //\r
+  ConfigResp = InternalHiiBlockToConfig (ConfigRequest, Buffer, BufferSize);\r
+  FreePool (ConfigRequest);\r
+  if (ConfigResp == NULL) {\r
+    return FALSE;\r
+  }\r
+\r
+  //\r
+  // Set data in the uncommitted browser state information\r
+  //\r
+  ResultsData = InternalHiiBrowserCallback (VariableGuid, VariableName, ConfigResp + StrLen(mConfigHdrTemplate) + 1);\r
+  FreePool (ConfigResp);\r
+\r
+  return (BOOLEAN)(ResultsData != NULL);\r
+}\r
+\r
+/////////////////////////////////////////\r
+/////////////////////////////////////////\r
+/// IFR Functions\r
+/////////////////////////////////////////\r
+/////////////////////////////////////////\r
+\r
+#define HII_LIB_OPCODE_ALLOCATION_SIZE  0x200\r
+\r
+typedef struct {\r
+  UINT8  *Buffer;\r
+  UINTN  BufferSize;\r
+  UINTN  Position;\r
+} HII_LIB_OPCODE_BUFFER;\r
+\r
+///\r
+/// Lookup table that converts EFI_IFR_TYPE_X enum values to a width in bytes\r
+///\r
+GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 mHiiDefaultTypeToWidth[] = {\r
+  1, // EFI_IFR_TYPE_NUM_SIZE_8\r
+  2, // EFI_IFR_TYPE_NUM_SIZE_16\r
+  4, // EFI_IFR_TYPE_NUM_SIZE_32\r
+  8, // EFI_IFR_TYPE_NUM_SIZE_64\r
+  1, // EFI_IFR_TYPE_BOOLEAN\r
+  3, // EFI_IFR_TYPE_TIME\r
+  4, // EFI_IFR_TYPE_DATE\r
+  2  // EFI_IFR_TYPE_STRING\r
+};\r
+\r
+/**\r
+  Allocates and returns a new OpCode Handle.  OpCode Handles must be freed with \r
+  HiiFreeOpCodeHandle().\r
+\r
+  @retval NULL   There are not enough resources to allocate a new OpCode Handle.\r
+  @retval Other  A new OpCode handle.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+HiiAllocateOpCodeHandle (\r
+  VOID\r
+  )\r
+{\r
+  HII_LIB_OPCODE_BUFFER  *OpCodeBuffer;\r
+\r
+  OpCodeBuffer = (HII_LIB_OPCODE_BUFFER *)AllocatePool (sizeof (HII_LIB_OPCODE_BUFFER));\r
+  if (OpCodeBuffer == NULL) {\r
+    return NULL;\r
+  }\r
+  OpCodeBuffer->Buffer = (UINT8 *)AllocatePool (HII_LIB_OPCODE_ALLOCATION_SIZE);\r
+  if (OpCodeBuffer->Buffer == NULL) {\r
+    FreePool (OpCodeBuffer);\r
+    return NULL;\r
+  }\r
+  OpCodeBuffer->BufferSize = HII_LIB_OPCODE_ALLOCATION_SIZE;\r
+  OpCodeBuffer->Position = 0;\r
+  return (VOID *)OpCodeBuffer;\r
+}\r
+\r
+/**\r
+  Frees an OpCode Handle that was peviously allocated with HiiAllocateOpCodeHandle().\r
+  When an OpCode Handle is freed, all of the opcodes associated with the OpCode\r
+  Handle are also freed.\r
+\r
+  If OpCodeHandle is NULL, then ASSERT().\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+HiiFreeOpCodeHandle (\r
+  VOID  *OpCodeHandle\r
+  )\r
+{\r
+  HII_LIB_OPCODE_BUFFER  *OpCodeBuffer;\r
+\r
+  ASSERT (OpCodeHandle != NULL);\r
+\r
+  OpCodeBuffer = (HII_LIB_OPCODE_BUFFER *)OpCodeHandle;\r
+  if (OpCodeBuffer->Buffer != NULL) {\r
+    FreePool (OpCodeBuffer->Buffer);\r
+  }\r
+  FreePool (OpCodeBuffer);\r
+}\r
+\r
+UINTN\r
+EFIAPI\r
+InternalHiiOpCodeHandlePosition (\r
+  IN VOID  *OpCodeHandle\r
+  )\r
+{\r
+  return ((HII_LIB_OPCODE_BUFFER  *)OpCodeHandle)->Position;\r
+}\r
+\r
+UINT8 *\r
+EFIAPI\r
+InternalHiiOpCodeHandleBuffer (\r
+  IN VOID  *OpCodeHandle\r
+  )\r
+{\r
+  return ((HII_LIB_OPCODE_BUFFER  *)OpCodeHandle)->Buffer;\r
+}\r
+\r
+UINT8 *\r
+EFIAPI\r
+InternalHiiGrowOpCodeHandle (\r
+  VOID   *OpCodeHandle,\r
+  UINTN  Size\r
+  )\r
+{\r
+  HII_LIB_OPCODE_BUFFER  *OpCodeBuffer;\r
+  UINT8                  *Buffer;\r
+\r
+  ASSERT (OpCodeHandle != NULL);\r
+\r
+  OpCodeBuffer = (HII_LIB_OPCODE_BUFFER *)OpCodeHandle;\r
+  if (OpCodeBuffer->Position + Size > OpCodeBuffer->BufferSize) {\r
+    Buffer = ReallocatePool (\r
+              OpCodeBuffer->BufferSize, \r
+              OpCodeBuffer->BufferSize + (Size + HII_LIB_OPCODE_ALLOCATION_SIZE),\r
+              OpCodeBuffer->Buffer\r
+              );\r
+    if (Buffer == NULL) {\r
+      return NULL;\r
+    }\r
+    OpCodeBuffer->Buffer = Buffer;\r
+    OpCodeBuffer->BufferSize += (Size + HII_LIB_OPCODE_ALLOCATION_SIZE);\r
+  }\r
+  Buffer = OpCodeBuffer->Buffer + OpCodeBuffer->Position;\r
+  OpCodeBuffer->Position += Size;\r
+  return Buffer;\r
+}\r
+\r
+UINT8 *\r
+EFIAPI\r
+InternalHiiCreateOpCodeExtended (\r
+  IN VOID   *OpCodeHandle,\r
+  IN VOID   *OpCodeTemplate,\r
+  IN UINT8  OpCode,\r
+  IN UINTN  OpCodeSize,\r
+  IN UINTN  ExtensionSize,\r
+  IN UINT8  Scope\r
+  )\r
+{\r
+  EFI_IFR_OP_HEADER  *Header;\r
+  UINT8              *Buffer;\r
+\r
+  ASSERT (OpCodeTemplate != NULL);\r
+  ASSERT ((OpCodeSize + ExtensionSize) <= 0x7F);\r
+\r
+  Header = (EFI_IFR_OP_HEADER *)OpCodeTemplate;\r
+  Header->OpCode = OpCode;\r
+  Header->Scope  = Scope;\r
+  Header->Length = (UINT8)(OpCodeSize + ExtensionSize);\r
+  Buffer = InternalHiiGrowOpCodeHandle (OpCodeHandle, Header->Length);\r
+  return (UINT8 *)CopyMem (Buffer, Header, OpCodeSize);\r
+}\r
+\r
+UINT8 *\r
+EFIAPI\r
+InternalHiiCreateOpCode (\r
+  IN VOID   *OpCodeHandle,\r
+  IN VOID   *OpCodeTemplate,\r
+  IN UINT8  OpCode,\r
+  IN UINTN  OpCodeSize\r
+  )\r
+{\r
+  return InternalHiiCreateOpCodeExtended (OpCodeHandle, OpCodeTemplate, OpCode, OpCodeSize, 0, 0);\r
+}\r
+\r
+/**\r
+  Append raw opcodes to an OpCodeHandle.\r
+\r
+  If OpCodeHandle is NULL, then ASSERT().\r
+  If RawBuffer is NULL, then ASSERT();\r
+\r
+  @param[in]  OpCodeHandle   Handle to the buffer of opcodes.\r
+  @param[in]  RawBuffer      Buffer of opcodes to append.\r
+  @param[in]  RawBufferSize  The size, in bytes, of Buffer.\r
+\r
+  @retval NULL   There is not enough space left in Buffer to add the opcode.\r
+  @retval Other  A pointer to the appended opcodes.\r
+\r
+**/\r
+UINT8 *\r
+EFIAPI\r
+InternalHiiCreateRawOpCodes (\r
+  IN VOID   *OpCodeHandle,\r
+  IN UINT8  *RawBuffer,\r
+  IN UINTN  RawBufferSize\r
+  )\r
+{\r
+  UINT8  *Buffer;\r
+\r
+  ASSERT (RawBuffer != NULL);\r
+\r
+  Buffer = InternalHiiGrowOpCodeHandle (OpCodeHandle, RawBufferSize);\r
+  return (UINT8 *)CopyMem (Buffer, RawBuffer, RawBufferSize);\r
+}\r
+\r
+/**\r
+  Append opcodes from one OpCode Handle to another OpCode handle.\r
+\r
+  If OpCodeHandle is NULL, then ASSERT().\r
+  If RawOpCodeHandle is NULL, then ASSERT();\r
+\r
+  @param[in]  OpCodeHandle     Handle to the buffer of opcodes.\r
+  @param[in]  RawOpCodeHandle  Handle to the buffer of opcodes.\r
+\r
+  @retval NULL   There is not enough space left in Buffer to add the opcode.\r
+  @retval Other  A pointer to the appended opcodes.\r
+\r
+**/\r
+UINT8 *\r
+EFIAPI\r
+InternalHiiAppendOpCodes (\r
+  IN VOID  *OpCodeHandle,\r
+  IN VOID  *RawOpCodeHandle\r
+  )\r
+{\r
+  HII_LIB_OPCODE_BUFFER  *RawOpCodeBuffer;\r
+\r
+  ASSERT (RawOpCodeHandle != NULL);\r
+\r
+  RawOpCodeBuffer = (HII_LIB_OPCODE_BUFFER *)RawOpCodeHandle;\r
+  return InternalHiiCreateRawOpCodes (OpCodeHandle, RawOpCodeBuffer->Buffer, RawOpCodeBuffer->Position);\r
+}\r
+\r
+/**\r
+  Create EFI_IFR_END_OP opcode.\r
+\r
+  If OpCodeHandle is NULL, then ASSERT().\r
+\r
+  @param[in]  OpCodeHandle  Handle to the buffer of opcodes.\r
+\r
+  @retval NULL   There is not enough space left in Buffer to add the opcode.\r
+  @retval Other  A pointer to the created opcode.\r
+\r
+**/\r
+UINT8 *\r
+EFIAPI\r
+HiiCreateEndOpCode (\r
+  IN VOID  *OpCodeHandle\r
+  )\r
+{\r
+  EFI_IFR_END  OpCode;\r
+\r
+  return InternalHiiCreateOpCode (OpCodeHandle, &OpCode, EFI_IFR_END_OP, sizeof (OpCode));\r
+}\r
+\r
+/**\r
+  Create EFI_IFR_ONE_OF_OPTION_OP opcode.\r
+\r
+  If OpCodeHandle is NULL, then ASSERT().\r
+  If Type is invalid, then ASSERT().\r
+  If Flags is invalid, then ASSERT().\r
+\r
+  @param[in]  OpCodeHandle  Handle to the buffer of opcodes.\r
+  @param[in]  StringId      StringId for the option\r
+  @param[in]  Flags         Flags for the option\r
+  @param[in]  Type          Type for the option\r
+  @param[in]  Value         Value for the option\r
+\r
+  @retval NULL   There is not enough space left in Buffer to add the opcode.\r
+  @retval Other  A pointer to the created opcode.\r
+\r
+**/\r
+UINT8 *\r
+EFIAPI\r
+HiiCreateOneOfOptionOpCode (\r
+  IN VOID    *OpCodeHandle,\r
+  IN UINT16  StringId,\r
+  IN UINT8   Flags,\r
+  IN UINT8   Type,\r
+  IN UINT64  Value\r
+  )\r
+{\r
+  EFI_IFR_ONE_OF_OPTION  OpCode;\r
+\r
+  ASSERT (Type < EFI_IFR_TYPE_OTHER);\r
+\r
+  ZeroMem (&OpCode, sizeof (OpCode));\r
+  OpCode.Option = StringId;\r
+  OpCode.Flags  = (UINT8) (Flags & (EFI_IFR_OPTION_DEFAULT | EFI_IFR_OPTION_DEFAULT_MFG));\r
+  OpCode.Type   = Type;\r
+  CopyMem (&OpCode.Value, &Value, mHiiDefaultTypeToWidth[Type]);\r
+\r
+  return InternalHiiCreateOpCode (OpCodeHandle, &OpCode, EFI_IFR_ONE_OF_OPTION_OP, sizeof (OpCode));\r
+}\r
+\r
+/**\r
+  Create EFI_IFR_DEFAULT_OP opcode.\r
+\r
+  If OpCodeHandle is NULL, then ASSERT().\r
+  If Type is invalid, then ASSERT().\r
+\r
+  @param[in]  OpCodeHandle  Handle to the buffer of opcodes.\r
+  @param[in]  DefaultId     DefaultId for the default\r
+  @param[in]  Type          Type for the default\r
+  @param[in]  Value         Value for the default\r
+\r
+  @retval NULL   There is not enough space left in Buffer to add the opcode.\r
+  @retval Other  A pointer to the created opcode.\r
+\r
+**/\r
+UINT8 *\r
+EFIAPI\r
+HiiCreateDefaultOpCode (\r
+  IN VOID    *OpCodeHandle,\r
+  IN UINT16  DefaultId,\r
+  IN UINT8   Type,\r
+  IN UINT64  Value\r
+  )\r
+{\r
+  EFI_IFR_DEFAULT  OpCode;\r
+\r
+  ASSERT (Type < EFI_IFR_TYPE_OTHER);\r
+\r
+  ZeroMem (&OpCode, sizeof (OpCode));\r
+  OpCode.Type      = Type;\r
+  OpCode.DefaultId = DefaultId;\r
+  CopyMem (&OpCode.Value, &Value, mHiiDefaultTypeToWidth[Type]);\r
+\r
+  return InternalHiiCreateOpCode (OpCodeHandle, &OpCode, EFI_IFR_DEFAULT_OP, sizeof (OpCode));\r
+}\r
+\r
+/**\r
+  Create EFI_IFR_GUID opcode.\r
+\r
+  If OpCodeHandle is NULL, then ASSERT().\r
+  If Guid is NULL, then ASSERT().\r
+  If OpCodeSize < sizeof (EFI_IFR_GUID), then ASSERT().\r
+\r
+  @param[in]  OpCodeHandle  Handle to the buffer of opcodes.\r
+  @param[in]  Guid          Pointer to EFI_GUID of this guided opcode.\r
+  @param[in]  GuidOpCode    Pointer to an EFI_IFR_GUID opcode.  This is an \r
+                            optional parameter that may be NULL.  If this\r
+                            parameter is NULL, then the GUID extension \r
+                            region of the created opcode is filled with zeros.\r
+                            If this parameter is not NULL, then the GUID \r
+                            extension region of GuidData will be copied to \r
+                            the GUID extension region of the created opcode.\r
+  @param[in]  OpCodeSize    The size, in bytes, of created opcode.  This value \r
+                            must be >= sizeof(EFI_IFR_GUID).\r
+\r
+  @retval NULL   There is not enough space left in Buffer to add the opcode.\r
+  @retval Other  A pointer to the created opcode.\r
+\r
+**/\r
+UINT8 *\r
+EFIAPI\r
+HiiCreateGuidOpCode (\r
+  IN VOID            *OpCodeHandle,\r
+  IN CONST EFI_GUID  *Guid,\r
+  IN CONST VOID      *GuidOpCode,    OPTIONAL\r
+  IN UINTN           OpCodeSize\r
+  )\r
+{\r
+  EFI_IFR_GUID  OpCode;\r
+  EFI_IFR_GUID  *OpCodePointer;\r
+\r
+  ASSERT (Guid != NULL);\r
+  ASSERT (OpCodeSize >= sizeof (OpCode));\r
+\r
+  ZeroMem (&OpCode, sizeof (OpCode));\r
+  CopyGuid (&OpCode.Guid, Guid);\r
+\r
+  OpCodePointer = (EFI_IFR_GUID *)InternalHiiCreateOpCodeExtended (\r
+                                    OpCodeHandle, \r
+                                    &OpCode,\r
+                                    EFI_IFR_GUID_OP,\r
+                                    sizeof (OpCode),\r
+                                    OpCodeSize - sizeof (OpCode),\r
+                                    0\r
+                                    );\r
+  if (OpCodePointer != NULL && GuidOpCode != NULL) {\r
+    CopyMem (OpCodePointer + 1, (EFI_IFR_GUID *)GuidOpCode + 1, OpCodeSize - sizeof (OpCode));\r
+  }\r
+  return (UINT8 *)OpCodePointer;\r
+}\r
+\r
+/**\r
+  Create EFI_IFR_ACTION_OP opcode.\r
+\r
+  If OpCodeHandle is NULL, then ASSERT().\r
+  If any reserved bits are set in QuestionFlags, then ASSERT().\r
+\r
+  @param[in]  OpCodeHandle  Handle to the buffer of opcodes.\r
+  @param[in]  QuestionId      Question ID\r
+  @param[in]  Prompt          String ID for Prompt\r
+  @param[in]  Help            String ID for Help\r
+  @param[in]  QuestionFlags   Flags in Question Header\r
+  @param[in]  QuestionConfig  String ID for configuration\r
+\r
+  @retval NULL   There is not enough space left in Buffer to add the opcode.\r
+  @retval Other  A pointer to the created opcode.\r
+\r
+**/\r
+UINT8 *\r
+EFIAPI\r
+HiiCreateActionOpCode (\r
+  IN VOID             *OpCodeHandle,\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
+  )\r
+{\r
+  EFI_IFR_ACTION  OpCode;\r
+\r
+  ASSERT ((QuestionFlags & (~(EFI_IFR_FLAG_READ_ONLY | EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED | EFI_IFR_FLAG_OPTIONS_ONLY))) == 0);\r
+\r
+  ZeroMem (&OpCode, sizeof (OpCode));\r
+  OpCode.Question.QuestionId    = QuestionId;\r
+  OpCode.Question.Header.Prompt = Prompt;\r
+  OpCode.Question.Header.Help   = Help;\r
+  OpCode.Question.Flags         = QuestionFlags;\r
+  OpCode.QuestionConfig         = QuestionConfig;\r
+\r
+  return InternalHiiCreateOpCode (OpCodeHandle, &OpCode, EFI_IFR_ACTION_OP, sizeof (OpCode));\r
+}\r
+\r
+/**\r
+  Create EFI_IFR_SUBTITLE_OP opcode.\r
+\r
+  If OpCodeHandle is NULL, then ASSERT().\r
+  If any reserved bits are set in Flags, then ASSERT().\r
+  If Scope > 1, then ASSERT().\r
+\r
+  @param[in]  OpCodeHandle  Handle to the buffer of opcodes.\r
+  @param[in]  Prompt      String ID for Prompt\r
+  @param[in]  Help        String ID for Help\r
+  @param[in]  Flags       Subtitle opcode flags\r
+  @param[in]  Scope       1 if this opcpde is the beginning of a new scope.\r
+                          0 if this opcode is within the current scope.\r
+\r
+  @retval NULL   There is not enough space left in Buffer to add the opcode.\r
+  @retval Other  A pointer to the created opcode.\r
+\r
+**/\r
+UINT8 *\r
+EFIAPI\r
+HiiCreateSubTitleOpCode (\r
+  IN VOID           *OpCodeHandle,\r
+  IN EFI_STRING_ID  Prompt,\r
+  IN EFI_STRING_ID  Help,\r
+  IN UINT8          Flags,\r
+  IN UINT8          Scope\r
+  )\r
+{\r
+  EFI_IFR_SUBTITLE  OpCode;\r
+\r
+  ASSERT (Scope <= 1);\r
+  ASSERT ((Flags & (~(EFI_IFR_FLAGS_HORIZONTAL))) == 0);\r
+\r
+  ZeroMem (&OpCode, sizeof (OpCode));\r
+  OpCode.Statement.Prompt = Prompt;\r
+  OpCode.Statement.Help   = Help;\r
+  OpCode.Flags            = Flags;\r
+\r
+  return InternalHiiCreateOpCodeExtended (\r
+           OpCodeHandle, \r
+           &OpCode,\r
+           EFI_IFR_SUBTITLE_OP, \r
+           sizeof (OpCode), \r
+           0, \r
+           Scope\r
+           );\r
+}\r
+\r
+/**\r
+  Create EFI_IFR_REF_OP opcode.\r
+\r
+  If OpCodeHandle is NULL, then ASSERT().\r
+  If any reserved bits are set in QuestionFlags, then ASSERT().\r
+\r
+  @param[in]  OpCodeHandle   Handle to the buffer of opcodes.\r
+  @param[in]  FormId         Destination Form ID\r
+  @param[in]  Prompt         String ID for Prompt\r
+  @param[in]  Help           String ID for Help\r
+  @param[in]  QuestionFlags  Flags in Question Header\r
+  @param[in]  QuestionId     Question ID\r
+\r
+  @retval NULL   There is not enough space left in Buffer to add the opcode.\r
+  @retval Other  A pointer to the created opcode.\r
+\r
+**/\r
+UINT8 *\r
+EFIAPI\r
+HiiCreateGotoOpCode (\r
+  IN VOID             *OpCodeHandle,\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
+  )\r
+{\r
+  EFI_IFR_REF  OpCode;\r
+\r
+  ASSERT ((QuestionFlags & (~(EFI_IFR_FLAG_READ_ONLY | EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED | EFI_IFR_FLAG_OPTIONS_ONLY))) == 0);\r
+\r
+  ZeroMem (&OpCode, sizeof (OpCode));\r
+  OpCode.Question.Header.Prompt = Prompt;\r
+  OpCode.Question.Header.Help   = Help;\r
+  OpCode.Question.QuestionId    = QuestionId;\r
+  OpCode.Question.Flags         = QuestionFlags;\r
+  OpCode.FormId                 = FormId;\r
+\r
+  return InternalHiiCreateOpCode (OpCodeHandle, &OpCode, EFI_IFR_REF_OP, sizeof (OpCode));\r
+}\r
+\r
+/**\r
+  Create EFI_IFR_CHECKBOX_OP opcode.\r
+\r
+  If OpCodeHandle is NULL, then ASSERT().\r
+  If any reserved bits are set in QuestionFlags, then ASSERT().\r
+  If any reserved bits are set in CheckBoxFlags, then ASSERT().\r
+\r
+  @param[in]  OpCodeHandle          Handle to the buffer of opcodes.\r
+  @param[in]  QuestionId            Question ID\r
+  @param[in]  VarStoreId            Storage ID\r
+  @param[in]  VarOffset             Offset in Storage\r
+  @param[in]  Prompt                String ID for Prompt\r
+  @param[in]  Help                  String ID for Help\r
+  @param[in]  QuestionFlags         Flags in Question Header\r
+  @param[in]  CheckBoxFlags         Flags for checkbox opcode\r
+  @param[in]  DefaultsOpCodeHandle  Handle for a buffer of DEFAULT opcodes.  This\r
+                                    is an optional parameter that may be NULL.\r
+\r
+  @retval NULL   There is not enough space left in Buffer to add the opcode.\r
+  @retval Other  A pointer to the created opcode.\r
+\r
+**/\r
+UINT8 *\r
+EFIAPI\r
+HiiCreateCheckBoxOpCode (\r
+  IN VOID             *OpCodeHandle,\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 VOID             *DefaultsOpCodeHandle  OPTIONAL\r
+  )\r
+{\r
+  EFI_IFR_CHECKBOX  OpCode;\r
+  UINTN             Position;\r
+\r
+  ASSERT ((QuestionFlags & (~(EFI_IFR_FLAG_READ_ONLY | EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED | EFI_IFR_FLAG_OPTIONS_ONLY))) == 0);\r
+\r
+  ZeroMem (&OpCode, sizeof (OpCode));\r
+  OpCode.Question.QuestionId             = QuestionId;\r
+  OpCode.Question.VarStoreId             = VarStoreId;\r
+  OpCode.Question.VarStoreInfo.VarOffset = VarOffset;\r
+  OpCode.Question.Header.Prompt          = Prompt;\r
+  OpCode.Question.Header.Help            = Help;\r
+  OpCode.Question.Flags                  = QuestionFlags;\r
+  OpCode.Flags                           = CheckBoxFlags;\r
+\r
+  if (DefaultsOpCodeHandle == NULL) {\r
+    return InternalHiiCreateOpCode (OpCodeHandle, &OpCode, EFI_IFR_CHECKBOX_OP, sizeof (OpCode));\r
+  }\r
+\r
+  Position = InternalHiiOpCodeHandlePosition (OpCodeHandle);\r
+  InternalHiiCreateOpCodeExtended (OpCodeHandle, &OpCode, EFI_IFR_CHECKBOX_OP, sizeof (OpCode), 0, 1);\r
+  InternalHiiAppendOpCodes (OpCodeHandle, DefaultsOpCodeHandle);\r
+  HiiCreateEndOpCode (OpCodeHandle);\r
+  return InternalHiiOpCodeHandleBuffer (OpCodeHandle) + Position;\r
+}\r
+\r
+/**\r
+  Create EFI_IFR_NUMERIC_OP opcode.\r
+\r
+  If OpCodeHandle is NULL, then ASSERT().\r
+  If any reserved bits are set in QuestionFlags, then ASSERT().\r
+  If any reserved bits are set in NumericFlags, then ASSERT().\r
+\r
+  @param[in]  OpCodeHandle          Handle to the buffer of opcodes.\r
+  @param[in]  QuestionId            Question ID\r
+  @param[in]  VarStoreId            Storage ID\r
+  @param[in]  VarOffset             Offset in Storage\r
+  @param[in]  Prompt                String ID for Prompt\r
+  @param[in]  Help                  String ID for Help\r
+  @param[in]  QuestionFlags         Flags in Question Header\r
+  @param[in]  NumericFlags          Flags for numeric opcode\r
+  @param[in]  Minimum               Numeric minimum value\r
+  @param[in]  Maximum               Numeric maximum value\r
+  @param[in]  Step                  Numeric step for edit\r
+  @param[in]  DefaultsOpCodeHandle  Handle for a buffer of DEFAULT opcodes.  This\r
+                                    is an optional parameter that may be NULL.\r
+\r
+  @retval NULL   There is not enough space left in Buffer to add the opcode.\r
+  @retval Other  A pointer to the created opcode.\r
+\r
+**/\r
+UINT8 *\r
+EFIAPI\r
+HiiCreateNumericOpCode (\r
+  IN VOID             *OpCodeHandle,\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 VOID             *DefaultsOpCodeHandle  OPTIONAL\r
+  )\r
+{\r
+  EFI_IFR_NUMERIC  OpCode;\r
+  UINTN            Position;\r
+\r
+  ASSERT ((QuestionFlags & (~(EFI_IFR_FLAG_READ_ONLY | EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED | EFI_IFR_FLAG_OPTIONS_ONLY))) == 0);\r
+\r
+  ZeroMem (&OpCode, sizeof (OpCode));\r
+  OpCode.Question.QuestionId             = QuestionId;\r
+  OpCode.Question.VarStoreId             = VarStoreId;\r
+  OpCode.Question.VarStoreInfo.VarOffset = VarOffset;\r
+  OpCode.Question.Header.Prompt          = Prompt;\r
+  OpCode.Question.Header.Help            = Help;\r
+  OpCode.Question.Flags                  = QuestionFlags;\r
+  OpCode.Flags                           = NumericFlags;\r
+\r
+  switch (NumericFlags & EFI_IFR_NUMERIC_SIZE) {\r
+  case EFI_IFR_NUMERIC_SIZE_1:\r
+    OpCode.data.u8.MinValue = (UINT8)Minimum;\r
+    OpCode.data.u8.MaxValue = (UINT8)Maximum;\r
+    OpCode.data.u8.Step     = (UINT8)Step;\r
+    break;\r
+\r
+  case EFI_IFR_NUMERIC_SIZE_2:\r
+    OpCode.data.u16.MinValue = (UINT16)Minimum;\r
+    OpCode.data.u16.MaxValue = (UINT16)Maximum;\r
+    OpCode.data.u16.Step     = (UINT16)Step;\r
+    break;\r
+\r
+  case EFI_IFR_NUMERIC_SIZE_4:\r
+    OpCode.data.u32.MinValue = (UINT32)Minimum;\r
+    OpCode.data.u32.MaxValue = (UINT32)Maximum;\r
+    OpCode.data.u32.Step     = (UINT32)Step;\r
+    break;\r
+\r
+  case EFI_IFR_NUMERIC_SIZE_8:\r
+    OpCode.data.u64.MinValue = Minimum;\r
+    OpCode.data.u64.MaxValue = Maximum;\r
+    OpCode.data.u64.Step     = Step;\r
+    break;\r
+  }\r
+\r
+  if (DefaultsOpCodeHandle == NULL) {\r
+    return InternalHiiCreateOpCode (OpCodeHandle, &OpCode, EFI_IFR_NUMERIC_OP, sizeof (OpCode));\r
+  }\r
+\r
+  Position = InternalHiiOpCodeHandlePosition (OpCodeHandle);\r
+  InternalHiiCreateOpCodeExtended (OpCodeHandle, &OpCode, EFI_IFR_NUMERIC_OP, sizeof (OpCode), 0, 1);\r
+  InternalHiiAppendOpCodes (OpCodeHandle, DefaultsOpCodeHandle);\r
+  HiiCreateEndOpCode (OpCodeHandle);\r
+  return InternalHiiOpCodeHandleBuffer (OpCodeHandle) + Position;\r
+}\r
+\r
+/**\r
+  Create EFI_IFR_STRING_OP opcode.\r
+\r
+  If OpCodeHandle is NULL, then ASSERT().\r
+  If any reserved bits are set in QuestionFlags, then ASSERT().\r
+  If any reserved bits are set in StringFlags, then ASSERT().\r
+\r
+  @param[in]  OpCodeHandle          Handle to the buffer of opcodes.\r
+  @param[in]  QuestionId            Question ID\r
+  @param[in]  VarStoreId            Storage ID\r
+  @param[in]  VarOffset             Offset in Storage\r
+  @param[in]  Prompt                String ID for Prompt\r
+  @param[in]  Help                  String ID for Help\r
+  @param[in]  QuestionFlags         Flags in Question Header\r
+  @param[in]  StringFlags           Flags for string opcode\r
+  @param[in]  MinSize               String minimum length\r
+  @param[in]  MaxSize               String maximum length\r
+  @param[in]  DefaultsOpCodeHandle  Handle for a buffer of DEFAULT opcodes.  This\r
+                                    is an optional parameter that may be NULL.\r
+\r
+  @retval NULL   There is not enough space left in Buffer to add the opcode.\r
+  @retval Other  A pointer to the created opcode.\r
+\r
+**/\r
+UINT8 *\r
+EFIAPI\r
+HiiCreateStringOpCode (\r
+  IN VOID             *OpCodeHandle,\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 VOID             *DefaultsOpCodeHandle  OPTIONAL\r
+  )\r
+{\r
+  EFI_IFR_STRING  OpCode;\r
+  UINTN           Position;\r
+\r
+  ASSERT ((QuestionFlags & (~(EFI_IFR_FLAG_READ_ONLY | EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED | EFI_IFR_FLAG_OPTIONS_ONLY))) == 0);\r
+\r
+  ZeroMem (&OpCode, sizeof (OpCode));\r
+  OpCode.Question.Header.Prompt          = Prompt;\r
+  OpCode.Question.Header.Help            = Help;\r
+  OpCode.Question.QuestionId             = QuestionId;\r
+  OpCode.Question.VarStoreId             = VarStoreId;\r
+  OpCode.Question.VarStoreInfo.VarOffset = VarOffset;\r
+  OpCode.Question.Flags                  = QuestionFlags;\r
+  OpCode.MinSize                         = MinSize;\r
+  OpCode.MaxSize                         = MaxSize;\r
+  OpCode.Flags                           = (UINT8) (StringFlags & EFI_IFR_STRING_MULTI_LINE);\r
+\r
+  if (DefaultsOpCodeHandle == NULL) {\r
+    return InternalHiiCreateOpCode (OpCodeHandle, &OpCode, EFI_IFR_STRING_OP, sizeof (OpCode));\r
+  }\r
+\r
+  Position = InternalHiiOpCodeHandlePosition (OpCodeHandle);\r
+  InternalHiiCreateOpCodeExtended (OpCodeHandle, &OpCode, EFI_IFR_STRING_OP, sizeof (OpCode), 0, 1);\r
+  InternalHiiAppendOpCodes (OpCodeHandle, DefaultsOpCodeHandle);\r
+  HiiCreateEndOpCode (OpCodeHandle);\r
+  return InternalHiiOpCodeHandleBuffer (OpCodeHandle) + Position;\r
+}\r
+\r
+/**\r
+  Create EFI_IFR_ONE_OF_OP opcode.\r
+\r
+  If OpCodeHandle is NULL, then ASSERT().\r
+  If any reserved bits are set in QuestionFlags, then ASSERT().\r
+  If any reserved bits are set in OneOfFlags, then ASSERT().\r
+\r
+  @param[in]  OpCodeHandle          Handle to the buffer of opcodes.\r
+  @param[in]  QuestionId            Question ID\r
+  @param[in]  VarStoreId            Storage ID\r
+  @param[in]  VarOffset             Offset in Storage\r
+  @param[in]  Prompt                String ID for Prompt\r
+  @param[in]  Help                  String ID for Help\r
+  @param[in]  QuestionFlags         Flags in Question Header\r
+  @param[in]  OneOfFlags            Flags for oneof opcode\r
+  @param[in]  OptionsOpCodeHandle   Handle for a buffer of ONE_OF_OPTION opcodes.\r
+  @param[in]  DefaultsOpCodeHandle  Handle for a buffer of DEFAULT opcodes.  This\r
+                                    is an optional parameter that may be NULL.\r
+\r
+  @retval NULL   There is not enough space left in Buffer to add the opcode.\r
+  @retval Other  A pointer to the created opcode.\r
+\r
+**/\r
+UINT8 *\r
+EFIAPI\r
+HiiCreateOneOfOpCode (\r
+  IN VOID             *OpCodeHandle,\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 VOID             *OptionsOpCodeHandle,\r
+  IN VOID             *DefaultsOpCodeHandle  OPTIONAL\r
+  )\r
+{\r
+  EFI_IFR_ONE_OF  OpCode;\r
+  UINTN           Position;\r
+\r
+  ASSERT (OptionsOpCodeHandle != NULL);\r
+  ASSERT ((QuestionFlags & (~(EFI_IFR_FLAG_READ_ONLY | EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED | EFI_IFR_FLAG_OPTIONS_ONLY))) == 0);\r
+\r
+  ZeroMem (&OpCode, sizeof (OpCode));\r
+  OpCode.Question.Header.Prompt          = Prompt;\r
+  OpCode.Question.Header.Help            = Help;\r
+  OpCode.Question.QuestionId             = QuestionId;\r
+  OpCode.Question.VarStoreId             = VarStoreId;\r
+  OpCode.Question.VarStoreInfo.VarOffset = VarOffset;\r
+  OpCode.Question.Flags                  = QuestionFlags;\r
+  OpCode.Flags                           = OneOfFlags;\r
+\r
+  Position = InternalHiiOpCodeHandlePosition (OpCodeHandle);\r
+  InternalHiiCreateOpCodeExtended (OpCodeHandle, &OpCode, EFI_IFR_ONE_OF_OP, sizeof (OpCode), 0, 1);\r
+  InternalHiiAppendOpCodes (OpCodeHandle, OptionsOpCodeHandle);\r
+  if (DefaultsOpCodeHandle != NULL) {\r
+    InternalHiiAppendOpCodes (OpCodeHandle, DefaultsOpCodeHandle);\r
+  }\r
+  HiiCreateEndOpCode (OpCodeHandle);\r
+  return InternalHiiOpCodeHandleBuffer (OpCodeHandle) + Position;\r
+}\r
+\r
+/**\r
+  Create EFI_IFR_ORDERED_LIST_OP opcode.\r
+\r
+  If OpCodeHandle is NULL, then ASSERT().\r
+  If any reserved bits are set in QuestionFlags, then ASSERT().\r
+  If any reserved bits are set in OrderedListFlags, then ASSERT().\r
+\r
+  @param[in]  OpCodeHandle          Handle to the buffer of opcodes.\r
+  @param[in]  QuestionId            Question ID\r
+  @param[in]  VarStoreId            Storage ID\r
+  @param[in]  VarOffset             Offset in Storage\r
+  @param[in]  Prompt                String ID for Prompt\r
+  @param[in]  Help                  String ID for Help\r
+  @param[in]  QuestionFlags         Flags in Question Header\r
+  @param[in]  OrderedListFlags      Flags for ordered list opcode\r
+  @param[in]  DataType              Type for option value\r
+  @param[in]  MaxContainers         Maximum count for options in this ordered list\r
+  @param[in]  OptionsOpCodeHandle   Handle for a buffer of ONE_OF_OPTION opcodes.\r
+  @param[in]  DefaultsOpCodeHandle  Handle for a buffer of DEFAULT opcodes.  This\r
+                                    is an optional parameter that may be NULL.\r
+\r
+  @retval NULL   There is not enough space left in Buffer to add the opcode.\r
+  @retval Other  A pointer to the created opcode.\r
+\r
+**/\r
+UINT8 *\r
+EFIAPI\r
+HiiCreateOrderedListOpCode (\r
+  IN VOID             *OpCodeHandle,\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 VOID             *OptionsOpCodeHandle,\r
+  IN VOID             *DefaultsOpCodeHandle  OPTIONAL\r
+  )\r
+{\r
+  EFI_IFR_ORDERED_LIST  OpCode;\r
+  UINTN                 Position;\r
+\r
+  ASSERT (OptionsOpCodeHandle != NULL);\r
+  ASSERT ((QuestionFlags & (~(EFI_IFR_FLAG_READ_ONLY | EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED | EFI_IFR_FLAG_OPTIONS_ONLY))) == 0);\r
+\r
+  ZeroMem (&OpCode, sizeof (OpCode));\r
+  OpCode.Question.Header.Prompt          = Prompt;\r
+  OpCode.Question.Header.Help            = Help;\r
+  OpCode.Question.QuestionId             = QuestionId;\r
+  OpCode.Question.VarStoreId             = VarStoreId;\r
+  OpCode.Question.VarStoreInfo.VarOffset = VarOffset;\r
+  OpCode.Question.Flags                  = QuestionFlags;\r
+  OpCode.MaxContainers                   = MaxContainers;\r
+  OpCode.Flags                           = OrderedListFlags;\r
+\r
+  Position = InternalHiiOpCodeHandlePosition (OpCodeHandle);\r
+  InternalHiiCreateOpCodeExtended (OpCodeHandle, &OpCode, EFI_IFR_ORDERED_LIST_OP, sizeof (OpCode), 0, 1);\r
+  InternalHiiAppendOpCodes (OpCodeHandle, OptionsOpCodeHandle);\r
+  if (DefaultsOpCodeHandle != NULL) {\r
+    InternalHiiAppendOpCodes (OpCodeHandle, DefaultsOpCodeHandle);\r
+  }\r
+  HiiCreateEndOpCode (OpCodeHandle);\r
+  return InternalHiiOpCodeHandleBuffer (OpCodeHandle) + Position;\r
+}\r
+\r
+/**\r
+  This is the internal worker function to update the data in\r
+  a form specified by FormSetGuid, FormId and Label.\r
+\r
+  @param FormSetGuid     The optional Formset GUID.\r
+  @param FormId          The Form ID.\r
+  @param Package         The package header.\r
+\r
+  @param TempPacakge     The resultant package.\r
+\r
+  @retval EFI_SUCCESS    The function completes successfully.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+InternalHiiUpdateFormPackageData (\r
+  IN  EFI_GUID               *FormSetGuid, OPTIONAL\r
+  IN  EFI_FORM_ID            FormId,\r
+  IN  EFI_HII_PACKAGE_HEADER *Package,\r
+  IN  HII_LIB_OPCODE_BUFFER  *OpCodeBufferStart,\r
+  IN  HII_LIB_OPCODE_BUFFER  *OpCodeBufferEnd,    OPTIONAL\r
+  OUT EFI_HII_PACKAGE_HEADER *TempPackage\r
+  )\r
+{\r
+  UINTN                     AddSize;\r
+  UINT8                     *BufferPos;\r
+  EFI_HII_PACKAGE_HEADER    PackageHeader;\r
+  UINTN                     Offset;\r
+  EFI_IFR_OP_HEADER         *IfrOpHdr;\r
+  EFI_IFR_OP_HEADER         *UpdateIfrOpHdr;\r
+  BOOLEAN                   GetFormSet;\r
+  BOOLEAN                   GetForm;\r
+  BOOLEAN                   Updated;\r
+  EFI_IFR_OP_HEADER         *AddOpCode;\r
+  UINT32                    UpdatePackageLength;\r
+\r
+  CopyMem (TempPackage, Package, sizeof (EFI_HII_PACKAGE_HEADER));\r
+  UpdatePackageLength = sizeof (EFI_HII_PACKAGE_HEADER);\r
+  BufferPos           = (UINT8 *) (TempPackage + 1);\r
+\r
+  CopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));\r
+  IfrOpHdr   = (EFI_IFR_OP_HEADER *)((UINT8 *) Package + sizeof (EFI_HII_PACKAGE_HEADER));\r
+  Offset     = sizeof (EFI_HII_PACKAGE_HEADER);\r
+  GetFormSet = (BOOLEAN) ((FormSetGuid == NULL) ? TRUE : FALSE);\r
+  GetForm    = FALSE;\r
+  Updated    = FALSE;\r
+\r
+  while (Offset < PackageHeader.Length) {\r
+    CopyMem (BufferPos, IfrOpHdr, IfrOpHdr->Length);\r
+    BufferPos           += IfrOpHdr->Length;\r
+    UpdatePackageLength += IfrOpHdr->Length;\r
+    \r
+    //\r
+    // Find the matched FormSet and Form\r
+    //\r
+    if ((IfrOpHdr->OpCode == EFI_IFR_FORM_SET_OP) && (FormSetGuid != NULL)) {\r
+      if (CompareGuid((GUID *)(VOID *)&((EFI_IFR_FORM_SET *) IfrOpHdr)->Guid, FormSetGuid)) {\r
+        GetFormSet = TRUE;\r
+      } else {\r
+        GetFormSet = FALSE;\r
+      }\r
+    } else if (IfrOpHdr->OpCode == EFI_IFR_FORM_OP) {\r
+      if (CompareMem (&((EFI_IFR_FORM *) IfrOpHdr)->FormId, &FormId, sizeof (EFI_FORM_ID)) == 0) {\r
+        GetForm = TRUE;\r
+      } else {\r
+        GetForm = FALSE;\r
+      }\r
+    }\r
+    \r
+    //\r
+    // The matched Form is found, and Update data in this form\r
+    //\r
+    if (GetFormSet && GetForm && !Updated) {\r
+      UpdateIfrOpHdr = (EFI_IFR_OP_HEADER *) OpCodeBufferStart->Buffer;\r
+      if ((UpdateIfrOpHdr->Length == IfrOpHdr->Length) && \\r
+          (CompareMem (IfrOpHdr, UpdateIfrOpHdr, UpdateIfrOpHdr->Length) == 0)) {\r
+        //\r
+        // Remove the original data when End OpCode buffer exist.\r
+        //\r
+        if (OpCodeBufferEnd != NULL) {\r
+          Offset        += IfrOpHdr->Length;\r
+          IfrOpHdr       = (EFI_IFR_OP_HEADER *) ((UINT8 *) (IfrOpHdr) + IfrOpHdr->Length);\r
+          UpdateIfrOpHdr = (EFI_IFR_OP_HEADER *) OpCodeBufferEnd->Buffer;\r
+          while (Offset < PackageHeader.Length) {\r
+            //\r
+            // Search the matched end opcode\r
+            //\r
+            if ((UpdateIfrOpHdr->Length == IfrOpHdr->Length) && \\r
+                (CompareMem (IfrOpHdr, UpdateIfrOpHdr, UpdateIfrOpHdr->Length) == 0)) {\r
+              break;\r
+            }\r
+            //\r
+            // Go to the next Op-Code\r
+            //\r
+            Offset        += IfrOpHdr->Length;\r
+            IfrOpHdr       = (EFI_IFR_OP_HEADER *) ((UINT8 *) (IfrOpHdr) + IfrOpHdr->Length);\r
+          }\r
+          \r
+          if (Offset >= PackageHeader.Length) {\r
+            //\r
+            // The end opcode is not found.\r
+            //\r
+            return EFI_NOT_FOUND;\r
+          }\r
+        }\r
+        //\r
+        // Insert the updated data\r
+        //\r
+        UpdateIfrOpHdr = (EFI_IFR_OP_HEADER *) OpCodeBufferStart->Buffer;\r
+        AddOpCode      = (EFI_IFR_OP_HEADER *) (OpCodeBufferStart->Buffer + UpdateIfrOpHdr->Length);\r
+        AddSize        = UpdateIfrOpHdr->Length;\r
+        while (AddSize < OpCodeBufferStart->Position) {\r
+          CopyMem (BufferPos, AddOpCode, AddOpCode->Length);\r
+          BufferPos           += AddOpCode->Length;\r
+          UpdatePackageLength += AddOpCode->Length;\r
+\r
+          AddOpCode = (EFI_IFR_OP_HEADER *) ((UINT8 *) (AddOpCode) + AddOpCode->Length);\r
+          AddSize += AddOpCode->Length;          \r
+        }\r
+\r
+        if (OpCodeBufferEnd != NULL) {\r
+          //\r
+          // Add the end opcode\r
+          //\r
+          CopyMem (BufferPos, IfrOpHdr, IfrOpHdr->Length);\r
+          BufferPos           += IfrOpHdr->Length;\r
+          UpdatePackageLength += IfrOpHdr->Length;\r
+        }\r
+        //\r
+        // Set update flag\r
+        //\r
+        Updated = TRUE;\r
+      }\r
+    }\r
+\r
+    //\r
+    // Go to the next Op-Code\r
+    //\r
+    Offset   += IfrOpHdr->Length;\r
+    IfrOpHdr = (EFI_IFR_OP_HEADER *) ((CHAR8 *) (IfrOpHdr) + IfrOpHdr->Length);\r
+  }\r
+  \r
+  if (!Updated) {\r
+    //\r
+    // The updated opcode buffer is not found.\r
+    //\r
+    return EFI_NOT_FOUND;\r
+  }\r
+  //\r
+  // Update the package length.\r
+  //\r
+  PackageHeader.Length = UpdatePackageLength;\r
+  CopyMem (TempPackage, &PackageHeader, sizeof (EFI_HII_PACKAGE_HEADER));\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  This function updates a form that has previously been registered with the HII \r
+  Database.  This function will perform at most one update operation.\r
+    \r
+  The form to update is specified by Handle, FormSetGuid, and FormId.  Binary \r
+  comparisons of IFR opcodes are performed from the beginning of the form being \r
+  updated until an IFR opcode is found that exactly matches the first IFR opcode \r
+  specifed by StartOpCodeHandle.  The following rules are used to determine if\r
+  an insert, replace, or delete operation is performed.\r
+  \r
+  1) If no matches are found, then NULL is returned.  \r
+  2) If a match is found, and EndOpCodeHandle is NULL, then all of the IFR opcodes\r
+     from StartOpcodeHandle except the first opcode are inserted immediately after \r
+     the matching IFR opcode in the form beng updated.\r
+  3) If a match is found, and EndOpCodeHandle is not NULL, then a search is made \r
+     from the matching IFR opcode until an IFR opcode exatly matches the first \r
+     IFR opcode specified by EndOpCodeHandle.  If no match is found for the first\r
+     IFR opcode specified by EndOpCodeHandle, then NULL is returned.  If a match\r
+     is found, then all of the IFR opcodes between the start match and the end \r
+     match are deleted from the form being updated and all of the IFR opcodes\r
+     from StartOpcodeHandle except the first opcode are inserted immediately after \r
+     the matching start IFR opcode.  If StartOpCcodeHandle only contains one\r
+     IFR instruction, then the result of ths operation will delete all of the IFR\r
+     opcodes between the start end matches.\r
+\r
+  If HiiHandle is NULL, then ASSERT().\r
+  If StartOpCodeHandle is NULL, then ASSERT().\r
+\r
+  @param[in]  HiiHandle          The HII Handle of the form to update.\r
+  @param[in]  FormSetGuid        The Formset GUID of the form to update.  This\r
+                                 is an optional parameter that may be NULL.\r
+                                 If it is NULL, all FormSet will be updated.\r
+  @param[in]  FormId             The ID of the form to update.\r
+  @param[in]  StartOpCodeHandle  An OpCode Handle that contains the set of IFR \r
+                                 opcodes to be inserted or replaced in the form.\r
+                                 The first IFR instruction in StartOpCodeHandle \r
+                                 is used to find matching IFR opcode in the \r
+                                 form. \r
+  @param[in]  EndOpCodeHandle    An OpCcode Handle that contains the IFR opcode\r
+                                 that marks the end of a replace operation in\r
+                                 the form.  This is an optional parameter that\r
+                                 may be NULL.  If it is NULL, then an the IFR\r
+                                 opcodes specified by StartOpCodeHandle are \r
+                                 inserted into the form.\r
+  \r
+  @retval EFI_OUT_OF_RESOURCES   No enough memory resource is allocated.\r
+  @retval EFI_NOT_FOUND          The following cases will return EFI_NOT_FOUND.\r
+                                 1) The form specified by HiiHandle, FormSetGuid, \r
+                                 and FormId could not be found in the HII Database.\r
+                                 2) No IFR opcodes in the target form match the first\r
+                                 IFR opcode in StartOpCodeHandle.\r
+                                 3) EndOpCOde is not NULL, and no IFR opcodes in the \r
+                                 target form following a matching start opcode match \r
+                                 the first IFR opcode in EndOpCodeHandle.\r
+  @retval EFI_SUCCESS            The matched form is updated by StartOpcode.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+HiiUpdateForm (\r
+  IN EFI_HII_HANDLE  HiiHandle,           \r
+  IN EFI_GUID        *FormSetGuid,        OPTIONAL\r
+  IN EFI_FORM_ID     FormId,\r
+  IN VOID            *StartOpcodeHandle,\r
+  IN VOID            *EndOpcodeHandle     OPTIONAL\r
+  )\r
+{\r
+  EFI_STATUS                   Status;\r
+  EFI_HII_PACKAGE_LIST_HEADER  *HiiPackageList;\r
+  UINT32                       PackageListLength;  \r
+  UINT32                       Offset;\r
+  EFI_HII_PACKAGE_LIST_HEADER  *UpdatePackageList;\r
+  UINTN                        BufferSize;\r
+  UINT8                        *UpdateBufferPos;\r
+  EFI_HII_PACKAGE_HEADER       *Package;\r
+  EFI_HII_PACKAGE_HEADER       *TempPacakge;\r
+  EFI_HII_PACKAGE_HEADER       PackageHeader;\r
+  BOOLEAN                      Updated;\r
+  HII_LIB_OPCODE_BUFFER        *OpCodeBufferStart;\r
+  HII_LIB_OPCODE_BUFFER        *OpCodeBufferEnd;\r
+  \r
+  //\r
+  // Input update data can't be NULL.\r
+  //\r
+  ASSERT (HiiHandle != NULL);\r
+  ASSERT (StartOpcodeHandle != NULL);\r
+  UpdatePackageList = NULL;\r
+  TempPacakge       = NULL;\r
+  HiiPackageList    = NULL;\r
+  \r
+  //\r
+  // Restrive buffer data from Opcode Handle\r
+  //\r
+  OpCodeBufferStart = (HII_LIB_OPCODE_BUFFER *) StartOpcodeHandle;\r
+  OpCodeBufferEnd   = (HII_LIB_OPCODE_BUFFER *) EndOpcodeHandle;\r
+  \r
+  //\r
+  // Get the orginal package list\r
+  //\r
+  BufferSize = 0;\r
+  HiiPackageList   = NULL;\r
+  Status = gHiiDatabase->ExportPackageLists (gHiiDatabase, HiiHandle, &BufferSize, HiiPackageList);\r
+  //\r
+  // The return status should always be EFI_BUFFER_TOO_SMALL as input buffer's size is 0.\r
+  //\r
+  if (Status != EFI_BUFFER_TOO_SMALL) {\r
+    return Status;\r
+  }\r
+\r
+  HiiPackageList = AllocatePool (BufferSize);\r
+  if (HiiPackageList == NULL) {\r
+    Status = EFI_OUT_OF_RESOURCES;\r
+    goto Finish;\r
+  }\r
+\r
+  Status = gHiiDatabase->ExportPackageLists (gHiiDatabase, HiiHandle, &BufferSize, HiiPackageList);\r
+  if (EFI_ERROR (Status)) {\r
+    goto Finish;\r
+  }\r
+\r
+  //\r
+  // Calculate and allocate space for retrieval of IFR data\r
+  //\r
+  BufferSize += OpCodeBufferStart->Position;\r
+  UpdatePackageList = AllocateZeroPool (BufferSize);\r
+  if (UpdatePackageList == NULL) {\r
+    Status = EFI_OUT_OF_RESOURCES;\r
+    goto Finish;\r
+  }\r
+  \r
+  //\r
+  // Allocate temp buffer to store the temp updated package buffer\r
+  //\r
+  TempPacakge = AllocateZeroPool (BufferSize);\r
+  if (TempPacakge == NULL) {\r
+    Status = EFI_OUT_OF_RESOURCES;\r
+    goto Finish;\r
+  }\r
+\r
+  UpdateBufferPos = (UINT8 *) UpdatePackageList;\r
+\r
+  //\r
+  // Copy the package list header\r
+  //\r
+  CopyMem (UpdateBufferPos, HiiPackageList, sizeof (EFI_HII_PACKAGE_LIST_HEADER));\r
+  UpdateBufferPos += sizeof (EFI_HII_PACKAGE_LIST_HEADER);\r
+  \r
+  //\r
+  // Go through each package to find the matched pacakge and update one by one\r
+  //\r
+  Updated = FALSE;\r
+  Offset  = sizeof (EFI_HII_PACKAGE_LIST_HEADER);\r
+  PackageListLength = ReadUnaligned32 (&HiiPackageList->PackageLength);\r
+  while (Offset < PackageListLength) {\r
+    Package = (EFI_HII_PACKAGE_HEADER *) (((UINT8 *) HiiPackageList) + Offset);\r
+    CopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));\r
+    Offset += Package->Length;\r
+\r
+    if (Package->Type == EFI_HII_PACKAGE_FORMS) {\r
+      //\r
+      // Check this package is the matched package.\r
+      //\r
+      Status = InternalHiiUpdateFormPackageData (FormSetGuid, FormId, Package, OpCodeBufferStart, OpCodeBufferEnd, TempPacakge);\r
+      //\r
+      // The matched package is found. Its pacakge buffer will be updated by the input new data.\r
+      //\r
+      if (!EFI_ERROR(Status)) {\r
+        //\r
+        // Set Update Flag\r
+        //        \r
+        Updated = TRUE;\r
+        //\r
+        // Add updated package buffer\r
+        //\r
+        Package = TempPacakge;\r
+      }\r
+    }\r
+\r
+    //\r
+    // Add pacakge buffer\r
+    //\r
+    CopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));\r
+    CopyMem (UpdateBufferPos, Package, PackageHeader.Length);\r
+    UpdateBufferPos += PackageHeader.Length;\r
+  }\r
+  \r
+  if (Updated) {\r
+    //\r
+    // Update package list length\r
+    //\r
+    BufferSize = UpdateBufferPos - (UINT8 *) UpdatePackageList;\r
+    WriteUnaligned32 (&UpdatePackageList->PackageLength, (UINT32) BufferSize);\r
+    \r
+    //\r
+    // Update Pacakge to show form\r
+    //\r
+    Status = gHiiDatabase->UpdatePackageList (gHiiDatabase, HiiHandle, UpdatePackageList);\r
+  } else {\r
+    //\r
+    // Not matched form is found and updated.\r
+    //\r
+    Status = EFI_NOT_FOUND;\r
+  }\r
+\r
+Finish:\r
+  if (HiiPackageList != NULL) {\r
+    FreePool (HiiPackageList);\r
+  }\r
+  \r
+  if (UpdatePackageList != NULL) {\r
+    FreePool (UpdatePackageList);\r
+  }\r
+  \r
+  if (TempPacakge != NULL) {\r
+    FreePool (TempPacakge);\r
+  }\r
+\r
+  return Status; \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
+  This ConfigBody strings is generated by UEFI VfrCompiler for the default\r
+  values in a Form Set. The name of the ConfigBody strings is VfrMyIfrNVDataDefault0000\r
+  constructed following this rule: \r
+   "Vfr" + varstore.name + "Default" + defaultstore.attributes.\r
+  Check the generated C file in Output for details.\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
+  @param  ...                    Variable argument list for default value in <AltResp> format \r
+                                 generated by the tool.\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
+  VA_LIST                         Args;\r
+  UINTN                           Index;\r
+  UINT32                          TotalLen;\r
+  UINT8                           *BufCfgArray;\r
+  UINT8                           *BufferPos;\r
+  UINT16                          Offset;\r
+  UINT16                          Width;\r
+  UINT8                           *Value;\r
+\r
+  if ((Buffer == NULL) || (BufferSize == NULL)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Offset = 0;\r
+  Width  = 0;\r
+  Value  = NULL;\r
+\r
+  VA_START (Args, Number);\r
+  for (Index = 0; Index < Number; Index++) {\r
+    BufCfgArray = (UINT8 *) VA_ARG (Args, VOID *);\r
+    TotalLen = ReadUnaligned32 ((UINT32 *)BufCfgArray);\r
+    BufferPos = BufCfgArray + sizeof (UINT32);\r
+\r
+    while ((UINT32)(BufferPos - BufCfgArray) < TotalLen) {\r
+      Offset = ReadUnaligned16 ((UINT16 *)BufferPos);\r
+      BufferPos += sizeof (UINT16);\r
+      Width = ReadUnaligned16 ((UINT16 *)BufferPos);\r
+      BufferPos += sizeof (UINT16);\r
+      Value = BufferPos;\r
+      BufferPos += Width;\r
+\r
+      if ((UINTN)(Offset + Width) > *BufferSize) {\r
+        return EFI_BUFFER_TOO_SMALL;\r
+      }\r
+\r
+      CopyMem ((UINT8 *)Buffer + Offset, Value, Width);\r
+    }\r
+  }\r
+  VA_END (Args);\r
+\r
+  *BufferSize = (UINTN)Offset;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
index 333c29fc3be2b337eee321e781ba58ea22c0477b..7d8ca5e11720664a8c1f670d9db2d7ce16ba9514 100644 (file)
@@ -214,8 +214,8 @@ HiiLibNewString (
     // For each language supported by the package,\r
     // a string token is created.\r
     //\r
-    Status = mHiiStringProt->NewString (\r
-                                 mHiiStringProt,\r
+    Status = gHiiString->NewString (\r
+                                 gHiiString,\r
                                  PackageList,\r
                                  StringId,\r
                                  Lang,\r
@@ -287,8 +287,8 @@ HiiLibSetString (
     // For each language supported by the package,\r
     // the string is updated.\r
     //\r
-    Status = mHiiStringProt->SetString (\r
-                                 mHiiStringProt,\r
+    Status = gHiiString->SetString (\r
+                                 gHiiString,\r
                                  PackageList,\r
                                  StringId,\r
                                  Lang,\r
@@ -425,8 +425,8 @@ HiiLibGetString (
                    NULL\r
                    );\r
   if (BestLanguage != NULL ) {\r
-     Status = mHiiStringProt->GetString (\r
-                               mHiiStringProt,\r
+     Status = gHiiString->GetString (\r
+                               gHiiString,\r
                                BestLanguage,\r
                                PackageList,\r
                                StringId,\r
index 8f2aeb45818cb05310f34833eef52a26bd648d7c..e1446351d7b36e0c0178956e9cb9ae699db53a4a 100644 (file)
@@ -20,6 +20,7 @@
 #include <Protocol/HiiDatabase.h>\r
 #include <Protocol/HiiString.h>\r
 #include <Protocol/DevicePath.h>\r
+#include <Protocol/FormBrowser2.h>\r
 \r
 #include <Guid/GlobalVariable.h>\r
 \r
@@ -30,7 +31,9 @@
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/DevicePathLib.h>\r
+#include <Library/UefiHiiServicesLib.h>\r
 #include <Library/UefiLib.h>\r
+#include <Library/PrintLib.h>\r
 #include <Library/PcdLib.h>\r
 #include <Library/UefiRuntimeServicesTableLib.h>\r
 \r
index 8c8a2f2c4aa3ad9d87502d615034da2e9aadba43..1a03ff1fa58e34883122facdfa411f133bba40e4 100644 (file)
@@ -25,7 +25,6 @@
   VERSION_STRING                 = 1.0\r
   LIBRARY_CLASS                  = HiiLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER\r
   EFI_SPECIFICATION_VERSION      = 0x0002000A \r
-  CONSTRUCTOR                    = HiiLibConstructor\r
 \r
 #\r
 #  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
   UefiBootServicesTableLib\r
   DevicePathLib\r
   UefiLib\r
+  UefiHiiServicesLib\r
+  PrintLib\r
   PcdLib\r
-  UefiRuntimeServicesTableLib\r
 \r
 [Protocols]\r
-  gEfiHiiDatabaseProtocolGuid  ## CONSUMES\r
-  gEfiHiiStringProtocolGuid    ## CONSUMES\r
+  gEfiFormBrowser2ProtocolGuid ## CONSUMES\r
   gEfiDevicePathProtocolGuid   ## CONSUMES\r
 \r
 [Pcd]\r
   gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultPlatformLang\r
-\r
-[Guids]  \r
-  gEfiGlobalVariableGuid        ## SOMETIMES_CONSUMES ## Variable:L"PlatformLang"\r
-\r
-[Depex]\r
-  gEfiHiiDatabaseProtocolGuid AND\r
-  gEfiHiiStringProtocolGuid\r
-  \r
index 8351a3279c19e5e79d41a921be6dc21593a8dc8e..9ef7c3bf836a26f09fbc7aa6aceb558137bad404 100644 (file)
@@ -16,7 +16,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include "DriverSample.h"\r
 \r
-#define DISPLAY_ONLY_MY_ITEM  0x0000\r
+#define DISPLAY_ONLY_MY_ITEM  0x0002\r
 \r
 EFI_GUID   mFormSetGuid = FORMSET_GUID;\r
 EFI_GUID   mInventoryGuid = INVENTORY_GUID;\r
@@ -218,10 +218,10 @@ SetPassword (
   )\r
 {\r
   EFI_STATUS                      Status;\r
-  UINTN                           BufferSize;\r
   CHAR16                          *Password;\r
   UINTN                           PasswordSize;\r
   DRIVER_SAMPLE_CONFIGURATION     *Configuration;\r
+  UINTN                           BufferSize;\r
 \r
   //\r
   // Get Buffer Storage data from EFI variable\r
@@ -253,11 +253,8 @@ SetPassword (
   //\r
   // Retrive uncommitted data from Browser\r
   //\r
-  BufferSize = sizeof (DRIVER_SAMPLE_CONFIGURATION);\r
-  Configuration = AllocateZeroPool (sizeof (DRIVER_SAMPLE_PRIVATE_DATA));\r
-  ASSERT (Configuration != NULL);\r
-  Status = GetBrowserData (&mFormSetGuid, VariableName, &BufferSize, (UINT8 *) Configuration);\r
-  if (!EFI_ERROR (Status)) {\r
+  Configuration = (DRIVER_SAMPLE_CONFIGURATION *) HiiGetBrowserData (&mFormSetGuid, VariableName, sizeof (DRIVER_SAMPLE_CONFIGURATION));\r
+  if (Configuration != NULL) {\r
     //\r
     // Update password's clear text in the screen\r
     //\r
@@ -266,16 +263,17 @@ SetPassword (
     //\r
     // Update uncommitted data of Browser\r
     //\r
-    BufferSize = sizeof (DRIVER_SAMPLE_CONFIGURATION);\r
-    Status = SetBrowserData (\r
-               &mFormSetGuid,\r
-               VariableName,\r
-               BufferSize,\r
-               (UINT8 *) Configuration,\r
-               NULL\r
-               );\r
+    HiiSetBrowserData (\r
+       &mFormSetGuid,\r
+       VariableName,\r
+       sizeof (DRIVER_SAMPLE_CONFIGURATION),\r
+       (UINT8 *) Configuration,\r
+       NULL\r
+       );\r
+    \r
+    FreePool (Configuration);\r
   }\r
-  FreePool (Configuration);\r
+\r
 \r
   //\r
   // Set password\r
@@ -355,31 +353,36 @@ ExtractConfig (
     //\r
     // Request is set to NULL, return all configurable elements together with ALTCFG\r
     //\r
-    Status = ConstructConfigAltResp (\r
-               NULL,\r
-               NULL,\r
-               Results,\r
-               &mFormSetGuid,\r
-               VariableName,\r
-               PrivateData->DriverHandle[0],\r
-               &PrivateData->Configuration,\r
-               BufferSize,\r
-               VfrMyIfrNVDataBlockName,\r
-               2,\r
-               STRING_TOKEN (STR_STANDARD_DEFAULT_PROMPT),\r
-               VfrMyIfrNVDataDefault0000,\r
-               STRING_TOKEN (STR_MANUFACTURE_DEFAULT_PROMPT),\r
-               VfrMyIfrNVDataDefault0001\r
+    *Results = HiiConstructConfigAltResp (\r
+                 &mFormSetGuid,\r
+                 VariableName,\r
+                 PrivateData->DriverHandle[0],\r
+                 &PrivateData->Configuration,\r
+                 BufferSize,\r
+                 VfrMyIfrNVDataBlockName,\r
+                 STRING_TOKEN (STR_STANDARD_DEFAULT_PROMPT),\r
+                 VfrMyIfrNVDataDefault0000,\r
+                 STRING_TOKEN (STR_MANUFACTURE_DEFAULT_PROMPT),\r
+                 VfrMyIfrNVDataDefault0001,\r
+                 0,\r
+                 NULL\r
                );\r
+    \r
+    //\r
+    // No matched storage is found.\r
+    //\r
+    if (*Results == NULL) {\r
+      return EFI_NOT_FOUND;\r
+    }\r
 \r
-    return Status;\r
+    return EFI_SUCCESS;\r
   }\r
 \r
   //\r
   // Check routing data in <ConfigHdr>.\r
   // Note: if only one Storage is used, then this checking could be skipped.\r
   //\r
-  if (!IsConfigHdrMatch (Request, &mFormSetGuid, VariableName)) {\r
+  if (!HiiIsConfigHdrMatch (Request, &mFormSetGuid, VariableName)) {\r
     *Progress = Request;\r
     return EFI_NOT_FOUND;\r
   }\r
@@ -440,7 +443,7 @@ RouteConfig (
   // Check routing data in <ConfigHdr>.\r
   // Note: if only one Storage is used, then this checking could be skipped.\r
   //\r
-  if (!IsConfigHdrMatch (Configuration, &mFormSetGuid, VariableName)) {\r
+  if (!HiiIsConfigHdrMatch (Configuration, &mFormSetGuid, VariableName)) {\r
     *Progress = Configuration;\r
     return EFI_NOT_FOUND;\r
   }\r
@@ -525,9 +528,12 @@ DriverCallback (
 {\r
   DRIVER_SAMPLE_PRIVATE_DATA      *PrivateData;\r
   EFI_STATUS                      Status;\r
-  EFI_HII_UPDATE_DATA             UpdateData;\r
-  IFR_OPTION                      *IfrOptionList;\r
   UINT8                           MyVar;\r
+  VOID                            *StartOpCodeHandle;\r
+  VOID                            *OptionsOpCodeHandle;\r
+  EFI_IFR_GUID_LABEL              *StartLabel;\r
+  VOID                            *EndOpCodeHandle;\r
+  EFI_IFR_GUID_LABEL              *EndLabel;\r
 \r
   if ((Value == NULL) || (ActionRequest == NULL)) {\r
     return EFI_INVALID_PARAMETER;\r
@@ -541,139 +547,179 @@ DriverCallback (
     //\r
     // Initialize the container for dynamic opcodes\r
     //\r
-    IfrLibInitUpdateData (&UpdateData, 0x1000);\r
-\r
-    IfrOptionList = AllocatePool (2 * sizeof (IFR_OPTION));\r
-    ASSERT (IfrOptionList != NULL);\r
-\r
-    IfrOptionList[0].Flags        = 0;\r
-    IfrOptionList[0].StringToken  = STRING_TOKEN (STR_BOOT_OPTION1);\r
-    IfrOptionList[0].Value.u8     = 1;\r
-    IfrOptionList[1].Flags        = EFI_IFR_OPTION_DEFAULT;\r
-    IfrOptionList[1].StringToken  = STRING_TOKEN (STR_BOOT_OPTION2);\r
-    IfrOptionList[1].Value.u8     = 2;\r
-\r
-      CreateActionOpCode (\r
-        0x1237,                           // Question ID\r
-        STRING_TOKEN(STR_EXIT_TEXT),      // Prompt text\r
-        STRING_TOKEN(STR_EXIT_TEXT),      // Help text\r
-        EFI_IFR_FLAG_CALLBACK,            // Question flag\r
-        0,                                // Action String ID\r
-        &UpdateData                       // Container for dynamic created opcodes\r
-        );\r
-    \r
-      //\r
-      // Prepare initial value for the dynamic created oneof Question\r
-      //\r
-      PrivateData->Configuration.DynamicOneof = 2;\r
-      Status = gRT->SetVariable(\r
-                      VariableName,\r
-                      &mFormSetGuid,\r
-                      EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r
-                      sizeof (DRIVER_SAMPLE_CONFIGURATION),\r
-                      &PrivateData->Configuration\r
-                      );\r
-      CreateOneOfOpCode (\r
-        0x8001,                                    // Question ID (or call it "key")\r
-        CONFIGURATION_VARSTORE_ID,                 // VarStore ID\r
-        (UINT16) DYNAMIC_ONE_OF_VAR_OFFSET,        // Offset in Buffer Storage\r
-        STRING_TOKEN (STR_ONE_OF_PROMPT),          // Question prompt text\r
-        STRING_TOKEN (STR_ONE_OF_HELP),            // Question help text\r
-        EFI_IFR_FLAG_CALLBACK,                     // Question flag\r
-        EFI_IFR_NUMERIC_SIZE_1,                    // Data type of Question Value\r
-        IfrOptionList,                             // Option list\r
-        2,                                         // Number of options in Option list\r
-        &UpdateData                                // Container for dynamic created opcodes\r
-        );\r
-    \r
-      CreateOrderedListOpCode (\r
-        0x8002,                                    // Question ID\r
-        CONFIGURATION_VARSTORE_ID,                 // VarStore ID\r
-        (UINT16) DYNAMIC_ORDERED_LIST_VAR_OFFSET,  // Offset in Buffer Storage\r
-        STRING_TOKEN (STR_BOOT_OPTIONS),           // Question prompt text\r
-        STRING_TOKEN (STR_BOOT_OPTIONS),           // Question help text\r
-        EFI_IFR_FLAG_RESET_REQUIRED,               // Question flag\r
-        0,                                         // Ordered list flag, e.g. EFI_IFR_UNIQUE_SET\r
-        EFI_IFR_NUMERIC_SIZE_1,                    // Data type of Question value\r
-        5,                                         // Maximum container\r
-        IfrOptionList,                             // Option list\r
-        2,                                         // Number of options in Option list\r
-        &UpdateData                                // Container for dynamic created opcodes\r
-        );\r
-    \r
-      CreateGotoOpCode (\r
-        1,                                // Target Form ID\r
-        STRING_TOKEN (STR_GOTO_FORM1),    // Prompt text\r
-        STRING_TOKEN (STR_GOTO_HELP),     // Help text\r
-        0,                                // Question flag\r
-        0x8003,                           // Question ID\r
-        &UpdateData                       // Container for dynamic created opcodes\r
-        );\r
-    \r
-      Status = IfrLibUpdateForm (\r
-                 PrivateData->HiiHandle[0],  // HII handle\r
-                 &mFormSetGuid,              // Formset GUID\r
-                 0x1234,                     // Form ID\r
-                 0x1234,                     // Label for where to insert opcodes\r
-                 TRUE,                       // Append or replace\r
-                 &UpdateData                 // Dynamic created opcodes\r
-                 );\r
-      FreePool (IfrOptionList);\r
-      IfrLibFreeUpdateData (&UpdateData);\r
-      break;\r
-    \r
-    case 0x5678:\r
-      //\r
-      // We will reach here once the Question is refreshed\r
-      //\r
-      IfrLibInitUpdateData (&UpdateData, 0x1000);\r
-    \r
-      IfrOptionList = AllocatePool (2 * sizeof (IFR_OPTION));\r
-      ASSERT (IfrOptionList != NULL);\r
-    \r
-      CreateActionOpCode (\r
-        0x1237,                           // Question ID\r
-        STRING_TOKEN(STR_EXIT_TEXT),      // Prompt text\r
-        STRING_TOKEN(STR_EXIT_TEXT),      // Help text\r
-        EFI_IFR_FLAG_CALLBACK,            // Question flag\r
-        0,                                // Action String ID\r
-        &UpdateData                       // Container for dynamic created opcodes\r
-        );\r
-    \r
-      Status = IfrLibUpdateForm (\r
-                 PrivateData->HiiHandle[0],  // HII handle\r
-                 &mFormSetGuid,              // Formset GUID\r
-                 3,                          // Form ID\r
-                 0x2234,                     // Label for where to insert opcodes\r
-                 TRUE,                       // Append or replace\r
-                 &UpdateData                 // Dynamic created opcodes\r
-                 );\r
-      IfrLibFreeUpdateData (&UpdateData);\r
+    StartOpCodeHandle = HiiAllocateOpCodeHandle ();\r
+    ASSERT (StartOpCodeHandle != NULL);\r
+\r
+    EndOpCodeHandle = HiiAllocateOpCodeHandle ();\r
+    ASSERT (EndOpCodeHandle != NULL);\r
+\r
+    //\r
+    // Create Hii Extend Label OpCode as the start opcode\r
+    //\r
+    StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));\r
+    StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
+    StartLabel->Number       = LABEL_UPDATE1;\r
+\r
+    //\r
+    // Create Hii Extend Label OpCode as the end opcode\r
+    //\r
+    EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (EndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));\r
+    EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
+    EndLabel->Number       = LABEL_END;\r
+\r
+    HiiCreateActionOpCode (\r
+      StartOpCodeHandle,                // Container for dynamic created opcodes\r
+      0x1237,                           // Question ID\r
+      STRING_TOKEN(STR_EXIT_TEXT),      // Prompt text\r
+      STRING_TOKEN(STR_EXIT_TEXT),      // Help text\r
+      EFI_IFR_FLAG_CALLBACK,            // Question flag\r
+      0                                 // Action String ID\r
+    );\r
+\r
+    //\r
+    // Create Option OpCode\r
+    //\r
+    OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();\r
+    ASSERT (OptionsOpCodeHandle != NULL);\r
+\r
+    HiiCreateOneOfOptionOpCode (\r
+      OptionsOpCodeHandle,\r
+      STRING_TOKEN (STR_BOOT_OPTION1),\r
+      0,\r
+      EFI_IFR_NUMERIC_SIZE_1,\r
+      1\r
+      );\r
+\r
+    HiiCreateOneOfOptionOpCode (\r
+      OptionsOpCodeHandle,\r
+      STRING_TOKEN (STR_BOOT_OPTION2),\r
+      0,\r
+      EFI_IFR_NUMERIC_SIZE_1,\r
+      2\r
+      );\r
+\r
+    //\r
+    // Prepare initial value for the dynamic created oneof Question\r
+    //\r
+    PrivateData->Configuration.DynamicOneof = 2;\r
+    Status = gRT->SetVariable(\r
+                    VariableName,\r
+                    &mFormSetGuid,\r
+                    EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r
+                    sizeof (DRIVER_SAMPLE_CONFIGURATION),\r
+                    &PrivateData->Configuration\r
+                    );\r
+\r
+    HiiCreateOneOfOpCode (\r
+      StartOpCodeHandle,                         // Container for dynamic created opcodes\r
+      0x8001,                                    // Question ID (or call it "key")\r
+      CONFIGURATION_VARSTORE_ID,                 // VarStore ID\r
+      (UINT16) DYNAMIC_ONE_OF_VAR_OFFSET,        // Offset in Buffer Storage\r
+      STRING_TOKEN (STR_ONE_OF_PROMPT),          // Question prompt text\r
+      STRING_TOKEN (STR_ONE_OF_HELP),            // Question help text\r
+      EFI_IFR_FLAG_CALLBACK,                     // Question flag\r
+      EFI_IFR_NUMERIC_SIZE_1,                    // Data type of Question Value\r
+      OptionsOpCodeHandle,                       // Option Opcode list\r
+      NULL                                       // Default Opcode is NULl\r
+      );\r
+\r
+    HiiCreateOrderedListOpCode (\r
+      StartOpCodeHandle,                         // Container for dynamic created opcodes\r
+      0x8002,                                    // Question ID\r
+      CONFIGURATION_VARSTORE_ID,                 // VarStore ID\r
+      (UINT16) DYNAMIC_ORDERED_LIST_VAR_OFFSET,  // Offset in Buffer Storage\r
+      STRING_TOKEN (STR_BOOT_OPTIONS),           // Question prompt text\r
+      STRING_TOKEN (STR_BOOT_OPTIONS),           // Question help text\r
+      EFI_IFR_FLAG_RESET_REQUIRED,               // Question flag\r
+      0,                                         // Ordered list flag, e.g. EFI_IFR_UNIQUE_SET\r
+      EFI_IFR_NUMERIC_SIZE_1,                    // Data type of Question value\r
+      5,                                         // Maximum container\r
+      OptionsOpCodeHandle,                       // Option Opcode list\r
+      NULL                                       // Default Opcode is NULl\r
+      );\r
+\r
+    HiiCreateGotoOpCode (\r
+      StartOpCodeHandle,                // Container for dynamic created opcodes\r
+      1,                                // Target Form ID\r
+      STRING_TOKEN (STR_GOTO_FORM1),    // Prompt text\r
+      STRING_TOKEN (STR_GOTO_HELP),     // Help text\r
+      0,                                // Question flag\r
+      0x8003                            // Question ID\r
+      );\r
+\r
+    HiiUpdateForm (\r
+      PrivateData->HiiHandle[0],  // HII handle\r
+      &mFormSetGuid,              // Formset GUID\r
+      0x1234,                     // Form ID\r
+      StartOpCodeHandle,          // Label for where to insert opcodes\r
+      EndOpCodeHandle             // Replace data\r
+      );\r
+\r
+    HiiFreeOpCodeHandle (StartOpCodeHandle);\r
+    HiiFreeOpCodeHandle (OptionsOpCodeHandle);\r
+    break;\r
     \r
-      //\r
-      // Refresh the Question value\r
-      //\r
-      PrivateData->Configuration.DynamicRefresh++;\r
-      Status = gRT->SetVariable(\r
-                      VariableName,\r
-                      &mFormSetGuid,\r
-                      EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r
-                      sizeof (DRIVER_SAMPLE_CONFIGURATION),\r
-                      &PrivateData->Configuration\r
-                      );\r
+  case 0x5678:\r
+    //\r
+    // We will reach here once the Question is refreshed\r
+    //\r
+\r
+    //\r
+    // Initialize the container for dynamic opcodes\r
+    //\r
+    StartOpCodeHandle = HiiAllocateOpCodeHandle ();\r
+    ASSERT (StartOpCodeHandle != NULL);\r
+\r
+    //\r
+    // Create Hii Extend Label OpCode as the start opcode\r
+    //\r
+    StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));\r
+    StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
+    StartLabel->Number       = LABEL_UPDATE2;\r
+\r
+    HiiCreateActionOpCode (\r
+      StartOpCodeHandle,                // Container for dynamic created opcodes\r
+      0x1237,                           // Question ID\r
+      STRING_TOKEN(STR_EXIT_TEXT),      // Prompt text\r
+      STRING_TOKEN(STR_EXIT_TEXT),      // Help text\r
+      EFI_IFR_FLAG_CALLBACK,            // Question flag\r
+      0                                 // Action String ID\r
+    );\r
     \r
-      //\r
-      // Change an EFI Variable storage (MyEfiVar) asynchronous, this will cause\r
-      // the first statement in Form 3 be suppressed\r
-      //\r
-      MyVar = 111;\r
-      Status = gRT->SetVariable(\r
-                      L"MyVar",\r
-                      &mFormSetGuid,\r
-                      EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r
-                      1,\r
-                      &MyVar\r
-                      );\r
+    HiiUpdateForm (\r
+      PrivateData->HiiHandle[0],  // HII handle\r
+      &mFormSetGuid,              // Formset GUID\r
+      0x3,                        // Form ID\r
+      StartOpCodeHandle,          // Label for where to insert opcodes\r
+      NULL                        // Insert data\r
+      );\r
+\r
+    HiiFreeOpCodeHandle (StartOpCodeHandle); \r
+  \r
+    //\r
+    // Refresh the Question value\r
+    //\r
+    PrivateData->Configuration.DynamicRefresh++;\r
+    Status = gRT->SetVariable(\r
+                    VariableName,\r
+                    &mFormSetGuid,\r
+                    EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r
+                    sizeof (DRIVER_SAMPLE_CONFIGURATION),\r
+                    &PrivateData->Configuration\r
+                    );\r
+  \r
+    //\r
+    // Change an EFI Variable storage (MyEfiVar) asynchronous, this will cause\r
+    // the first statement in Form 3 be suppressed\r
+    //\r
+    MyVar = 111;\r
+    Status = gRT->SetVariable(\r
+                    L"MyVar",\r
+                    &mFormSetGuid,\r
+                    EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r
+                    1,\r
+                    &MyVar\r
+                    );\r
     break;\r
 \r
   case 0x1237:\r
@@ -934,32 +980,43 @@ DriverSampleInit (
              );\r
     }\r
   }\r
+  \r
+  SavedStatus = EFI_SUCCESS;\r
 \r
   //\r
-  // Example of how to display only the item we sent to HII\r
+  // Default this driver is built into Flash device image, \r
+  // the following code doesn't run.\r
   //\r
+\r
   //\r
-  // Have the browser pull out our copy of the data, and only display our data\r
+  // Example of how to display only the item we sent to HII\r
+  // When this driver is not built into Flash device image, \r
+  // it need to call SendForm to show front page by itself.\r
   //\r
-  Status = FormBrowser2->SendForm (\r
-                           FormBrowser2,\r
-                           &(HiiHandle[DISPLAY_ONLY_MY_ITEM]),\r
-                           1,\r
-                           NULL,\r
-                           0,\r
-                           NULL,\r
-                           NULL\r
-                           );\r
-  SavedStatus = Status;\r
-\r
-  Status = HiiDatabase->RemovePackageList (HiiDatabase, HiiHandle[0]);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = HiiDatabase->RemovePackageList (HiiDatabase, HiiHandle[1]);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
+  if (DISPLAY_ONLY_MY_ITEM <= 1) {\r
+    //\r
+    // Have the browser pull out our copy of the data, and only display our data\r
+    //\r
+    Status = FormBrowser2->SendForm (\r
+                             FormBrowser2,\r
+                             &(HiiHandle[DISPLAY_ONLY_MY_ITEM]),\r
+                             1,\r
+                             NULL,\r
+                             0,\r
+                             NULL,\r
+                             NULL\r
+                             );\r
+    SavedStatus = Status;\r
+  \r
+    Status = HiiDatabase->RemovePackageList (HiiDatabase, HiiHandle[0]);\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+  \r
+    Status = HiiDatabase->RemovePackageList (HiiDatabase, HiiHandle[1]);\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
   }\r
 \r
   return SavedStatus;\r
index cdecddbfe78b0ddb076d57ee5533e85b3389addf..3317e4fdc2740a063f00b1600b7f41944b475440 100644 (file)
@@ -39,8 +39,6 @@ Revision History
 #include <Library/UefiDriverEntryPoint.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
-#include <Library/IfrSupportLib.h>\r
-#include <Library/ExtendedIfrSupportLib.h>\r
 #include <Library/HiiLib.h>\r
 #include <Library/DevicePathLib.h>\r
 \r
index 9e5ff999998dea5957de500135d75bcb066e98e8..3ed56e934e18f02d60ad38353dbb33157542da13 100644 (file)
@@ -53,8 +53,9 @@
   BaseMemoryLib\r
   DebugLib\r
   HiiLib\r
-  IfrSupportLib\r
-  ExtendedIfrSupportLib\r
+\r
+[Guids]\r
+  gEfiIfrTianoGuid                              ## CONSUMES ## Guid\r
 \r
 [Protocols]\r
   gEfiHiiStringProtocolGuid                     ## CONSUMES\r
index 4fbd6a5650e2724c6f1fb1fffd20163823551985..162c5ecd1f54f8cb6720ff5a0e53ef71f14d9c83 100644 (file)
@@ -71,6 +71,12 @@ typedef struct {
   UINT8         OrderedList[3];\r
 } MY_DATA2;\r
 \r
+//\r
+// Labels definition\r
+//\r
+#define LABEL_UPDATE1               0x1234\r
+#define LABEL_UPDATE2               0x2234\r
+#define LABEL_END                   0x2223\r
 \r
 #pragma pack()\r
 \r
index 01c76345b47d0e02858ebe28978a36de94a8e3f8..fc6b5da766c143d000290754bc6188e6c592d8b1 100644 (file)
@@ -49,7 +49,6 @@
 #define LABEL_1_VALUE               0x01\r
 #define LABEL_2_VALUE               0x1000\r
 #define LABEL_UPDATE_BBS            0x2222\r
-#define LABEL_END                   0x2223\r
 \r
 formset\r
   guid     = FORMSET_GUID,\r
@@ -519,7 +518,7 @@ formset
             refresh interval = 3             // Refresh interval in seconds\r
     endnumeric;\r
 \r
-    label 0x2234;\r
+    label LABEL_UPDATE2;\r
     label LABEL_END;\r
 \r
   endform;\r
@@ -531,7 +530,7 @@ formset
   form formid = 0x1234,            // Dynamically created page,\r
        title = STRING_TOKEN(STR_DYNAMIC_TITLE);  // note formid is a variable (for readability) (UINT16) - also added Form to the line to signify the Op-Code\r
 \r
-    label 0x1234;\r
+    label LABEL_UPDATE1;\r
     //\r
     // This is where we will insert dynamic created opcodes\r
     //\r
index 34942f752a05030f0eec3768599f53ade77c8732..76068e573e7c4d367c808a85d9fb9793b6287047 100644 (file)
@@ -15,6 +15,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include "IScsiImpl.h"\r
 \r
 EFI_GUID        mVendorGuid              = ISCSI_CONFIG_GUID;\r
+CHAR16          mVendorStorageName[]     = L"ISCSI_CONFIG_IFR_NVDATA";\r
 BOOLEAN         mIScsiDeviceListUpdated  = FALSE;\r
 UINTN           mNumberOfIScsiDevices    = 0;\r
 ISCSI_FORM_CALLBACK_INFO  *mCallbackInfo = NULL;\r
@@ -504,14 +505,12 @@ IScsiFormCallback (
   //\r
   // Retrive uncommitted data from Browser\r
   //\r
-  BufferSize = sizeof (ISCSI_CONFIG_IFR_NVDATA);\r
-  IfrNvData = AllocateZeroPool (BufferSize);\r
-  ASSERT (IfrNvData != NULL);\r
-  Status = GetBrowserData (NULL, NULL, &BufferSize, (UINT8 *) IfrNvData);\r
-  if (EFI_ERROR (Status)) {\r
-    gBS->FreePool (IfrNvData);\r
-    return Status;\r
+  IfrNvData = (ISCSI_CONFIG_IFR_NVDATA *) HiiGetBrowserData (&mVendorGuid, mVendorStorageName, sizeof (ISCSI_CONFIG_IFR_NVDATA));\r
+  if (IfrNvData == NULL) {\r
+    return EFI_NOT_FOUND;\r
   }\r
+  \r
+  Status = EFI_SUCCESS;\r
 \r
   switch (QuestionId) {\r
   case KEY_INITIATOR_NAME:\r
@@ -730,11 +729,10 @@ IScsiFormCallback (
     //\r
     // Pass changed uncommitted data back to Form Browser\r
     //\r
-    BufferSize = sizeof (ISCSI_CONFIG_IFR_NVDATA);\r
-    Status = SetBrowserData (NULL, NULL, BufferSize, (UINT8 *) IfrNvData, NULL);\r
+    HiiSetBrowserData (&mVendorGuid, mVendorStorageName, sizeof (ISCSI_CONFIG_IFR_NVDATA), (UINT8 *) IfrNvData, NULL);\r
   }\r
 \r
-  gBS->FreePool (IfrNvData);\r
+  FreePool (IfrNvData);\r
   return Status;\r
 }\r
 \r
@@ -761,12 +759,14 @@ IScsiConfigUpdateForm (
   ISCSI_CONFIG_FORM_ENTRY     *ConfigFormEntry;\r
   BOOLEAN                     EntryExisted;\r
   EFI_STATUS                  Status;\r
-  EFI_HII_UPDATE_DATA         UpdateData;\r
   EFI_SIMPLE_NETWORK_PROTOCOL *Snp;\r
   CHAR16                      PortString[128];\r
   UINT16                      FormIndex;\r
   UINTN                       BufferSize;\r
-\r
+  VOID                        *StartOpCodeHandle;\r
+  VOID                        *EndOpCodeHandle;\r
+  EFI_IFR_GUID_LABEL          *StartLabel;\r
+  EFI_IFR_GUID_LABEL          *EndLabel;\r
 \r
   ConfigFormEntry = NULL;\r
   EntryExisted    = FALSE;\r
@@ -861,36 +861,56 @@ IScsiConfigUpdateForm (
   //\r
   // Allocate space for creation of Buffer\r
   //\r
-  UpdateData.BufferSize = 0x1000;\r
-  UpdateData.Data = AllocateZeroPool (0x1000);\r
-  UpdateData.Offset = 0;\r
+\r
+  //\r
+  // Init OpCode Handle\r
+  //\r
+  StartOpCodeHandle = HiiAllocateOpCodeHandle ();\r
+  ASSERT (StartOpCodeHandle != NULL);\r
+\r
+  EndOpCodeHandle = HiiAllocateOpCodeHandle ();\r
+  ASSERT (EndOpCodeHandle != NULL);\r
+\r
+  //\r
+  // Create Hii Extend Label OpCode as the start opcode\r
+  //\r
+  StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));\r
+  StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
+  StartLabel->Number       = DEVICE_ENTRY_LABEL;\r
+\r
+  //\r
+  // Create Hii Extend Label OpCode as the end opcode\r
+  //\r
+  EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (EndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));\r
+  EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
+  EndLabel->Number       = LABEL_END;\r
 \r
   FormIndex = 0;\r
   NET_LIST_FOR_EACH (Entry, &mIScsiConfigFormList) {\r
     ConfigFormEntry = NET_LIST_USER_STRUCT (Entry, ISCSI_CONFIG_FORM_ENTRY, Link);\r
 \r
-    CreateGotoOpCode (\r
-      FORMID_DEVICE_FORM,\r
-      ConfigFormEntry->PortTitleToken,\r
-      ConfigFormEntry->PortTitleHelpToken,\r
-      EFI_IFR_FLAG_CALLBACK,\r
-      (UINT16)(KEY_DEVICE_ENTRY_BASE + FormIndex),\r
-      &UpdateData\r
+    HiiCreateGotoOpCode (\r
+      StartOpCodeHandle,                            // Container for dynamic created opcodes\r
+      FORMID_DEVICE_FORM,                           // Target Form ID\r
+      ConfigFormEntry->PortTitleToken,              // Prompt text\r
+      ConfigFormEntry->PortTitleHelpToken,          // Help text\r
+      EFI_IFR_FLAG_CALLBACK,                        // Question flag\r
+      (UINT16)(KEY_DEVICE_ENTRY_BASE + FormIndex)   // Question ID\r
       );\r
 \r
     FormIndex++;\r
   }\r
 \r
-  IfrLibUpdateForm (\r
+  HiiUpdateForm (\r
     mCallbackInfo->RegisteredHandle,\r
     &mVendorGuid,\r
     FORMID_MAIN_FORM,\r
-    DEVICE_ENTRY_LABEL,\r
-    FALSE,\r
-    &UpdateData\r
+    StartOpCodeHandle, // Label DEVICE_ENTRY_LABEL\r
+    EndOpCodeHandle    // LABEL_END\r
     );\r
 \r
-  gBS->FreePool (UpdateData.Data);\r
+  HiiFreeOpCodeHandle (StartOpCodeHandle);\r
+  HiiFreeOpCodeHandle (EndOpCodeHandle);\r
 \r
   return EFI_SUCCESS;\r
 }\r
index fd6a2c41cf8fbba2021127b997b0e265d85a33d5..b0a748ae9ca62f505475a0ff7dd235df62de80af 100644 (file)
@@ -15,11 +15,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #ifndef _ISCSI_CONFIG_H_\r
 #define _ISCSI_CONFIG_H_\r
 \r
+#include <Guid/MdeModuleHii.h>\r
 #include <Protocol/HiiConfigRouting.h>\r
 #include <Library/HiiLib.h>\r
 #include <Library/DevicePathLib.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 10f1c4ed758db55d102ae6f54b49a3a8527eb255..666fa04170e30cbc712f278f51b86ea00765e572 100644 (file)
@@ -16,8 +16,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include "IScsiConfigNVDataStruc.h"\r
 #define EFI_NETWORK_DEVICE_CLASS  0x04\r
 \r
-#define LABEL_END                 0xffff\r
-\r
 formset \r
   guid     = ISCSI_CONFIG_GUID,\r
   title    = STRING_TOKEN(STR_ISCSI_CONFIG_FORM_TITLE),\r
index eb9e7dc3c24066aa636fe1173458f13155f472aa..7b77a19e78ad98d699c3c49f0d32eda84c8d43c8 100644 (file)
@@ -47,6 +47,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #define TARGET_PORT_MAX_NUM       65535\r
 \r
 #define DEVICE_ENTRY_LABEL        0x1234\r
+#define LABEL_END                 0xffff\r
 \r
 #define KEY_INITIATOR_NAME        0x101\r
 #define KEY_DHCP_ENABLE           0x102\r
index 29509911e7c3fc9d93336112672173d1fac24633..3587c307abf16a18b8c7c6f355bcb970e807851c 100644 (file)
@@ -78,8 +78,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
   DebugLib\r
   PrintLib\r
   HiiLib\r
-  IfrSupportLib\r
-  ExtendedIfrSupportLib\r
   NetLib\r
 \r
 [Protocols]\r
@@ -97,3 +95,4 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 [Guids]\r
   gEfiEventExitBootServicesGuid\r
+  gEfiIfrTianoGuid                              ## CONSUMES ## Guid\r
index 90ab529ef34eaaeb478b41043d0ebb314c6cbca6..e612d4f8550645dea7eaa6e8977f8468e82c1ebd 100644 (file)
@@ -323,40 +323,25 @@ InitializeConfigHdr (
   IN OUT FORMSET_STORAGE   *Storage\r
   )\r
 {\r
-  EFI_STATUS  Status;\r
-  UINTN       StrBufferLen;\r
   CHAR16      *Name;\r
-\r
+  \r
   if (Storage->Type == EFI_HII_VARSTORE_BUFFER) {\r
     Name = Storage->Name;\r
   } else {\r
     Name = NULL;\r
   }\r
-\r
-  StrBufferLen = 0;\r
-  Status = ConstructConfigHdr (\r
-             Storage->ConfigHdr,\r
-             &StrBufferLen,\r
-             &Storage->Guid,\r
-             Name,\r
-             FormSet->DriverHandle\r
-             );\r
-  if (Status == EFI_BUFFER_TOO_SMALL) {\r
-    Storage->ConfigHdr = AllocateZeroPool (StrBufferLen);\r
-    Status = ConstructConfigHdr (\r
-               Storage->ConfigHdr,\r
-               &StrBufferLen,\r
-               &Storage->Guid,\r
-               Name,\r
-               FormSet->DriverHandle\r
-               );\r
-  }\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
+  \r
+  Storage->ConfigHdr = HiiConstructConfigHdr (\r
+                         &Storage->Guid,\r
+                         Name,\r
+                         FormSet->DriverHandle\r
+                         );\r
+  \r
+  if (Storage->ConfigHdr == NULL) {\r
+    return EFI_NOT_FOUND;\r
   }\r
 \r
-  Storage->ConfigRequest = AllocateCopyPool (StrBufferLen, Storage->ConfigHdr);\r
+  Storage->ConfigRequest = AllocateCopyPool (StrSize (Storage->ConfigHdr), Storage->ConfigHdr);\r
   Storage->SpareStrLen = 0;\r
 \r
   return EFI_SUCCESS;\r
index 699b2c457b4e7f3bf857f593ebbf8739918039b9..b19d1ba5b9ea450272e3a9cbaf7e7c8cdab53148 100644 (file)
@@ -39,7 +39,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/BaseLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
-#include <Library/IfrSupportLib.h>\r
 #include <Library/HiiLib.h>\r
 #include <Library/PcdLib.h>\r
 \r
index d531d7b9afeb7a7085fae4343a32e0807162398d..bd4ba108be911fed0e7df7f554d3a948ab29d17c 100644 (file)
@@ -49,7 +49,6 @@
   MdePkg/MdePkg.dec\r
   MdeModulePkg/MdeModulePkg.dec\r
 \r
-\r
 [LibraryClasses]\r
   MemoryAllocationLib\r
   BaseLib\r
@@ -59,9 +58,8 @@
   BaseMemoryLib\r
   DebugLib\r
   PrintLib\r
-  IfrSupportLib\r
   HiiLib\r
-\r
+  \r
 [Guids]\r
   gEfiIfrTianoGuid                              ## CONSUMES  ## GUID\r
   gEfiIfrFrameworkGuid                          ## CONSUMES  ## GUID\r