From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=40.92.65.96; helo=eur01-he1-obe.outbound.protection.outlook.com; envelope-from=marvin.haeuser@outlook.com; receiver=edk2-devel@lists.01.org Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-oln040092065096.outbound.protection.outlook.com [40.92.65.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 864DA211C3F51 for ; Wed, 13 Jun 2018 12:57:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/IqOZ3oMGk1TnznwnNiQUVK/gnoVnkNB+z5L7XlwZBA=; b=d9GFJRZD0JoGLZ1Yl163MODyn4h0SROm9TiHnDhkDHpQoUKOqI5zeYoC4uzjMi6wPzNSMbAfVz02dC5vhFnqhMEQIzHtpVZs2Th4E9TjweQ075Z7Ju2N0ygPXxGUQH8g+QtFft5EtEX9gQhKOZdkRlxVff3a18w9LDkPjrXyLtWhzZrG+lngOJvYT7iVZSFwWyvJVM0QwYFDuStOa6jqwMurvf0ZTSlWaogW997MJ6obh9riw3VKPytFfyI0vnyhcKbydg4Tz/WyGmAFDY3oZw0D8ApbeROGDH53F9UBtx4u5bTPH79ndJ4/XtGNG8Pd/bjL98vQmqtgY4bUNLGLDg== Received: from VE1EUR01FT040.eop-EUR01.prod.protection.outlook.com (10.152.2.55) by VE1EUR01HT055.eop-EUR01.prod.protection.outlook.com (10.152.3.60) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.863.11; Wed, 13 Jun 2018 19:57:53 +0000 Received: from VI1PR0801MB1790.eurprd08.prod.outlook.com (10.152.2.56) by VE1EUR01FT040.mail.protection.outlook.com (10.152.3.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.20.863.11 via Frontend Transport; Wed, 13 Jun 2018 19:57:53 +0000 Received: from VI1PR0801MB1790.eurprd08.prod.outlook.com ([fe80::b8fa:4bfe:9d63:439c]) by VI1PR0801MB1790.eurprd08.prod.outlook.com ([fe80::b8fa:4bfe:9d63:439c%2]) with mapi id 15.20.0841.019; Wed, 13 Jun 2018 19:57:53 +0000 From: =?iso-8859-1?Q?Marvin_H=E4user?= To: "edk2-devel@lists.01.org" CC: "hao.a.wu@intel.com" Thread-Topic: [PATCH v2] SourceLevelDebugPkg/DebugCommunicationLibUsb: Add endpoint configuration. Thread-Index: AQHUA1DQ/mf1XxE7gU6kNmXE15+v2Q== Date: Wed, 13 Jun 2018 19:57:53 +0000 Message-ID: Accept-Language: de-DE, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM6PR03CA0032.eurprd03.prod.outlook.com (2603:10a6:20b::45) To VI1PR0801MB1790.eurprd08.prod.outlook.com (2603:10a6:800:5b::15) x-incomingtopheadermarker: OriginalChecksum:84EEF3C69FA733F88999E24B709441E0CA8E927731A68EF8ADDE7D8A4F129F21; UpperCasedChecksum:8A438C18323EE5408A99C385C0F9A003A960C028CBE534C3C6D2C2623322E7B4; SizeAsReceived:7418; Count:48 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [ebui79wLXe2ZWWyMTTpW/AEou32is4F3] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VE1EUR01HT055; 7:nhQ1WPdz41iglnKrgClRzUdCSOiIAFJ2aCIDYIPqK14Kzwnjen8Mkq/1q8RoJF8OsMBOwiMrmgxrRLa0/sdJmcW3smVuY7wnU8xyOAk08fPko5VGaWFhaOAAJ7IyeNuMU/aThkOVZLDdjstKXB5mT0wtEFz9BtU401tsLw7mWSM9OLFKkKumKxMeyPQPVp1PvbFZGgqfZkdcmrcnxq7CEissJ5qkKiVwya9oQqaqFoBYt7V+3FvpBRcmrkBao1zh x-incomingheadercount: 48 x-eopattributedmessage: 0 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(201702061078)(5061506573)(5061507331)(1603103135)(2017031320274)(2017031324274)(2017031323274)(2017031322404)(1603101448)(1601125500)(1701031045); SRVR:VE1EUR01HT055; x-ms-traffictypediagnostic: VE1EUR01HT055: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(444000031); SRVR:VE1EUR01HT055; BCL:0; PCL:0; RULEID:; SRVR:VE1EUR01HT055; x-forefront-prvs: 07025866F6 x-forefront-antispam-report: SFV:NSPM; SFS:(7070007)(189003)(199004)(305945005)(99286004)(8676002)(81156014)(20460500001)(2351001)(104016004)(8936002)(5250100002)(106356001)(25786009)(105586002)(7696005)(68736007)(575784001)(2501003)(86362001)(74316002)(97736004)(72206003)(102836004)(4326008)(55016002)(82202002)(3280700002)(6916009)(5640700003)(6346003)(14454004)(87572001)(386003)(26005)(476003)(426003)(3660700001)(6436002)(33656002)(2900100001)(486006)(5660300001); DIR:OUT; SFP:1901; SCL:1; SRVR:VE1EUR01HT055; H:VI1PR0801MB1790.eurprd08.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:; received-spf: None (protection.outlook.com: outlook.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Marvin.Haeuser@outlook.com; x-microsoft-antispam-message-info: p2gGCuvKyrPNsQrkbC3SSvtW6o1Bs6rC4xC2tOX04qm/tSd+axP1skNtElhYOJbF6xRrmCIlaOUjwQI38OkC99Sdh8l7QcDx26pROxIZUChvAxEb9/qHzvEYNj4FQyiNy3Q3+xWDnkoUt1vEy+qRB/YcDO1kXw5PCwDn4eDE24rw3dH2bcYrXveziOjm9ZL4 MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 3aa5827f-80e2-45b8-037b-08d5d167f2d5 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 7181d4b0-87d6-4f4e-ba33-0d3746212cec X-MS-Exchange-CrossTenant-Network-Message-Id: 3aa5827f-80e2-45b8-037b-08d5d167f2d5 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 7181d4b0-87d6-4f4e-ba33-0d3746212cec X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Jun 2018 19:57:53.6702 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1EUR01HT055 Subject: [PATCH v2] SourceLevelDebugPkg/DebugCommunicationLibUsb: Add endpoint configuration. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jun 2018 19:57:57 -0000 Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable 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, two PCDs have been introduced to configure the in and out endpoints of the EHCI Debug Device. These may be set to 0 to retrieve the endpoints from the USB Device Descriptor directly. To ensure maximum compatibility, the PCD defaults have been set to the former hardcoded values. V2: - Store endpoint data in the USB Debug Port handle sturcture. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Marvin Haeuser --- SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLib= Usb.c | 32 ++++++++++++++++++-- SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLib= Usb.inf | 6 +++- SourceLevelDebugPkg/SourceLevelDebugPkg.dec = | 12 ++++++++ 3 files changed, 47 insertions(+), 3 deletions(-) diff --git a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugComm= unicationLibUsb.c b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/De= bugCommunicationLibUsb.c index d996f80f59e3..a9a9ea07a39b 100644 --- a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicati= onLibUsb.c +++ b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicati= onLibUsb.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; @@ -603,6 +611,8 @@ InitializeUsbDebugHardware ( UINT32 *UsbHCSParam; UINT8 DebugPortNumber; UINT8 Length; + UINT8 InEndpoint; + UINT8 OutEndpoint; =20 UsbDebugPortRegister =3D (USB_DEBUG_PORT_REGISTER *)((UINTN)Handle->UsbD= ebugPortMemoryBase + Handle->DebugPortOffset); UsbHCSParam =3D (UINT32 *)((UINTN)Handle->EhciMemoryBase + 0x04); @@ -722,6 +732,24 @@ InitializeUsbDebugHardware ( return RETURN_DEVICE_ERROR; } =20 + // + // Determine the usb debug device endpoints. + // + InEndpoint =3D PcdGet8 (PcdUsbDebugPortInEndpoint); + + if (InEndpoint =3D=3D 0) { + InEndpoint =3D UsbDebugPortDescriptor.DebugInEndpoint; + } + + OutEndpoint =3D PcdGet8 (PcdUsbDebugPortOutEndpoint); + + if (OutEndpoint =3D=3D 0) { + OutEndpoint =3D UsbDebugPortDescriptor.DebugOutEndpoint; + } + + Handle->InEndpoint =3D InEndpoint; + Handle->OutEndpoint =3D OutEndpoint; + // // enable the usb debug feature. // @@ -879,7 +907,7 @@ DebugPortWriteBuffer ( Sent =3D (UINT8)(NumberOfBytes - Total); } =20 - Status =3D UsbDebugPortOut(UsbDebugPortRegister, Buffer + Total, Sent,= OUTPUT_PID, 0x7F, 0x01, UsbDebugPortHandle->BulkOutToggle); + Status =3D UsbDebugPortOut(UsbDebugPortRegister, Buffer + Total, Sent,= OUTPUT_PID, 0x7F, UsbDebugPortHandle->OutEndpoint, UsbDebugPortHandle->Bul= kOutToggle); =20 if (RETURN_ERROR(Status)) { return Total; @@ -959,7 +987,7 @@ DebugPortPollBuffer ( UsbDebugPortRegister->SendPid =3D DATA1_PID; } UsbDebugPortRegister->UsbAddress =3D 0x7F; - UsbDebugPortRegister->UsbEndPoint =3D 0x82 & 0x0F; + UsbDebugPortRegister->UsbEndPoint =3D UsbDebugPortHandle->InEndpoint & 0= x0F; =20 // // Clearing W/R bit to indicate it's a READ operation diff --git a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugComm= unicationLibUsb.inf b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/= DebugCommunicationLibUsb.inf index 028b04afbf00..eb55e5ee0f63 100644 --- a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicati= onLibUsb.inf +++ b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicati= onLibUsb.inf @@ -43,9 +43,13 @@ [Pcd] # The pci address of ehci host controller, in which usb debug feature is= enabled. # The format of pci address please refer to SourceLevelDebugPkg.dec gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdUsbEhciPciAddress = ## CONSUMES + # The endpoint that should be used for read transactions from the usb de= bug device. + gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdUsbDebugPortInEndpoint = ## CONSUMES + # The endpoint that should be used for write transactions to the usb deb= ug device. + gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdUsbDebugPortOutEndpoint = ## 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 =20 [LibraryClasses] TimerLib diff --git a/SourceLevelDebugPkg/SourceLevelDebugPkg.dec b/SourceLevelDebug= Pkg/SourceLevelDebugPkg.dec index b89e9c6ad601..76410444f385 100644 --- a/SourceLevelDebugPkg/SourceLevelDebugPkg.dec +++ b/SourceLevelDebugPkg/SourceLevelDebugPkg.dec @@ -72,6 +72,18 @@ [PcdsFixedAtBuild, PcdsPatchableInModule] # @Expression 0x80000001 | (gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdUs= bEhciPciAddress & 0xF0000FFF) =3D=3D 0 gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdUsbEhciPciAddress|0x000EF000|UI= NT32|0x00000003 =20 + ## The endpoint that should be used for read transactions from the usb d= ebug device. + # 0: Determine the endpoint dynamically. + # other: The endpoint that should be used. + # @Prompt Configure the endpoint to read from the usb debug device. + gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdUsbDebugPortInEndpoint|0x82|UIN= T8|0x0000000b + + ## The endpoint that should be used for write transactions to the usb de= bug device. + # 0: Determine the endpoint dynamically. + # other: The endpoint that should be used. + # @Prompt Configure the endpoint to write to the usb debug device. + gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdUsbDebugPortOutEndpoint|0x01|UI= NT8|0x0000000c + ## The mask of exception numbers whose handlers would be ignored and can= not be replaced or=20 # hooked by Debug Agent Library. Masking INT1/INT3 is invalid. # @Prompt Configure exception numbers not to be hooked by Debug Agent. --=20 2.17.1.windows.2