]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c
sync comments, fix function header, rename variable name to follow coding style.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / IScsiDxe / IScsiConfig.c
index 494415211166af6abff29cdfd03ecd8342f07eb5..86e41ba1a1814342270bc6ebec2d31fc353012f6 100644 (file)
@@ -1,4 +1,5 @@
-/*++\r
+/** @file\r
+  Helper functions for configuring or getting the parameters relating to ISCSI\r
 \r
 Copyright (c) 2004 - 2008, Intel Corporation\r
 All rights reserved. This program and the accompanying materials\r
@@ -15,7 +16,9 @@ Module Name:
 \r
 Abstract:\r
 \r
---*/\r
+  Helper functions for configuring or getting the parameters relating to ISCSI\r
+\r
+**/\r
 \r
 #include "IScsiImpl.h"\r
 \r
@@ -29,76 +32,55 @@ LIST_ENTRY      mIScsiConfigFormList = {
   &mIScsiConfigFormList\r
 };\r
 \r
-STATIC\r
-VOID\r
-IScsiIpToStr (\r
-  IN  EFI_IPv4_ADDRESS  *Ip,\r
-  OUT CHAR16            *Str\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\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
+  @param  Ip[in]   The IPv4 address.\r
 \r
-Returns:\r
+  @param  Str[out] The dotted IP string.\r
 \r
-  None.\r
+  @retval None.\r
 \r
---*/\r
+**/\r
+VOID\r
+IScsiIpToStr (\r
+  IN  EFI_IPv4_ADDRESS  *Ip,\r
+  OUT CHAR16            *Str\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
+/**\r
   Pop up an invalid notify which displays the message in Warning.\r
 \r
-Arguments:\r
-\r
-  Warning - The warning message.\r
+  @param  Warning[in] The warning message.\r
 \r
-Returns:\r
+  @retval None.\r
 \r
-  None.\r
-\r
---*/\r
+**/\r
+VOID\r
+PopUpInvalidNotify (\r
+  IN CHAR16 *Warning\r
+  )\r
 {\r
   EFI_INPUT_KEY             Key;\r
 \r
   IfrLibCreatePopUp (1, &Key, Warning);\r
 }\r
 \r
-EFI_STATUS\r
-IScsiUpdateDeviceList (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
+/**\r
   Update the list of iSCSI devices the iSCSI driver is controlling.\r
 \r
-Arguments:\r
-\r
-  None.\r
+  @param  None.\r
 \r
-Returns:\r
+  @retval None.\r
 \r
-  None.\r
-\r
---*/\r
+**/\r
+EFI_STATUS\r
+IScsiUpdateDeviceList (\r
+  VOID\r
+  )\r
 {\r
   EFI_STATUS                  Status;\r
   ISCSI_DEVICE_LIST           *DeviceList;\r
@@ -222,30 +204,23 @@ Returns:
         );\r
 \r
   gBS->FreePool (DeviceList);\r
+  gBS->FreePool (Handles);\r
 \r
   return Status;\r
 }\r
 \r
-STATIC\r
-ISCSI_CONFIG_FORM_ENTRY *\r
-IScsiGetConfigFormEntryByIndex (\r
-  IN UINT32 Index\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\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
+  @param  Index[in] The 0-based index of the goto opcode actived.\r
 \r
-  The iSCSI configuration form entry found.\r
+  @retval The iSCSI configuration form entry found.\r
 \r
---*/\r
+**/\r
+ISCSI_CONFIG_FORM_ENTRY *\r
+IScsiGetConfigFormEntryByIndex (\r
+  IN UINT32 Index\r
+  )\r
 {\r
   UINT32                  CurrentIndex;\r
   LIST_ENTRY              *Entry;\r
@@ -266,28 +241,21 @@ Returns:
   return ConfigFormEntry;\r
 }\r
 \r
-STATIC\r
-VOID\r
-IScsiConvertDeviceConfigDataToIfrNvData (\r
-  IN ISCSI_CONFIG_FORM_ENTRY  *ConfigFormEntry,\r
-  IN ISCSI_CONFIG_IFR_NVDATA  *IfrNvData\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\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
+  @param  ConfigFormEntry[in] The iSCSI configuration form entry.\r
 \r
-Returns:\r
+  @param  IfrNvData[in]       The IFR nv data.\r
 \r
-  None.\r
+  @retval None.\r
 \r
---*/\r
+**/\r
+VOID\r
+IScsiConvertDeviceConfigDataToIfrNvData (\r
+  IN ISCSI_CONFIG_FORM_ENTRY  *ConfigFormEntry,\r
+  IN ISCSI_CONFIG_IFR_NVDATA  *IfrNvData\r
+  )\r
 {\r
   ISCSI_SESSION_CONFIG_NVDATA   *SessionConfigData;\r
   ISCSI_CHAP_AUTH_CONFIG_NVDATA *AuthConfigData;\r
@@ -324,7 +292,33 @@ Returns:
   IScsiAsciiStrToUnicodeStr (AuthConfigData->ReverseCHAPSecret, IfrNvData->ReverseCHAPSecret);\r
 }\r
 \r
+/**\r
+  This function allows a caller to extract the current configuration for one\r
+  or more named elements from the target driver.\r
+\r
+  @param  This[in]              Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
+\r
+  @param  Request[in]           A null-terminated Unicode string in <ConfigRequest> format.\r
+\r
+  @param  Progress[out]         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
 \r
+  @param  Results[out]          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
+  @retval EFI_SUCCESS           The Results is filled with the requested values.\r
+\r
+  @retval EFI_OUT_OF_RESOURCES  Not enough memory to store the results.\r
+\r
+  @retval EFI_INVALID_PARAMETER Request is NULL, illegal syntax, or unknown name.\r
+\r
+  @retval EFI_NOT_FOUND         Routing data doesn't match any storage in this driver.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 IScsiFormExtractConfig (\r
@@ -333,31 +327,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 +335,10 @@ IScsiFormExtractConfig (
   ISCSI_FORM_CALLBACK_INFO         *Private;\r
   EFI_HII_CONFIG_ROUTING_PROTOCOL  *HiiConfigRouting;\r
 \r
+  if (Request == NULL) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
   if (!mIScsiDeviceListUpdated) {\r
     //\r
     // Update the device list.\r
@@ -406,6 +379,25 @@ IScsiFormExtractConfig (
   return Status;\r
 }\r
 \r
+/**\r
+  This function processes the results of changes in configuration.\r
+\r
+  @param  This[in]              Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
+\r
+  @param  Configuration[in]     A null-terminated Unicode string in <ConfigResp> format.\r
+\r
+  @param  Progress[out]         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
+  @retval EFI_SUCCESS           The Results is processed successfully.\r
+\r
+  @retval EFI_INVALID_PARAMETER Configuration is NULL.\r
+\r
+  @retval EFI_NOT_FOUND         Routing data doesn't match any storage in this driver.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 IScsiFormRouteConfig (\r
@@ -413,29 +405,35 @@ IScsiFormRouteConfig (
   IN  CONST EFI_STRING                       Configuration,\r
   OUT EFI_STRING                             *Progress\r
   )\r
-/*++\r
+{\r
+  return EFI_SUCCESS;\r
+}\r
 \r
-  Routine Description:\r
-    This function processes the results of changes in configuration.\r
+/**\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
+  @param  This[in]             Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\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
+  @param  Action[in]           Specifies the type of action taken by the browser.\r
 \r
---*/\r
-{\r
-  return EFI_SUCCESS;\r
-}\r
+  @param  QuestionId[in]       A unique value which is sent to the original exporting driver\r
+                               so that it can identify the type of data to expect.\r
+\r
+  @param  Type[in]             The type of value for the question.\r
+\r
+  @param  Value[in]            A pointer to the data being sent to the original exporting driver.\r
+\r
+  @param  ActionRequest[out]   On return, points to the action requested by the callback function.\r
+\r
+  @retval EFI_SUCCESS          The callback successfully handled the action.\r
+\r
+  @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.\r
 \r
+  @retval EFI_DEVICE_ERROR     The variable could not be saved.\r
+\r
+  @retval EFI_UNSUPPORTED      The specified Action is not supported by the callback.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 IScsiFormCallback (\r
@@ -446,27 +444,6 @@ IScsiFormCallback (
   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,7 +452,7 @@ 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
@@ -699,7 +676,7 @@ IScsiFormCallback (
       ASSERT (ConfigFormEntry != NULL);\r
 \r
       UnicodeSPrint (PortString, (UINTN) 128, L"Port %s", ConfigFormEntry->MacString);\r
-      DeviceFormTitleToken = (STRING_REF) STR_ISCSI_DEVICE_FORM_TITLE;\r
+      DeviceFormTitleToken = (EFI_STRING_ID) STR_ISCSI_DEVICE_FORM_TITLE;\r
       HiiLibSetString (Private->RegisteredHandle, DeviceFormTitleToken, PortString);\r
 \r
       IScsiConvertDeviceConfigDataToIfrNvData (ConfigFormEntry, IfrNvData);\r
@@ -722,32 +699,27 @@ IScsiFormCallback (
   return Status;\r
 }\r
 \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
+/**\r
   Updates the iSCSI configuration form to add/delete an entry for the iSCSI\r
   device specified by the Controller.\r
 \r
-Arguments:\r
+  @param  DriverBindingHandle[in] The driverbinding handle.\r
+\r
+  @param  Controller[in]          The controller handle of the iSCSI device.\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
+  @param  AddForm[in]             Whether to add or delete a form entry.\r
 \r
-Returns:\r
+  @retval EFI_SUCCESS             The iSCSI configuration form is updated.\r
 \r
-  EFI_SUCCESS          - The iSCSI configuration form is updated.\r
-  EFI_OUT_OF_RESOURCES - Failed to allocate memory.\r
+  @retval EFI_OUT_OF_RESOURCES    Failed to allocate memory.\r
 \r
---*/\r
+**/\r
+EFI_STATUS\r
+IScsiConfigUpdateForm (\r
+  IN EFI_HANDLE  DriverBindingHandle,\r
+  IN EFI_HANDLE  Controller,\r
+  IN BOOLEAN     AddForm\r
+  )\r
 {\r
   LIST_ENTRY                  *Entry;\r
   ISCSI_CONFIG_FORM_ENTRY     *ConfigFormEntry;\r
@@ -829,13 +801,13 @@ Returns:
         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
       HiiLibNewString (mCallbackInfo->RegisteredHandle, &ConfigFormEntry->PortTitleToken, PortString);\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
       HiiLibNewString (mCallbackInfo->RegisteredHandle, &ConfigFormEntry->PortTitleHelpToken, PortString);\r
@@ -887,26 +859,20 @@ Returns:
   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
+  @param  DriverBindingHandle[in] The iSCSI driverbinding handle.\r
 \r
-  DriverBindingHandle - The iSCSI driverbinding handle.\r
+  @retval EFI_SUCCESS             The iSCSI configuration form is initialized.\r
 \r
-Returns:\r
+  @retval EFI_OUT_OF_RESOURCES    Failed to allocate memory.\r
 \r
-  EFI_SUCCESS          - The iSCSI configuration form is initialized.\r
-  EFI_OUT_OF_RESOURCES - Failed to allocate memory.\r
-\r
---*/\r
+**/\r
+EFI_STATUS\r
+IScsiConfigFormInit (\r
+  IN EFI_HANDLE  DriverBindingHandle\r
+  )\r
 {\r
   EFI_STATUS                  Status;\r
   EFI_HII_DATABASE_PROTOCOL   *HiiDatabase;\r
@@ -980,28 +946,22 @@ 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
+  @param  DriverBindingHandle[in] The iSCSI driverbinding handle.\r
 \r
-Returns:\r
+  @retval EFI_SUCCESS             The iSCSI configuration form is unloaded.\r
 \r
-  EFI_SUCCESS          - The iSCSI configuration form is unloaded.\r
-  EFI_OUT_OF_RESOURCES - Failed to allocate memory.\r
+  @retval EFI_OUT_OF_RESOURCES    Failed to allocate memory.\r
 \r
---*/\r
+**/\r
+EFI_STATUS\r
+IScsiConfigFormUnload (\r
+  IN EFI_HANDLE  DriverBindingHandle\r
+  )\r
 {\r
   ISCSI_CONFIG_FORM_ENTRY     *ConfigFormEntry;\r
 \r