]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/IScsiDxe/IScsiDriver.c
sync comments, fix function header, rename variable name to follow coding style.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / IScsiDxe / IScsiDriver.c
index 8cc2a5050f9c793f78848b1a9f536d7eabff3d5d..beee62c51bad0fcd2868a4d8db0f5f873f1bf66a 100644 (file)
@@ -1,6 +1,7 @@
-/*++\r
+/** @file\r
+  The entry point of IScsi driver\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation\r
+Copyright (c) 2004 - 2008, Intel Corporation\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
@@ -14,8 +15,9 @@ Module Name:
   IScsiDriver.c\r
 \r
 Abstract:\r
+  The entry point of IScsi driver\r
 \r
---*/\r
+**/\r
 \r
 #include "IScsiImpl.h"\r
 \r
@@ -30,32 +32,29 @@ EFI_DRIVER_BINDING_PROTOCOL gIScsiDriverBinding = {
 \r
 EFI_GUID                    mIScsiPrivateGuid   = ISCSI_PRIVATE_GUID;\r
 \r
-EFI_STATUS\r
-EFIAPI\r
-IScsiDriverBindingSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  * This,\r
-  IN EFI_HANDLE                   ControllerHandle,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     * RemainingDevicePath OPTIONAL\r
-  )\r
-/*++\r
+/**\r
+  Test to see if IScsi driver supports the given controller. \r
 \r
-Routine Description:\r
+  @param  This[in]                Protocol instance pointer.\r
 \r
-  Test to see if iSCSI driver supports the given controller. \r
+  @param  ControllerHandle[in]    Handle of controller to test.\r
 \r
-Arguments:\r
+  @param  RemainingDevicePath[in] Optional parameter use to pick a specific child device to start.\r
 \r
-  This                - Protocol instance pointer.\r
-  ControllerHandle    - Handle of controller to test.\r
-  RemainingDevicePath - Optional parameter use to pick a specific child device to start.\r
+  @retval EFI_SUCCES              This driver supports the controller.\r
 \r
-Returns:\r
+  @retval EFI_ALREADY_STARTED     This driver is already running on this device.\r
 \r
-  EFI_SUCCES          - This driver supports the controller.\r
-  EFI_ALREADY_STARTED - This driver is already running on this device.\r
-  EFI_UNSUPPORTED     - This driver doesn't support the controller.\r
+  @retval EFI_UNSUPPORTED         This driver doesn't support the controller.\r
 \r
---*/\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+IScsiDriverBindingSupported (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL  * This,\r
+  IN EFI_HANDLE                   ControllerHandle,\r
+  IN EFI_DEVICE_PATH_PROTOCOL     * RemainingDevicePath OPTIONAL\r
+  )\r
 {\r
   EFI_STATUS                Status;\r
   EFI_DEVICE_PATH_PROTOCOL  *CurrentDevicePath;\r
@@ -100,6 +99,20 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Start to manage the controller. \r
+\r
+  @param  This[in]                Protocol instance pointer.\r
+\r
+  @param  ControllerHandle[in]    Handle of the controller.\r
+\r
+  @param  RemainingDevicePath[in] Optional parameter use to pick a specific child device to start.\r
+\r
+  @retval EFI_SUCCES              This driver supports this device.\r
+\r
+  @retval EFI_ALREADY_STARTED     This driver is already running on this device.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 IScsiDriverBindingStart (\r
@@ -107,24 +120,6 @@ IScsiDriverBindingStart (
   IN EFI_HANDLE                   ControllerHandle,\r
   IN EFI_DEVICE_PATH_PROTOCOL     * RemainingDevicePath OPTIONAL\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Start to manage the controller. \r
-\r
-Arguments:\r
-\r
-  This                - Protocol instance pointer.\r
-  ControllerHandle    - Handle of the controller.\r
-  RemainingDevicePath - Optional parameter use to pick a specific child device to start.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCES          - This driver supports this device.\r
-  EFI_ALREADY_STARTED - This driver is already running on this device.\r
-\r
---*/\r
 {\r
   EFI_STATUS        Status;\r
   ISCSI_DRIVER_DATA *Private;\r
@@ -209,6 +204,20 @@ ON_ERROR:
   return Status;\r
 }\r
 \r
+/**\r
+  Release the control of this controller and remove the IScsi functions.\r
+\r
+  @param  This[in]              Protocol instance pointer.\r
+\r
+  @param  ControllerHandle[in]  Handle of controller to stop.\r
+\r
+  @param  NumberOfChildren[in]  Not used.\r
+\r
+  @param  ChildHandleBuffer[in] Not used.\r
+\r
+  @retval EFI_SUCCES            This driver supports this device.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 IScsiDriverBindingStop (\r
@@ -217,24 +226,6 @@ IScsiDriverBindingStop (
   IN UINTN                        NumberOfChildren,\r
   IN EFI_HANDLE                   *ChildHandleBuffer\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Release the control of this controller and remove the iSCSI functions.\r
-\r
-Arguments:\r
-\r
-  This                - Protocol instance pointer.\r
-  ControllerHandle    - Handle of controller to stop.\r
-  NumberOfChildren    - Not used.\r
-  ChildHandleBuffer   - Not used.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCES          - This driver supports this device.\r
-\r
---*/\r
 {\r
   EFI_HANDLE                      IScsiController;\r
   EFI_STATUS                      Status;\r
@@ -315,27 +306,21 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
-EFI_STATUS\r
-EFIAPI\r
-EfiIScsiUnload (\r
-  IN EFI_HANDLE  ImageHandle\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
+/**\r
   Unload the iSCSI driver.\r
 \r
-Arguments:\r
+  @param  ImageHandle[in]  The handle of the driver image.\r
 \r
-  ImageHandle - The handle of the driver image.\r
+  @retval EFI_SUCCESS      The driver is unloaded.\r
 \r
-Returns:\r
+  @retval EFI_DEVICE_ERROR Some unexpected error happened.\r
 \r
-  EFI_SUCCESS      - The driver is unloaded.\r
-  EFI_DEVICE_ERROR - Some unexpected error happened.\r
-\r
---*/\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiIScsiUnload (\r
+  IN EFI_HANDLE  ImageHandle\r
+  )\r
 {\r
   EFI_STATUS  Status;\r
   UINTN       DeviceHandleCount;\r
@@ -389,32 +374,40 @@ Returns:
   return Status;\r
 }\r
 \r
+/**\r
+  Initialize the global variables publish the driver binding protocol.\r
+\r
+  @param  ImageHandle[in]  The handle of the driver image.\r
+\r
+  @param  SystemTable[in]  The EFI system table.\r
+\r
+  @retval EFI_SUCCESS      The protocols are installed.\r
+\r
+  @retval EFI_DEVICE_ERROR Some unexpected error happened.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 IScsiDriverEntryPoint (\r
   IN EFI_HANDLE         ImageHandle,\r
   IN EFI_SYSTEM_TABLE   *SystemTable\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Initialize the global variables publish the driver binding protocol.\r
-\r
-Arguments:\r
-\r
-  ImageHandle - The handle of the driver image.\r
-  SystemTable - The EFI system table.\r
-\r
-Returns:\r
+{\r
+  EFI_STATUS                         Status;\r
+  EFI_ISCSI_INITIATOR_NAME_PROTOCOL  *IScsiInitiatorName;\r
 \r
-  EFI_SUCCESS      - The protocols are installed.\r
-  EFI_DEVICE_ERROR - Some unexpected error happened.\r
+  //\r
+  // There should be only one EFI_ISCSI_INITIATOR_NAME_PROTOCOL.\r
+  //\r
+  Status = gBS->LocateProtocol (\r
+                   &gEfiIScsiInitiatorNameProtocolGuid,\r
+                   NULL,\r
+                   (VOID**) &IScsiInitiatorName\r
+                   );\r
 \r
---*/\r
-{\r
-  EFI_STATUS  Status;\r
-  //EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;\r
+  if (!EFI_ERROR (Status)) {\r
+    return EFI_ACCESS_DENIED;\r
+  }\r
 \r
   //\r
   // Initialize the EFI Driver Library\r
@@ -427,12 +420,11 @@ Returns:
              &gIScsiComponentName,\r
              &gIScsiComponentName2\r
            );\r
-  \r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
 \r
   if (!EFI_ERROR (Status)) {\r
+    //\r
+    // Install the iSCSI Initiator Name Protocol.\r
+    //\r
     Status = gBS->InstallProtocolInterface (\r
                     &ImageHandle,\r
                     &gEfiIScsiInitiatorNameProtocolGuid,\r
@@ -450,13 +442,28 @@ Returns:
             &gIScsiComponentName,\r
             NULL\r
             );\r
+      return Status;\r
+    }\r
+  \r
+    //\r
+    // Initialize the configuration form of iSCSI.\r
+    //\r
+    Status = IScsiConfigFormInit (gIScsiDriverBinding.DriverBindingHandle);\r
+    if (EFI_ERROR (Status)) {\r
+      gBS->UninstallMultipleProtocolInterfaces (\r
+            ImageHandle,\r
+            &gEfiDriverBindingProtocolGuid,\r
+            &gIScsiDriverBinding,\r
+            &gEfiComponentName2ProtocolGuid,\r
+            &gIScsiComponentName2,\r
+            &gEfiComponentNameProtocolGuid,\r
+            &gIScsiComponentName,\r
+            &gEfiIScsiInitiatorNameProtocolGuid,\r
+            &gIScsiInitiatorName,\r
+            NULL\r
+            );\r
     }\r
   }\r
-  //\r
-  // Initialize the configuration form of iSCSI.\r
-  //\r
-  IScsiConfigFormInit (gIScsiDriverBinding.DriverBindingHandle);\r
-\r
   return Status;\r
 }\r
 \r