public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Marvin Häuser" <Marvin.Haeuser@outlook.com>
To: "edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "hao.a.wu@intel.com" <hao.a.wu@intel.com>
Subject: [PATCH v3] SourceLevelDebugPkg/DebugCommunicationLibUsb: Add endpoint configuration.
Date: Sat, 16 Jun 2018 16:16:24 +0000	[thread overview]
Message-ID: <VI1PR0801MB17904FE502FC830E2AE917E580730@VI1PR0801MB1790.eurprd08.prod.outlook.com> (raw)

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 sturcture.

V3:
  - Remove the static endpoint PCDs as requested.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Marvin Haeuser <Marvin.Haeuser@outlook.com>
---
 SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.c   | 18 ++++++++++++++++--
 SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.inf |  2 +-
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.c b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.c
index d996f80f59e3..1836c055267b 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 028b04afbf00..8009f62075ff 100644
--- a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.inf
+++ b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.inf
@@ -45,7 +45,7 @@ [Pcd]
   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
-- 
2.17.1.windows.2



             reply	other threads:[~2018-06-16 16:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-16 16:16 Marvin Häuser [this message]
2018-06-19  1:27 ` [PATCH v3] SourceLevelDebugPkg/DebugCommunicationLibUsb: Add endpoint configuration Wu, Hao A

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=VI1PR0801MB17904FE502FC830E2AE917E580730@VI1PR0801MB1790.eurprd08.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox