]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.c
updated the Bus Driver that is able to create all or one of its child handles on...
[mirror_edk2.git] / MdeModulePkg / Bus / Scsi / ScsiBusDxe / ScsiBus.c
index 2a765460b26a5e6709810627ccc0f95beb9e0dc7..d53fdc8eb38f433bb3eb7c742cc9b7664b23d607 100644 (file)
@@ -2,7 +2,7 @@
   SCSI Bus driver that layers on every SCSI Pass Thru and\r
   Extended SCSI Pass Thru protocol in the system.\r
 \r
-Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
+Copyright (c) 2006 - 2009, Intel Corporation. <BR>\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
@@ -142,9 +142,30 @@ SCSIBusDriverBindingSupported (
   IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
   )\r
 {\r
-  EFI_STATUS  Status;\r
-  EFI_SCSI_PASS_THRU_PROTOCOL *PassThru;\r
+  EFI_STATUS                      Status;\r
+  EFI_SCSI_PASS_THRU_PROTOCOL     *PassThru;\r
   EFI_EXT_SCSI_PASS_THRU_PROTOCOL *ExtPassThru;\r
+  EFI_DEV_PATH                    *Node;\r
+\r
+  if (RemainingDevicePath != NULL) {\r
+    Node = (EFI_DEV_PATH *) RemainingDevicePath;\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_SCSI_DP ||\r
+          DevicePathNodeLength(&Node->DevPath) != sizeof(ATAPI_DEVICE_PATH)) {\r
+        return EFI_UNSUPPORTED;\r
+      }\r
+    }\r
+  }\r
+\r
   //\r
   // Check for the existence of Extended SCSI Pass Thru Protocol and SCSI Pass Thru Protocol\r
   //\r
@@ -188,6 +209,9 @@ SCSIBusDriverBindingSupported (
     return EFI_SUCCESS;\r
   }\r
 \r
+  //\r
+  // Close the I/O Abstraction(s) used to perform the supported test\r
+  //\r
   gBS->CloseProtocol (\r
     Controller,\r
     &gEfiExtScsiPassThruProtocolGuid,\r
@@ -377,16 +401,32 @@ SCSIBusDriverBindingStart (
     ScsiBusDev = SCSI_BUS_CONTROLLER_DEVICE_FROM_THIS (BusIdentify);\r
   }\r
 \r
+  Lun  = 0;\r
   if (RemainingDevicePath == NULL) {\r
+    //\r
+    // If RemainingDevicePath is NULL, \r
+    // must enumerate all SCSI devices anyway\r
+    //\r
     SetMem (ScsiTargetId, TARGET_MAX_BYTES,0xFF);\r
-    Lun  = 0;\r
     FromFirstTarget = TRUE;\r
-  } else {\r
+\r
+  } else if (!IsDevicePathEnd (RemainingDevicePath)) {\r
+    //\r
+    // If RemainingDevicePath isn't the End of Device Path Node, \r
+    // only scan the specified device by RemainingDevicePath\r
+    //\r
     if (ScsiBusDev->ExtScsiSupport) {\r
       ScsiBusDev->ExtScsiInterface->GetTargetLun (ScsiBusDev->ExtScsiInterface, RemainingDevicePath, &TargetId, &Lun);  \r
     } else {\r
       ScsiBusDev->ScsiInterface->GetTargetLun (ScsiBusDev->ScsiInterface, RemainingDevicePath, &ScsiTargetId->ScsiId.Scsi, &Lun);\r
     }\r
+\r
+  } else {\r
+    //\r
+    // If RemainingDevicePath is the End of Device Path Node,\r
+    // skip enumerate any device and return EFI_SUCESSS\r
+    // \r
+    ScanOtherPuns = FALSE;\r
   }\r
 \r
   while(ScanOtherPuns) {\r
@@ -1024,7 +1064,7 @@ ScsiScanCreateDevice (
                                           );\r
   }\r
 \r
-  if (Status == EFI_OUT_OF_RESOURCES) {\r
+  if (EFI_ERROR(Status)) {\r
     FreePool (ScsiIoDevice);\r
     return Status;\r
   }\r