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 687687803E6 for ; Wed, 20 Mar 2024 13:15:52 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=Ek2KdYF2e1gF/nX7LKLaG2vmT6wpk+7qBOcMwwdo3IM=; 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:Resent-Date:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type:Content-Transfer-Encoding; s=20240206; t=1710940551; v=1; b=IKMOmutxn3Hj3nr8AvE6hgDpHFuPWgohDGvbTahN4BKG08ugZV0xG34cx9fjKV3z2/SHl6hN nD/5ahBYDsPzXs9cjEonvpkTgvNYwfv2MwUuud2t4X27ZcEH/eL4ZPAmIhJbYSoDpGEV7raiQIg 9OLISmMAiy8g2bcBh0nKJaYsbKv5y2Nis1o6roD583FaAb2X9qseR/m3z9cORJspJ0WoyMSZXAX nCglR4kch1VMf+rjDUQ9U1cO7iMkJEZtKFeki0wgBQnvooDXwfqj0InBzK1w6sjI0ONKWE8eiCt 1RBJH7XmBnsgbRjsbXDbkNpfo55ClmzsJH6cL+cfKnouA== X-Received: by 127.0.0.2 with SMTP id YEhsYY7687511xtcPTkO5n05; Wed, 20 Mar 2024 06:15:51 -0700 X-Received: from muminek.juszkiewicz.com.pl (muminek.juszkiewicz.com.pl [213.251.184.221]) by mx.groups.io with SMTP id smtpd.web10.44070.1710940550088510812 for ; Wed, 20 Mar 2024 06:15:50 -0700 X-Received: from localhost (localhost [127.0.0.1]) by muminek.juszkiewicz.com.pl (Postfix) with ESMTP id C24BD26108F; Wed, 20 Mar 2024 14:15:45 +0100 (CET) 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 gkE5vsRJST_8; Wed, 20 Mar 2024 14:15:44 +0100 (CET) X-Received: from [172.17.0.1] (83.11.22.169.ipv4.supernova.orange.pl [83.11.22.169]) by muminek.juszkiewicz.com.pl (Postfix) with ESMTPSA id 813E3260CC8; Wed, 20 Mar 2024 14:15:41 +0100 (CET) From: "Marcin Juszkiewicz" Date: Wed, 20 Mar 2024 14:15:33 +0100 Subject: [edk2-devel] [PATCH edk2-platforms v8 2/4] Platform/SbsaQemu: use SbsaQemuHardwareInfoLib for cpu information MIME-Version: 1.0 Message-Id: <20240320-no-dt-for-cpu-v8-2-599ba99861ec@linaro.org> References: <20240320-no-dt-for-cpu-v8-0-599ba99861ec@linaro.org> In-Reply-To: <20240320-no-dt-for-cpu-v8-0-599ba99861ec@linaro.org> To: devel@edk2.groups.io Cc: Leif Lindholm , Ard Biesheuvel , Graeme Gregory , Xiong Yining , Chen Baozi , Marcin Juszkiewicz 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 Resent-Date: Wed, 20 Mar 2024 06:15:50 -0700 Reply-To: devel@edk2.groups.io,marcin.juszkiewicz@linaro.org List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: uSutYKaEIqeoWsV9iYkxobiDx7686176AA= 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=20240206 header.b=IKMOmutx; 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 We have SbsaQemuHardwareInfoLib to ask for hardware details. No need to parse DeviceTree anymore. Signed-off-by: Marcin Juszkiewicz --- Platform/Qemu/SbsaQemu/OemMiscLib/OemMiscLib.inf | 6 ++---- .../Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf | 5 ++--- .../SbsaQemu/Library/SbsaQemuLib/SbsaQemuLib.inf | 4 ++-- Platform/Qemu/SbsaQemu/OemMiscLib/OemMiscLib.c | 11 +++++----- .../Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c | 21 +++++++---------= ---- 5 files changed, 18 insertions(+), 29 deletions(-) diff --git a/Platform/Qemu/SbsaQemu/OemMiscLib/OemMiscLib.inf b/Platform/Qe= mu/SbsaQemu/OemMiscLib/OemMiscLib.inf index a34f54d431d4..f959d8e0e4ee 100644 --- a/Platform/Qemu/SbsaQemu/OemMiscLib/OemMiscLib.inf +++ b/Platform/Qemu/SbsaQemu/OemMiscLib/OemMiscLib.inf @@ -3,7 +3,7 @@ # # Copyright (c) 2021, NUVIA Inc. All rights reserved. # Copyright (c) 2018, Hisilicon Limited. All rights reserved. -# Copyright (c) 2018, Linaro Limited. All rights reserved. +# Copyright (c) 2018-2024, Linaro Ltd. All rights reserved. # # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -29,8 +29,7 @@ [Packages] =20 [LibraryClasses] BaseMemoryLib - FdtLib - FdtHelperLib + HardwareInfoLib IoLib PcdLib =20 @@ -40,7 +39,6 @@ [Guids] [Pcd] gArmTokenSpaceGuid.PcdEmbeddedControllerFirmwareRelease gArmTokenSpaceGuid.PcdSystemBiosRelease - gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdDeviceTreeBaseAddress =20 gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdSystemManufacturer gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdSystemSerialNumber diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.= inf b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf index 291743b19115..727c8e82d16e 100644 --- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf +++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf @@ -1,7 +1,7 @@ ## @file # This driver modifies ACPI tables for the Qemu SBSA platform # -# Copyright (c) 2020, Linaro Ltd. All rights reserved. +# Copyright (c) 2020-2024, Linaro Ltd. All rights reserved. # # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -35,7 +35,7 @@ [LibraryClasses] BaseLib DebugLib DxeServicesLib - FdtHelperLib + HardwareInfoLib PcdLib PrintLib UefiDriverEntryPoint @@ -44,7 +44,6 @@ [LibraryClasses] =20 [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiTableStorageFile - gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdCoreCount gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdClusterCount =20 gArmTokenSpaceGuid.PcdGicDistributorBase diff --git a/Silicon/Qemu/SbsaQemu/Library/SbsaQemuLib/SbsaQemuLib.inf b/Si= licon/Qemu/SbsaQemu/Library/SbsaQemuLib/SbsaQemuLib.inf index c067a80cc715..07e6bc4e9b11 100644 --- a/Silicon/Qemu/SbsaQemu/Library/SbsaQemuLib/SbsaQemuLib.inf +++ b/Silicon/Qemu/SbsaQemu/Library/SbsaQemuLib/SbsaQemuLib.inf @@ -1,6 +1,6 @@ #/* @file # -# Copyright (c) 2019, Linaro Limited. All rights reserved. +# Copyright (c) 2019-2024, Linaro Limited. All rights reserved. # # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -32,9 +32,9 @@ [LibraryClasses] ArmLib BaseMemoryLib DebugLib - FdtLib MemoryAllocationLib PcdLib + SbsaQemuHardwareInfoLib =20 [Pcd] gArmTokenSpaceGuid.PcdSystemMemoryBase diff --git a/Platform/Qemu/SbsaQemu/OemMiscLib/OemMiscLib.c b/Platform/Qemu= /SbsaQemu/OemMiscLib/OemMiscLib.c index c38f2851904f..854f6f4072d5 100644 --- a/Platform/Qemu/SbsaQemu/OemMiscLib/OemMiscLib.c +++ b/Platform/Qemu/SbsaQemu/OemMiscLib/OemMiscLib.c @@ -2,7 +2,7 @@ * OemMiscLib.c * * Copyright (c) 2021, NUVIA Inc. All rights reserved. -* Copyright (c) 2020, Linaro Ltd. All rights reserved. +* Copyright (c) 2020-2024, Linaro Ltd. All rights reserved. * * SPDX-License-Identifier: BSD-2-Clause-Patent * @@ -12,14 +12,13 @@ #include #include #include -#include #include #include #include #include +#include #include #include -#include =20 /** Returns whether the specified processor is present or not. =20 @@ -33,7 +32,7 @@ OemIsProcessorPresent ( UINTN ProcessorIndex ) { - if (ProcessorIndex < FdtHelperCountCpus ()) { + if (ProcessorIndex < GetCpuCount ()) { return TRUE; } =20 @@ -76,7 +75,7 @@ OemGetProcessorInformation ( { UINT16 ProcessorCount; =20 - ProcessorCount =3D FdtHelperCountCpus (); + ProcessorCount =3D GetCpuCount (); =20 if (ProcessorIndex < ProcessorCount) { ProcessorStatus->Bits.CpuStatus =3D 1; // CPU enabled @@ -121,7 +120,7 @@ OemGetMaxProcessors ( VOID ) { - return FdtHelperCountCpus (); + return GetCpuCount (); } =20 /** Gets information about the cache at the specified cache level. diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.= c b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c index 9fb17151d7b8..4ebe2a445344 100644 --- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c +++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c @@ -1,7 +1,7 @@ /** @file * This file is an ACPI driver for the Qemu SBSA platform. * -* Copyright (c) 2020, Linaro Ltd. All rights reserved. +* Copyright (c) 2020-2024, Linaro Ltd. All rights reserved. * * SPDX-License-Identifier: BSD-2-Clause-Patent * @@ -15,10 +15,10 @@ #include #include #include -#include #include #include #include +#include #include #include #include @@ -255,8 +255,7 @@ AddMadtTable ( // Initialize GIC Redistributor Structure EFI_ACPI_6_0_GICR_STRUCTURE Gicr =3D SBSAQEMU_MADT_GICR_INIT(); =20 - // Get CoreCount which was determined eariler after parsing device tree - NumCores =3D PcdGet32 (PcdCoreCount); + NumCores =3D GetCpuCount (); =20 // Calculate the new table size based on the number of cores TableSize =3D sizeof (EFI_ACPI_6_0_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADE= R) + @@ -291,13 +290,13 @@ AddMadtTable ( New +=3D sizeof (EFI_ACPI_6_0_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER); =20 // Add new GICC structures for the Cores - for (CoreIndex =3D 0; CoreIndex < PcdGet32 (PcdCoreCount); CoreIndex++) = { + for (CoreIndex =3D 0; CoreIndex < NumCores; CoreIndex++) { EFI_ACPI_6_0_GIC_STRUCTURE *GiccPtr; =20 CopyMem (New, &Gicc, sizeof (EFI_ACPI_6_0_GIC_STRUCTURE)); GiccPtr =3D (EFI_ACPI_6_0_GIC_STRUCTURE *) New; GiccPtr->AcpiProcessorUid =3D CoreIndex; - GiccPtr->MPIDR =3D FdtHelperGetMpidr (CoreIndex); + GiccPtr->MPIDR =3D GetMpidr (CoreIndex); New +=3D sizeof (EFI_ACPI_6_0_GIC_STRUCTURE); } =20 @@ -396,7 +395,7 @@ AddSsdtTable ( UINT32 CpuId; UINT32 Offset; UINT8 ScopeOpName[] =3D SBSAQEMU_ACPI_SCOPE_NAME; - UINT32 NumCores =3D PcdGet32 (PcdCoreCount); + UINT32 NumCores =3D GetCpuCount (); =20 EFI_ACPI_DESCRIPTION_HEADER Header =3D SBSAQEMU_ACPI_HEADER ( @@ -497,7 +496,7 @@ AddPpttTable ( EFI_PHYSICAL_ADDRESS PageAddress; UINT8 *New; UINT32 CpuId; - UINT32 NumCores =3D PcdGet32 (PcdCoreCount); + UINT32 NumCores =3D GetCpuCount (); =20 EFI_ACPI_6_3_PPTT_STRUCTURE_CACHE L1DCache =3D SBSAQEMU_ACPI_PPTT_L1_D_C= ACHE_STRUCT; EFI_ACPI_6_3_PPTT_STRUCTURE_CACHE L1ICache =3D SBSAQEMU_ACPI_PPTT_L1_I_C= ACHE_STRUCT; @@ -758,12 +757,6 @@ InitializeSbsaQemuAcpiDxe ( { EFI_STATUS Status; EFI_ACPI_TABLE_PROTOCOL *AcpiTable; - UINT32 NumCores; - - // Parse the device tree and get the number of CPUs - NumCores =3D FdtHelperCountCpus (); - Status =3D PcdSet32S (PcdCoreCount, NumCores); - ASSERT_RETURN_ERROR (Status); =20 // Check if ACPI Table Protocol has been installed Status =3D gBS->LocateProtocol ( --=20 2.44.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 (#116939): https://edk2.groups.io/g/devel/message/116939 Mute This Topic: https://groups.io/mt/105044064/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-