]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/IScsiDxe/IScsiConfig.c
Set RTC initial time to be BIOS Release time.
[mirror_edk2.git] / NetworkPkg / IScsiDxe / IScsiConfig.c
index d347d8dc70c3c79afff7ddd625e81afe898b4c5c..c6b48c651bbf28f13a43c97b32faf8e200abc1f8 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Helper functions for configuring or getting the parameters relating to iSCSI.\r
 \r
-Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>\r
 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
@@ -541,7 +541,24 @@ IScsiConvertIfrNvDataToAttemptConfigData (
           );\r
         return EFI_INVALID_PARAMETER;\r
       }\r
+\r
+      //\r
+      // Validate iSCSI target name configuration again:\r
+      // The format of iSCSI target name is already verified in IScsiFormCallback() when\r
+      // user input the name; here we only check the case user does not input the name.\r
+      //\r
+      if (Attempt->SessionConfigData.TargetName[0] == '\0') {\r
+        CreatePopUp (\r
+          EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r
+          &Key,\r
+          L"iSCSI target name is NULL!",\r
+          NULL\r
+          );\r
+        return EFI_INVALID_PARAMETER;\r
+      }\r
     }\r
+\r
+\r
     //\r
     // Validate the authentication info.\r
     //\r
@@ -784,7 +801,7 @@ IScsiConvertIfrNvDataToAttemptConfigData (
     Status = gRT->SetVariable (\r
                     L"AttemptOrder",\r
                     &gIScsiConfigGuid,\r
-                    EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
+                    EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
                     AttemptConfigOrderSize,\r
                     AttemptConfigOrder\r
                     );\r
@@ -1246,8 +1263,7 @@ IScsiConfigDeleteAttempts (
     }\r
   }\r
 \r
-  Attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS\r
-              | EFI_VARIABLE_NON_VOLATILE;\r
+  Attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE;\r
 \r
   //\r
   // Update AttemptOrder in NVR.\r
@@ -1397,6 +1413,7 @@ IScsiConfigDisplayOrderAttempts (
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
+  ASSERT (StartOpCodeHandle != NULL);\r
 \r
   OptionsOpCodeHandle = NULL;\r
 \r
@@ -1557,7 +1574,7 @@ IScsiConfigOrderAttempts (
   Status = gRT->SetVariable (\r
                   L"AttemptOrder",\r
                   &gIScsiConfigGuid,\r
-                  EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
+                  EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
                   AttemptConfigOrderSize,\r
                   AttemptConfigOrderTmp\r
                   );\r
@@ -1605,14 +1622,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 +1646,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 +2120,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 +2206,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 +2244,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 +2253,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
@@ -2334,7 +2372,7 @@ IScsiFormCallback (
           &Key,\r
           L"Invalid iSCSI Name!",\r
           NULL\r
-          );       \r
+          );\r
       } else {\r
         AsciiStrCpy (Private->Current->SessionConfigData.TargetName, IScsiName);\r
       }\r
@@ -2409,38 +2447,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