From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 5971A740037 for ; Fri, 13 Oct 2023 12:29:02 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=dR8ZBj69Ua72ywjW5o6YPgPk+ByidEXLS98d0htAvAA=; c=relaxed/simple; d=groups.io; h=From:Date:Subject:MIME-Version:Message-Id:References:In-Reply-To:To:Cc:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type:Content-Transfer-Encoding; s=20140610; t=1697200141; v=1; b=vXYOUmcrg2RkMZtgmEB4mW0hYHTqJArLEjz2LrwIymtu61BqUYNuvTtPUogxeByL9jpsnL0P 2SvisJbflwxsDCetoIkK1rvrdu3eewBzlYuLc4Sy5E8pPKuh2M3BdOnuvzdzbHMj4o7GrqMFCoc rrPWuS8Xb4YOuD5yu+6PF97Y= X-Received: by 127.0.0.2 with SMTP id mq3AYY7687511xOtkLFDUsyA; Fri, 13 Oct 2023 05:29:01 -0700 X-Received: from muminek.juszkiewicz.com.pl (muminek.juszkiewicz.com.pl [213.251.184.221]) by mx.groups.io with SMTP id smtpd.web11.37084.1697200139920933707 for ; Fri, 13 Oct 2023 05:29:00 -0700 X-Received: from localhost (localhost [127.0.0.1]) by muminek.juszkiewicz.com.pl (Postfix) with ESMTP id EBAB7260BB4; Fri, 13 Oct 2023 14:28:57 +0200 (CEST) X-Virus-Scanned: Debian amavis at juszkiewicz.com.pl X-Received: from muminek.juszkiewicz.com.pl ([127.0.0.1]) by localhost (muminek.juszkiewicz.com.pl [127.0.0.1]) (amavis, port 10024) with ESMTP id 5VqrUh_-tovk; Fri, 13 Oct 2023 14:28:56 +0200 (CEST) X-Received: from [172.17.0.1] (83.11.27.172.ipv4.supernova.orange.pl [83.11.27.172]) by muminek.juszkiewicz.com.pl (Postfix) with ESMTPSA id AE36B260C04; Fri, 13 Oct 2023 14:28:53 +0200 (CEST) From: "Marcin Juszkiewicz" Date: Fri, 13 Oct 2023 14:28:53 +0200 Subject: [edk2-devel] [PATCH edk2-platforms WIP 5/5] WIP: try to enable/disable proper USB controller MIME-Version: 1.0 Message-Id: <20231013-ehci-xhci-fix-v1-5-f56f28e70e36@linaro.org> References: <20231013-ehci-xhci-fix-v1-0-f56f28e70e36@linaro.org> In-Reply-To: <20231013-ehci-xhci-fix-v1-0-f56f28e70e36@linaro.org> To: devel@edk2.groups.io Cc: Leif Lindholm , Ard Biesheuvel , Jeremy Linton Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,marcin.juszkiewicz@linaro.org List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: DPbGg3ULSWLVIA76eQqqIpeqx7686176AA= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=vXYOUmcr; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=linaro.org (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io If platform version < 0.3 then we want EHCI. Otherwise XHCI needs to be present. The problem: LocateAndInstallAcpiFromFvConditional() gets only DBG2 and FACP tables. Looks like synchronization issue as there were moments when it got all present tables. Anyway even if all goes well then SSDT nodes for both XHCI and EHCI were present in resulting system. --- Platform/Qemu/SbsaQemu/SbsaQemu.dsc | 2 + .../Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf | 3 + .../Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c | 62 ++++++++++++++++= ++++ 3 files changed, 67 insertions(+) diff --git a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc b/Platform/Qemu/SbsaQemu/S= bsaQemu.dsc index 3900fed0c7dc..80ea4ed2edd2 100644 --- a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc +++ b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc @@ -172,6 +172,8 @@ [LibraryClasses.common] =20 ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseRepor= tStatusCodeLibNull.inf =20 + AcpiLib|EmbeddedPkg/Library/AcpiLib/AcpiLib.inf + ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf =20 diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.= inf b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf index 7c7e08e0fd3a..c67f9a92fd4c 100644 --- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf +++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf @@ -29,6 +29,7 @@ [Packages] Silicon/Qemu/SbsaQemu/SbsaQemu.dec =20 [LibraryClasses] + AcpiLib ArmLib BaseMemoryLib BaseLib @@ -50,6 +51,8 @@ [Pcd] gArmTokenSpaceGuid.PcdGicRedistributorsBase gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdGicItsBase gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdSmmuBase + gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMajor + gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMinor =20 [Depex] gEfiAcpiTableProtocolGuid ## CONSUMES diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.= c b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c index fd849ca1594b..b103111606e3 100644 --- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c +++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -26,6 +27,14 @@ =20 #pragma pack(1) =20 +/* + * The GUID inside Silicon/Qemu/SbsaQemu/AcpiTables/AcpiTables.inf _must_ = match + * below. + */ +STATIC CONST EFI_GUID mAcpiTableFile =3D { + 0x7E374E25, 0x8E01, 0x4FEE, { 0x87, 0xf2, 0x39, 0x0C, 0x23, 0xC6, 0x06, = 0xCD } + //7E374E25-8E01-4FEE-87F2-390C23C606CD +}; =20 static UINTN GicItsBase; =20 @@ -682,6 +691,55 @@ AddGtdtTable ( return Status; } =20 +// +// Monitor the ACPI tables being installed and when +// a DSDT/SSDT is detected check do we want to enable +// EHCI or XHCI USB controller +// +STATIC +BOOLEAN +HandleDynamicNamespace ( + IN EFI_ACPI_DESCRIPTION_HEADER *AcpiHeader + ) +{ + switch (AcpiHeader->Signature) { + case SIGNATURE_32 ('D', 'S', 'D', 'T'): + case SIGNATURE_32 ('S', 'S', 'D', 'T'): + if (AcpiHeader->OemTableId =3D=3D SIGNATURE_64 ('S', 'B', 'S', 'A', 'X= ', 'H', 'C', 'I')) + { + DEBUG ((DEBUG_ERROR, "HRW: XHCI\n")); + if (! PLATFORM_VERSION_LESS_THAN(0, 3) ) + { + + DEBUG ((DEBUG_ERROR, "HRW: XHCI enabled\n")); + return TRUE; + } + else + { + DEBUG ((DEBUG_ERROR, "HRW: XHCI disabled\n")); + return FALSE; + } + } + if (AcpiHeader->OemTableId =3D=3D SIGNATURE_64 ('S', 'B', 'S', 'A', 'E= ', 'H', 'C', 'I')) + { + DEBUG ((DEBUG_ERROR, "HRW: EHCI\n")); + if ( PLATFORM_VERSION_LESS_THAN(0, 3) ) + { + + DEBUG ((DEBUG_ERROR, "HRW: EHCI enabled\n")); + return TRUE; + } + else + { + DEBUG ((DEBUG_ERROR, "HRW: EHCI disabled\n")); + return FALSE; + } + } + } + + return TRUE; +} + EFI_STATUS EFIAPI InitializeSbsaQemuAcpiDxe ( @@ -738,5 +796,9 @@ InitializeSbsaQemuAcpiDxe ( DEBUG ((DEBUG_ERROR, "Failed to add GTDT table\n")); } =20 + Status =3D LocateAndInstallAcpiFromFvConditional (&mAcpiTableFile, + &HandleDynamicNamespace)= ; + ASSERT_EFI_ERROR (Status); + return EFI_SUCCESS; } --=20 2.41.0 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#109591): https://edk2.groups.io/g/devel/message/109591 Mute This Topic: https://groups.io/mt/101938744/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-