]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c
Enhance the Usb bus driver to support Star with Remaining device path.
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbBusDxe / UsbEnumer.c
index 28052de91f58b27f49835bb88c65b93bf1f27240..6b46e5c3ce4548ef91f249a29b394e9f3d31a015 100644 (file)
@@ -288,18 +288,24 @@ UsbConnectDriver (
     // twisted TPL used. It should be no problem for us to connect\r
     // or disconnect at CALLBACK.\r
     //\r
-    OldTpl            = UsbGetCurrentTpl ();\r
-    DEBUG ((EFI_D_INFO, "UsbConnectDriver: TPL before connect is %d\n", OldTpl));\r
+    \r
+    //\r
+    // Only recursively wanted usb child device\r
+    //\r
+    if (UsbBusIsWantedUsbIO (UsbIf->Device->Bus, UsbIf)) {\r
+      OldTpl            = UsbGetCurrentTpl ();\r
+      DEBUG ((EFI_D_INFO, "UsbConnectDriver: TPL before connect is %d\n", OldTpl));\r
 \r
-    gBS->RestoreTPL (TPL_CALLBACK);\r
+      gBS->RestoreTPL (TPL_CALLBACK);\r
 \r
-    Status            = gBS->ConnectController (UsbIf->Handle, NULL, NULL, TRUE);\r
-    UsbIf->IsManaged  = (BOOLEAN)!EFI_ERROR (Status);\r
+      Status            = gBS->ConnectController (UsbIf->Handle, NULL, NULL, TRUE);\r
+      UsbIf->IsManaged  = (BOOLEAN)!EFI_ERROR (Status);\r
 \r
-    DEBUG ((EFI_D_INFO, "UsbConnectDriver: TPL after connect is %d\n", UsbGetCurrentTpl()));\r
-    ASSERT (UsbGetCurrentTpl () == TPL_CALLBACK);\r
+      DEBUG ((EFI_D_INFO, "UsbConnectDriver: TPL after connect is %d\n", UsbGetCurrentTpl()));\r
+      ASSERT (UsbGetCurrentTpl () == TPL_CALLBACK);\r
 \r
-    gBS->RaiseTPL (OldTpl);\r
+      gBS->RaiseTPL (OldTpl);\r
+    }\r
   }\r
 \r
   return Status;\r
@@ -656,13 +662,9 @@ UsbEnumerateNewDev (
   Parent  = HubIf->Device;\r
   Bus     = Parent->Bus;\r
   HubApi  = HubIf->HubApi;\r
-\r
-\r
-  //\r
-  // Wait at least 100 ms for the power on port to stable\r
-  //\r
-  gBS->Stall (100 * USB_STALL_1_MS);\r
-\r
+  \r
+  gBS->Stall (USB_WAIT_PORT_STABLE_STALL);\r
+  \r
   //\r
   // Hub resets the device for at least 10 milliseconds.\r
   // Host learns device speed. If device is of low/full speed\r
@@ -774,11 +776,8 @@ UsbEnumerateNewDev (
     DEBUG ((EFI_D_ERROR, "UsbEnumerateNewDev: failed to set device address - %r\n", Status));\r
     goto ON_ERROR;\r
   }\r
-\r
-  //\r
-  // Wait 20ms for set address to complete\r
-  //\r
-  gBS->Stall (20 * USB_STALL_1_MS);\r
+  \r
+  gBS->Stall (USB_SET_DEVICE_ADDRESS_STALL);\r
 \r
   DEBUG ((EFI_D_INFO, "UsbEnumerateNewDev: device is now ADDRESSED at %d\n", Address));\r
 \r
@@ -886,47 +885,44 @@ UsbEnumeratePort (
 \r
     if (USB_BIT_IS_SET (PortState.PortStatus, USB_PORT_STAT_OVERCURRENT)) {\r
       //\r
-      // Both OverCurrent and OverCurrentChange set, means over current occurs, \r
-      // which probably is caused by short circuit. It has to wait system hardware\r
-      // to perform recovery.\r
+      // Case1:\r
+      //   Both OverCurrent and OverCurrentChange set, means over current occurs, \r
+      //   which probably is caused by short circuit. It has to wait system hardware\r
+      //   to perform recovery.\r
       //\r
       DEBUG (( EFI_D_ERROR, "UsbEnumeratePort: Critical Over Current\n", Port));\r
       return EFI_DEVICE_ERROR;\r
       \r
-    } else {\r
-      //\r
-      // Only OverCurrentChange set, means system has been recoveried from \r
-      // over current. As a result, all ports are nearly power-off, so\r
-      // it's necessary to detach and enumerate all ports again. \r
-      //\r
-      DEBUG (( EFI_D_ERROR, "UsbEnumeratePort: 2.0 device Recovery Over Current\n", Port)); \r
-      goto ON_ENUMERATE;\r
-      \r
-    }\r
+    } \r
+    //\r
+    // Case2:\r
+    //   Only OverCurrentChange set, means system has been recoveried from \r
+    //   over current. As a result, all ports are nearly power-off, so\r
+    //   it's necessary to detach and enumerate all ports again. \r
+    //\r
+    DEBUG (( EFI_D_ERROR, "UsbEnumeratePort: 2.0 device Recovery Over Current\n", Port)); \r
   }\r
 \r
   if (USB_BIT_IS_SET (PortState.PortChangeStatus, USB_PORT_STAT_C_ENABLE)) {  \r
     //\r
-    // 1.1 roothub port reg doesn't reflect over-current state, while its counterpart\r
-    // on 2.0 roothub does. When over-current has influence on 1.1 device, the port \r
-    // would be disabled, so it's also necessary to detach and enumerate again.\r
+    // Case3:\r
+    //   1.1 roothub port reg doesn't reflect over-current state, while its counterpart\r
+    //   on 2.0 roothub does. When over-current has influence on 1.1 device, the port \r
+    //   would be disabled, so it's also necessary to detach and enumerate again.\r
     //\r
     DEBUG (( EFI_D_ERROR, "UsbEnumeratePort: 1.1 device Recovery Over Current\n", Port));\r
-    goto ON_ENUMERATE;\r
   }\r
   \r
   if (USB_BIT_IS_SET (PortState.PortChangeStatus, USB_PORT_STAT_C_CONNECTION)) {\r
     //\r
-    // Device connected or disconnected normally. \r
+    // Case4:\r
+    //   Device connected or disconnected normally. \r
     //\r
-    goto ON_ENUMERATE;\r
+    DEBUG ((EFI_D_ERROR, "UsbEnumeratePort: Device Connect/Discount Normally\n", Port));\r
   }\r
 \r
-ON_ENUMERATE:\r
-\r
   // \r
-  // In case there is already a device on this port logically, it's safety to remove\r
-  // and enumerate again.\r
+  // Following as the above cases, it's safety to remove and create again.\r
   //\r
   Child = UsbFindChild (HubIf, Port);\r
   \r
@@ -1011,6 +1007,7 @@ UsbHubEnumeration (
 \r
 **/\r
 VOID\r
+EFIAPI\r
 UsbRootHubEnumeration (\r
   IN EFI_EVENT            Event,\r
   IN VOID                 *Context\r