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 AE5819411F3 for ; Thu, 28 Mar 2024 07:47:10 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=YHOPijCgEkqlBZ1KirIg8mSl81ldYllCGJooJ/9Ro1g=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20240206; t=1711612029; v=1; b=YXxxB3sTmfMcCLWU3oA0JoR3iCJM7i5/nZEsEUSpInE01U5o0I6cx/fhNhMl2iFR0w1JAFPa 6ZXTnpw0RE7JOtQ+hEmW1nIRFB/OpVF/0i9WYz6jmQVUe8ZKh1gBG6bSMHJANsGRwY5wGKSlt/h CQtnP3u16fk6reZctkxc1KnKE36FrYkglEDEAjoQM9zLmbrbc16YVir15oCTmv75R8W2G/KrUxC QELKour1GtUIE2kB+gErxS5+pnEcVOCHiCruicu4+M9D06oqO2kyDBZPDMngOB5gBOP30460u1I A+1OKYqzrLeU0uj0Q0dhWK+/HqoQx5+iIQF+vniAoM9Sg== X-Received: by 127.0.0.2 with SMTP id EypdYY7687511xKN6LMghZAy; Thu, 28 Mar 2024 00:47:09 -0700 X-Received: from zg8tmtyylji0my4xnjqumte4.icoremail.net (zg8tmtyylji0my4xnjqumte4.icoremail.net [162.243.164.118]) by mx.groups.io with SMTP id smtpd.web10.10316.1711612027394604043 for ; Thu, 28 Mar 2024 00:47:08 -0700 X-Received: from prodtpl.icoremail.net (unknown [10.12.1.20]) by hzbj-icmmx-7 (Coremail) with SMTP id AQAAfwBXXUV3IAVm9ZIqEA--.3720S2; Thu, 28 Mar 2024 15:47:03 +0800 (CST) X-Received: from phytium.com.cn (unknown [218.76.62.144]) by mail (Coremail) with SMTP id AQAAfwCHPitoIAVmRm4AAA--.403S5; Thu, 28 Mar 2024 15:46:59 +0800 (CST) From: "Xiong Yining" To: devel@edk2.groups.io Cc: quic_llindhol@quicinc.com, ardb+tianocore@kernel.org, graeme@xora.org.uk, marcin.juszkiewicz@linaro.org, chenbaozi@phytium.com.cn, Xiong Yining Subject: [edk2-devel] [PATCH v11 2/4] Platform/SbsaQemu: use SbsaQemuHardwareInfoLib for cpu information Date: Thu, 28 Mar 2024 07:46:28 +0000 Message-Id: <20240328074630.3817643-3-xiongyining1480@phytium.com.cn> In-Reply-To: <20240328074630.3817643-1-xiongyining1480@phytium.com.cn> References: <20240328074630.3817643-1-xiongyining1480@phytium.com.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAfwCHPitoIAVmRm4AAA--.403S5 X-CM-SenderInfo: x0lr0wp1lqx0bjrumio6sk53xlxphulrpou0/1tbiAQASBmYEdOgDIwACsJ X-Coremail-Antispam: 1Uk129KBjvJXoWxtF4rJrW7KFy3tr17Jry3twb_yoWfJr1fpF 1vkFZYkr1UJ34S9rs7Ga1FvFn8WFnxG3yUKrZ0vr1xZrsxJ3Z2q3y5t3s7Xr1UJrnI93yk WF40vw1UZF1kGFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj DUYxn0WfASr-VFAU7a7-sFnT9fnUUIcSsGvfJ3UbIYCTnIWIevJa73UjIFyTuYvj4RJUUU UUUUU 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: Thu, 28 Mar 2024 00:47:08 -0700 Reply-To: devel@edk2.groups.io,xiongyining1480@phytium.com.cn List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 8AYLbGCKceYceXcI5d9lHc6dx7686176AA= Content-Transfer-Encoding: 8bit X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=YXxxB3sT; dmarc=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 From: Marcin Juszkiewicz We have SbsaQemuHardwareInfoLib to ask for hardware details. No need to parse DeviceTree anymore. Signed-off-by: Marcin Juszkiewicz Signed-off-by: Xiong Yining Reviewed-by: Leif Lindholm --- .../Qemu/SbsaQemu/OemMiscLib/OemMiscLib.inf | 6 ++---- .../SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf | 5 ++--- .../Library/SbsaQemuLib/SbsaQemuLib.inf | 4 ++-- .../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/Qemu/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 @@ [LibraryClasses] BaseMemoryLib - FdtLib - FdtHelperLib + HardwareInfoLib IoLib PcdLib @@ -40,7 +39,6 @@ [Pcd] gArmTokenSpaceGuid.PcdEmbeddedControllerFirmwareRelease gArmTokenSpaceGuid.PcdSystemBiosRelease - gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdDeviceTreeBaseAddress 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 @@ BaseLib DebugLib DxeServicesLib - FdtHelperLib + HardwareInfoLib PcdLib PrintLib UefiDriverEntryPoint @@ -44,7 +44,6 @@ [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiTableStorageFile - gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdCoreCount gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdClusterCount gArmTokenSpaceGuid.PcdGicDistributorBase diff --git a/Silicon/Qemu/SbsaQemu/Library/SbsaQemuLib/SbsaQemuLib.inf b/Silicon/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 @@ ArmLib BaseMemoryLib DebugLib - FdtLib MemoryAllocationLib PcdLib + SbsaQemuHardwareInfoLib [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 /** Returns whether the specified processor is present or not. @@ -33,7 +32,7 @@ OemIsProcessorPresent ( UINTN ProcessorIndex ) { - if (ProcessorIndex < FdtHelperCountCpus ()) { + if (ProcessorIndex < GetCpuCount ()) { return TRUE; } @@ -76,7 +75,7 @@ OemGetProcessorInformation ( { UINT16 ProcessorCount; - ProcessorCount = FdtHelperCountCpus (); + ProcessorCount = GetCpuCount (); if (ProcessorIndex < ProcessorCount) { ProcessorStatus->Bits.CpuStatus = 1; // CPU enabled @@ -121,7 +120,7 @@ OemGetMaxProcessors ( VOID ) { - return FdtHelperCountCpus (); + return GetCpuCount (); } /** 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 = SBSAQEMU_MADT_GICR_INIT(); - // Get CoreCount which was determined eariler after parsing device tree - NumCores = PcdGet32 (PcdCoreCount); + NumCores = GetCpuCount (); // Calculate the new table size based on the number of cores TableSize = sizeof (EFI_ACPI_6_0_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER) + @@ -291,13 +290,13 @@ AddMadtTable ( New += sizeof (EFI_ACPI_6_0_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER); // Add new GICC structures for the Cores - for (CoreIndex = 0; CoreIndex < PcdGet32 (PcdCoreCount); CoreIndex++) { + for (CoreIndex = 0; CoreIndex < NumCores; CoreIndex++) { EFI_ACPI_6_0_GIC_STRUCTURE *GiccPtr; CopyMem (New, &Gicc, sizeof (EFI_ACPI_6_0_GIC_STRUCTURE)); GiccPtr = (EFI_ACPI_6_0_GIC_STRUCTURE *) New; GiccPtr->AcpiProcessorUid = CoreIndex; - GiccPtr->MPIDR = FdtHelperGetMpidr (CoreIndex); + GiccPtr->MPIDR = GetMpidr (CoreIndex); New += sizeof (EFI_ACPI_6_0_GIC_STRUCTURE); } @@ -396,7 +395,7 @@ AddSsdtTable ( UINT32 CpuId; UINT32 Offset; UINT8 ScopeOpName[] = SBSAQEMU_ACPI_SCOPE_NAME; - UINT32 NumCores = PcdGet32 (PcdCoreCount); + UINT32 NumCores = GetCpuCount (); EFI_ACPI_DESCRIPTION_HEADER Header = SBSAQEMU_ACPI_HEADER ( @@ -497,7 +496,7 @@ AddPpttTable ( EFI_PHYSICAL_ADDRESS PageAddress; UINT8 *New; UINT32 CpuId; - UINT32 NumCores = PcdGet32 (PcdCoreCount); + UINT32 NumCores = GetCpuCount (); EFI_ACPI_6_3_PPTT_STRUCTURE_CACHE L1DCache = SBSAQEMU_ACPI_PPTT_L1_D_CACHE_STRUCT; EFI_ACPI_6_3_PPTT_STRUCTURE_CACHE L1ICache = SBSAQEMU_ACPI_PPTT_L1_I_CACHE_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 = FdtHelperCountCpus (); - Status = PcdSet32S (PcdCoreCount, NumCores); - ASSERT_RETURN_ERROR (Status); // Check if ACPI Table Protocol has been installed Status = gBS->LocateProtocol ( -- 2.34.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#117196): https://edk2.groups.io/g/devel/message/117196 Mute This Topic: https://groups.io/mt/105192919/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-