From nobody Fri May 3 03:36:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=outlook.com Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1528806836494119.32521879449189; Tue, 12 Jun 2018 05:33:56 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 8A7722121AA0F; Tue, 12 Jun 2018 05:33:55 -0700 (PDT) Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-oln040092064082.outbound.protection.outlook.com [40.92.64.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 9189521214939 for ; Tue, 12 Jun 2018 05:33:53 -0700 (PDT) Received: from HE1EUR01FT058.eop-EUR01.prod.protection.outlook.com (10.152.0.51) by HE1EUR01HT008.eop-EUR01.prod.protection.outlook.com (10.152.1.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.863.11; Tue, 12 Jun 2018 12:33:50 +0000 Received: from VI1PR0801MB1790.eurprd08.prod.outlook.com (10.152.0.60) by HE1EUR01FT058.mail.protection.outlook.com (10.152.0.218) 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; Tue, 12 Jun 2018 12:33:50 +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; Tue, 12 Jun 2018 12:33:50 +0000 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=40.92.64.82; helo=eur01-db5-obe.outbound.protection.outlook.com; envelope-from=marvin.haeuser@outlook.com; receiver=edk2-devel@lists.01.org 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=3P73neqg1b9myV1V9SedElQFEdfbz0LkV2Kj98YyotE=; b=jucTaqH6/V6aGFThwZBX/D4Kd81rprrXf3twJoXIEPfwgGHTZIi9XutAPUK4i6iocm5AqqbCLmG1lXO+5frssnWbVGcLu7RZb0uUE/5lem7dMHFRA02sjNxlEW87U0pQgahRwgHKx4qmJcvIlUf74JhjwAZ+YRPiX5C6jG0wyclMCeiVAFokGmHHtA71Vp93euVNyehEjFMU5HDGrLi7J+HbDn6wIONqfs5gDZRAsV7k7TgEJggFalCM7jJ5Jsq2FnJ6sB/wMEz6eNrDPGXXQ8rRqmE1esAhbpzbUopceIBEY3ZEAoOnPDRN/CO/B8e/w+mOREJ6mzuV8h1n/ZluOA== From: =?iso-8859-1?Q?Marvin_H=E4user?= To: "edk2-devel@lists.01.org" Thread-Topic: [PATCH] SourceLevelDebugPkg/DebugCommunicationLibUsb: Add endpoint configuration. Thread-Index: AQHUAkmdG1LQz8obV0OUZc43/zz+CA== Date: Tue, 12 Jun 2018 12:33:50 +0000 Message-ID: Accept-Language: de-DE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM6PR06CA0016.eurprd06.prod.outlook.com (2603:10a6:20b:14::29) To VI1PR0801MB1790.eurprd08.prod.outlook.com (2603:10a6:800:5b::15) x-incomingtopheadermarker: OriginalChecksum:46068487063A97065A9AC89FDC368C8E0A41D34B78F1D5DB90F815080FBDC43E; UpperCasedChecksum:4090BCF1B2B5FDC86877C0201C470E869149D19303165C2C4E1C0A3615141A18; SizeAsReceived:7456; Count:48 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [qNRuIwIl1bvzkAOK39mlJCSHeCiXpar0] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; HE1EUR01HT008; 7:gx9ulM9IPEsFlVOGT9U8nQoTFiguOzZtS+s0PsM0uiopq+yvTT9gnZ79byM2IN5MhMzVsB73mRDMvk05r8njeOMM4JQMiWjkJv0TnK9mKGK9lJoWRVdAdEu+ekwGlSdFQoyCBa9Uwh2He4wVPxQSkEeLjM7WxspDOuH5OvtwFR1H/XUVEh05l6Jn0+jHxYgrQ9SenoawqtJaQhQ18mz4KCS88lkKLBLb/+XbgDIn+tpjLSYkkZPvaEoMJyM65Nu7 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:HE1EUR01HT008; x-ms-traffictypediagnostic: HE1EUR01HT008: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(444000031); SRVR:HE1EUR01HT008; BCL:0; PCL:0; RULEID:; SRVR:HE1EUR01HT008; x-forefront-prvs: 07013D7479 x-forefront-antispam-report: SFV:NSPM; SFS:(7070007)(189003)(199004)(87572001)(81156014)(20460500001)(3280700002)(5660300001)(6916009)(2351001)(8676002)(8936002)(3660700001)(82202002)(104016004)(14454004)(55016002)(5640700003)(72206003)(99286004)(33656002)(551934003)(6436002)(105586002)(97736004)(575784001)(106356001)(74316002)(86362001)(1857600001)(2501003)(26005)(4326008)(68736007)(305945005)(7696005)(426003)(102836004)(5250100002)(6346003)(25786009)(386003)(476003)(2900100001)(486006); DIR:OUT; SFP:1901; SCL:1; SRVR:HE1EUR01HT008; 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: AZ4wYuQtfK3MmUT+j5t89mJIDs9nCts+VmWU0NXtOFvFSSFWeAAZXa0K8pLQWdCYiieUaaCWberWO4y9ghykkVafNwYPg1tnfoF5I7Ib9iHCCjHTgvX9pvZ8vSHhCEpa5iVuBB/JJcsBy4Hfss7PK/vdhXh8F5kXSKfOV8oNsIWt+t/EqvrK2MyFp6LFJH3e MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 1c7974f8-336c-4324-1170-08d5d060bfc9 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 7181d4b0-87d6-4f4e-ba33-0d3746212cec X-MS-Exchange-CrossTenant-Network-Message-Id: 1c7974f8-336c-4324-1170-08d5d060bfc9 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 7181d4b0-87d6-4f4e-ba33-0d3746212cec X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Jun 2018 12:33:50.6795 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1EUR01HT008 Subject: [edk2] [PATCH] 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: , Cc: "hao.a.wu@intel.com" Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Marvin Haeuser --- SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLib= Usb.c | 46 +++++++++++++++++--- SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLib= Usb.inf | 4 ++ SourceLevelDebugPkg/SourceLevelDebugPkg.dec = | 12 +++++ 3 files changed, 55 insertions(+), 7 deletions(-) diff --git a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugComm= unicationLibUsb.c b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/De= bugCommunicationLibUsb.c index d996f80f59e3..bb4be7b0710f 100644 --- a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicati= onLibUsb.c +++ b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicati= onLibUsb.c @@ -583,6 +583,8 @@ NeedReinitializeHardware( 5. configure the usb debug device to debug mode. =20 @param Handle Debug port handle. + @param DebugInEndpoint IN Endpoint of the usb debug device. + @param DebugOutEndpoint OUT Endpoint of the usb debug device. =20 @retval TRUE The usb debug port hardware configuration is ch= anged. @retval FALSE The usb debug port hardware configuration is no= t changed. @@ -591,7 +593,9 @@ NeedReinitializeHardware( RETURN_STATUS EFIAPI InitializeUsbDebugHardware ( - IN USB_DEBUG_PORT_HANDLE *Handle + IN USB_DEBUG_PORT_HANDLE *Handle, + OUT UINT8 *DebugInEndpoint, OPTIONAL + OUT UINT8 *DebugOutEndpoint OPTIONAL ) { RETURN_STATUS Status; @@ -722,6 +726,14 @@ InitializeUsbDebugHardware ( return RETURN_DEVICE_ERROR; } =20 + if (DebugInEndpoint !=3D NULL) { + *DebugInEndpoint =3D UsbDebugPortDescriptor.DebugInEndpoint; + } + + if (DebugOutEndpoint !=3D NULL) { + *DebugOutEndpoint =3D UsbDebugPortDescriptor.DebugOutEndpoint; + } + // // enable the usb debug feature. // @@ -790,7 +802,7 @@ DebugPortReadBuffer ( } =20 if (NeedReinitializeHardware(UsbDebugPortHandle)) { - Status =3D InitializeUsbDebugHardware (UsbDebugPortHandle); + Status =3D InitializeUsbDebugHardware (UsbDebugPortHandle, NULL, NULL); if (RETURN_ERROR(Status)) { return 0; } @@ -845,6 +857,8 @@ DebugPortWriteBuffer ( UINT8 Sent; UINTN Total; UINT8 ReceivedPid; + UINT8 OutEndpoint; + UINT8 StaticOutEndpoint; =20 if (NumberOfBytes =3D=3D 0 || Buffer =3D=3D NULL) { return 0; @@ -864,12 +878,20 @@ DebugPortWriteBuffer ( } =20 if (NeedReinitializeHardware(UsbDebugPortHandle)) { - Status =3D InitializeUsbDebugHardware (UsbDebugPortHandle); + Status =3D InitializeUsbDebugHardware (UsbDebugPortHandle, NULL, &OutE= ndpoint); if (RETURN_ERROR(Status)) { return 0; } } =20 + StaticOutEndpoint =3D PcdGet8 (PcdUsbDebugPortOutEndpoint); + // + // If the endpoint has been configured statically, use it. + // + if (StaticOutEndpoint !=3D 0) { + OutEndpoint =3D StaticOutEndpoint; + } + UsbDebugPortRegister =3D (USB_DEBUG_PORT_REGISTER *)((UINTN)UsbDebugPort= Handle->UsbDebugPortMemoryBase + UsbDebugPortHandle->DebugPortOffset); =20 while ((Total < NumberOfBytes)) { @@ -879,7 +901,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, OutEndpoint, UsbDebugPortHandle->BulkOutToggle); =20 if (RETURN_ERROR(Status)) { return Total; @@ -924,6 +946,8 @@ DebugPortPollBuffer ( UINT8 Length; UINT8 Index; RETURN_STATUS Status; + UINT8 InEndpoint; + UINT8 StaticInEndpoint; =20 // // If Handle is NULL, it means memory is ready for use. @@ -936,12 +960,20 @@ DebugPortPollBuffer ( } =20 if (NeedReinitializeHardware(UsbDebugPortHandle)) { - Status =3D InitializeUsbDebugHardware(UsbDebugPortHandle); + Status =3D InitializeUsbDebugHardware(UsbDebugPortHandle, &InEndpoint,= NULL); if (RETURN_ERROR(Status)) { return FALSE; } } =20 + StaticInEndpoint =3D PcdGet8 (PcdUsbDebugPortInEndpoint); + // + // If the endpoint has been configured statically, use it. + // + if (StaticInEndpoint !=3D 0) { + InEndpoint =3D StaticInEndpoint; + } + // // If the data buffer is not empty, then return TRUE directly. // else initialize a usb read transaction and read data to the data buff= er. @@ -959,7 +991,7 @@ DebugPortPollBuffer ( UsbDebugPortRegister->SendPid =3D DATA1_PID; } UsbDebugPortRegister->UsbAddress =3D 0x7F; - UsbDebugPortRegister->UsbEndPoint =3D 0x82 & 0x0F; + UsbDebugPortRegister->UsbEndPoint =3D InEndpoint & 0x0F; =20 // // Clearing W/R bit to indicate it's a READ operation @@ -1078,7 +1110,7 @@ DebugPortInitialize ( =20 if (NeedReinitializeHardware(&Handle)) { DEBUG ((EFI_D_ERROR, "UsbDbg: Start EHCI debug port initialization!\n"= )); - Status =3D InitializeUsbDebugHardware (&Handle); + Status =3D InitializeUsbDebugHardware (&Handle, NULL, NULL); if (RETURN_ERROR(Status)) { DEBUG ((EFI_D_ERROR, "UsbDbg: Failed, please check if USB debug cabl= e is plugged into EHCI debug port correctly!\n")); goto Exit; diff --git a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugComm= unicationLibUsb.inf b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/= DebugCommunicationLibUsb.inf index 028b04afbf00..8d3a7e477802 100644 --- a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicati= onLibUsb.inf +++ b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicati= onLibUsb.inf @@ -43,6 +43,10 @@ [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 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 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel