From 73ae70db0f7a2ccada149e9dd03fda30923fdd75 Mon Sep 17 00:00:00 2001 From: Marvin H?user Date: Sun, 17 Jun 2018 00:16:24 +0800 Subject: SourceLevelDebugPkg/DebugCommunicationLibUsb: Add endpoint config. 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 Reviewed-by: Hao Wu --- .../DebugCommunicationLibUsb.c | 18 ++++++++++++++++-- .../DebugCommunicationLibUsb.inf | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) (limited to 'SourceLevelDebugPkg') diff --git a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.c b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.c index d996f80f59..1836c05526 100644 --- a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.c +++ b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.c @@ -132,6 +132,14 @@ typedef struct _USB_DEBUG_PORT_HANDLE{ // UINT32 EhciMemoryBase; // + // The usb debug device In endpoint. + // + UINT8 InEndpoint; + // + // The usb debug device Out endpoint. + // + UINT8 OutEndpoint; + // // The Bulk In endpoint toggle bit. // UINT8 BulkInToggle; @@ -722,6 +730,12 @@ InitializeUsbDebugHardware ( return RETURN_DEVICE_ERROR; } + // + // Determine the usb debug device endpoints. + // + Handle->InEndpoint = UsbDebugPortDescriptor.DebugInEndpoint; + Handle->OutEndpoint = UsbDebugPortDescriptor.DebugOutEndpoint; + // // enable the usb debug feature. // @@ -879,7 +893,7 @@ DebugPortWriteBuffer ( Sent = (UINT8)(NumberOfBytes - Total); } - Status = UsbDebugPortOut(UsbDebugPortRegister, Buffer + Total, Sent, OUTPUT_PID, 0x7F, 0x01, UsbDebugPortHandle->BulkOutToggle); + Status = UsbDebugPortOut(UsbDebugPortRegister, Buffer + Total, Sent, OUTPUT_PID, 0x7F, UsbDebugPortHandle->OutEndpoint, UsbDebugPortHandle->BulkOutToggle); if (RETURN_ERROR(Status)) { return Total; @@ -959,7 +973,7 @@ DebugPortPollBuffer ( UsbDebugPortRegister->SendPid = DATA1_PID; } UsbDebugPortRegister->UsbAddress = 0x7F; - UsbDebugPortRegister->UsbEndPoint = 0x82 & 0x0F; + UsbDebugPortRegister->UsbEndPoint = UsbDebugPortHandle->InEndpoint & 0x0F; // // Clearing W/R bit to indicate it's a READ operation diff --git a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.inf b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.inf index 028b04afbf..8009f62075 100644 --- a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.inf +++ b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.inf @@ -45,7 +45,7 @@ gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdUsbEhciPciAddress ## CONSUMES # The value of data buffer size used for USB debug port handle. # It should be equal to sizeof (USB_DEBUG_PORT_HANDLE). - gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdDebugPortHandleBufferSize|23 ## SOMETIMES_CONSUMES + gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdDebugPortHandleBufferSize|25 ## SOMETIMES_CONSUMES [LibraryClasses] TimerLib -- cgit v1.2.3