]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c
Add VLAN support.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / IScsiDxe / IScsiConfig.c
index 14e42e358ef51eafff1e517da907e2b815a0024c..35214f2ce95b19c09d7f7b0ee286b22584c51516 100644 (file)
@@ -1,6 +1,7 @@
-/*++\r
+/** @file\r
+  Helper functions for configuring or getting the parameters relating to iSCSI.\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation\r
+Copyright (c) 2004 - 2009, Intel Corporation.<BR>\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -9,96 +10,71 @@ http://opensource.org/licenses/bsd-license.php
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
-Module Name:\r
-\r
-  IScsiConfig.c\r
-\r
-Abstract:\r
-\r
---*/\r
+**/\r
 \r
 #include "IScsiImpl.h"\r
 \r
-EFI_GUID        mVendorGuid             = ISCSI_CONFIG_GUID;\r
-BOOLEAN         mIScsiDeviceListUpdated = FALSE;\r
-UINTN           mNumberOfIScsiDevices   = 0;\r
-ISCSI_FORM_CALLBACK_INFO  *mCallbackInfo;\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
 \r
-NET_LIST_ENTRY  mIScsiConfigFormList = {\r
+LIST_ENTRY      mIScsiConfigFormList = {\r
   &mIScsiConfigFormList,\r
   &mIScsiConfigFormList\r
 };\r
 \r
-STATIC\r
+HII_VENDOR_DEVICE_PATH  mIScsiHiiVendorDevicePath = {\r
+  {\r
+    {\r
+      HARDWARE_DEVICE_PATH,\r
+      HW_VENDOR_DP,\r
+      {\r
+        (UINT8) (sizeof (VENDOR_DEVICE_PATH)),\r
+        (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)\r
+      }\r
+    },\r
+    //\r
+    // {49D7B73E-143D-4716-977B-C45F1CB038CC}\r
+    //\r
+    { 0x49d7b73e, 0x143d, 0x4716, { 0x97, 0x7b, 0xc4, 0x5f, 0x1c, 0xb0, 0x38, 0xcc } }\r
+  },\r
+  {\r
+    END_DEVICE_PATH_TYPE,\r
+    END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
+    { \r
+      (UINT8) (END_DEVICE_PATH_LENGTH),\r
+      (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)\r
+    }\r
+  }\r
+};\r
+\r
+/**\r
+  Convert the IPv4 address into a dotted string.\r
+\r
+  @param[in]   Ip   The IPv4 address.\r
+  @param[out]  Str  The dotted IP string.\r
+**/\r
 VOID\r
 IScsiIpToStr (\r
   IN  EFI_IPv4_ADDRESS  *Ip,\r
   OUT CHAR16            *Str\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Convert the IPv4 address into a dotted string.\r
-\r
-Arguments:\r
-\r
-  Ip  - The IPv4 address.\r
-  Str - The dotted IP string.\r
-\r
-Returns:\r
-\r
-  None.\r
-\r
---*/\r
 {\r
   UnicodeSPrint ( Str, 2 * IP4_STR_MAX_SIZE, L"%d.%d.%d.%d", Ip->Addr[0], Ip->Addr[1], Ip->Addr[2], Ip->Addr[3]);\r
 }\r
 \r
-VOID\r
-PopUpInvalidNotify (\r
-  IN CHAR16 *Warning\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Pop up an invalid notify which displays the message in Warning.\r
-\r
-Arguments:\r
-\r
-  Warning - The warning message.\r
-\r
-Returns:\r
-\r
-  None.\r
-\r
---*/\r
-{\r
-  EFI_INPUT_KEY             Key;\r
-\r
-  IfrLibCreatePopUp (1, &Key, Warning);\r
-}\r
+/**\r
+  Update the list of iSCSI devices the iSCSI driver is controlling.\r
 \r
+  @retval EFI_SUCCESS            The callback successfully handled the action.\r
+  @retval Others                 Other errors as indicated.   \r
+**/\r
 EFI_STATUS\r
 IScsiUpdateDeviceList (\r
   VOID\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Update the list of iSCSI devices the iSCSI driver is controlling.\r
-\r
-Arguments:\r
-\r
-  None.\r
-\r
-Returns:\r
-\r
-  None.\r
-\r
---*/\r
 {\r
   EFI_STATUS                  Status;\r
   ISCSI_DEVICE_LIST           *DeviceList;\r
@@ -108,19 +84,20 @@ Returns:
   UINTN                       HandleIndex;\r
   UINTN                       Index;\r
   UINTN                       LastDeviceIndex;\r
-  EFI_SIMPLE_NETWORK_PROTOCOL *Snp;\r
-  EFI_SIMPLE_NETWORK_MODE     *Mode;\r
+  EFI_MAC_ADDRESS             MacAddress;\r
+  UINTN                       HwAddressSize;\r
+  UINT16                      VlanId;\r
   ISCSI_MAC_INFO              *CurMacInfo;\r
   ISCSI_MAC_INFO              TempMacInfo;\r
-  CHAR16                      MacString[65];\r
+  CHAR16                      MacString[70];\r
   UINTN                       DeviceListSize;\r
 \r
   //\r
-  // Dump all the handles the Simple Network Protocol is installed on.\r
+  // Dump all the handles the Managed Network Service Binding Protocol is installed on.\r
   //\r
   Status = gBS->LocateHandleBuffer (\r
                   ByProtocol,\r
-                  &gEfiSimpleNetworkProtocolGuid,\r
+                  &gEfiManagedNetworkServiceBindingProtocolGuid,\r
                   NULL,\r
                   &NumHandles,\r
                   &Handles\r
@@ -138,7 +115,7 @@ Returns:
                   NULL\r
                   );\r
   if (Status == EFI_BUFFER_TOO_SMALL) {\r
-    DeviceList = (ISCSI_DEVICE_LIST *) NetAllocatePool (DataSize);\r
+    DeviceList = (ISCSI_DEVICE_LIST *) AllocatePool (DataSize);\r
 \r
     gRT->GetVariable (\r
           L"iSCSIDeviceList",\r
@@ -151,14 +128,15 @@ Returns:
     LastDeviceIndex = 0;\r
 \r
     for (HandleIndex = 0; HandleIndex < NumHandles; HandleIndex++) {\r
-      gBS->HandleProtocol (Handles[HandleIndex], &gEfiSimpleNetworkProtocolGuid, (VOID **)&Snp);\r
-\r
-      Mode = Snp->Mode;\r
+      Status = NetLibGetMacAddress (Handles[HandleIndex], &MacAddress, &HwAddressSize);\r
+      ASSERT (Status == EFI_SUCCESS);\r
+      VlanId = NetLibGetVlanId (Handles[HandleIndex]);\r
 \r
       for (Index = LastDeviceIndex; Index < DeviceList->NumDevice; Index++) {\r
         CurMacInfo = &DeviceList->MacInfo[Index];\r
-        if ((CurMacInfo->Len == Mode->HwAddressSize) &&\r
-            (NET_MAC_EQUAL (&CurMacInfo->Mac, &Mode->PermanentAddress, Mode->HwAddressSize))\r
+        if ((CurMacInfo->Len == HwAddressSize) &&\r
+            (CurMacInfo->VlanId == VlanId) &&\r
+            (NET_MAC_EQUAL (&CurMacInfo->Mac, MacAddress.Addr, HwAddressSize))\r
             ) {\r
           //\r
           // The previous configured NIC is still here.\r
@@ -168,9 +146,9 @@ Returns:
             // Swap the current MAC address entry with the one indexed by\r
             // LastDeviceIndex.\r
             //\r
-            NetCopyMem (&TempMacInfo, CurMacInfo, sizeof (ISCSI_MAC_INFO));\r
-            NetCopyMem (CurMacInfo, &DeviceList->MacInfo[LastDeviceIndex], sizeof (ISCSI_MAC_INFO));\r
-            NetCopyMem (&DeviceList->MacInfo[LastDeviceIndex], &TempMacInfo, sizeof (ISCSI_MAC_INFO));\r
+            CopyMem (&TempMacInfo, CurMacInfo, sizeof (ISCSI_MAC_INFO));\r
+            CopyMem (CurMacInfo, &DeviceList->MacInfo[LastDeviceIndex], sizeof (ISCSI_MAC_INFO));\r
+            CopyMem (&DeviceList->MacInfo[LastDeviceIndex], &TempMacInfo, sizeof (ISCSI_MAC_INFO));\r
           }\r
 \r
           LastDeviceIndex++;\r
@@ -187,30 +165,30 @@ Returns:
       // delete the variables\r
       //\r
       CurMacInfo = &DeviceList->MacInfo[Index];\r
-      IScsiMacAddrToStr (&CurMacInfo->Mac, CurMacInfo->Len, MacString);\r
+      IScsiMacAddrToStr (&CurMacInfo->Mac, CurMacInfo->Len, CurMacInfo->VlanId, MacString);\r
       gRT->SetVariable (MacString, &gEfiIScsiInitiatorNameProtocolGuid, 0, 0, NULL);\r
       gRT->SetVariable (MacString, &mIScsiCHAPAuthInfoGuid, 0, 0, NULL);\r
     }\r
 \r
-    NetFreePool (DeviceList);\r
+    FreePool (DeviceList);\r
   } else if (Status != EFI_NOT_FOUND) {\r
-    NetFreePool (Handles);\r
+    FreePool (Handles);\r
     return Status;\r
   }\r
   //\r
   // Construct the new iSCSI device list.\r
   //\r
   DeviceListSize        = sizeof (ISCSI_DEVICE_LIST) + (NumHandles - 1) * sizeof (ISCSI_MAC_INFO);\r
-  DeviceList            = (ISCSI_DEVICE_LIST *) NetAllocatePool (DeviceListSize);\r
+  DeviceList            = (ISCSI_DEVICE_LIST *) AllocatePool (DeviceListSize);\r
   DeviceList->NumDevice = (UINT8) NumHandles;\r
 \r
   for (Index = 0; Index < NumHandles; Index++) {\r
-    gBS->HandleProtocol (Handles[Index], &gEfiSimpleNetworkProtocolGuid, (VOID **)&Snp);\r
-    Mode        = Snp->Mode;\r
+    NetLibGetMacAddress (Handles[Index], &MacAddress, &HwAddressSize);\r
 \r
     CurMacInfo  = &DeviceList->MacInfo[Index];\r
-    NetCopyMem (&CurMacInfo->Mac, &Mode->PermanentAddress, Mode->HwAddressSize);\r
-    CurMacInfo->Len = (UINT8) Mode->HwAddressSize;\r
+    CopyMem (&CurMacInfo->Mac, MacAddress.Addr, HwAddressSize);\r
+    CurMacInfo->Len = (UINT8) HwAddressSize;\r
+    CurMacInfo->VlanId = NetLibGetVlanId (Handles[Index]);\r
   }\r
 \r
   gRT->SetVariable (\r
@@ -221,34 +199,26 @@ Returns:
         DeviceList\r
         );\r
 \r
-  NetFreePool (DeviceList);\r
+  FreePool (DeviceList);\r
+  FreePool (Handles);\r
 \r
   return Status;\r
 }\r
 \r
-STATIC\r
+/**\r
+  Get the iSCSI configuration form entry by the index of the goto opcode actived.\r
+\r
+  @param[in]  Index The 0-based index of the goto opcode actived.\r
+\r
+  @return The iSCSI configuration form entry found.\r
+**/\r
 ISCSI_CONFIG_FORM_ENTRY *\r
 IScsiGetConfigFormEntryByIndex (\r
   IN UINT32 Index\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Get the iSCSI configuration form entry by the index of the goto opcode actived.\r
-\r
-Arguments:\r
-\r
-  Index - The 0-based index of the goto opcode actived.\r
-\r
-Returns:\r
-\r
-  The iSCSI configuration form entry found.\r
-\r
---*/\r
 {\r
   UINT32                  CurrentIndex;\r
-  NET_LIST_ENTRY          *Entry;\r
+  LIST_ENTRY              *Entry;\r
   ISCSI_CONFIG_FORM_ENTRY *ConfigFormEntry;\r
 \r
   CurrentIndex    = 0;\r
@@ -266,28 +236,17 @@ Returns:
   return ConfigFormEntry;\r
 }\r
 \r
-STATIC\r
+/**\r
+  Convert the iSCSI configuration data into the IFR data.\r
+\r
+  @param[in]   ConfigFormEntry The iSCSI configuration form entry.\r
+  @param[out]  IfrNvData       The IFR nv data.\r
+**/\r
 VOID\r
 IScsiConvertDeviceConfigDataToIfrNvData (\r
-  IN ISCSI_CONFIG_FORM_ENTRY  *ConfigFormEntry,\r
-  IN ISCSI_CONFIG_IFR_NVDATA  *IfrNvData\r
+  IN ISCSI_CONFIG_FORM_ENTRY      *ConfigFormEntry,\r
+  OUT ISCSI_CONFIG_IFR_NVDATA     *IfrNvData\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Convert the iSCSI configuration data into the IFR data.\r
-\r
-Arguments:\r
-\r
-  ConfigFormEntry - The iSCSI configuration form entry.\r
-  IfrNvData       - The IFR nv data.\r
-\r
-Returns:\r
-\r
-  None.\r
-\r
---*/\r
 {\r
   ISCSI_SESSION_CONFIG_NVDATA   *SessionConfigData;\r
   ISCSI_CHAP_AUTH_CONFIG_NVDATA *AuthConfigData;\r
@@ -324,7 +283,68 @@ Returns:
   IScsiAsciiStrToUnicodeStr (AuthConfigData->ReverseCHAPSecret, IfrNvData->ReverseCHAPSecret);\r
 }\r
 \r
-\r
+/**\r
+  This function allows the caller to request the current\r
+  configuration for one or more named elements. The resulting\r
+  string is in <ConfigAltResp> format. Any and all alternative\r
+  configuration strings shall also be appended to the end of the\r
+  current configuration string. If they are, they must appear\r
+  after the current configuration. They must contain the same\r
+  routing (GUID, NAME, PATH) as the current configuration string.\r
+  They must have an additional description indicating the type of\r
+  alternative configuration the string represents,\r
+  "ALTCFG=<StringToken>". That <StringToken> (when\r
+  converted from Hex UNICODE to binary) is a reference to a\r
+  string in the associated string pack.\r
+\r
+  @param[in] This       Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
+  @param[in] Request    A null-terminated Unicode string in\r
+                        <ConfigRequest> format. Note that this\r
+                        includes the routing information as well as\r
+                        the configurable name / value pairs. It is\r
+                        invalid for this string to be in\r
+                        <MultiConfigRequest> format.\r
+  @param[out] Progress  On return, points to a character in the\r
+                        Request string. Points to the string's null\r
+                        terminator if request was successful. Points\r
+                        to the most recent "&" before the first\r
+                        failing name / value pair (or the beginning\r
+                        of the string if the failure is in the first\r
+                        name / value pair) if the request was not\r
+                        successful.\r
+  @param[out] Results   A null-terminated Unicode string in\r
+                        <ConfigAltResp> format which has all values\r
+                        filled in for the names in the Request string.\r
+                        String to be allocated by the called function.\r
+\r
+  @retval EFI_SUCCESS             The Results string is filled with the\r
+                                  values corresponding to all requested\r
+                                  names.\r
+  @retval EFI_OUT_OF_RESOURCES    Not enough memory to store the\r
+                                  parts of the results that must be\r
+                                  stored awaiting possible future\r
+                                  protocols.\r
+  @retval EFI_INVALID_PARAMETER   For example, passing in a NULL\r
+                                  for the Request parameter\r
+                                  would result in this type of\r
+                                  error. In this case, the\r
+                                  Progress parameter would be\r
+                                  set to NULL. \r
+  @retval EFI_NOT_FOUND           Routing data doesn't match any\r
+                                  known driver. Progress set to the\r
+                                  first character in the routing header.\r
+                                  Note: There is no requirement that the\r
+                                  driver validate the routing data. It\r
+                                  must skip the <ConfigHdr> in order to\r
+                                  process the names.\r
+  @retval EFI_INVALID_PARAMETER   Illegal syntax. Progress set\r
+                                  to most recent & before the\r
+                                  error or the beginning of the\r
+                                  string.\r
+  @retval EFI_INVALID_PARAMETER   Unknown name. Progress points\r
+                                  to the & before the name in\r
+                                  question.Currently not implemented.\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 IScsiFormExtractConfig (\r
@@ -333,31 +353,6 @@ IScsiFormExtractConfig (
   OUT EFI_STRING                             *Progress,\r
   OUT EFI_STRING                             *Results\r
   )\r
-/*++\r
-\r
-  Routine Description:\r
-    This function allows a caller to extract the current configuration for one\r
-    or more named elements from the target driver.\r
-\r
-  Arguments:\r
-    This       - Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
-    Request    - A null-terminated Unicode string in <ConfigRequest> format.\r
-    Progress   - On return, points to a character in the Request string.\r
-                 Points to the string's null terminator if request was successful.\r
-                 Points to the most recent '&' before the first failing name/value\r
-                 pair (or the beginning of the string if the failure is in the\r
-                 first name/value pair) if the request was not successful.\r
-    Results    - A null-terminated Unicode string in <ConfigAltResp> format which\r
-                 has all values filled in for the names in the Request string.\r
-                 String to be allocated by the called function.\r
-\r
-  Returns:\r
-    EFI_SUCCESS           - The Results is filled with the requested values.\r
-    EFI_OUT_OF_RESOURCES  - Not enough memory to store the results.\r
-    EFI_INVALID_PARAMETER - Request is NULL, illegal syntax, or unknown name.\r
-    EFI_NOT_FOUND         - Routing data doesn't match any storage in this driver.\r
-\r
---*/\r
 {\r
   EFI_STATUS                       Status;\r
   CHAR8                            InitiatorName[ISCSI_NAME_IFR_MAX_SIZE];\r
@@ -366,6 +361,11 @@ IScsiFormExtractConfig (
   ISCSI_FORM_CALLBACK_INFO         *Private;\r
   EFI_HII_CONFIG_ROUTING_PROTOCOL  *HiiConfigRouting;\r
 \r
+  if (Request == NULL || Progress == NULL || Results == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  *Progress = Request;\r
+\r
   if (!mIScsiDeviceListUpdated) {\r
     //\r
     // Update the device list.\r
@@ -402,10 +402,43 @@ IScsiFormExtractConfig (
                                Results,\r
                                Progress\r
                                );\r
-  NetFreePool (IfrNvData);\r
+  FreePool (IfrNvData);\r
   return Status;\r
 }\r
 \r
+/**\r
+  This function applies changes in a driver's configuration.\r
+  Input is a Configuration, which has the routing data for this\r
+  driver followed by name / value configuration pairs. The driver\r
+  must apply those pairs to its configurable storage. If the\r
+  driver's configuration is stored in a linear block of data\r
+  and the driver's name / value pairs are in <BlockConfig>\r
+  format, it may use the ConfigToBlock helper function (above) to\r
+  simplify the job. Currently not implemented.\r
+\r
+  @param[in]  This           Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
+  @param[in]  Configuration  A null-terminated Unicode string in\r
+                             <ConfigString> format.   \r
+  @param[out] Progress       A pointer to a string filled in with the\r
+                             offset of the most recent '&' before the\r
+                             first failing name / value pair (or the\r
+                             beginn ing of the string if the failure\r
+                             is in the first name / value pair) or\r
+                             the terminating NULL if all was\r
+                             successful.\r
+\r
+  @retval EFI_SUCCESS             The results have been distributed or are\r
+                                  awaiting distribution.  \r
+  @retval EFI_OUT_OF_RESOURCES    Not enough memory to store the\r
+                                  parts of the results that must be\r
+                                  stored awaiting possible future\r
+                                  protocols.\r
+  @retval EFI_INVALID_PARAMETERS  Passing in a NULL for the\r
+                                  Results parameter would result\r
+                                  in this type of error.\r
+  @retval EFI_NOT_FOUND           Target for the specified routing data\r
+                                  was not found.\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 IScsiFormRouteConfig (\r
@@ -413,60 +446,60 @@ IScsiFormRouteConfig (
   IN  CONST EFI_STRING                       Configuration,\r
   OUT EFI_STRING                             *Progress\r
   )\r
-/*++\r
-\r
-  Routine Description:\r
-    This function processes the results of changes in configuration.\r
-\r
-  Arguments:\r
-    This          - Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
-    Configuration - A null-terminated Unicode string in <ConfigResp> format.\r
-    Progress      - A pointer to a string filled in with the offset of the most\r
-                    recent '&' before the first failing name/value pair (or the\r
-                    beginning of the string if the failure is in the first\r
-                    name/value pair) or the terminating NULL if all was successful.\r
+{\r
+  if (Configuration == NULL || Progress == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
 \r
-  Returns:\r
-    EFI_SUCCESS           - The Results is processed successfully.\r
-    EFI_INVALID_PARAMETER - Configuration is NULL.\r
-    EFI_NOT_FOUND         - Routing data doesn't match any storage in this driver.\r
+  //\r
+  // Check routing data in <ConfigHdr>.\r
+  // Note: if only one Storage is used, then this checking could be skipped.\r
+  //\r
+  if (!HiiIsConfigHdrMatch (Configuration, &mVendorGuid, mVendorStorageName)) {\r
+    *Progress = Configuration;\r
+    return EFI_NOT_FOUND;\r
+  }\r
 \r
---*/\r
-{\r
+  *Progress = Configuration + StrLen (Configuration);\r
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  This function is called to provide results data to the driver.\r
+  This data consists of a unique key that is used to identify\r
+  which data is either being passed back or being asked for.\r
+\r
+  @param[in]  This               Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
+  @param[in]  Action             Specifies the type of action taken by the browser.\r
+  @param[in]  QuestionId         A unique value which is sent to the original\r
+                                 exporting driver so that it can identify the type\r
+                                 of data to expect. The format of the data tends to \r
+                                 vary based on the opcode that enerated the callback.\r
+  @param[in]  Type               The type of value for the question.\r
+  @param[in]  Value              A pointer to the data being sent to the original\r
+                                 exporting driver.\r
+  @param[out]  ActionRequest     On return, points to the action requested by the\r
+                                 callback function.\r
+\r
+  @retval EFI_SUCCESS            The callback successfully handled the action.\r
+  @retval EFI_OUT_OF_RESOURCES   Not enough storage is available to hold the\r
+                                 variable and its data.\r
+  @retval EFI_DEVICE_ERROR       The variable could not be saved.\r
+  @retval EFI_UNSUPPORTED        The specified Action is not supported by the\r
+                                 callback.Currently not implemented.\r
+  @retval EFI_INVALID_PARAMETERS Passing in wrong parameter. \r
+  @retval Others                 Other errors as indicated. \r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 IScsiFormCallback (\r
   IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,\r
   IN  EFI_BROWSER_ACTION                     Action,\r
-  IN  EFI_QUESTION_ID                        KeyValue,\r
+  IN  EFI_QUESTION_ID                        QuestionId,\r
   IN  UINT8                                  Type,\r
   IN  EFI_IFR_TYPE_VALUE                     *Value,\r
   OUT EFI_BROWSER_ACTION_REQUEST             *ActionRequest\r
   )\r
-/*++\r
-\r
-  Routine Description:\r
-    This function processes the results of changes in configuration.\r
-\r
-  Arguments:\r
-    This          - Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
-    Action        - Specifies the type of action taken by the browser.\r
-    QuestionId    - A unique value which is sent to the original exporting driver\r
-                    so that it can identify the type of data to expect.\r
-    Type          - The type of value for the question.\r
-    Value         - A pointer to the data being sent to the original exporting driver.\r
-    ActionRequest - On return, points to the action requested by the callback function.\r
-\r
-  Returns:\r
-    EFI_SUCCESS          - The callback successfully handled the action.\r
-    EFI_OUT_OF_RESOURCES - Not enough storage is available to hold the variable and its data.\r
-    EFI_DEVICE_ERROR     - The variable could not be saved.\r
-    EFI_UNSUPPORTED      - The specified Action is not supported by the callback.\r
-\r
---*/\r
 {\r
   ISCSI_FORM_CALLBACK_INFO  *Private;\r
   UINTN                     BufferSize;\r
@@ -475,36 +508,37 @@ IScsiFormCallback (
   CHAR8                     Ip4String[IP4_STR_MAX_SIZE];\r
   CHAR8                     LunString[ISCSI_LUN_STR_MAX_LEN];\r
   UINT64                    Lun;\r
-  STRING_REF                DeviceFormTitleToken;\r
+  EFI_STRING_ID             DeviceFormTitleToken;\r
   ISCSI_CONFIG_IFR_NVDATA   *IfrNvData;\r
   ISCSI_CONFIG_FORM_ENTRY   *ConfigFormEntry;\r
   EFI_IP_ADDRESS            HostIp;\r
   EFI_IP_ADDRESS            SubnetMask;\r
   EFI_IP_ADDRESS            Gateway;\r
   EFI_STATUS                Status;\r
+  EFI_INPUT_KEY             Key;\r
 \r
   Private   = ISCSI_FORM_CALLBACK_INFO_FROM_FORM_CALLBACK (This);\r
 \r
   //\r
   // Retrive uncommitted data from Browser\r
   //\r
-  BufferSize = sizeof (ISCSI_CONFIG_IFR_NVDATA);\r
-  IfrNvData = AllocateZeroPool (BufferSize);\r
+  IfrNvData = AllocateZeroPool (sizeof (ISCSI_CONFIG_IFR_NVDATA));\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
+  if (!HiiGetBrowserData (&mVendorGuid, mVendorStorageName, sizeof (ISCSI_CONFIG_IFR_NVDATA), (UINT8 *) IfrNvData)) {\r
+    FreePool (IfrNvData);\r
+    return EFI_NOT_FOUND;\r
   }\r
+  \r
+  Status = EFI_SUCCESS;\r
 \r
-  switch (KeyValue) {\r
+  switch (QuestionId) {\r
   case KEY_INITIATOR_NAME:\r
     IScsiUnicodeStrToAsciiStr (IfrNvData->InitiatorName, IScsiName);\r
     BufferSize  = AsciiStrLen (IScsiName) + 1;\r
 \r
     Status      = gIScsiInitiatorName.Set (&gIScsiInitiatorName, &BufferSize, IScsiName);\r
     if (EFI_ERROR (Status)) {\r
-      PopUpInvalidNotify (L"Invalid iSCSI Name!");\r
+      CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid iSCSI Name!", NULL);\r
     }\r
 \r
     break;\r
@@ -512,11 +546,11 @@ IScsiFormCallback (
   case KEY_LOCAL_IP:\r
     IScsiUnicodeStrToAsciiStr (IfrNvData->LocalIp, Ip4String);\r
     Status = IScsiAsciiStrToIp (Ip4String, &HostIp.v4);\r
-    if (EFI_ERROR (Status) || !Ip4IsUnicast (NTOHL (HostIp.Addr[0]), 0)) {\r
-      PopUpInvalidNotify (L"Invalid IP address!");\r
+    if (EFI_ERROR (Status) || !NetIp4IsUnicast (NTOHL (HostIp.Addr[0]), 0)) {\r
+      CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid IP address!", NULL);\r
       Status = EFI_INVALID_PARAMETER;\r
     } else {\r
-      NetCopyMem (&Private->Current->SessionConfigData.LocalIp, &HostIp.v4, sizeof (HostIp.v4));\r
+      CopyMem (&Private->Current->SessionConfigData.LocalIp, &HostIp.v4, sizeof (HostIp.v4));\r
     }\r
 \r
     break;\r
@@ -525,10 +559,10 @@ IScsiFormCallback (
     IScsiUnicodeStrToAsciiStr (IfrNvData->SubnetMask, Ip4String);\r
     Status = IScsiAsciiStrToIp (Ip4String, &SubnetMask.v4);\r
     if (EFI_ERROR (Status) || ((SubnetMask.Addr[0] != 0) && (IScsiGetSubnetMaskPrefixLength (&SubnetMask.v4) == 0))) {\r
-      PopUpInvalidNotify (L"Invalid Subnet Mask!");\r
+      CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Subnet Mask!", NULL);\r
       Status = EFI_INVALID_PARAMETER;\r
     } else {\r
-      NetCopyMem (&Private->Current->SessionConfigData.SubnetMask, &SubnetMask.v4, sizeof (SubnetMask.v4));\r
+      CopyMem (&Private->Current->SessionConfigData.SubnetMask, &SubnetMask.v4, sizeof (SubnetMask.v4));\r
     }\r
 \r
     break;\r
@@ -536,11 +570,11 @@ IScsiFormCallback (
   case KEY_GATE_WAY:\r
     IScsiUnicodeStrToAsciiStr (IfrNvData->Gateway, Ip4String);\r
     Status = IScsiAsciiStrToIp (Ip4String, &Gateway.v4);\r
-    if (EFI_ERROR (Status) || ((Gateway.Addr[0] != 0) && !Ip4IsUnicast (NTOHL (Gateway.Addr[0]), 0))) {\r
-      PopUpInvalidNotify (L"Invalid Gateway!");\r
+    if (EFI_ERROR (Status) || ((Gateway.Addr[0] != 0) && !NetIp4IsUnicast (NTOHL (Gateway.Addr[0]), 0))) {\r
+      CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Gateway!", NULL);\r
       Status = EFI_INVALID_PARAMETER;\r
     } else {\r
-      NetCopyMem (&Private->Current->SessionConfigData.Gateway, &Gateway.v4, sizeof (Gateway.v4));\r
+      CopyMem (&Private->Current->SessionConfigData.Gateway, &Gateway.v4, sizeof (Gateway.v4));\r
     }\r
 \r
     break;\r
@@ -548,11 +582,11 @@ IScsiFormCallback (
   case KEY_TARGET_IP:\r
     IScsiUnicodeStrToAsciiStr (IfrNvData->TargetIp, Ip4String);\r
     Status = IScsiAsciiStrToIp (Ip4String, &HostIp.v4);\r
-    if (EFI_ERROR (Status) || !Ip4IsUnicast (NTOHL (HostIp.Addr[0]), 0)) {\r
-      PopUpInvalidNotify (L"Invalid IP address!");\r
+    if (EFI_ERROR (Status) || !NetIp4IsUnicast (NTOHL (HostIp.Addr[0]), 0)) {\r
+      CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid IP address!", NULL);\r
       Status = EFI_INVALID_PARAMETER;\r
     } else {\r
-      NetCopyMem (&Private->Current->SessionConfigData.TargetIp, &HostIp.v4, sizeof (HostIp.v4));\r
+      CopyMem (&Private->Current->SessionConfigData.TargetIp, &HostIp.v4, sizeof (HostIp.v4));\r
     }\r
 \r
     break;\r
@@ -561,7 +595,7 @@ IScsiFormCallback (
     IScsiUnicodeStrToAsciiStr (IfrNvData->TargetName, IScsiName);\r
     Status = IScsiNormalizeName (IScsiName, AsciiStrLen (IScsiName));\r
     if (EFI_ERROR (Status)) {\r
-      PopUpInvalidNotify (L"Invalid iSCSI Name!");\r
+      CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid iSCSI Name!", NULL);\r
     } else {\r
       AsciiStrCpy (Private->Current->SessionConfigData.TargetName, IScsiName);\r
     }\r
@@ -579,9 +613,9 @@ IScsiFormCallback (
     IScsiUnicodeStrToAsciiStr (IfrNvData->BootLun, LunString);\r
     Status = IScsiAsciiStrToLun (LunString, (UINT8 *) &Lun);\r
     if (EFI_ERROR (Status)) {\r
-      PopUpInvalidNotify (L"Invalid LUN string!");\r
+      CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid LUN string!", NULL);\r
     } else {\r
-      NetCopyMem (Private->Current->SessionConfigData.BootLun, &Lun, sizeof (Lun));\r
+      CopyMem (Private->Current->SessionConfigData.BootLun, &Lun, sizeof (Lun));\r
     }\r
 \r
     break;\r
@@ -625,17 +659,17 @@ IScsiFormCallback (
       // deployed.\r
       //\r
       if (!Private->Current->SessionConfigData.InitiatorInfoFromDhcp) {\r
-        NetCopyMem (&HostIp.v4, &Private->Current->SessionConfigData.LocalIp, sizeof (HostIp.v4));\r
-        NetCopyMem (&SubnetMask.v4, &Private->Current->SessionConfigData.SubnetMask, sizeof (SubnetMask.v4));\r
-        NetCopyMem (&Gateway.v4, &Private->Current->SessionConfigData.Gateway, sizeof (Gateway.v4));\r
+        CopyMem (&HostIp.v4, &Private->Current->SessionConfigData.LocalIp, sizeof (HostIp.v4));\r
+        CopyMem (&SubnetMask.v4, &Private->Current->SessionConfigData.SubnetMask, sizeof (SubnetMask.v4));\r
+        CopyMem (&Gateway.v4, &Private->Current->SessionConfigData.Gateway, sizeof (Gateway.v4));\r
 \r
         if ((Gateway.Addr[0] != 0)) {\r
           if (SubnetMask.Addr[0] == 0) {\r
-            PopUpInvalidNotify (L"Gateway address is set but subnet mask is zero.");\r
+            CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Gateway address is set but subnet mask is zero.", NULL);\r
             Status = EFI_INVALID_PARAMETER;\r
             break;\r
           } else if (!IP4_NET_EQUAL (HostIp.Addr[0], Gateway.Addr[0], SubnetMask.Addr[0])) {\r
-            PopUpInvalidNotify (L"Local IP and Gateway are not in the same subnet.");\r
+            CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Local IP and Gateway are not in the same subnet.", NULL);\r
             Status = EFI_INVALID_PARAMETER;\r
             break;\r
           }\r
@@ -645,9 +679,9 @@ IScsiFormCallback (
       // Validate target configuration if DHCP isn't deployed.\r
       //\r
       if (!Private->Current->SessionConfigData.TargetInfoFromDhcp) {\r
-        NetCopyMem (&HostIp.v4, &Private->Current->SessionConfigData.TargetIp, sizeof (HostIp.v4));\r
-        if (!Ip4IsUnicast (NTOHL (HostIp.Addr[0]), 0)) {\r
-          PopUpInvalidNotify (L"Target IP is invalid!");\r
+        CopyMem (&HostIp.v4, &Private->Current->SessionConfigData.TargetIp, sizeof (HostIp.v4));\r
+        if (!NetIp4IsUnicast (NTOHL (HostIp.Addr[0]), 0)) {\r
+          CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Target IP is invalid!", NULL);\r
           Status = EFI_INVALID_PARAMETER;\r
           break;\r
         }\r
@@ -655,7 +689,7 @@ IScsiFormCallback (
 \r
       if (IfrNvData->CHAPType != ISCSI_CHAP_NONE) {\r
         if ((IfrNvData->CHAPName[0] == '\0') || (IfrNvData->CHAPSecret[0] == '\0')) {\r
-          PopUpInvalidNotify (L"CHAP Name or CHAP Secret is invalid!");\r
+          CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"CHAP Name or CHAP Secret is invalid!", NULL);\r
           Status = EFI_INVALID_PARAMETER;\r
           break;\r
         }\r
@@ -663,7 +697,7 @@ IScsiFormCallback (
         if ((IfrNvData->CHAPType == ISCSI_CHAP_MUTUAL) &&\r
             ((IfrNvData->ReverseCHAPName[0] == '\0') || (IfrNvData->ReverseCHAPSecret[0] == '\0'))\r
             ) {\r
-          PopUpInvalidNotify (L"Reverse CHAP Name or Reverse CHAP Secret is invalid!");\r
+          CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Reverse CHAP Name or Reverse CHAP Secret is invalid!", NULL);\r
           Status = EFI_INVALID_PARAMETER;\r
           break;\r
         }\r
@@ -691,16 +725,16 @@ IScsiFormCallback (
     break;\r
 \r
   default:\r
-    if ((KeyValue >= KEY_DEVICE_ENTRY_BASE) && (KeyValue < (mNumberOfIScsiDevices + KEY_DEVICE_ENTRY_BASE))) {\r
+    if ((QuestionId >= KEY_DEVICE_ENTRY_BASE) && (QuestionId < (mNumberOfIScsiDevices + KEY_DEVICE_ENTRY_BASE))) {\r
       //\r
       // In case goto the device configuration form, update the device form title.\r
       //\r
-      ConfigFormEntry = IScsiGetConfigFormEntryByIndex ((UINT32) (KeyValue - KEY_DEVICE_ENTRY_BASE));\r
+      ConfigFormEntry = IScsiGetConfigFormEntryByIndex ((UINT32) (QuestionId - KEY_DEVICE_ENTRY_BASE));\r
       ASSERT (ConfigFormEntry != NULL);\r
 \r
       UnicodeSPrint (PortString, (UINTN) 128, L"Port %s", ConfigFormEntry->MacString);\r
-      DeviceFormTitleToken = (STRING_REF) STR_ISCSI_DEVICE_FORM_TITLE;\r
-      IfrLibSetString (Private->RegisteredHandle, DeviceFormTitleToken, PortString);\r
+      DeviceFormTitleToken = (EFI_STRING_ID) STR_ISCSI_DEVICE_FORM_TITLE;\r
+      HiiSetString (Private->RegisteredHandle, DeviceFormTitleToken, PortString, NULL);\r
 \r
       IScsiConvertDeviceConfigDataToIfrNvData (ConfigFormEntry, IfrNvData);\r
 \r
@@ -714,51 +748,46 @@ 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
-  NetFreePool (IfrNvData);\r
+  FreePool (IfrNvData);\r
   return Status;\r
 }\r
 \r
+/**\r
+  Updates the iSCSI configuration form to add/delete an entry for the iSCSI\r
+  device specified by the Controller.\r
 \r
+  @param[in]  DriverBindingHandle The driverbinding handle.\r
+  @param[in]  Controller          The controller handle of the iSCSI device.\r
+  @param[in]  AddForm             Whether to add or delete a form entry.\r
+\r
+  @retval EFI_SUCCESS             The iSCSI configuration form is updated.\r
+  @retval EFI_OUT_OF_RESOURCES    Failed to allocate memory.\r
+  @retval Others                  Other errors as indicated.\r
+**/\r
 EFI_STATUS\r
 IScsiConfigUpdateForm (\r
   IN EFI_HANDLE  DriverBindingHandle,\r
   IN EFI_HANDLE  Controller,\r
   IN BOOLEAN     AddForm\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Updates the iSCSI configuration form to add/delete an entry for the iSCSI\r
-  device specified by the Controller.\r
-\r
-Arguments:\r
-\r
-  DriverBindingHandle - The driverbinding handle.\r
-  Controller          - The controller handle of the iSCSI device.\r
-  AddForm             - Whether to add or delete a form entry.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS          - The iSCSI configuration form is updated.\r
-  EFI_OUT_OF_RESOURCES - Failed to allocate memory.\r
-\r
---*/\r
 {\r
-  NET_LIST_ENTRY              *Entry;\r
+  LIST_ENTRY                  *Entry;\r
   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
+  EFI_MAC_ADDRESS             MacAddress;\r
+  UINTN                       HwAddressSize;\r
+  UINT16                      VlanId;\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
@@ -779,26 +808,22 @@ Returns:
       //\r
       // Add a new form.\r
       //\r
-      ConfigFormEntry = (ISCSI_CONFIG_FORM_ENTRY *) NetAllocateZeroPool (sizeof (ISCSI_CONFIG_FORM_ENTRY));\r
+      ConfigFormEntry = (ISCSI_CONFIG_FORM_ENTRY *) AllocateZeroPool (sizeof (ISCSI_CONFIG_FORM_ENTRY));\r
       if (ConfigFormEntry == NULL) {\r
         return EFI_OUT_OF_RESOURCES;\r
       }\r
 \r
-      NetListInit (&ConfigFormEntry->Link);\r
+      InitializeListHead (&ConfigFormEntry->Link);\r
       ConfigFormEntry->Controller = Controller;\r
 \r
       //\r
-      // Get the simple network protocol and convert the MAC address into\r
-      // the formatted string.\r
+      // Get the MAC address and convert it into the formatted string.\r
       //\r
-      Status = gBS->HandleProtocol (\r
-                      Controller,\r
-                      &gEfiSimpleNetworkProtocolGuid,\r
-                      (VOID **)&Snp\r
-                      );\r
+      Status = NetLibGetMacAddress (Controller, &MacAddress, &HwAddressSize);\r
       ASSERT (Status == EFI_SUCCESS);\r
+      VlanId = NetLibGetVlanId (Controller);\r
 \r
-      IScsiMacAddrToStr (&Snp->Mode->PermanentAddress, Snp->Mode->HwAddressSize, ConfigFormEntry->MacString);\r
+      IScsiMacAddrToStr (&MacAddress, (UINT32) HwAddressSize, VlanId, ConfigFormEntry->MacString);\r
 \r
       //\r
       // Get the normal session configuration data.\r
@@ -812,7 +837,7 @@ Returns:
                       &ConfigFormEntry->SessionConfigData\r
                       );\r
       if (EFI_ERROR (Status)) {\r
-        NetZeroMem (&ConfigFormEntry->SessionConfigData, sizeof (ConfigFormEntry->SessionConfigData));\r
+        ZeroMem (&ConfigFormEntry->SessionConfigData, sizeof (ConfigFormEntry->SessionConfigData));\r
       }\r
       //\r
       // Get the CHAP authentication configuration data.\r
@@ -826,91 +851,103 @@ Returns:
                       &ConfigFormEntry->AuthConfigData\r
                       );\r
       if (EFI_ERROR (Status)) {\r
-        NetZeroMem (&ConfigFormEntry->AuthConfigData, sizeof (ConfigFormEntry->AuthConfigData));\r
+        ZeroMem (&ConfigFormEntry->AuthConfigData, sizeof (ConfigFormEntry->AuthConfigData));\r
       }\r
       //\r
-      // Compose the Port string and create a new STRING_REF.\r
+      // Compose the Port string and create a new EFI_STRING_ID.\r
       //\r
       UnicodeSPrint (PortString, 128, L"Port %s", ConfigFormEntry->MacString);\r
-      IfrLibNewString (mCallbackInfo->RegisteredHandle, &ConfigFormEntry->PortTitleToken, PortString);\r
+      ConfigFormEntry->PortTitleToken = HiiSetString (mCallbackInfo->RegisteredHandle, 0, PortString, NULL);\r
 \r
       //\r
-      // Compose the help string of this port and create a new STRING_REF.\r
+      // Compose the help string of this port and create a new EFI_STRING_ID.\r
       //\r
       UnicodeSPrint (PortString, 128, L"Set the iSCSI parameters on port %s", ConfigFormEntry->MacString);\r
-      IfrLibNewString (mCallbackInfo->RegisteredHandle, &ConfigFormEntry->PortTitleHelpToken, PortString);\r
+      ConfigFormEntry->PortTitleHelpToken = HiiSetString (mCallbackInfo->RegisteredHandle, 0, PortString, NULL);\r
 \r
-      NetListInsertTail (&mIScsiConfigFormList, &ConfigFormEntry->Link);\r
+      InsertTailList (&mIScsiConfigFormList, &ConfigFormEntry->Link);\r
       mNumberOfIScsiDevices++;\r
     }\r
   } else {\r
     ASSERT (EntryExisted);\r
 \r
     mNumberOfIScsiDevices--;\r
-    NetListRemoveEntry (&ConfigFormEntry->Link);\r
-    NetFreePool (ConfigFormEntry);\r
+    RemoveEntryList (&ConfigFormEntry->Link);\r
+    FreePool (ConfigFormEntry);\r
   }\r
   //\r
   // Allocate space for creation of Buffer\r
   //\r
-  UpdateData.BufferSize = 0x1000;\r
-  UpdateData.Data = NetAllocateZeroPool (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
-  NetFreePool (UpdateData.Data);\r
+  HiiFreeOpCodeHandle (StartOpCodeHandle);\r
+  HiiFreeOpCodeHandle (EndOpCodeHandle);\r
 \r
   return EFI_SUCCESS;\r
 }\r
 \r
-EFI_STATUS\r
-IScsiConfigFormInit (\r
-  IN EFI_HANDLE  DriverBindingHandle\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
+/**\r
   Initialize the iSCSI configuration form.\r
 \r
-Arguments:\r
-\r
-  DriverBindingHandle - The iSCSI driverbinding handle.\r
-\r
-Returns:\r
+  @param[in]  DriverBindingHandle  The iSCSI driverbinding handle.\r
 \r
-  EFI_SUCCESS          - The iSCSI configuration form is initialized.\r
-  EFI_OUT_OF_RESOURCES - Failed to allocate memory.\r
-\r
---*/\r
+  @retval EFI_SUCCESS              The iSCSI configuration form is initialized.\r
+  @retval EFI_OUT_OF_RESOURCES     Failed to allocate memory.\r
+  @retval Others                   Other errors as indicated.\r
+**/\r
+EFI_STATUS\r
+IScsiConfigFormInit (\r
+  VOID\r
+  )\r
 {\r
   EFI_STATUS                  Status;\r
   EFI_HII_DATABASE_PROTOCOL   *HiiDatabase;\r
-  EFI_HII_PACKAGE_LIST_HEADER *PackageList;\r
   ISCSI_FORM_CALLBACK_INFO    *CallbackInfo;\r
 \r
   Status = gBS->LocateProtocol (&gEfiHiiDatabaseProtocolGuid, NULL, (VOID **)&HiiDatabase);\r
@@ -918,14 +955,14 @@ Returns:
     return Status;\r
   }\r
 \r
-  CallbackInfo = (ISCSI_FORM_CALLBACK_INFO *) NetAllocatePool (sizeof (ISCSI_FORM_CALLBACK_INFO));\r
+  CallbackInfo = (ISCSI_FORM_CALLBACK_INFO *) AllocateZeroPool (sizeof (ISCSI_FORM_CALLBACK_INFO));\r
   if (CallbackInfo == NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
 \r
-  CallbackInfo->Signature             = ISCSI_FORM_CALLBACK_INFO_SIGNATURE;\r
+  CallbackInfo->Signature   = ISCSI_FORM_CALLBACK_INFO_SIGNATURE;\r
   CallbackInfo->HiiDatabase = HiiDatabase;\r
-  CallbackInfo->Current               = NULL;\r
+  CallbackInfo->Current     = NULL;\r
 \r
   CallbackInfo->ConfigAccess.ExtractConfig = IScsiFormExtractConfig;\r
   CallbackInfo->ConfigAccess.RouteConfig = IScsiFormRouteConfig;\r
@@ -933,43 +970,36 @@ Returns:
 \r
   Status = gBS->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid, NULL, (VOID **)&CallbackInfo->ConfigRouting);\r
   if (EFI_ERROR (Status)) {\r
+    FreePool(CallbackInfo);\r
     return Status;\r
   }\r
 \r
   //\r
-  // Create driver handle used by HII database\r
-  //\r
-  Status = HiiLibCreateHiiDriverHandle (&CallbackInfo->DriverHandle);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  \r
-  //\r
-  // Install Config Access protocol to driver handle\r
+  // Install Device Path Protocol and Config Access protocol to driver handle\r
   //\r
-  Status = gBS->InstallProtocolInterface (\r
+  Status = gBS->InstallMultipleProtocolInterfaces (\r
                   &CallbackInfo->DriverHandle,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  &mIScsiHiiVendorDevicePath,\r
                   &gEfiHiiConfigAccessProtocolGuid,\r
-                  EFI_NATIVE_INTERFACE,\r
-                  &CallbackInfo->ConfigAccess\r
+                  &CallbackInfo->ConfigAccess,\r
+                  NULL\r
                   );\r
   ASSERT_EFI_ERROR (Status);\r
   \r
   //\r
   // Publish our HII data\r
   //\r
-  PackageList = PreparePackageList (2, &mVendorGuid, IScsiDxeStrings, IScsiConfigDxeBin);\r
-  ASSERT (PackageList != NULL);\r
-  \r
-  Status = HiiDatabase->NewPackageList (\r
-                           HiiDatabase,\r
-                           PackageList,\r
-                           CallbackInfo->DriverHandle,\r
-                           &CallbackInfo->RegisteredHandle\r
-                           );\r
-  NetFreePool (PackageList);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
+  CallbackInfo->RegisteredHandle = HiiAddPackages (\r
+                                     &mVendorGuid,\r
+                                     CallbackInfo->DriverHandle,\r
+                                     IScsiDxeStrings,\r
+                                     IScsiConfigDxeBin,\r
+                                     NULL\r
+                                     );\r
+  if (CallbackInfo->RegisteredHandle == NULL) {\r
+    FreePool(CallbackInfo);\r
+    return EFI_OUT_OF_RESOURCES;\r
   }\r
 \r
   mCallbackInfo = CallbackInfo;\r
@@ -977,32 +1007,24 @@ Returns:
   return Status;\r
 }\r
 \r
-EFI_STATUS\r
-IScsiConfigFormUnload (\r
-  IN EFI_HANDLE  DriverBindingHandle\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
+/**\r
   Unload the iSCSI configuration form, this includes: delete all the iSCSI\r
   device configuration entries, uninstall the form callback protocol and\r
   free the resources used.\r
 \r
-Arguments:\r
-\r
-  DriverBindingHandle - The iSCSI driverbinding handle.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS          - The iSCSI configuration form is unloaded.\r
-  EFI_OUT_OF_RESOURCES - Failed to allocate memory.\r
-\r
---*/\r
+  @param[in]  DriverBindingHandle The iSCSI driverbinding handle.\r
+  \r
+  @retval EFI_SUCCESS             The iSCSI configuration form is unloaded.\r
+  @retval EFI_OUT_OF_RESOURCES    Failed to allocate memory.\r
+**/\r
+EFI_STATUS\r
+IScsiConfigFormUnload (\r
+  IN EFI_HANDLE  DriverBindingHandle\r
+  )\r
 {\r
   ISCSI_CONFIG_FORM_ENTRY     *ConfigFormEntry;\r
 \r
-  while (!NetListIsEmpty (&mIScsiConfigFormList)) {\r
+  while (!IsListEmpty (&mIScsiConfigFormList)) {\r
     //\r
     // Uninstall the device forms as the iSCSI driver instance may fail to\r
     // control the controller but still install the device configuration form.\r
@@ -1025,14 +1047,15 @@ Returns:
   //\r
   // Uninstall EFI_HII_CONFIG_ACCESS_PROTOCOL\r
   //\r
-  gBS->UninstallProtocolInterface (\r
-        mCallbackInfo->DriverHandle,\r
-        &gEfiHiiConfigAccessProtocolGuid,\r
-        &mCallbackInfo->ConfigAccess\r
-        );\r
-  HiiLibDestroyHiiDriverHandle (mCallbackInfo->DriverHandle);\r
-\r
-  NetFreePool (mCallbackInfo);\r
+  gBS->UninstallMultipleProtocolInterfaces (\r
+         mCallbackInfo->DriverHandle,\r
+         &gEfiDevicePathProtocolGuid,\r
+         &mIScsiHiiVendorDevicePath,\r
+         &gEfiHiiConfigAccessProtocolGuid,\r
+         &mCallbackInfo->ConfigAccess,\r
+         NULL\r
+         );\r
+  FreePool (mCallbackInfo);\r
 \r
   return EFI_SUCCESS;\r
 }\r