]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Usb/UsbBusDxe/usbbus.h
Enhance the Usb bus driver to support Star with Remaining device path.
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbBusDxe / usbbus.h
index 5fd8e763e393ed775e9042afed43117a87061eec..e85fc84fe8f816b93cc7f860ac80109c9bc00a27 100644 (file)
@@ -32,6 +32,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Protocol/UsbIo.h>\r
 #include <Protocol/DevicePath.h>\r
 \r
+#include <library/BaseLib.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/UefiDriverEntryPoint.h>\r
@@ -55,20 +56,76 @@ typedef struct _USB_HUB_API    USB_HUB_API;
 #include "UsbEnumer.h"\r
 \r
 enum {\r
+  USB_MAX_LANG_ID           = 16,\r
+  USB_MAX_INTERFACE         = 16,\r
+  USB_MAX_DEVICES           = 128,\r
+\r
+  USB_BUS_1_MILLISECOND     = 1000,\r
+\r
   //\r
-  // Time definition\r
+  // Roothub and hub's polling interval, set by experience,\r
+  // The unit of roothub is 100us, means 1s as interval, and\r
+  // the unit of hub is 1ms, means 64ms as interval.\r
   //\r
-  USB_STALL_1_MS            = 1000,\r
-  TICKS_PER_MS              = 10000U,\r
-  USB_ROOTHUB_POLL_INTERVAL = 1000 * TICKS_PER_MS,\r
+  USB_ROOTHUB_POLL_INTERVAL = 1000 * 10000U,\r
   USB_HUB_POLL_INTERVAL     = 64,\r
 \r
   //\r
-  // Maximum definition\r
+  // Wait for port stable to work, refers to specification\r
+  // [USB20-9.1.2]\r
   //\r
-  USB_MAX_LANG_ID           = 16,\r
-  USB_MAX_INTERFACE         = 16,\r
-  USB_MAX_DEVICES           = 128,\r
+  USB_WAIT_PORT_STABLE_STALL     = 100 * USB_BUS_1_MILLISECOND,\r
+\r
+  //\r
+  // Wait for port statue reg change, set by experience\r
+  //\r
+  USB_WAIT_PORT_STS_CHANGE_STALL = 5 * USB_BUS_1_MILLISECOND,\r
+\r
+  //\r
+  // Wait for set device address, refers to specification\r
+  // [USB20-9.2.6.3, it says 2ms]\r
+  //\r
+  USB_SET_DEVICE_ADDRESS_STALL   = 20 * USB_BUS_1_MILLISECOND,\r
+\r
+  //\r
+  // Wait for retry max packet size, set by experience\r
+  //\r
+  USB_RETRY_MAX_PACK_SIZE_STALL  = 100 * USB_BUS_1_MILLISECOND,\r
+\r
+  //\r
+  // Wait for hub port power-on, refers to specification\r
+  // [USB20-11.23.2]\r
+  //\r
+  USB_SET_PORT_POWER_STALL       = 2 * USB_BUS_1_MILLISECOND,\r
+\r
+  //\r
+  // Wait for port reset, refers to specification\r
+  // [USB20-7.1.7.5, it says 10ms for hub and 50ms for\r
+  // root hub]\r
+  //\r
+  USB_SET_PORT_RESET_STALL       = 20 * USB_BUS_1_MILLISECOND,\r
+  USB_SET_ROOT_PORT_RESET_STALL  = 50 * USB_BUS_1_MILLISECOND,\r
+\r
+  //\r
+  // Wait for clear roothub port reset, set by experience\r
+  //\r
+  USB_CLR_ROOT_PORT_RESET_STALL  = 1 * USB_BUS_1_MILLISECOND,\r
+\r
+  //\r
+  // Wait for set roothub port enable, set by experience\r
+  //\r
+  USB_SET_ROOT_PORT_ENABLE_STALL = 20 * USB_BUS_1_MILLISECOND,\r
+\r
+  //\r
+  // Send general device request timeout, refers to\r
+  // specification[USB20-11.24.1]\r
+  //\r
+  USB_GENERAL_DEVICE_REQUEST_TIMEOUT = 50 * USB_BUS_1_MILLISECOND,\r
+\r
+  //\r
+  // Send clear feature request timeout, set by experience\r
+  //\r
+  USB_CLEAR_FEATURE_REQUEST_TIMEOUT  = 10 * USB_BUS_1_MILLISECOND,\r
 \r
   //\r
   // Bus raises TPL to TPL_NOTIFY to serialize all its operations\r
@@ -195,10 +252,62 @@ struct _USB_BUS {
   // for root hub. Device with address i is at Devices[i].\r
   //\r
   USB_DEVICE                *Devices[USB_MAX_DEVICES];\r
+\r
+  //\r
+  // USB Bus driver need to control the recursive connect policy of the bus, only those wanted\r
+  // usb child device will be recursively connected.\r
+  //\r
+  // WantedUsbIoDPList tracks the Usb child devices which user want to recursivly fully connecte,\r
+  // every wanted child device is stored in a item of the WantedUsbIoDPList, whose structrure is\r
+  // DEVICE_PATH_LIST_ITEM\r
+  //\r
+  LIST_ENTRY                WantedUsbIoDPList;\r
+\r
 };\r
 \r
-extern EFI_USB_IO_PROTOCOL           mUsbIoProtocol;\r
-extern EFI_DRIVER_BINDING_PROTOCOL   mUsbBusDriverBinding;\r
-extern EFI_COMPONENT_NAME_PROTOCOL   mUsbBusComponentName;\r
+#define USB_US_LAND_ID   0x0409\r
+\r
+#define DEVICE_PATH_LIST_ITEM_SIGNATURE     EFI_SIGNATURE_32('d','p','l','i')\r
+typedef struct _DEVICE_PATH_LIST_ITEM{\r
+  UINTN                                 Signature;\r
+  LIST_ENTRY                            Link;\r
+  EFI_DEVICE_PATH_PROTOCOL              *DevicePath;\r
+} DEVICE_PATH_LIST_ITEM;\r
+\r
+typedef struct {\r
+  USB_CLASS_DEVICE_PATH           UsbClass;\r
+  EFI_DEVICE_PATH_PROTOCOL        End;\r
+} USB_CLASS_FORMAT_DEVICE_PATH;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UsbBusFreeUsbDPList (\r
+  IN     LIST_ENTRY                                 *UsbIoDPList\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UsbBusAddWantedUsbIoDP (\r
+  IN EFI_USB_BUS_PROTOCOL         *UsbBusId,\r
+  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
+  );\r
+\r
+BOOLEAN\r
+EFIAPI\r
+UsbBusIsWantedUsbIO (\r
+  IN USB_BUS                 *Bus,\r
+  IN USB_INTERFACE           *UsbIf\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UsbBusRecursivelyConnectWantedUsbIo (\r
+  IN EFI_USB_BUS_PROTOCOL         *UsbBusId\r
+  );\r
+\r
+extern EFI_USB_IO_PROTOCOL            mUsbIoProtocol;\r
+extern EFI_DRIVER_BINDING_PROTOCOL    mUsbBusDriverBinding;\r
+extern EFI_COMPONENT_NAME_PROTOCOL    mUsbBusComponentName;\r
+extern EFI_COMPONENT_NAME2_PROTOCOL   mUsbBusComponentName2;\r
 \r
 #endif\r