From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=40.92.72.34; helo=eur03-ve1-obe.outbound.protection.outlook.com; envelope-from=marvin.haeuser@outlook.com; receiver=edk2-devel@lists.01.org Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-oln040092072034.outbound.protection.outlook.com [40.92.72.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B6846212E13CE for ; Tue, 12 Jun 2018 12:10:29 -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=yP8G0FaCOSvm/UQQ8lSyU7TbeWQPX6KX2ciNY+8WESM=; b=S6UZ/1Yh4O3ii0iCcEEeThtRDqaePxPX6f035aPdKF7N7+GVP5JY3WKqr26fBv/2ZK0lkFciikUNP4tTSZgtxcXo6IsFIDVbe562XG7D83+JrLhL80CnyxiMq1Rr1lMQdzBcYb9+W7SM1ADb4k9gf1vN5LHraz1VPIBnBLx2IIFiFGDGdxG12TzB9hgtuAl9FLTwEdNrtpc0yZ5Gs16MkmhSoj23jQSnq7SHfM2ABqLwh+wxwgV/GloyVVM3W6Yk/eSIDGYuKommvpXZ6G97RTYoJca9C0K/jhbcMC8OB44943nqlOCUdaY/Rcr74SPwMO8AOMkdTCd6DvJvMNJxZw== Received: from DB5EUR03FT039.eop-EUR03.prod.protection.outlook.com (10.152.20.52) by DB5EUR03HT210.eop-EUR03.prod.protection.outlook.com (10.152.21.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.863.11; Tue, 12 Jun 2018 19:10:26 +0000 Received: from VI1PR0801MB1790.eurprd08.prod.outlook.com (10.152.20.59) by DB5EUR03FT039.mail.protection.outlook.com (10.152.21.120) 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 19:10:26 +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 19:10:26 +0000 From: =?iso-8859-1?Q?Marvin_H=E4user?= To: "edk2-devel@lists.01.org" , "hao.a.wu@intel.com" Thread-Topic: [PATCH] SourceLevelDebugPkg/DebugCommunicationLibUsb: Add endpoint configuration. Thread-Index: AQHUAkmdG1LQz8obV0OUZc43/zz+CKRc/R6g Date: Tue, 12 Jun 2018 19:10:26 +0000 Message-ID: References: In-Reply-To: Accept-Language: de-DE, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:DDD0775BEBAECC64C57AF07F8B364335BA52CE2359C9C98B601DE51B92D2548E; UpperCasedChecksum:9EE2E840807BFB060E832D11E36ACD44B6F124BEFDAE6C76EB199C57F3E13C12; SizeAsReceived:7214; Count:45 x-tmn: [dWZ0M0cdyXBVD0m/Ja5LQeScAvZtSzh6] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB5EUR03HT210; 7:oIzRsM/JwLJ25wr1Cs3ZJiAzqmhJttR7kdVr0kAbBgzD/2eSYJ5+rWIl4zlQftCmUDNQtunjMdXq1G182z9UC6h0UWOQ6Wd8L3i1dBc1+EWUs3rdYaJluKqcVsKSef3OnSVAfM/y1WcAzX2mhUkAIOj0efwFtC4CUscQ1z+bpEwQfUeXK+HAeKV1kZlKcdwohd7sdbbEemtZtXlckL/NZEFOWWeFgcZuES1wPJBcnS1POkkX+OHN4/MV9S/JiZZs x-incomingheadercount: 45 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:DB5EUR03HT210; x-ms-traffictypediagnostic: DB5EUR03HT210: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(444000031); SRVR:DB5EUR03HT210; BCL:0; PCL:0; RULEID:; SRVR:DB5EUR03HT210; x-forefront-prvs: 07013D7479 x-forefront-antispam-report: SFV:NSPM; SFS:(7070007)(189003)(199004)(13464003)(76176011)(966005)(99286004)(575784001)(86362001)(72206003)(14454004)(7696005)(110136005)(53546011)(102836004)(2940100002)(68736007)(2501003)(26005)(2900100001)(426003)(3280700002)(6346003)(476003)(11346002)(5250100002)(74316002)(446003)(3660700001)(305945005)(486006)(8936002)(20460500001)(87572001)(104016004)(25786009)(82202002)(6246003)(8676002)(81156014)(229853002)(6436002)(55016002)(6306002)(33656002)(551934003)(106356001)(105586002)(97736004)(5660300001); DIR:OUT; SFP:1901; SCL:1; SRVR:DB5EUR03HT210; 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: Wx/16lfZv06mUaVPWSOcWQKSn0+zkzf6IFr6/fgTzlQpZxJ+6gQceZ489SndbDX3T3h7gQPw6FBeDsZvz5nkRXla2dzcO+79upejSA1W0LwqYyUOJMBwQ1GDDKsmdL6rFe21AAaQzSv2uOg2Sj/LJyNcNLz9SHDso+Z/qNOjgIRX/Bqj/Kl0jyIY5lZ1RWJG MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 653cbc1c-b25b-4a83-037d-08d5d09827c6 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 7181d4b0-87d6-4f4e-ba33-0d3746212cec X-MS-Exchange-CrossTenant-Network-Message-Id: 653cbc1c-b25b-4a83-037d-08d5d09827c6 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 7181d4b0-87d6-4f4e-ba33-0d3746212cec X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Jun 2018 19:10:26.2517 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5EUR03HT210 Subject: Re: [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: , X-List-Received-Date: Tue, 12 Jun 2018 19:10:30 -0000 Content-Language: de-DE Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sorry, I made a mistake overlooking that the Initialization function is onl= y called under certain circumstances. I will submit a V2 soon. Thanks, Marvin > -----Original Message----- > From: edk2-devel On Behalf Of Marvin > H=E4user > Sent: Tuesday, June 12, 2018 2:34 PM > To: edk2-devel@lists.01.org > Cc: hao.a.wu@intel.com > Subject: [edk2] [PATCH] > SourceLevelDebugPkg/DebugCommunicationLibUsb: Add endpoint > configuration. >=20 > 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. >=20 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Marvin Haeuser > --- >=20 > SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommun > icationLibUsb.c | 46 +++++++++++++++++--- >=20 > SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommun > icationLibUsb.inf | 4 ++ > SourceLevelDebugPkg/SourceLevelDebugPkg.dec = | 12 > +++++ > 3 files changed, 55 insertions(+), 7 deletions(-) >=20 > diff --git > a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugComm > unicationLibUsb.c > b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugComm > unicationLibUsb.c > index d996f80f59e3..bb4be7b0710f 100644 > --- > a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugComm > unicationLibUsb.c > +++ > b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugComm > unic > +++ ationLibUsb.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 = changed. > @retval FALSE The usb debug port hardware configuration is = not > 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, > + &OutEndpoint); > 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)UsbDebugPortHandle->UsbDebugPortMemoryBase + > UsbDebugPortHandle->DebugPortOffset); >=20 > while ((Total < NumberOfBytes)) { > @@ -879,7 +901,7 @@ DebugPortWriteBuffer ( > Sent =3D (UINT8)(NumberOfBytes - Total); > } >=20 > - Status =3D UsbDebugPortOut(UsbDebugPortRegister, Buffer + Total, Sen= t, > 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 bu= ffer. > @@ -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 ca= ble > is plugged into EHCI debug port correctly!\n")); > goto Exit; > diff --git > a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugComm > unicationLibUsb.inf > b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugComm > unicationLibUsb.inf > index 028b04afbf00..8d3a7e477802 100644 > --- > a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugComm > unicationLibUsb.inf > +++ > b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugComm > unic > +++ ationLibUsb.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 > debug device. > + gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdUsbDebugPortInEndpoint > ## CONSUMES > + # The endpoint that should be used for write transactions to the usb > debug 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). >=20 > gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdDebugPortHandleBufferSize| > 23 ## SOMETIMES_CONSUMES > diff --git a/SourceLevelDebugPkg/SourceLevelDebugPkg.dec > b/SourceLevelDebugPkg/SourceLevelDebugPkg.dec > index b89e9c6ad601..76410444f385 100644 > --- a/SourceLevelDebugPkg/SourceLevelDebugPkg.dec > +++ b/SourceLevelDebugPkg/SourceLevelDebugPkg.dec > @@ -72,6 +72,18 @@ [PcdsFixedAtBuild, PcdsPatchableInModule] > # @Expression 0x80000001 | > (gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdUsbEhciPciAddress & > 0xF0000FFF) =3D=3D 0 >=20 > gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdUsbEhciPciAddress|0x000EF0 > 00|UINT32|0x00000003 >=20 > + ## The endpoint that should be used for read transactions from the usb > debug 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|0x > 82|U > + INT8|0x0000000b > + > + ## The endpoint that should be used for write transactions to the usb > debug 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|0 > x01| > + UINT8|0x0000000c > + > ## The mask of exception numbers whose handlers would be ignored and > cannot be replaced or > # hooked by Debug Agent Library. Masking INT1/INT3 is invalid. > # @Prompt Configure exception numbers not to be hooked by Debug > Agent. > -- > 2.17.1.windows.2 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel