]> git.proxmox.com Git - mirror_edk2.git/commitdiff
updated IdeBus driver not to create new child handle if RemainingDeviepath is the...
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 8 Sep 2009 07:57:40 +0000 (07:57 +0000)
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 8 Sep 2009 07:57:40 +0000 (07:57 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9248 6f19259b-4bc3-4df7-8a09-765794883524

IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBus.c

index 3c7159502de335ea403f9af36db9ce15c274dc87..0d182cf56296575a9e3d92835189a3ffb114ba54 100644 (file)
@@ -3,7 +3,7 @@
   Child device(Disk, CDROM, etc) enumeration and child handler installation, and \r
   driver stop.\r
     \r
-  Copyright (c) 2006 - 2008, Intel Corporation\r
+  Copyright (c) 2006 - 2009, 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
@@ -151,69 +151,79 @@ IDEBusDriverBindingSupported (
 \r
   if (RemainingDevicePath != NULL) {\r
     Node = (EFI_DEV_PATH *) RemainingDevicePath;\r
-    if (Node->DevPath.Type != MESSAGING_DEVICE_PATH ||\r
-        Node->DevPath.SubType != MSG_ATAPI_DP ||\r
-        DevicePathNodeLength(&Node->DevPath) != sizeof(ATAPI_DEVICE_PATH)) {\r
-      return EFI_UNSUPPORTED;\r
+    //\r
+    // Check if RemainingDevicePath is the End of Device Path Node, \r
+    // if yes, go on checking other conditions\r
+    //\r
+    if (!IsDevicePathEnd (Node)) {\r
+      //\r
+      // If RemainingDevicePath isn't the End of Device Path Node,\r
+      // check its validation\r
+      //\r
+      if (Node->DevPath.Type != MESSAGING_DEVICE_PATH ||\r
+          Node->DevPath.SubType != MSG_ATAPI_DP ||\r
+          DevicePathNodeLength(&Node->DevPath) != sizeof(ATAPI_DEVICE_PATH)) {\r
+        return EFI_UNSUPPORTED;\r
+      }\r
     }\r
   }\r
 \r
   //\r
-  // Open the IO Abstraction(s) needed to perform the supported test\r
+  // Verify the Ide Controller Init Protocol, which installed by the\r
+  // IdeController module.\r
+  // Note 1: PciIo protocol has been opened BY_DRIVER by ide_init, so We can't\r
+  //         open BY_DRIVER here) That's why we don't check pciio protocol\r
+  // Note 2: ide_init driver check ide controller's pci config space, so we dont\r
+  //         check here any more to save code size\r
   //\r
   Status = gBS->OpenProtocol (\r
                   Controller,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID **) &ParentDevicePath,\r
+                  &gEfiIdeControllerInitProtocolGuid,\r
+                  (VOID **) &IdeInit,\r
                   This->DriverBindingHandle,\r
                   Controller,\r
                   EFI_OPEN_PROTOCOL_BY_DRIVER\r
                   );\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
-  // Close protocol, don't use device path protocol in the .Support() function\r
+  // If protocols were opened normally, closed it\r
   //\r
   gBS->CloseProtocol (\r
         Controller,\r
-        &gEfiDevicePathProtocolGuid,\r
+        &gEfiIdeControllerInitProtocolGuid,\r
         This->DriverBindingHandle,\r
         Controller\r
         );\r
 \r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
   //\r
-  // Verify the Ide Controller Init Protocol, which installed by the\r
-  // IdeController module.\r
-  // Note 1: PciIo protocol has been opened BY_DRIVER by ide_init, so We can't\r
-  //         open BY_DRIVER here) That's why we don't check pciio protocol\r
-  // Note 2: ide_init driver check ide controller's pci config space, so we dont\r
-  //         check here any more to save code size\r
+  // Open the EFI Device Path protocol needed to perform the supported test\r
   //\r
   Status = gBS->OpenProtocol (\r
                   Controller,\r
-                  &gEfiIdeControllerInitProtocolGuid,\r
-                  (VOID **) &IdeInit,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  (VOID **) &ParentDevicePath,\r
                   This->DriverBindingHandle,\r
                   Controller,\r
                   EFI_OPEN_PROTOCOL_BY_DRIVER\r
                   );\r
-\r
   if (Status == EFI_ALREADY_STARTED) {\r
     return EFI_SUCCESS;\r
   }\r
 \r
   //\r
-  // If protocols were opened normally, closed it\r
+  // Close protocol, don't use device path protocol in the Support() function\r
   //\r
   gBS->CloseProtocol (\r
         Controller,\r
-        &gEfiIdeControllerInitProtocolGuid,\r
+        &gEfiDevicePathProtocolGuid,\r
         This->DriverBindingHandle,\r
         Controller\r
         );\r
@@ -415,28 +425,20 @@ IDEBusDriverBindingStart (
     ConfigurationOptions = 0x0f;\r
   }\r
 \r
-  if (EnumAll) {\r
+   if (EnumAll || RemainingDevicePath == NULL) {\r
     //\r
-    // If IdeInit->EnumAll is TRUE, must enumerate all IDE device anyway\r
+    // If IdeInit->EnumAll is TRUE or RemainingDevicePath is NULL, \r
+    // must enumerate all IDE device anyway\r
     //\r
     BeginningIdeChannel = IdePrimary;\r
     EndIdeChannel       = IdeSecondary;\r
     BeginningIdeDevice  = IdeMaster;\r
     EndIdeDevice        = IdeSlave;\r
-  } else if (RemainingDevicePath == NULL) {\r
-    //\r
-    // RemainingDevicePath is NULL, scan IDE bus for each device;\r
-    //\r
-    BeginningIdeChannel = IdePrimary;\r
-    EndIdeChannel       = IdeSecondary;\r
-    BeginningIdeDevice  = IdeMaster;\r
-    //\r
-    // default, may be redefined by IdeInit\r
-    //\r
-    EndIdeDevice = IdeSlave;\r
-  } else {\r
+\r
+  } else if (!IsDevicePathEnd (RemainingDevicePath)) {\r
     //\r
-    // RemainingDevicePath is not NULL, only scan the specified device.\r
+    // RemainingDevicePath is the End of Device Path Node, \r
+    // only scan the specified device by RemainingDevicePath.\r
     //\r
     Node                = (EFI_DEV_PATH *) RemainingDevicePath;\r
     BeginningIdeChannel = Node->Atapi.PrimarySecondary;\r
@@ -451,6 +453,16 @@ IDEBusDriverBindingStart (
       Status = EFI_INVALID_PARAMETER;\r
       goto ErrorExit;\r
     }\r
+\r
+  } else {\r
+    //\r
+    // If RemainingDevicePath is not the End of Device Path Node,\r
+    // skip enumerate any device and return EFI_SUCESSS\r
+    // \r
+    BeginningIdeChannel = IdeMaxChannel;\r
+    EndIdeChannel       = IdeMaxChannel - 1;\r
+    BeginningIdeDevice  = IdeMaxDevice;\r
+    EndIdeDevice        = IdeMaxDevice - 1;\r
   }\r
 \r
   //\r
@@ -846,7 +858,7 @@ IDEBusDriverBindingStart (
   IdeInit->NotifyPhase (IdeInit, EfiIdeBusPhaseMaximum, 0);\r
 \r
   if (SupportedModes != NULL) {\r
-    gBS->FreePool (SupportedModes);\r
+    FreePool (SupportedModes);\r
   }\r
 \r
   PERF_START (NULL, "Finish IDE detection", "IDE", 1);\r