Update for NetworkPkg.
[mirror_edk2.git] / NetworkPkg / IScsiDxe / IScsiConfig.c
index d347d8d..eea73a8 100644 (file)
@@ -1605,14 +1605,6 @@ IScsiConfigProcessDefault (
   UINTN                       TotalNumber;\r
   UINTN                       Index;\r
 \r
-  //\r
-  // Free any attempt that is previously created but not saved to system.\r
-  //\r
-  if (mPrivate->NewAttempt != NULL) {\r
-    FreePool (mPrivate->NewAttempt);\r
-    mPrivate->NewAttempt = NULL;\r
-  }\r
-\r
   //\r
   // Is User creating a new attempt?\r
   //\r
@@ -1637,6 +1629,14 @@ IScsiConfigProcessDefault (
     //\r
     return EFI_SUCCESS;\r
   }\r
+  \r
+  //\r
+  // Free any attempt that is previously created but not saved to system.\r
+  //\r
+  if (mPrivate->NewAttempt != NULL) {\r
+    FreePool (mPrivate->NewAttempt);\r
+    mPrivate->NewAttempt = NULL;\r
+  }\r
 \r
   if (NewAttempt) {\r
     //\r
@@ -2103,37 +2103,75 @@ IScsiFormCallback (
     return EFI_SUCCESS;\r
   }\r
 \r
-  if (Action == EFI_BROWSER_ACTION_CHANGING) {\r
-    if (This == NULL || Value == NULL || ActionRequest == NULL) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
-    Private = ISCSI_FORM_CALLBACK_INFO_FROM_FORM_CALLBACK (This);\r
-\r
+  if ((Action != EFI_BROWSER_ACTION_CHANGING) && (Action != EFI_BROWSER_ACTION_CHANGED)) {\r
     //\r
-    // Retrieve uncommitted data from Browser\r
+    // All other type return unsupported.\r
     //\r
+    return EFI_UNSUPPORTED;\r
+  }\r
 \r
-    BufferSize = sizeof (ISCSI_CONFIG_IFR_NVDATA);\r
-    IfrNvData = AllocateZeroPool (BufferSize);\r
-    if (IfrNvData == NULL) {\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-\r
-    IScsiName = (CHAR8 *) AllocateZeroPool (ISCSI_NAME_MAX_SIZE);\r
-    if (IScsiName == NULL) {\r
-      FreePool (IfrNvData);\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-\r
-    Status = EFI_SUCCESS;\r
+  if ((Value == NULL) || (ActionRequest == NULL)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
 \r
-    ZeroMem (&OldIfrNvData, BufferSize);\r
+  Private = ISCSI_FORM_CALLBACK_INFO_FROM_FORM_CALLBACK (This);\r
+  \r
+  //\r
+  // Retrieve uncommitted data from Browser\r
+  //\r
+  \r
+  BufferSize = sizeof (ISCSI_CONFIG_IFR_NVDATA);\r
+  IfrNvData = AllocateZeroPool (BufferSize);\r
+  if (IfrNvData == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+  \r
+  IScsiName = (CHAR8 *) AllocateZeroPool (ISCSI_NAME_MAX_SIZE);\r
+  if (IScsiName == NULL) {\r
+    FreePool (IfrNvData);\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+  \r
+  Status = EFI_SUCCESS;\r
+  \r
+  ZeroMem (&OldIfrNvData, BufferSize);\r
+  \r
+  HiiGetBrowserData (NULL, NULL, BufferSize, (UINT8 *) IfrNvData);\r
+  \r
+  CopyMem (&OldIfrNvData, IfrNvData, BufferSize);\r
 \r
-    HiiGetBrowserData (NULL, NULL, BufferSize, (UINT8 *) IfrNvData);\r
+  if (Action == EFI_BROWSER_ACTION_CHANGING) {\r
+    switch (QuestionId) {\r
+    case KEY_ADD_ATTEMPT:\r
+      Status = IScsiConfigAddAttempt ();\r
+      break;\r
 \r
-    CopyMem (&OldIfrNvData, IfrNvData, BufferSize);\r
+    case KEY_DELETE_ATTEMPT:\r
+      CopyMem (\r
+        OldIfrNvData.DeleteAttemptList,\r
+        IfrNvData->DeleteAttemptList,\r
+        sizeof (IfrNvData->DeleteAttemptList)\r
+        );\r
+      Status = IScsiConfigDisplayDeleteAttempts (IfrNvData);\r
+      break;\r
 \r
+    case KEY_ORDER_ATTEMPT_CONFIG:\r
+      //\r
+      // Order the attempt according to user input.\r
+      //\r
+      CopyMem (\r
+        OldIfrNvData.DynamicOrderedList,\r
+        IfrNvData->DynamicOrderedList,\r
+        sizeof (IfrNvData->DynamicOrderedList)\r
+        );\r
+      IScsiConfigDisplayOrderAttempts ();\r
+      break;\r
+    \r
+    default:\r
+      Status = IScsiConfigProcessDefault (QuestionId, IfrNvData);\r
+      break;\r
+    }\r
+  } else if (Action == EFI_BROWSER_ACTION_CHANGED) {  \r
     switch (QuestionId) {\r
     case KEY_INITIATOR_NAME:\r
       UnicodeStrToAsciiStr (IfrNvData->InitiatorName, IScsiName);\r
@@ -2151,54 +2189,34 @@ IScsiFormCallback (
 \r
       *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;\r
       break;\r
+    case KEY_ATTEMPT_NAME:\r
+      if (StrLen (IfrNvData->AttemptName) > ATTEMPT_NAME_SIZE) {\r
+        CopyMem (AttemptName, IfrNvData->AttemptName, ATTEMPT_NAME_SIZE * sizeof (CHAR16));\r
+        CopyMem (&AttemptName[ATTEMPT_NAME_SIZE], L"...", 4 * sizeof (CHAR16));\r
+      } else {\r
+        CopyMem (\r
+          AttemptName,\r
+          IfrNvData->AttemptName,\r
+          (StrLen (IfrNvData->AttemptName) + 1) * sizeof (CHAR16)\r
+          );\r
+      }\r
 \r
-    case KEY_ADD_ATTEMPT:\r
-      Status = IScsiConfigAddAttempt ();\r
-      break;\r
+      UnicodeStrToAsciiStr (IfrNvData->AttemptName, Private->Current->AttemptName);\r
 \r
-    case KEY_DELETE_ATTEMPT:\r
-      CopyMem (\r
-        OldIfrNvData.DeleteAttemptList,\r
-        IfrNvData->DeleteAttemptList,\r
-        sizeof (IfrNvData->DeleteAttemptList)\r
-        );\r
-      Status = IScsiConfigDisplayDeleteAttempts (IfrNvData);\r
-      break;\r
+      IScsiConfigUpdateAttempt ();\r
 \r
-    case KEY_SAVE_DELETE_ATTEMPT:\r
-      //\r
-      // Delete the Attempt Order from NVR\r
-      //\r
-      Status = IScsiConfigDeleteAttempts (IfrNvData);\r
+      *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;\r
+      break;\r
+      \r
+    case KEY_SAVE_ATTEMPT_CONFIG:\r
+      Status = IScsiConvertIfrNvDataToAttemptConfigData (IfrNvData, Private->Current);\r
       if (EFI_ERROR (Status)) {\r
         break;\r
       }\r
 \r
-      IScsiConfigUpdateAttempt ();\r
       *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;\r
       break;\r
 \r
-    case KEY_IGNORE_DELETE_ATTEMPT:\r
-      CopyMem (\r
-        IfrNvData->DeleteAttemptList,\r
-        OldIfrNvData.DeleteAttemptList,\r
-        sizeof (IfrNvData->DeleteAttemptList)\r
-        );\r
-      *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD;\r
-      break;\r
-\r
-    case KEY_ORDER_ATTEMPT_CONFIG:\r
-      //\r
-      // Order the attempt according to user input.\r
-      //\r
-      CopyMem (\r
-        OldIfrNvData.DynamicOrderedList,\r
-        IfrNvData->DynamicOrderedList,\r
-        sizeof (IfrNvData->DynamicOrderedList)\r
-        );\r
-      IScsiConfigDisplayOrderAttempts ();\r
-      break;\r
-\r
     case KEY_SAVE_ORDER_CHANGES:\r
       //\r
       // Sync the Attempt Order to NVR.\r
@@ -2209,7 +2227,7 @@ IScsiFormCallback (
       }\r
 \r
       IScsiConfigUpdateAttempt ();\r
-      *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;\r
+      *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT;\r
       break;\r
 \r
     case KEY_IGNORE_ORDER_CHANGES:\r
@@ -2218,26 +2236,29 @@ IScsiFormCallback (
         OldIfrNvData.DynamicOrderedList,\r
         sizeof (IfrNvData->DynamicOrderedList)\r
         );\r
-      *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD;\r
+      *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT;\r
       break;\r
 \r
-    case KEY_ATTEMPT_NAME:\r
-      if (StrLen (IfrNvData->AttemptName) > ATTEMPT_NAME_SIZE) {\r
-        CopyMem (AttemptName, IfrNvData->AttemptName, ATTEMPT_NAME_SIZE * sizeof (CHAR16));\r
-        CopyMem (&AttemptName[ATTEMPT_NAME_SIZE], L"...", 4 * sizeof (CHAR16));\r
-      } else {\r
-        CopyMem (\r
-          AttemptName,\r
-          IfrNvData->AttemptName,\r
-          (StrLen (IfrNvData->AttemptName) + 1) * sizeof (CHAR16)\r
-          );\r
+    case KEY_SAVE_DELETE_ATTEMPT:\r
+      //\r
+      // Delete the Attempt Order from NVR\r
+      //\r
+      Status = IScsiConfigDeleteAttempts (IfrNvData);\r
+      if (EFI_ERROR (Status)) {\r
+        break;\r
       }\r
 \r
-      UnicodeStrToAsciiStr (IfrNvData->AttemptName, Private->Current->AttemptName);\r
-\r
       IScsiConfigUpdateAttempt ();\r
+      *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT;\r
+      break;\r
 \r
-      *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;\r
+    case KEY_IGNORE_DELETE_ATTEMPT:\r
+      CopyMem (\r
+        IfrNvData->DeleteAttemptList,\r
+        OldIfrNvData.DeleteAttemptList,\r
+        sizeof (IfrNvData->DeleteAttemptList)\r
+        );\r
+      *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT;\r
       break;\r
 \r
     case KEY_IP_MODE:\r
@@ -2409,38 +2430,23 @@ IScsiFormCallback (
 \r
       break;\r
 \r
-    case KEY_SAVE_ATTEMPT_CONFIG:\r
-      Status = IScsiConvertIfrNvDataToAttemptConfigData (IfrNvData, Private->Current);\r
-      if (EFI_ERROR (Status)) {\r
-        break;\r
-      }\r
-\r
-      *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;\r
-      break;\r
-\r
     default:\r
-      Status = IScsiConfigProcessDefault (QuestionId, IfrNvData);\r
       break;\r
     }\r
+  }\r
 \r
-    if (!EFI_ERROR (Status)) {\r
-      //\r
-      // Pass changed uncommitted data back to Form Browser.\r
-      //\r
-      BufferSize = sizeof (ISCSI_CONFIG_IFR_NVDATA);\r
-      HiiSetBrowserData (NULL, NULL, BufferSize, (UINT8 *) IfrNvData, NULL);\r
-    }\r
-\r
-    FreePool (IfrNvData);\r
-    FreePool (IScsiName);\r
-\r
-    return Status;\r
+  if (!EFI_ERROR (Status)) {\r
+    //\r
+    // Pass changed uncommitted data back to Form Browser.\r
+    //\r
+    BufferSize = sizeof (ISCSI_CONFIG_IFR_NVDATA);\r
+    HiiSetBrowserData (NULL, NULL, BufferSize, (UINT8 *) IfrNvData, NULL);\r
   }\r
 \r
-  //\r
-  // All other action return unsupported.\r
-  //\r
-  return EFI_UNSUPPORTED;\r
+  FreePool (IfrNvData);\r
+  FreePool (IScsiName);\r
+\r
+  return Status;\r
 }\r
 \r
 \r