]> git.proxmox.com Git - mirror_edk2.git/commitdiff
SourceLevelDebugPkg/DebugCommunicationLibUsb: Add endpoint config.
authorMarvin H?user <Marvin.Haeuser@outlook.com>
Sat, 16 Jun 2018 16:16:24 +0000 (00:16 +0800)
committerHao Wu <hao.a.wu@intel.com>
Tue, 19 Jun 2018 01:23:49 +0000 (09:23 +0800)
Currently, DebugCommunicationLibUsb uses the hardcoded endpoints 0x82
and 0x01 to communicate with the EHCI Debug Device. These, however,
are not standardized and may vary across different hardware.
To solve this problem, the endpoints are retrieved from the
USB Device Descriptor directly.

V2:
  - Store endpoint data in the USB Debug Port handle structure.

V3:
  - Remove the static endpoint PCDs as requested.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Marvin Haeuser <Marvin.Haeuser@outlook.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.c
SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.inf

index d996f80f59e31ed087c982bc2cf674b7e9136924..1836c055267b669422dac55edb62b32ed20dad30 100644 (file)
@@ -132,6 +132,14 @@ typedef struct _USB_DEBUG_PORT_HANDLE{
   //\r
   UINT32       EhciMemoryBase;\r
   //\r
+  // The usb debug device In endpoint.\r
+  //\r
+  UINT8        InEndpoint;\r
+  //\r
+  // The usb debug device Out endpoint.\r
+  //\r
+  UINT8        OutEndpoint;\r
+  //\r
   // The Bulk In endpoint toggle bit.\r
   //\r
   UINT8        BulkInToggle;\r
@@ -722,6 +730,12 @@ InitializeUsbDebugHardware (
       return RETURN_DEVICE_ERROR;\r
     }\r
 \r
+    //\r
+    // Determine the usb debug device endpoints.\r
+    //\r
+    Handle->InEndpoint  = UsbDebugPortDescriptor.DebugInEndpoint;\r
+    Handle->OutEndpoint = UsbDebugPortDescriptor.DebugOutEndpoint;\r
+\r
     //\r
     // enable the usb debug feature.\r
     //\r
@@ -879,7 +893,7 @@ DebugPortWriteBuffer (
       Sent = (UINT8)(NumberOfBytes - Total);\r
     }\r
 \r
-    Status = UsbDebugPortOut(UsbDebugPortRegister, Buffer + Total, Sent, OUTPUT_PID, 0x7F, 0x01, UsbDebugPortHandle->BulkOutToggle);\r
+    Status = UsbDebugPortOut(UsbDebugPortRegister, Buffer + Total, Sent, OUTPUT_PID, 0x7F, UsbDebugPortHandle->OutEndpoint, UsbDebugPortHandle->BulkOutToggle);\r
 \r
     if (RETURN_ERROR(Status)) {\r
       return Total;\r
@@ -959,7 +973,7 @@ DebugPortPollBuffer (
     UsbDebugPortRegister->SendPid  = DATA1_PID;\r
   }\r
   UsbDebugPortRegister->UsbAddress  = 0x7F;\r
-  UsbDebugPortRegister->UsbEndPoint = 0x82 & 0x0F;\r
+  UsbDebugPortRegister->UsbEndPoint = UsbDebugPortHandle->InEndpoint & 0x0F;\r
 \r
   //\r
   // Clearing W/R bit to indicate it's a READ operation\r
index 028b04afbf00e7fdb78af66b01d00c1e67e46385..8009f62075ff53b4b2e96e1f28eb8771e60721a6 100644 (file)
@@ -45,7 +45,7 @@
   gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdUsbEhciPciAddress              ## CONSUMES\r
   # The value of data buffer size used for USB debug port handle.\r
   # It should be equal to sizeof (USB_DEBUG_PORT_HANDLE).\r
-  gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdDebugPortHandleBufferSize|23   ## SOMETIMES_CONSUMES\r
+  gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdDebugPortHandleBufferSize|25   ## SOMETIMES_CONSUMES\r
 \r
 [LibraryClasses]\r
   TimerLib\r