]> git.proxmox.com Git - mirror_edk2.git/commitdiff
updated the Bus Driver that is able to create all or one of its child handles on...
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 14 Sep 2009 08:55:03 +0000 (08:55 +0000)
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 14 Sep 2009 08:55:03 +0000 (08:55 +0000)
The others changes include:
1. Check RemainingDevicePath at beginning of Supported(), make sure it has been verified before Start() is called.
2. Check IO protocol firstly rather than EfiDevicePathProtocolGuid, reduce the times entering into Start() function because EfiDevicePathProtocolGuid existed on most of handle.
3. If no any child device is created on last time, and RemainingDevicePath is valid Uart Devcie path, go on creating child device handle based on this RemainingDevicePath.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9262 6f19259b-4bc3-4df7-8a09-765794883524

IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.c
IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBus.c
MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.c
MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c
MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.c
MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
Nt32Pkg/WinNtBusDriverDxe/WinNtBusDriver.c
Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIo.c
UnixPkg/UnixBusDriverDxe/UnixBusDriver.c
UnixPkg/UnixSerialIoDxe/UnixSerialIo.c

index 47ec6b7b5e12b984827013b04aeae4ea0e77609b..a5ee00049e297a2ae54c6aea25b88dad5d85d897 100644 (file)
@@ -144,18 +144,66 @@ SerialControllerDriverSupported (
   EFI_STATUS                                Status;\r
   EFI_DEVICE_PATH_PROTOCOL                  *ParentDevicePath;\r
   EFI_ISA_IO_PROTOCOL                       *IsaIo;\r
-  UART_DEVICE_PATH                          UartNode;\r
+  UART_DEVICE_PATH                          *UartNode;\r
 \r
   //\r
-  // Ignore the RemainingDevicePath\r
+  // Check RemainingDevicePath validation\r
   //\r
+  if (RemainingDevicePath != NULL) {\r
+    //\r
+    // Check if RemainingDevicePath is the End of Device Path Node, \r
+    // if yes, go on checking other conditions\r
+    //\r
+    if (!IsDevicePathEnd (RemainingDevicePath)) {\r
+      //\r
+      // If RemainingDevicePath isn't the End of Device Path Node,\r
+      // check its validation\r
+      //\r
+      Status = EFI_UNSUPPORTED;\r
+\r
+      UartNode = (UART_DEVICE_PATH *) RemainingDevicePath;\r
+      if (UartNode->Header.Type != MESSAGING_DEVICE_PATH ||\r
+          UartNode->Header.SubType != MSG_UART_DP ||\r
+          sizeof (UART_DEVICE_PATH) != DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) UartNode)\r
+                                        ) {\r
+        goto Error;\r
+      }\r
+  \r
+      if (UartNode->BaudRate > SERIAL_PORT_MAX_BAUD_RATE) {\r
+        goto Error;\r
+      }\r
+  \r
+      if (UartNode->Parity < NoParity || UartNode->Parity > SpaceParity) {\r
+        goto Error;\r
+      }\r
+  \r
+      if (UartNode->DataBits < 5 || UartNode->DataBits > 8) {\r
+        goto Error;\r
+      }\r
+  \r
+      if (UartNode->StopBits < OneStopBit || UartNode->StopBits > TwoStopBits) {\r
+        goto Error;\r
+      }\r
+  \r
+      if ((UartNode->DataBits == 5) && (UartNode->StopBits == TwoStopBits)) {\r
+        goto Error;\r
+      }\r
+  \r
+      if ((UartNode->DataBits >= 6) && (UartNode->DataBits <= 8) && (UartNode->StopBits == OneFiveStopBits)) {\r
+        goto Error;\r
+      }\r
+  \r
+      Status = EFI_SUCCESS;\r
+    }\r
+  }\r
+\r
   //\r
   // Open the IO Abstraction(s) needed to perform the supported test\r
   //\r
   Status = gBS->OpenProtocol (\r
                   Controller,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID **) &ParentDevicePath,\r
+                  &gEfiIsaIoProtocolGuid,\r
+                  (VOID **) &IsaIo,\r
                   This->DriverBindingHandle,\r
                   Controller,\r
                   EFI_OPEN_PROTOCOL_BY_DRIVER\r
@@ -168,22 +216,27 @@ SerialControllerDriverSupported (
     return Status;\r
   }\r
 \r
+  //\r
+  // Close the I/O Abstraction(s) used to perform the supported test\r
+  //\r
   gBS->CloseProtocol (\r
          Controller,\r
-         &gEfiDevicePathProtocolGuid,\r
+         &gEfiIsaIoProtocolGuid,\r
          This->DriverBindingHandle,\r
          Controller\r
          );\r
 \r
+  //\r
+  // Open the EFI Device Path protocol needed to perform the supported test\r
+  //\r
   Status = gBS->OpenProtocol (\r
                   Controller,\r
-                  &gEfiIsaIoProtocolGuid,\r
-                  (VOID **) &IsaIo,\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
@@ -200,57 +253,14 @@ SerialControllerDriverSupported (
     Status = EFI_UNSUPPORTED;\r
     goto Error;\r
   }\r
-  //\r
-  // Make sure RemainingDevicePath is valid\r
-  //\r
-  if (RemainingDevicePath != NULL) {\r
-    Status = EFI_UNSUPPORTED;\r
-    CopyMem (\r
-      &UartNode,\r
-      (UART_DEVICE_PATH *) RemainingDevicePath,\r
-      sizeof (UART_DEVICE_PATH)\r
-      );\r
-    if (UartNode.Header.Type != MESSAGING_DEVICE_PATH ||\r
-        UartNode.Header.SubType != MSG_UART_DP ||\r
-        sizeof (UART_DEVICE_PATH) != DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) &UartNode)\r
-                                      ) {\r
-      goto Error;\r
-    }\r
-\r
-    if (UartNode.BaudRate > SERIAL_PORT_MAX_BAUD_RATE) {\r
-      goto Error;\r
-    }\r
-\r
-    if (UartNode.Parity < NoParity || UartNode.Parity > SpaceParity) {\r
-      goto Error;\r
-    }\r
-\r
-    if (UartNode.DataBits < 5 || UartNode.DataBits > 8) {\r
-      goto Error;\r
-    }\r
-\r
-    if (UartNode.StopBits < OneStopBit || UartNode.StopBits > TwoStopBits) {\r
-      goto Error;\r
-    }\r
-\r
-    if ((UartNode.DataBits == 5) && (UartNode.StopBits == TwoStopBits)) {\r
-      goto Error;\r
-    }\r
-\r
-    if ((UartNode.DataBits >= 6) && (UartNode.DataBits <= 8) && (UartNode.StopBits == OneFiveStopBits)) {\r
-      goto Error;\r
-    }\r
-\r
-    Status = EFI_SUCCESS;\r
-  }\r
 \r
 Error:\r
   //\r
-  // Close the I/O Abstraction(s) used to perform the supported test\r
+  // Close protocol, don't use device path protocol in the Support() function\r
   //\r
   gBS->CloseProtocol (\r
          Controller,\r
-         &gEfiIsaIoProtocolGuid,\r
+         &gEfiDevicePathProtocolGuid,\r
          This->DriverBindingHandle,\r
          Controller\r
          );\r
@@ -281,11 +291,11 @@ SerialControllerDriverStart (
   EFI_ISA_IO_PROTOCOL                 *IsaIo;\r
   SERIAL_DEV                          *SerialDevice;\r
   UINTN                               Index;\r
-  UART_DEVICE_PATH                    Node;\r
   EFI_DEVICE_PATH_PROTOCOL            *ParentDevicePath;\r
   EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer;\r
   UINTN                               EntryCount;\r
   EFI_SERIAL_IO_PROTOCOL              *SerialIo;\r
+  UART_DEVICE_PATH                    *UartNode;\r
 \r
   SerialDevice = NULL;\r
   //\r
@@ -328,9 +338,13 @@ SerialControllerDriverStart (
 \r
   if (Status == EFI_ALREADY_STARTED) {\r
 \r
-    if (RemainingDevicePath == NULL) {\r
+    if (RemainingDevicePath == NULL || IsDevicePathEnd (RemainingDevicePath)) {\r
+      //\r
+      // If RemainingDevicePath is NULL or is the End of Device Path Node\r
+      //\r
       return EFI_SUCCESS;\r
     }\r
+\r
     //\r
     // Make sure a child handle does not already exist.  This driver can only\r
     // produce one child per serial port.\r
@@ -357,24 +371,44 @@ SerialControllerDriverStart (
                         EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
                         );\r
         if (!EFI_ERROR (Status)) {\r
-          CopyMem (&Node, RemainingDevicePath, sizeof (UART_DEVICE_PATH));\r
+          UartNode = (UART_DEVICE_PATH *) RemainingDevicePath;\r
           Status = SerialIo->SetAttributes (\r
                                SerialIo,\r
-                               Node.BaudRate,\r
+                               UartNode->BaudRate,\r
                                SerialIo->Mode->ReceiveFifoDepth,\r
                                SerialIo->Mode->Timeout,\r
-                               (EFI_PARITY_TYPE) Node.Parity,\r
-                               Node.DataBits,\r
-                               (EFI_STOP_BITS_TYPE) Node.StopBits\r
+                               (EFI_PARITY_TYPE) UartNode->Parity,\r
+                               UartNode->DataBits,\r
+                               (EFI_STOP_BITS_TYPE) UartNode->StopBits\r
                                );\r
         }\r
         break;\r
       }\r
     }\r
+    FreePool (OpenInfoBuffer);\r
 \r
-    gBS->FreePool (OpenInfoBuffer);\r
-    return Status;\r
+    if (Index < EntryCount) {\r
+      //\r
+      // If gEfiSerialIoProtocolGuid is opened by one child device, return\r
+      //\r
+      return Status;\r
+    }\r
+    //\r
+    // If gEfiSerialIoProtocolGuid is not opened by any child device,\r
+    // go further to create child device handle based on RemainingDevicePath\r
+    //\r
   }\r
+\r
+  if (RemainingDevicePath != NULL) {\r
+    if (IsDevicePathEnd (RemainingDevicePath)) {\r
+      //\r
+      // If RemainingDevicePath is the End of Device Path Node,\r
+      // skip enumerate any device and return EFI_SUCESSS\r
+      // \r
+      return EFI_SUCCESS;\r
+    }\r
+  }\r
+\r
   //\r
   // Initialize the serial device instance\r
   //\r
@@ -388,6 +422,21 @@ SerialControllerDriverStart (
   SerialDevice->IsaIo               = IsaIo;\r
   SerialDevice->ParentDevicePath    = ParentDevicePath;\r
 \r
+  //\r
+  // Check if RemainingDevicePath is NULL, \r
+  // if yes, use the values from the gSerialDevTempate as no remaining device path was\r
+  // passed in.\r
+  //\r
+  if (RemainingDevicePath != NULL) {\r
+    //\r
+    // If RemainingDevicePath isn't NULL, \r
+    // match the configuration of the RemainingDevicePath. IsHandleSupported()\r
+    // already checked to make sure the RemainingDevicePath contains settings\r
+    // that we can support.\r
+    //\r
+    CopyMem (&SerialDevice->UartDevicePath, RemainingDevicePath, sizeof (UART_DEVICE_PATH));\r
+  }\r
+\r
   AddName (SerialDevice, IsaIo);\r
 \r
   for (Index = 0; SerialDevice->IsaIo->ResourceList->ResourceItem[Index].Type != EfiIsaAcpiResourceEndOfList; Index++) {\r
@@ -414,19 +463,6 @@ SerialControllerDriverStart (
     goto Error;\r
   }\r
 \r
-  if (RemainingDevicePath != NULL) {\r
-    //\r
-    // Match the configuration of the RemainingDevicePath. IsHandleSupported()\r
-    // already checked to make sure the RemainingDevicePath contains settings\r
-    // that we can support.\r
-    //\r
-    CopyMem (&SerialDevice->UartDevicePath, RemainingDevicePath, sizeof (UART_DEVICE_PATH));\r
-  } else {\r
-    //\r
-    // Use the values from the gSerialDevTempate as no remaining device path was\r
-    // passed in.\r
-    //\r
-  }\r
   //\r
   // Build the device path by appending the UART node to the ParentDevicePath.\r
   //The Uart setings are zero here, since  SetAttribute() will update them to match \r
index 4bd4413242c8599acaba15081c80eb08631d27da..588519de0db2e2705c78fa9fbd016c5a96e96e3c 100644 (file)
@@ -194,7 +194,7 @@ IDEBusDriverBindingSupported (
   }\r
   \r
   //\r
-  // If protocols were opened normally, closed it\r
+  // Close the I/O Abstraction(s) used to perform the supported test\r
   //\r
   gBS->CloseProtocol (\r
         Controller,\r
@@ -428,7 +428,7 @@ IDEBusDriverBindingStart (
    if (EnumAll || RemainingDevicePath == NULL) {\r
     //\r
     // If IdeInit->EnumAll is TRUE or RemainingDevicePath is NULL, \r
-    // must enumerate all IDE device anyway\r
+    // must enumerate all IDE devices anyway\r
     //\r
     BeginningIdeChannel = IdePrimary;\r
     EndIdeChannel       = IdeSecondary;\r
@@ -437,8 +437,8 @@ IDEBusDriverBindingStart (
 \r
   } else if (!IsDevicePathEnd (RemainingDevicePath)) {\r
     //\r
-    // RemainingDevicePath is the End of Device Path Node, \r
-    // only scan the specified device by RemainingDevicePath.\r
+    // If RemainingDevicePath isn't 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
@@ -456,7 +456,7 @@ IDEBusDriverBindingStart (
 \r
   } else {\r
     //\r
-    // If RemainingDevicePath is not the End of Device Path Node,\r
+    // If RemainingDevicePath is the End of Device Path Node,\r
     // skip enumerate any device and return EFI_SUCESSS\r
     // \r
     BeginningIdeChannel = IdeMaxChannel;\r
index 2325b645ed5e6fa3e8936a1ff0594c3f1704f9a4..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
index d0def777bd79aad2174e21344b6ff5f98ba896dc..b2f5fdbc7554166fa38bffe3a6da3576d0423b92 100644 (file)
@@ -2,7 +2,7 @@
 \r
     Usb Bus Driver Binding and Bus IO Protocol.\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation\r
+Copyright (c) 2004 - 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
@@ -1124,42 +1124,28 @@ UsbBusControllerDriverSupported (
   // Check whether device path is valid\r
   //\r
   if (RemainingDevicePath != NULL) {\r
-    DevicePathNode.DevPath = RemainingDevicePath;\r
-\r
-    if ((DevicePathNode.DevPath->Type    != MESSAGING_DEVICE_PATH) ||\r
-        (DevicePathNode.DevPath->SubType != MSG_USB_DP &&\r
-         DevicePathNode.DevPath->SubType != MSG_USB_CLASS_DP\r
-         && DevicePathNode.DevPath->SubType != MSG_USB_WWID_DP\r
-         )) {\r
-\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 (RemainingDevicePath)) {\r
+      //\r
+      // If RemainingDevicePath isn't the End of Device Path Node,\r
+      // check its validation\r
+      //\r
+      DevicePathNode.DevPath = RemainingDevicePath;\r
+      \r
+      if ((DevicePathNode.DevPath->Type    != MESSAGING_DEVICE_PATH) ||\r
+          (DevicePathNode.DevPath->SubType != MSG_USB_DP &&\r
+           DevicePathNode.DevPath->SubType != MSG_USB_CLASS_DP\r
+           && DevicePathNode.DevPath->SubType != MSG_USB_WWID_DP\r
+           )) {\r
+      \r
+        return EFI_UNSUPPORTED;\r
+      }\r
     }\r
   }\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
-  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
   // Check whether USB_HC2 protocol is installed\r
   //\r
@@ -1171,45 +1157,80 @@ UsbBusControllerDriverSupported (
                   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
+  if (EFI_ERROR (Status)) {\r
+    //\r
+    // If failed to open USB_HC2, fall back to USB_HC\r
+    //\r
+    Status = gBS->OpenProtocol (\r
+                    Controller,\r
+                    &gEfiUsbHcProtocolGuid,\r
+                    (VOID **) &UsbHc,\r
+                    This->DriverBindingHandle,\r
+                    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
+    // Close the USB_HC used to perform the supported test\r
+    //\r
     gBS->CloseProtocol (\r
           Controller,\r
-          &gEfiUsb2HcProtocolGuid,\r
+          &gEfiUsbHcProtocolGuid,\r
           This->DriverBindingHandle,\r
           Controller\r
           );\r
 \r
-    return EFI_SUCCESS;\r
-  }\r
+  } else {\r
 \r
+    //\r
+    // Close the USB_HC2 used to perform the supported test\r
+    //\r
+    gBS->CloseProtocol (\r
+           Controller,\r
+           &gEfiUsb2HcProtocolGuid,\r
+           This->DriverBindingHandle,\r
+           Controller\r
+           );\r
+  }\r
\r
   //\r
-  // If failed to open USB_HC2, fall back to USB_HC\r
+  // Open the EFI Device Path protocol needed to perform the supported test\r
   //\r
   Status = gBS->OpenProtocol (\r
                   Controller,\r
-                  &gEfiUsbHcProtocolGuid,\r
-                  (VOID **) &UsbHc,\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
   if (!EFI_ERROR (Status)) {\r
+    //\r
+    // Close protocol, don't use device path protocol in the Support() function\r
+    //\r
     gBS->CloseProtocol (\r
           Controller,\r
-          &gEfiUsbHcProtocolGuid,\r
+          &gEfiDevicePathProtocolGuid,\r
           This->DriverBindingHandle,\r
           Controller\r
           );\r
+\r
+    return EFI_SUCCESS;\r
   }\r
 \r
   return Status;\r
@@ -1283,6 +1304,16 @@ UsbBusControllerDriverStart (
     //\r
     // Save the passed in RemainingDevicePath this time\r
     //\r
+    if (RemainingDevicePath != NULL) {\r
+      if (IsDevicePathEnd (RemainingDevicePath)) {\r
+        //\r
+        // If RemainingDevicePath is the End of Device Path Node,\r
+        // skip enumerate any device and return EFI_SUCESSS\r
+        // \r
+        return EFI_SUCCESS;\r
+      }\r
+    }\r
+\r
     Status = UsbBusAddWantedUsbIoDP (UsbBusId, RemainingDevicePath);\r
     ASSERT (!EFI_ERROR (Status));\r
     //\r
index c59565fd1e4c69126243d0ca677ac263e58b43e7..2275d6efc986b66a8c7fb16c38043f043aa99fdd 100644 (file)
@@ -2,7 +2,7 @@
 \r
     Wrapper function for usb host controller interface.\r
 \r
-Copyright (c) 2007, Intel Corporation\r
+Copyright (c) 2007 - 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
@@ -1109,7 +1109,7 @@ UsbBusAddWantedUsbIoDP (
   //\r
   // Check whether remaining device path is valid\r
   //\r
-  if (RemainingDevicePath != NULL) {\r
+  if (RemainingDevicePath != NULL && !IsDevicePathEnd (RemainingDevicePath)) {\r
     if ((RemainingDevicePath->Type    != MESSAGING_DEVICE_PATH) ||\r
         (RemainingDevicePath->SubType != MSG_USB_DP &&\r
          RemainingDevicePath->SubType != MSG_USB_CLASS_DP\r
@@ -1127,24 +1127,31 @@ UsbBusAddWantedUsbIoDP (
 \r
   if (RemainingDevicePath == NULL) {\r
     //\r
-    // RemainingDevicePath== NULL means all Usb devices in this bus are wanted.\r
+    // RemainingDevicePath == NULL means all Usb devices in this bus are wanted.\r
     // Here use a Usb class Device Path in WantedUsbIoDPList to indicate all Usb devices\r
     // are wanted Usb devices\r
     //\r
     Status = UsbBusFreeUsbDPList (&Bus->WantedUsbIoDPList);\r
     ASSERT (!EFI_ERROR (Status));\r
     DevicePathPtr = DuplicateDevicePath ((EFI_DEVICE_PATH_PROTOCOL *) &mAllUsbClassDevicePath);\r
-  } else {\r
+  } else if (!IsDevicePathEnd (RemainingDevicePath)) {\r
     //\r
+    // If RemainingDevicePath isn't the End of Device Path Node, \r
     // Create new Usb device path according to the usb part in remaining device path\r
     //\r
     DevicePathPtr = GetUsbDPFromFullDP (RemainingDevicePath);\r
+  } else {\r
+    //\r
+    // If RemainingDevicePath is the End of Device Path Node,\r
+    // skip enumerate any device and return EFI_SUCESSS\r
+    // \r
+    return EFI_SUCCESS;\r
   }\r
 \r
   ASSERT (DevicePathPtr != NULL);\r
   Status = AddUsbDPToList (DevicePathPtr, &Bus->WantedUsbIoDPList);\r
   ASSERT (!EFI_ERROR (Status));\r
-  gBS->FreePool (DevicePathPtr);\r
+  FreePool (DevicePathPtr);\r
   return EFI_SUCCESS;\r
 }\r
 \r
index 5e3b689a18ccb2a9a7b2e84c6984b68399d7ed37..b68d45f7a4c659f665d45f13727fb714a17a87c0 100644 (file)
@@ -2,7 +2,7 @@
   Produces Simple Text Input Protocol, Simple Text Input Extended Protocol and\r
   Simple Text Output Protocol upon Serial IO Protocol.\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
@@ -124,34 +124,46 @@ TerminalDriverBindingSupported (
   // device path that describes a terminal communications protocol.\r
   //\r
   if (RemainingDevicePath != NULL) {\r
-\r
-    Node = (VENDOR_DEVICE_PATH *) RemainingDevicePath;\r
-\r
-    if (Node->Header.Type != MESSAGING_DEVICE_PATH ||\r
-        Node->Header.SubType != MSG_VENDOR_DP ||\r
-        DevicePathNodeLength(&Node->Header) != sizeof(VENDOR_DEVICE_PATH)) {\r
-\r
-      return EFI_UNSUPPORTED;\r
-\r
-    }\r
     //\r
-    // only supports PC ANSI, VT100, VT100+ and VT-UTF8 terminal types\r
+    // Check if RemainingDevicePath is the End of Device Path Node, \r
+    // if yes, go on checking other conditions\r
     //\r
-    if (!CompareGuid (&Node->Guid, &gEfiPcAnsiGuid) &&\r
-        !CompareGuid (&Node->Guid, &gEfiVT100Guid) &&\r
-        !CompareGuid (&Node->Guid, &gEfiVT100PlusGuid) &&\r
-        !CompareGuid (&Node->Guid, &gEfiVTUTF8Guid)) {\r
-\r
-      return EFI_UNSUPPORTED;\r
+    if (!IsDevicePathEnd (RemainingDevicePath)) {\r
+      //\r
+      // If RemainingDevicePath isn't the End of Device Path Node,\r
+      // check its validation\r
+      //\r
+      Node = (VENDOR_DEVICE_PATH *) RemainingDevicePath;\r
+  \r
+      if (Node->Header.Type != MESSAGING_DEVICE_PATH ||\r
+          Node->Header.SubType != MSG_VENDOR_DP ||\r
+          DevicePathNodeLength(&Node->Header) != sizeof(VENDOR_DEVICE_PATH)) {\r
+  \r
+        return EFI_UNSUPPORTED;\r
+  \r
+      }\r
+      //\r
+      // only supports PC ANSI, VT100, VT100+ and VT-UTF8 terminal types\r
+      //\r
+      if (!CompareGuid (&Node->Guid, &gEfiPcAnsiGuid) &&\r
+          !CompareGuid (&Node->Guid, &gEfiVT100Guid) &&\r
+          !CompareGuid (&Node->Guid, &gEfiVT100PlusGuid) &&\r
+          !CompareGuid (&Node->Guid, &gEfiVTUTF8Guid)) {\r
+  \r
+        return EFI_UNSUPPORTED;\r
+      }\r
     }\r
   }\r
   //\r
   // Open the IO Abstraction(s) needed to perform the supported test\r
+  // The Controller must support the Serial I/O Protocol.\r
+  // This driver is a bus driver with at most 1 child device, so it is\r
+  // ok for it to be already started.\r
   //\r
   Status = gBS->OpenProtocol (\r
                   Controller,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID **) &ParentDevicePath,\r
+                  &gEfiSerialIoProtocolGuid,\r
+                  (VOID **) &SerialIo,\r
                   This->DriverBindingHandle,\r
                   Controller,\r
                   EFI_OPEN_PROTOCOL_BY_DRIVER\r
@@ -164,22 +176,23 @@ TerminalDriverBindingSupported (
     return Status;\r
   }\r
 \r
+  //\r
+  // Close the I/O Abstraction(s) used to perform the supported test\r
+  //\r
   gBS->CloseProtocol (\r
         Controller,\r
-        &gEfiDevicePathProtocolGuid,\r
+        &gEfiSerialIoProtocolGuid,\r
         This->DriverBindingHandle,\r
         Controller\r
         );\r
 \r
   //\r
-  // The Controller must support the Serial I/O Protocol.\r
-  // This driver is a bus driver with at most 1 child device, so it is\r
-  // ok for it to be already started.\r
+  // Open the EFI Device Path protocol needed to perform the supported test\r
   //\r
   Status = gBS->OpenProtocol (\r
                   Controller,\r
-                  &gEfiSerialIoProtocolGuid,\r
-                  (VOID **) &SerialIo,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  (VOID **) &ParentDevicePath,\r
                   This->DriverBindingHandle,\r
                   Controller,\r
                   EFI_OPEN_PROTOCOL_BY_DRIVER\r
@@ -191,12 +204,13 @@ TerminalDriverBindingSupported (
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
+\r
   //\r
-  // Close the I/O Abstraction(s) used to perform the supported test\r
+  // Close protocol, don't use device path protocol in the Support() function\r
   //\r
   gBS->CloseProtocol (\r
         Controller,\r
-        &gEfiSerialIoProtocolGuid,\r
+        &gEfiDevicePathProtocolGuid,\r
         This->DriverBindingHandle,\r
         Controller\r
         );\r
@@ -353,8 +367,9 @@ TerminalDriverBindingStart (
 \r
     CopyMem (&DefaultNode->Guid, gTerminalType[TerminalType], sizeof (EFI_GUID));\r
     RemainingDevicePath = (EFI_DEVICE_PATH_PROTOCOL *) DefaultNode;\r
-  } else {\r
+  } else if (!IsDevicePathEnd (RemainingDevicePath)) {\r
     //\r
+    // If RemainingDevicePath isn't the End of Device Path Node, \r
     // Use the RemainingDevicePath to determine the terminal type\r
     //\r
     Node = (VENDOR_DEVICE_PATH *)RemainingDevicePath;\r
@@ -369,6 +384,12 @@ TerminalDriverBindingStart (
     } else {\r
       goto Error;\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
+    return EFI_SUCCESS;\r
   }\r
 \r
   //\r
index 86d7929671cf343339582e1c9375ce5a8a69e891..c2e76c348745e80435250ceb096b48499e614fbd 100644 (file)
@@ -1,6 +1,6 @@
 /**@file\r
 \r
-Copyright (c) 2006 - 2007, 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
@@ -239,20 +239,30 @@ Returns:
   // it is a legal Device Path Node for this bus driver's children.\r
   //\r
   if (RemainingDevicePath != NULL) {\r
-    if (RemainingDevicePath->Type != HARDWARE_DEVICE_PATH ||\r
-        RemainingDevicePath->SubType != HW_VENDOR_DP ||\r
-        DevicePathNodeLength(RemainingDevicePath) != sizeof(WIN_NT_VENDOR_DEVICE_PATH_NODE)) {\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-\r
-    for (Index = 0; Index < NT_PCD_ARRAY_SIZE; Index++) {\r
-      if (CompareGuid (&((VENDOR_DEVICE_PATH *) RemainingDevicePath)->Guid, mPcdEnvironment[Index].DevicePathGuid)) {\r
-        break;\r
+    //\r
+    // Check if RemainingDevicePath is the End of Device Path Node, \r
+    // if yes, go on checking other conditions\r
+    //\r
+    if (!IsDevicePathEnd (RemainingDevicePath)) {\r
+      //\r
+      // If RemainingDevicePath isn't the End of Device Path Node,\r
+      // check its validation\r
+      //\r
+      if (RemainingDevicePath->Type != HARDWARE_DEVICE_PATH ||\r
+          RemainingDevicePath->SubType != HW_VENDOR_DP ||\r
+          DevicePathNodeLength(RemainingDevicePath) != sizeof(WIN_NT_VENDOR_DEVICE_PATH_NODE)) {\r
+        return EFI_UNSUPPORTED;\r
+      }\r
+  \r
+      for (Index = 0; Index < NT_PCD_ARRAY_SIZE; Index++) {\r
+        if (CompareGuid (&((VENDOR_DEVICE_PATH *) RemainingDevicePath)->Guid, mPcdEnvironment[Index].DevicePathGuid)) {\r
+          break;\r
+        }\r
+      }\r
+  \r
+      if (Index >= NT_PCD_ARRAY_SIZE) {\r
+        return EFI_UNSUPPORTED;\r
       }\r
-    }\r
-\r
-    if (Index >= NT_PCD_ARRAY_SIZE) {\r
-      return EFI_UNSUPPORTED;\r
     }\r
   }\r
 \r
@@ -261,8 +271,8 @@ Returns:
   //\r
   Status = gBS->OpenProtocol (\r
                   ControllerHandle,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID **) &ParentDevicePath,\r
+                  &gEfiWinNtThunkProtocolGuid,\r
+                  (VOID **) &WinNtThunk,\r
                   This->DriverBindingHandle,\r
                   ControllerHandle,\r
                   EFI_OPEN_PROTOCOL_BY_DRIVER\r
@@ -275,17 +285,23 @@ Returns:
     return Status;\r
   }\r
 \r
+  //\r
+  // Close the I/O Abstraction(s) used to perform the supported test\r
+  //\r
   gBS->CloseProtocol (\r
         ControllerHandle,\r
-        &gEfiDevicePathProtocolGuid,\r
+        &gEfiWinNtThunkProtocolGuid,\r
         This->DriverBindingHandle,\r
         ControllerHandle\r
         );\r
 \r
+  //\r
+  // Open the EFI Device Path protocol needed to perform the supported test\r
+  //\r
   Status = gBS->OpenProtocol (\r
                   ControllerHandle,\r
-                  &gEfiWinNtThunkProtocolGuid,\r
-                  (VOID **) &WinNtThunk,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  (VOID **) &ParentDevicePath,\r
                   This->DriverBindingHandle,\r
                   ControllerHandle,\r
                   EFI_OPEN_PROTOCOL_BY_DRIVER\r
@@ -307,11 +323,11 @@ Returns:
   }\r
 \r
   //\r
-  // Close the I/O Abstraction(s) used to perform the supported test\r
+  // Close protocol, don't use device path protocol in the Support() function\r
   //\r
   gBS->CloseProtocol (\r
         ControllerHandle,\r
-        &gEfiWinNtThunkProtocolGuid,\r
+        &gEfiDevicePathProtocolGuid,\r
         This->DriverBindingHandle,\r
         ControllerHandle\r
         );\r
@@ -470,15 +486,25 @@ Returns:
       CreateDevice = TRUE;\r
       if (RemainingDevicePath != NULL) {\r
         CreateDevice  = FALSE;\r
-        Node          = (WIN_NT_VENDOR_DEVICE_PATH_NODE *) RemainingDevicePath;\r
-        if (Node->VendorDevicePath.Header.Type == HARDWARE_DEVICE_PATH &&\r
-            Node->VendorDevicePath.Header.SubType == HW_VENDOR_DP &&\r
-            DevicePathNodeLength (&Node->VendorDevicePath.Header) == sizeof (WIN_NT_VENDOR_DEVICE_PATH_NODE)\r
-            ) {\r
-          if (CompareGuid (&Node->VendorDevicePath.Guid, mPcdEnvironment[Index].DevicePathGuid) &&\r
-              Node->Instance == Count\r
+        //\r
+        // Check if RemainingDevicePath is the End of Device Path Node, \r
+        // if yes, don't create any child device \r
+        //\r
+        if (!IsDevicePathEnd (RemainingDevicePath)) {\r
+          //\r
+          // If RemainingDevicePath isn't the End of Device Path Node,\r
+          // check its validation\r
+          //\r
+          Node          = (WIN_NT_VENDOR_DEVICE_PATH_NODE *) RemainingDevicePath;\r
+          if (Node->VendorDevicePath.Header.Type == HARDWARE_DEVICE_PATH &&\r
+              Node->VendorDevicePath.Header.SubType == HW_VENDOR_DP &&\r
+              DevicePathNodeLength (&Node->VendorDevicePath.Header) == sizeof (WIN_NT_VENDOR_DEVICE_PATH_NODE)\r
               ) {\r
-            CreateDevice = TRUE;\r
+            if (CompareGuid (&Node->VendorDevicePath.Guid, mPcdEnvironment[Index].DevicePathGuid) &&\r
+                Node->Instance == Count\r
+                ) {\r
+              CreateDevice = TRUE;\r
+            }\r
           }\r
         }\r
       }\r
index 0f0243e1224d9949c55f9f1174c1dcc742fafc11..52d7ee8b06200a3584201611d5b48de40fb3fbbf 100644 (file)
@@ -188,7 +188,7 @@ Returns:
   }\r
 \r
   //\r
-  // If protocols were opened normally, closed it\r
+  // Close the I/O Abstraction(s) used to perform the supported test\r
   //\r
   gBS->CloseProtocol (\r
         Handle,\r
index 64f0245fc751249fac2e8b69270fb3f6d0f2356f..a7be30c3859a08713e640a47670dc9809e7501fd 100644 (file)
@@ -1,6 +1,6 @@
 /*+++\r
 \r
-Copyright (c) 2006, 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
@@ -186,20 +186,30 @@ Returns:
   // it is a legal Device Path Node for this bus driver's children.\r
   //\r
   if (RemainingDevicePath != NULL) {\r
-    if (RemainingDevicePath->Type != HARDWARE_DEVICE_PATH ||\r
-        RemainingDevicePath->SubType != HW_VENDOR_DP ||\r
-        DevicePathNodeLength(RemainingDevicePath) != sizeof(UNIX_VENDOR_DEVICE_PATH_NODE)) {\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-\r
-    for (Index = 0; Index < UNIX_PCD_ARRAY_SIZE; Index++) {\r
-      if (CompareGuid (&((VENDOR_DEVICE_PATH *) RemainingDevicePath)->Guid, mPcdEnvironment[Index].DevicePathGuid)) {\r
-        break;\r
+    //\r
+    // Check if RemainingDevicePath is the End of Device Path Node, \r
+    // if yes, go on checking other conditions\r
+    //\r
+    if (!IsDevicePathEnd (RemainingDevicePath)) {\r
+      //\r
+      // If RemainingDevicePath isn't the End of Device Path Node,\r
+      // check its validation\r
+      //\r
+      if (RemainingDevicePath->Type != HARDWARE_DEVICE_PATH ||\r
+          RemainingDevicePath->SubType != HW_VENDOR_DP ||\r
+          DevicePathNodeLength(RemainingDevicePath) != sizeof(UNIX_VENDOR_DEVICE_PATH_NODE)) {\r
+        return EFI_UNSUPPORTED;\r
+      }\r
+  \r
+      for (Index = 0; Index < UNIX_PCD_ARRAY_SIZE; Index++) {\r
+        if (CompareGuid (&((VENDOR_DEVICE_PATH *) RemainingDevicePath)->Guid, mPcdEnvironment[Index].DevicePathGuid)) {\r
+          break;\r
+        }\r
+      }\r
+  \r
+      if (Index >= UNIX_PCD_ARRAY_SIZE) {\r
+        return EFI_UNSUPPORTED;\r
       }\r
-    }\r
-\r
-    if (Index >= UNIX_PCD_ARRAY_SIZE) {\r
-      return EFI_UNSUPPORTED;\r
     }\r
   }\r
   \r
@@ -208,8 +218,8 @@ Returns:
   //\r
   Status = gBS->OpenProtocol (\r
                   ControllerHandle,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID **)&ParentDevicePath,\r
+                  &gEfiUnixThunkProtocolGuid,\r
+                  (VOID **)&UnixThunk,\r
                   This->DriverBindingHandle,\r
                   ControllerHandle,\r
                   EFI_OPEN_PROTOCOL_BY_DRIVER\r
@@ -222,17 +232,23 @@ Returns:
     return Status;\r
   }\r
 \r
+  //\r
+  // Close the I/O Abstraction(s) used to perform the supported test\r
+  //\r
   gBS->CloseProtocol (\r
         ControllerHandle,\r
-        &gEfiDevicePathProtocolGuid,\r
+        &gEfiUnixThunkProtocolGuid,\r
         This->DriverBindingHandle,\r
         ControllerHandle\r
         );\r
 \r
+  //\r
+  // Open the EFI Device Path protocol needed to perform the supported test\r
+  //\r
   Status = gBS->OpenProtocol (\r
                   ControllerHandle,\r
-                  &gEfiUnixThunkProtocolGuid,\r
-                  (VOID **)&UnixThunk,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  (VOID **)&ParentDevicePath,\r
                   This->DriverBindingHandle,\r
                   ControllerHandle,\r
                   EFI_OPEN_PROTOCOL_BY_DRIVER\r
@@ -253,12 +269,12 @@ Returns:
     Status = EFI_UNSUPPORTED;\r
   }\r
 \r
-  //\r
-  // Close the I/O Abstraction(s) used to perform the supported test\r
+   //\r
+  // Close protocol, don't use device path protocol in the Support() function\r
   //\r
   gBS->CloseProtocol (\r
         ControllerHandle,\r
-        &gEfiUnixThunkProtocolGuid,\r
+        &gEfiDevicePathProtocolGuid,\r
         This->DriverBindingHandle,\r
         ControllerHandle\r
         );\r
@@ -414,15 +430,25 @@ Returns:
       CreateDevice = TRUE;\r
       if (RemainingDevicePath != NULL) {\r
         CreateDevice  = FALSE;\r
-        Node          = (UNIX_VENDOR_DEVICE_PATH_NODE *) RemainingDevicePath;\r
-        if (Node->VendorDevicePath.Header.Type == HARDWARE_DEVICE_PATH &&\r
-            Node->VendorDevicePath.Header.SubType == HW_VENDOR_DP &&\r
-            DevicePathNodeLength (&Node->VendorDevicePath.Header) == sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)\r
-            ) {\r
-          if (CompareGuid (&Node->VendorDevicePath.Guid, mPcdEnvironment[Index].DevicePathGuid) &&\r
-              Node->Instance == Count\r
+        //\r
+        // Check if RemainingDevicePath is the End of Device Path Node, \r
+        // if yes, don't create any child device \r
+        //\r
+        if (!IsDevicePathEnd (RemainingDevicePath)) {\r
+          //\r
+          // If RemainingDevicePath isn't the End of Device Path Node,\r
+          // check its validation\r
+          //\r
+          Node          = (UNIX_VENDOR_DEVICE_PATH_NODE *) RemainingDevicePath;\r
+          if (Node->VendorDevicePath.Header.Type == HARDWARE_DEVICE_PATH &&\r
+              Node->VendorDevicePath.Header.SubType == HW_VENDOR_DP &&\r
+              DevicePathNodeLength (&Node->VendorDevicePath.Header) == sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)\r
               ) {\r
-            CreateDevice = TRUE;\r
+            if (CompareGuid (&Node->VendorDevicePath.Guid, mPcdEnvironment[Index].DevicePathGuid) &&\r
+                Node->Instance == Count\r
+                ) {\r
+              CreateDevice = TRUE;\r
+            }\r
           }\r
         }\r
       }\r
index edbfd0ad1353bfb715bea6e085946292d9b775cb..ff9bced4e98a7ffca598eaf725766b0e336198e3 100644 (file)
@@ -222,13 +222,54 @@ Returns:
   EFI_UNIX_IO_PROTOCOL      *UnixIo;\r
   UART_DEVICE_PATH          *UartNode;\r
 \r
+  //\r
+  // Check RemainingDevicePath validation\r
+  //\r
+  if (RemainingDevicePath != NULL) {\r
+    //\r
+    // Check if RemainingDevicePath is the End of Device Path Node, \r
+    // if yes, go on checking other conditions\r
+    //\r
+    if (!IsDevicePathEnd (RemainingDevicePath)) {\r
+      //\r
+      // If RemainingDevicePath isn't the End of Device Path Node,\r
+      // check its validation\r
+      //\r
+      Status = EFI_UNSUPPORTED;\r
+      UartNode  = (UART_DEVICE_PATH *) RemainingDevicePath;\r
+      if (UartNode->Header.Type != MESSAGING_DEVICE_PATH ||\r
+          UartNode->Header.SubType != MSG_UART_DP ||\r
+          DevicePathNodeLength((EFI_DEVICE_PATH_PROTOCOL *)UartNode) != sizeof(UART_DEVICE_PATH)) {\r
+        goto Error;\r
+      }\r
+      if (UartNode->BaudRate < 0 || UartNode->BaudRate > SERIAL_PORT_MAX_BAUD_RATE) {\r
+        goto Error;\r
+      }\r
+      if (UartNode->Parity < NoParity || UartNode->Parity > SpaceParity) {\r
+        goto Error;\r
+      }\r
+      if (UartNode->DataBits < 5 || UartNode->DataBits > 8) {\r
+        goto Error;\r
+      }\r
+      if (UartNode->StopBits < OneStopBit || UartNode->StopBits > TwoStopBits) {\r
+        goto Error;\r
+      }\r
+      if ((UartNode->DataBits == 5) && (UartNode->StopBits == TwoStopBits)) {\r
+        goto Error;\r
+      }\r
+      if ((UartNode->DataBits >= 6) && (UartNode->DataBits <= 8) && (UartNode->StopBits == OneFiveStopBits)) {\r
+        goto Error;\r
+      }\r
+    }\r
+  }\r
+\r
   //\r
   // Open the IO Abstraction(s) needed to perform the supported test\r
   //\r
   Status = gBS->OpenProtocol (\r
                   Handle,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID**)&ParentDevicePath,\r
+                  &gEfiUnixIoProtocolGuid,\r
+                  (VOID**)&UnixIo,\r
                   This->DriverBindingHandle,\r
                   Handle,\r
                   EFI_OPEN_PROTOCOL_BY_DRIVER\r
@@ -241,17 +282,23 @@ Returns:
     return Status;\r
   }\r
 \r
+  //\r
+  // Close the I/O Abstraction(s) used to perform the supported test\r
+  //\r
   gBS->CloseProtocol (\r
         Handle,\r
-        &gEfiDevicePathProtocolGuid,\r
+        &gEfiUnixIoProtocolGuid,\r
         This->DriverBindingHandle,\r
         Handle\r
         );\r
 \r
+  //\r
+  // Open the EFI Device Path protocol needed to perform the supported test\r
+  //\r
   Status = gBS->OpenProtocol (\r
                   Handle,\r
-                  &gEfiUnixIoProtocolGuid,\r
-                  (VOID**)&UnixIo,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  (VOID**)&ParentDevicePath,\r
                   This->DriverBindingHandle,\r
                   Handle,\r
                   EFI_OPEN_PROTOCOL_BY_DRIVER\r
@@ -264,6 +311,16 @@ Returns:
     return Status;\r
   }\r
 \r
+  //\r
+  // Close protocol, don't use device path protocol in the Support() function\r
+  //\r
+  gBS->CloseProtocol (\r
+        Handle,\r
+        &gEfiDevicePathProtocolGuid,\r
+        This->DriverBindingHandle,\r
+        Handle\r
+        );\r
+\r
   //\r
   // Make sure that the Unix Thunk Protocol is valid\r
   //\r
@@ -280,46 +337,9 @@ Returns:
     goto Error;\r
   }\r
 \r
-  if (RemainingDevicePath != NULL) {\r
-    Status    = EFI_UNSUPPORTED;\r
-    UartNode  = (UART_DEVICE_PATH *) RemainingDevicePath;\r
-    if (UartNode->Header.Type != MESSAGING_DEVICE_PATH ||\r
-        UartNode->Header.SubType != MSG_UART_DP ||\r
-        DevicePathNodeLength((EFI_DEVICE_PATH_PROTOCOL *)UartNode) != sizeof(UART_DEVICE_PATH)) {\r
-      goto Error;\r
-    }\r
-    if (UartNode->BaudRate < 0 || UartNode->BaudRate > SERIAL_PORT_MAX_BAUD_RATE) {\r
-      goto Error;\r
-    }\r
-    if (UartNode->Parity < NoParity || UartNode->Parity > SpaceParity) {\r
-      goto Error;\r
-    }\r
-    if (UartNode->DataBits < 5 || UartNode->DataBits > 8) {\r
-      goto Error;\r
-    }\r
-    if (UartNode->StopBits < OneStopBit || UartNode->StopBits > TwoStopBits) {\r
-      goto Error;\r
-    }\r
-    if ((UartNode->DataBits == 5) && (UartNode->StopBits == TwoStopBits)) {\r
-      goto Error;\r
-    }\r
-    if ((UartNode->DataBits >= 6) && (UartNode->DataBits <= 8) && (UartNode->StopBits == OneFiveStopBits)) {\r
-      goto Error;\r
-    }\r
-    Status = EFI_SUCCESS;\r
-  }\r
+  return EFI_SUCCESS;\r
 \r
 Error:\r
-  //\r
-  // Close the I/O Abstraction(s) used to perform the supported test\r
-  //\r
-  gBS->CloseProtocol (\r
-        Handle,\r
-        &gEfiUnixIoProtocolGuid,\r
-        This->DriverBindingHandle,\r
-        Handle\r
-        );\r
-\r
   return Status;\r
 }\r
 \r
@@ -353,6 +373,7 @@ Returns:
   UINTN                               Index;\r
   EFI_SERIAL_IO_PROTOCOL              *SerialIo;\r
   CHAR8                               AsciiDevName[1024];\r
+  UART_DEVICE_PATH                    *UartNode;\r
 \r
   DEBUG ((EFI_D_INFO, "SerialIo drive binding start!\r\n"));\r
   Private   = NULL;\r
@@ -396,7 +417,10 @@ Returns:
 \r
   if (Status == EFI_ALREADY_STARTED) {\r
 \r
-    if (RemainingDevicePath == NULL) {\r
+    if (RemainingDevicePath == NULL || IsDevicePathEnd (RemainingDevicePath)) {\r
+      //\r
+      // If RemainingDevicePath is NULL or is the End of Device Path Node\r
+      //\r
       return EFI_SUCCESS;\r
     }\r
 \r
@@ -426,15 +450,15 @@ Returns:
                         EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
                         );\r
         if (!EFI_ERROR (Status)) {\r
-          CopyMem (&Node, RemainingDevicePath, sizeof (UART_DEVICE_PATH));\r
+          UartNode = (UART_DEVICE_PATH *) RemainingDevicePath;\r
           Status = SerialIo->SetAttributes (\r
                               SerialIo,\r
-                              Node.BaudRate,\r
+                              UartNode->BaudRate,\r
                               SerialIo->Mode->ReceiveFifoDepth,\r
                               SerialIo->Mode->Timeout,\r
-                              Node.Parity,\r
-                              Node.DataBits,\r
-                              Node.StopBits\r
+                              UartNode->Parity,\r
+                              UartNode->DataBits,\r
+                              UartNode->StopBits\r
                               );\r
         }\r
         break;\r
@@ -442,7 +466,47 @@ Returns:
     }\r
 \r
     FreePool (OpenInfoBuffer);\r
-    return Status;\r
+    if (Index < EntryCount) {\r
+      //\r
+      // If gEfiUnixIoProtocolGuid is opened by one child device, return\r
+      //\r
+      return Status;\r
+    }\r
+    //\r
+    // If gEfiUnixIoProtocolGuid is not opened by any child device,\r
+    // go further to create child device handle based on RemainingDevicePath\r
+    //\r
+  }\r
+\r
+  if (RemainingDevicePath == NULL) {\r
+    //\r
+    // Build the device path by appending the UART node to the ParentDevicePath\r
+    // from the UnixIo handle. The Uart setings are zero here, since\r
+    // SetAttribute() will update them to match the default setings.\r
+    //\r
+    ZeroMem (&Node, sizeof (UART_DEVICE_PATH));\r
+    Node.Header.Type     = MESSAGING_DEVICE_PATH;\r
+    Node.Header.SubType  = MSG_UART_DP;\r
+    SetDevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) &Node, sizeof (UART_DEVICE_PATH));\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
+    //\r
+    // Match the configuration of the RemainingDevicePath. IsHandleSupported()\r
+    // already checked to make sure the RemainingDevicePath contains settings\r
+    // that we can support.\r
+    //\r
+    CopyMem (&Node, RemainingDevicePath, sizeof (UART_DEVICE_PATH));\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
+    return EFI_SUCCESS;\r
   }\r
 \r
   //\r
@@ -486,6 +550,8 @@ Returns:
   Private->Fifo.Last              = 0;\r
   Private->Fifo.Surplus           = SERIAL_MAX_BUFFER_SIZE;\r
 \r
+  CopyMem (&Private->UartDevicePath, &Node, sizeof (UART_DEVICE_PATH));\r
+\r
   AddUnicodeString (\r
     "eng",\r
     gUnixSerialIoComponentName.SupportedLanguages,\r
@@ -502,24 +568,7 @@ Returns:
   Private->SerialIo.Read          = UnixSerialIoRead;\r
   Private->SerialIo.Mode          = &Private->SerialIoMode;\r
 \r
-  if (RemainingDevicePath != NULL) {\r
-    //\r
-    // Match the configuration of the RemainingDevicePath. IsHandleSupported()\r
-    // already checked to make sure the RemainingDevicePath contains settings\r
-    // that we can support.\r
-    //\r
-    CopyMem (&Private->UartDevicePath, RemainingDevicePath, sizeof (UART_DEVICE_PATH));\r
-  } else {\r
-    //\r
-    // Build the device path by appending the UART node to the ParentDevicePath\r
-    // from the UnixIo handle. The Uart setings are zero here, since\r
-    // SetAttribute() will update them to match the default setings.\r
-    //\r
-    ZeroMem (&Private->UartDevicePath, sizeof (UART_DEVICE_PATH));\r
-    Private->UartDevicePath.Header.Type     = MESSAGING_DEVICE_PATH;\r
-    Private->UartDevicePath.Header.SubType  = MSG_UART_DP;\r
-    SetDevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) &Private->UartDevicePath, sizeof (UART_DEVICE_PATH));\r
-  }\r
+\r
 \r
   //\r
   // Build the device path by appending the UART node to the ParentDevicePath\r