]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBus.c
IntelFrameworkModulePkg: Removing ipf from edk2.
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Isa / IsaBusDxe / IsaBus.c
index daee1fb510995da369dd589d7bb91a09759eb4af..a409355dd1e82d43f21c3513930ae2f2bd9e300c 100644 (file)
@@ -1,30 +1,21 @@
-/*++\r
+/** @file\r
+  ISA Bus UEFI driver.\r
 \r
-Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved. <BR> \r
-This software and associated documentation (if any) is furnished\r
-under a license and may only be used or copied in accordance\r
-with the terms of the license. Except as permitted by such\r
-license, no part of this software or documentation may be\r
-reproduced, stored in a retrieval system, or transmitted in any\r
-form or by any means without the express written consent of\r
-Intel Corporation.\r
+  Discovers all the ISA Controllers and their resources by using the ISA ACPI\r
+  Protocol, produces an instance of the ISA I/O Protocol for every ISA\r
+  Controller found. This driver is designed to manage a PCI-to-ISA bridge Device\r
+  such as LPC bridge.\r
 \r
-Module Name:\r
+Copyright (c) 2006 - 2018, 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
+http://opensource.org/licenses/bsd-license.php\r
 \r
-  IsaBus.c\r
-  \r
-Abstract:\r
+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
-  Discovers all the ISA Controllers and their resources by using the ISA PnP \r
-  Protocol, produces an instance of the ISA I/O Protocol for every ISA \r
-  Controller found, loads and initializes all ISA Device Drivers, matches ISA\r
-  Device Drivers with their respective ISA Controllers in a deterministic \r
-  manner, and informs a ISA Device Driver when it is to start managing an ISA\r
-  Controller. \r
-\r
-Revision History:\r
-\r
---*/\r
+**/\r
 \r
 #include "InternalIsaBus.h"\r
 \r
@@ -40,42 +31,74 @@ EFI_DRIVER_BINDING_PROTOCOL gIsaBusControllerDriver = {
   NULL\r
 };\r
 \r
+/**\r
+  The main entry point for the ISA Bus driver.\r
+\r
+  @param[in] ImageHandle        The firmware allocated handle for the EFI image.\r
+  @param[in] SystemTable        A pointer to the EFI System Table.\r
+\r
+  @retval EFI_SUCCESS           The entry point is executed successfully.\r
+  @retval EFI_OUT_OF_RESOURCES  There was not enough memory in pool to install all the protocols.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeIsaBus(\r
+  IN EFI_HANDLE           ImageHandle,\r
+  IN EFI_SYSTEM_TABLE     *SystemTable\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+\r
+  //\r
+  // Install driver model protocol(s).\r
+  //\r
+  Status = EfiLibInstallDriverBindingComponentName2 (\r
+             ImageHandle,\r
+             SystemTable,\r
+             &gIsaBusControllerDriver,\r
+             ImageHandle,\r
+             &gIsaBusComponentName,\r
+             &gIsaBusComponentName2\r
+             );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Tests to see if a controller can be managed by the ISA Bus Driver. If a child device is provided,\r
+  it further tests to see if this driver supports creating a handle for the specified child device.\r
+\r
+  Note that the ISA Bus driver always creates all of its child handles on the first call to Start().\r
+  How the Start() function of a driver is implemented can affect how the Supported() function is implemented.\r
+\r
+  @param[in] This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+  @param[in] Controller           The handle of the controller to test.\r
+  @param[in] RemainingDevicePath  A pointer to the remaining portion of a device path.\r
+\r
+  @retval EFI_SUCCESS             The device is supported by this driver.\r
+  @retval EFI_ALREADY_STARTED     The device is already being managed by this driver.\r
+  @retval EFI_ACCESS_DENIED       The device is already being managed by a different driver\r
+                                  or an application that requires exclusive access.\r
+  @retval EFI_UNSUPPORTED         The device is is not supported by this driver.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 IsaBusControllerDriverSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  * This,\r
+  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
   IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     * RemainingDevicePath OPTIONAL\r
+  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL\r
   )\r
-/*++\r
-\r
-  Routine Description:\r
-  \r
-    This function checks to see if a controller can be managed by the ISA Bus \r
-    Driver. This is done by checking to see if the controller supports the \r
-    EFI_PCI_IO_PROTOCOL protocol, and then looking at the PCI Configuration \r
-    Header to see if the device is a PCI to ISA bridge. The class code of \r
-    PCI to ISA bridge: Base class 06h, Sub class 01h Interface 00h \r
-  \r
-  Arguments:\r
-  \r
-    This                 - The EFI_DRIVER_BINDING_PROTOCOL instance.\r
-    Controller           - The handle of the device to check.\r
-    RemainingDevicePath  - A pointer to the remaining portion of a device path.\r
-\r
-  Returns:\r
-  \r
-    EFI_SUCCESS          - The device is supported by this driver.\r
-    EFI_UNSUPPORTED      - The device is not supported by this driver.\r
-\r
---*/\r
 {\r
-  EFI_STATUS            Status;\r
-  EFI_ISA_ACPI_PROTOCOL *IsaAcpi;\r
+  EFI_STATUS                Status;\r
+  EFI_DEVICE_PATH_PROTOCOL  *ParentDevicePath;\r
+  EFI_ISA_ACPI_PROTOCOL     *IsaAcpi;\r
 \r
   //\r
   // If RemainingDevicePath is not NULL, it should verify that the first device\r
-  // path node in RemainingDevicePath is an ACPI Device path node\r
+  // path node in RemainingDevicePath is an ACPI Device path node which is a\r
+  // legal Device Path Node for this bus driver's children.\r
   //\r
   if (RemainingDevicePath != NULL) {\r
     if (RemainingDevicePath->Type != ACPI_DEVICE_PATH) {\r
@@ -93,11 +116,43 @@ IsaBusControllerDriverSupported (
     }\r
   }\r
   //\r
-  // Test the existence of DEVICE_PATH protocol\r
+  // Try to open EFI DEVICE PATH protocol on the controller\r
   //\r
   Status = gBS->OpenProtocol (\r
                   Controller,\r
                   &gEfiDevicePathProtocolGuid,\r
+                  (VOID **) &ParentDevicePath,\r
+                  This->DriverBindingHandle,\r
+                  Controller,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  //\r
+  // Although this driver creates all child handles at one time,\r
+  // but because all child handles may be not stopped at one time in EFI Driver Binding.Stop(),\r
+  // So it is allowed to create child handles again in successive calls to EFI Driver Binding.Start().\r
+  //\r
+  if (Status == EFI_ALREADY_STARTED) {\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  gBS->CloseProtocol (\r
+         Controller,\r
+         &gEfiDevicePathProtocolGuid,\r
+         This->DriverBindingHandle,\r
+         Controller\r
+         );\r
+\r
+  //\r
+  // Try to get Pci IO Protocol because it is assumed\r
+  // to have been opened by ISA ACPI driver\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  Controller,\r
+                  &gEfiPciIoProtocolGuid,\r
                   NULL,\r
                   This->DriverBindingHandle,\r
                   Controller,\r
@@ -106,8 +161,9 @@ IsaBusControllerDriverSupported (
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
+\r
   //\r
-  // Get the Isa Acpi protocol\r
+  // Try to open the Isa Acpi protocol on the controller\r
   //\r
   Status = gBS->OpenProtocol (\r
                   Controller,\r
@@ -117,14 +173,14 @@ IsaBusControllerDriverSupported (
                   Controller,\r
                   EFI_OPEN_PROTOCOL_BY_DRIVER\r
                   );\r
-  if (Status == EFI_ALREADY_STARTED) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
 \r
+  //\r
+  // Add more check to see if the child device is valid by calling IsaAcpi->DeviceEnumerate?\r
+  //\r
+\r
   gBS->CloseProtocol (\r
          Controller,\r
          &gEfiIsaAcpiProtocolGuid,\r
@@ -135,37 +191,40 @@ IsaBusControllerDriverSupported (
   return Status;\r
 }\r
 \r
+/**\r
+  Start this driver on ControllerHandle.\r
+\r
+  Note that the ISA Bus driver always creates all of its child handles on the first call to Start().\r
+  The Start() function is designed to be invoked from the EFI boot service ConnectController().\r
+  As a result, much of the error checking on the parameters to Start() has been moved into this\r
+  common boot service. It is legal to call Start() from other locations, but the following calling\r
+  restrictions must be followed or the system behavior will not be deterministic.\r
+  1. ControllerHandle must be a valid EFI_HANDLE.\r
+  2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned\r
+     EFI_DEVICE_PATH_PROTOCOL.\r
+  3. Prior to calling Start(), the Supported() function for the driver specified by This must\r
+     have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.\r
+\r
+  @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+  @param[in]  ControllerHandle     The handle of the controller to start. This handle\r
+                                   must support a protocol interface that supplies\r
+                                   an I/O abstraction to the driver.\r
+  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path.\r
+                                   This parameter is ignored by device drivers, and is optional for bus drivers.\r
+\r
+  @retval EFI_SUCCESS              The device was started.\r
+  @retval EFI_DEVICE_ERROR         The device could not be started due to a device error.\r
+                                   Currently not implemented.\r
+  @retval EFI_OUT_OF_RESOURCES     The request could not be completed due to a lack of resources.\r
+  @retval Others                   The driver failded to start the device.\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 IsaBusControllerDriverStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  * This,\r
+  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
   IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     * RemainingDevicePath OPTIONAL\r
+  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL\r
   )\r
-/*++\r
-\r
-  Routine Description:\r
-  \r
-    This function tells the ISA Bus Driver to start managing a PCI to ISA \r
-    Bridge controller. \r
-  \r
-  Arguments:\r
-  \r
-    This                  - The EFI_DRIVER_BINDING_PROTOCOL instance.\r
-    Controller            - A handle to the device being started. \r
-    RemainingDevicePath   - A pointer to the remaining portion of a device path.\r
-\r
-  Returns:\r
-  \r
-    EFI_SUCCESS           - The device was started.\r
-    EFI_UNSUPPORTED       - The device is not supported.\r
-    EFI_DEVICE_ERROR      - The device could not be started due to a device error.\r
-    EFI_ALREADY_STARTED   - The device has already been started.\r
-    EFI_INVALID_PARAMETER - One of the parameters has an invalid value.\r
-    EFI_OUT_OF_RESOURCES  - The request could not be completed due to a lack of \r
-                            resources.\r
-  \r
---*/\r
 {\r
   EFI_STATUS                            Status;\r
   EFI_PCI_IO_PROTOCOL                   *PciIo;\r
@@ -178,62 +237,40 @@ IsaBusControllerDriverStart (
   //\r
   // Local variables declaration for StatusCode reporting\r
   //\r
-  EFI_RESOURCE_ALLOC_FAILURE_ERROR_DATA AllocFailExtendedData;\r
   EFI_DEVICE_PATH_PROTOCOL              *DevicePathData;\r
 \r
-  BootScriptSaveInformationAsciiString (\r
-    EFI_ACPI_S3_RESUME_SCRIPT_TABLE,\r
-    "IsaBusBindingStartBegin"\r
-    );\r
+  DevicePathData = NULL;\r
 \r
   //\r
-  // Initialize status code structure\r
-  //\r
-  AllocFailExtendedData.DataHeader.HeaderSize = sizeof (EFI_STATUS_CODE_DATA);\r
-  AllocFailExtendedData.DataHeader.Size = sizeof (EFI_RESOURCE_ALLOC_FAILURE_ERROR_DATA) - sizeof (EFI_STATUS_CODE_DATA);\r
-  CopyMem (\r
-    &AllocFailExtendedData.DataHeader.Type,\r
-    &gEfiStatusCodeSpecificDataGuid,\r
-    sizeof (EFI_GUID)\r
-    );\r
-\r
-  //\r
-  // Open Device Path Protocol\r
+  // Get Pci IO Protocol\r
   //\r
   Status = gBS->OpenProtocol (\r
                   Controller,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID **) &ParentDevicePath,\r
+                  &gEfiPciIoProtocolGuid,\r
+                  (VOID **) &PciIo,\r
                   This->DriverBindingHandle,\r
                   Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
                   );\r
-  if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {\r
+  if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
+\r
   //\r
-  // Open Pci IO Protocol\r
+  // Open Device Path Protocol\r
   //\r
   Status = gBS->OpenProtocol (\r
                   Controller,\r
-                  &gEfiPciIoProtocolGuid,\r
-                  (VOID **) &PciIo,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  (VOID **) &ParentDevicePath,\r
                   This->DriverBindingHandle,\r
                   Controller,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
                   );\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // Close opened protocol\r
-    //\r
-    gBS->CloseProtocol (\r
-           Controller,\r
-           &gEfiDevicePathProtocolGuid,\r
-           This->DriverBindingHandle,\r
-           Controller\r
-           );\r
+  if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {\r
     return Status;\r
   }\r
+\r
   //\r
   // Open ISA Acpi Protocol\r
   //\r
@@ -255,12 +292,6 @@ IsaBusControllerDriverStart (
            This->DriverBindingHandle,\r
            Controller\r
            );\r
-    gBS->CloseProtocol (\r
-           Controller,\r
-           &gEfiPciIoProtocolGuid,\r
-           This->DriverBindingHandle,\r
-           Controller\r
-           );\r
     return Status;\r
   }\r
   //\r
@@ -326,6 +357,10 @@ IsaBusControllerDriverStart (
     //\r
     // Create handle for this ISA device\r
     //\r
+    // If any child device handle was created in previous call to Start() and not stopped\r
+    // in previous call to Stop(), it will not be created again because the\r
+    // InstallMultipleProtocolInterfaces() boot service will reject same device path.\r
+    //\r
     Status = IsaCreateDevice (\r
                This,\r
                Controller,\r
@@ -333,7 +368,6 @@ IsaBusControllerDriverStart (
                ParentDevicePath,\r
                ResourceList,\r
                &DevicePathData\r
-               //&AllocFailExtendedData.DevicePath\r
                );\r
 \r
     if (EFI_ERROR (Status)) {\r
@@ -356,9 +390,6 @@ IsaBusControllerDriverStart (
       //\r
       // It's hard to tell which resource conflicts\r
       //\r
-      AllocFailExtendedData.Bar       = 0;\r
-      AllocFailExtendedData.ReqRes    = NULL;\r
-      AllocFailExtendedData.AllocRes  = NULL;\r
       REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
          EFI_ERROR_CODE,\r
          (EFI_IO_BUS_LPC | EFI_IOB_EC_RESOURCE_CONFLICT),\r
@@ -378,14 +409,34 @@ IsaBusControllerDriverStart (
 \r
   } while (TRUE);\r
 \r
-  BootScriptSaveInformationAsciiString (\r
-    EFI_ACPI_S3_RESUME_SCRIPT_TABLE,\r
-    "IsaBusBindingStartEnd"\r
-    );\r
-\r
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Stop this driver on ControllerHandle.\r
+\r
+  The Stop() function is designed to be invoked from the EFI boot service DisconnectController().\r
+  As a result, much of the error checking on the parameters to Stop() has been moved\r
+  into this common boot service. It is legal to call Stop() from other locations,\r
+  but the following calling restrictions must be followed or the system behavior will not be deterministic.\r
+  1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this\r
+     same driver's Start() function.\r
+  2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid\r
+     EFI_HANDLE. In addition, all of these handles must have been created in this driver's\r
+     Start() function, and the Start() function must have called OpenProtocol() on\r
+     ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
+\r
+  @param[in]  This              A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+  @param[in]  ControllerHandle  A handle to the device being stopped. The handle must\r
+                                support a bus specific I/O protocol for the driver\r
+                                to use to stop the device.\r
+  @param[in]  NumberOfChildren  The number of child device handles in ChildHandleBuffer.\r
+  @param[in]  ChildHandleBuffer An array of child handles to be freed. May be NULL\r
+                                if NumberOfChildren is 0.\r
+\r
+  @retval EFI_SUCCESS           The device was stopped.\r
+  @retval EFI_DEVICE_ERROR      The device could not be stopped due to a device error.\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 IsaBusControllerDriverStop (\r
@@ -394,52 +445,18 @@ IsaBusControllerDriverStop (
   IN  UINTN                        NumberOfChildren,\r
   IN  EFI_HANDLE                   * ChildHandleBuffer OPTIONAL\r
   )\r
-/*++\r
-\r
-  Routine Description:\r
-  \r
-    This function tells the ISA Bus Driver to stop managing a PCI to ISA \r
-    Bridge controller. \r
-     \r
-  Arguments:\r
-  \r
-    This                   - The EFI_DRIVER_BINDING_PROTOCOL instance.\r
-    Controller             - A handle to the device being stopped.\r
-    NumberOfChindren       - The number of child device handles in ChildHandleBuffer.\r
-    ChildHandleBuffer      - An array of child handles to be freed.\r
-\r
-  \r
-  Returns:\r
-  \r
-    EFI_SUCCESS            - The device was stopped.\r
-    EFI_DEVICE_ERROR       - The device could not be stopped due to a device error.\r
-    EFI_NOT_STARTED        - The device has not been started.\r
-    EFI_INVALID_PARAMETER  - One of the parameters has an invalid value.\r
-    EFI_OUT_OF_RESOURCES   - The request could not be completed due to a lack of \r
-                             resources.\r
-\r
---*/\r
 {\r
   EFI_STATUS                          Status;\r
   UINTN                               Index;\r
   BOOLEAN                             AllChildrenStopped;\r
   ISA_IO_DEVICE                       *IsaIoDevice;\r
   EFI_ISA_IO_PROTOCOL                 *IsaIo;\r
+  EFI_PCI_IO_PROTOCOL                 *PciIo;\r
 \r
   if (NumberOfChildren == 0) {\r
     //\r
     // Close the bus driver\r
     //\r
-    Status = gBS->CloseProtocol (\r
-                    Controller,\r
-                    &gEfiPciIoProtocolGuid,\r
-                    This->DriverBindingHandle,\r
-                    Controller\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-\r
     Status = gBS->CloseProtocol (\r
                     Controller,\r
                     &gEfiDevicePathProtocolGuid,\r
@@ -487,6 +504,16 @@ IsaBusControllerDriverStop (
 \r
       IsaIoDevice = ISA_IO_DEVICE_FROM_ISA_IO_THIS (IsaIo);\r
 \r
+      //\r
+      // Close the child handle\r
+      //\r
+\r
+      Status = gBS->CloseProtocol (\r
+                      Controller,\r
+                      &gEfiPciIoProtocolGuid,\r
+                      This->DriverBindingHandle,\r
+                      ChildHandleBuffer[Index]\r
+                      );\r
       Status = gBS->UninstallMultipleProtocolInterfaces (\r
                       ChildHandleBuffer[Index],\r
                       &gEfiDevicePathProtocolGuid,\r
@@ -497,18 +524,21 @@ IsaBusControllerDriverStop (
                       );\r
 \r
       if (!EFI_ERROR (Status)) {\r
+        FreePool (IsaIoDevice->DevicePath);\r
+        FreePool (IsaIoDevice);\r
+      } else {\r
         //\r
-        // Close the child handle\r
+        // Re-open PCI IO Protocol on behalf of the child device\r
+        // because of failure of destroying the child device handle\r
         //\r
-        Status = gBS->CloseProtocol (\r
-                        Controller,\r
-                        &gEfiPciIoProtocolGuid,\r
-                        This->DriverBindingHandle,\r
-                        ChildHandleBuffer[Index]\r
-                        );\r
-\r
-        gBS->FreePool (IsaIoDevice->DevicePath);\r
-        gBS->FreePool (IsaIoDevice);\r
+        gBS->OpenProtocol (\r
+               Controller,\r
+               &gEfiPciIoProtocolGuid,\r
+               (VOID **) &PciIo,\r
+               This->DriverBindingHandle,\r
+               ChildHandleBuffer[Index],\r
+               EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
+               );\r
       }\r
     }\r
 \r
@@ -523,9 +553,25 @@ IsaBusControllerDriverStop (
 \r
   return EFI_SUCCESS;\r
 }\r
+\r
 //\r
 // Internal Function\r
 //\r
+\r
+/**\r
+  Create EFI Handle for a ISA device found via ISA ACPI Protocol\r
+\r
+  @param[in] This                   The EFI_DRIVER_BINDING_PROTOCOL instance.\r
+  @param[in] Controller             The handle of ISA bus controller(PCI to ISA bridge)\r
+  @param[in] PciIo                  The Pointer to the PCI protocol\r
+  @param[in] ParentDevicePath       Device path of the ISA bus controller\r
+  @param[in] IsaDeviceResourceList  The resource list of the ISA device\r
+  @param[out] ChildDevicePath       The pointer to the child device.\r
+\r
+  @retval EFI_SUCCESS               The handle for the child device was created.\r
+  @retval EFI_OUT_OF_RESOURCES      The request could not be completed due to a lack of resources.\r
+  @retval EFI_DEVICE_ERROR          The handle for the child device can not be created.\r
+**/\r
 EFI_STATUS\r
 IsaCreateDevice (\r
   IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
@@ -535,29 +581,6 @@ IsaCreateDevice (
   IN EFI_ISA_ACPI_RESOURCE_LIST   *IsaDeviceResourceList,\r
   OUT EFI_DEVICE_PATH_PROTOCOL    **ChildDevicePath\r
   )\r
-/*++\r
-\r
-  Routine Description:\r
-  \r
-    Create ISA device found by IsaPnpProtocol \r
-\r
-  Arguments:\r
-  \r
-    This                   - The EFI_DRIVER_BINDING_PROTOCOL instance.\r
-    Controller             - The handle of ISA bus controller(PCI to ISA bridge)\r
-    PciIo                  - The Pointer to the PCI protocol \r
-    ParentDevicePath       - Device path of the ISA bus controller\r
-    IsaDeviceResourceList  - The resource list of the ISA device\r
-    ChildDevicePath        - The pointer to the child device.\r
-\r
-  Returns:\r
-  \r
-    EFI_SUCCESS            - Create the child device.\r
-    EFI_OUT_OF_RESOURCES   - The request could not be completed due to a lack of \r
-                             resources.\r
-    EFI_DEVICE_ERROR       - Can not create child device.\r
-    \r
---*/\r
 {\r
   EFI_STATUS    Status;\r
   ISA_IO_DEVICE *IsaIoDevice;\r
@@ -578,11 +601,8 @@ IsaCreateDevice (
   //\r
   // Initialize the ISA I/O instance structure\r
   //\r
-  Status = InitializeIsaIoInstance (IsaIoDevice, IsaDeviceResourceList);\r
-  if (EFI_ERROR (Status)) {\r
-    gBS->FreePool (IsaIoDevice);\r
-    return Status;\r
-  }\r
+  InitializeIsaIoInstance (IsaIoDevice, IsaDeviceResourceList);\r
+\r
   //\r
   // Build the child device path\r
   //\r
@@ -598,15 +618,14 @@ IsaCreateDevice (
                               );\r
 \r
   if (IsaIoDevice->DevicePath == NULL) {\r
-    Status = EFI_DEVICE_ERROR;\r
+    Status = EFI_OUT_OF_RESOURCES;\r
     goto Done;\r
   }\r
 \r
   *ChildDevicePath = IsaIoDevice->DevicePath;\r
 \r
   //\r
-  // Create a child handle and attach the DevicePath,\r
-  // PCI I/O, and Controller State\r
+  // Create a child handle and install Device Path and ISA I/O protocols\r
   //\r
   Status = gBS->InstallMultipleProtocolInterfaces (\r
                   &IsaIoDevice->Handle,\r
@@ -643,11 +662,12 @@ Done:
 \r
   if (EFI_ERROR (Status)) {\r
     if (IsaIoDevice->DevicePath != NULL) {\r
-      gBS->FreePool (IsaIoDevice->DevicePath);\r
+      FreePool (IsaIoDevice->DevicePath);\r
     }\r
 \r
-    gBS->FreePool (IsaIoDevice);\r
+    FreePool (IsaIoDevice);\r
   }\r
 \r
   return Status;\r
 }\r
+\r