From: "Rebecca Cran" <rebecca@nuviainc.com>
To: devel@edk2.groups.io
Cc: Rebecca Cran <rebecca@nuviainc.com>,
Ard Biesheuvel <ardb+tianocore@kernel.org>,
Leif Lindholm <leif@nuviainc.com>,
Graeme Gregory <graeme@nuviainc.com>,
Radoslaw Biernacki <rad@semihalf.com>
Subject: [edk2-platforms PATCH v5 2/4] SbsaQemu: Update SbsaQemuAcpiDxe to use FdtHelperLib
Date: Tue, 23 Feb 2021 10:43:40 -0700 [thread overview]
Message-ID: <20210223174342.8572-3-rebecca@nuviainc.com> (raw)
In-Reply-To: <20210223174342.8572-1-rebecca@nuviainc.com>
Use FdtHelperCountCpus from FdtHelperLib.
Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
---
Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c | 55 ++------------------
Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf | 1 +
2 files changed, 6 insertions(+), 50 deletions(-)
diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c
index fb7c1835c3d7..037c7cff4c18 100644
--- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c
+++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c
@@ -12,6 +12,7 @@
#include <Library/AcpiLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
+#include <Library/FdtHelperLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/PcdLib.h>
#include <Library/PrintLib.h>
@@ -25,55 +26,6 @@
STATIC INT32 FdtFirstCpuOffset;
STATIC INT32 FdtCpuNodeSize;
-/*
- * A function that walks through the Device Tree created
- * by Qemu and counts the number of CPUs present in it.
- */
-STATIC
-VOID
-CountCpusFromFdt (
- VOID
-)
-{
- VOID *DeviceTreeBase;
- INT32 Node, Prev;
- RETURN_STATUS PcdStatus;
- INT32 CpuNode;
- INT32 CpuCount;
-
- DeviceTreeBase = (VOID *)(UINTN)PcdGet64 (PcdDeviceTreeBaseAddress);
- ASSERT (DeviceTreeBase != NULL);
-
- // Make sure we have a valid device tree blob
- ASSERT (fdt_check_header (DeviceTreeBase) == 0);
-
- CpuNode = fdt_path_offset (DeviceTreeBase, "/cpus");
- if (CpuNode <= 0) {
- DEBUG ((DEBUG_ERROR, "Unable to locate /cpus in device tree\n"));
- return;
- }
-
- CpuCount = 0;
-
- // Walk through /cpus node and count the number of subnodes.
- // The count of these subnodes corresponds to the number of
- // CPUs created by Qemu.
- Prev = fdt_first_subnode (DeviceTreeBase, CpuNode);
- FdtFirstCpuOffset = Prev;
- while (1) {
- CpuCount++;
- Node = fdt_next_subnode (DeviceTreeBase, Prev);
- if (Node < 0) {
- break;
- }
- FdtCpuNodeSize = Node - Prev;
- Prev = Node;
- }
-
- PcdStatus = PcdSet32S (PcdCoreCount, CpuCount);
- ASSERT_RETURN_ERROR (PcdStatus);
-}
-
/*
* Get MPIDR from device tree passed by Qemu
*/
@@ -487,9 +439,12 @@ InitializeSbsaQemuAcpiDxe (
{
EFI_STATUS Status;
EFI_ACPI_TABLE_PROTOCOL *AcpiTable;
+ UINT32 NumCores;
// Parse the device tree and get the number of CPUs
- CountCpusFromFdt ();
+ NumCores = FdtHelperCountCpus ();
+ Status = PcdSet32S (PcdCoreCount, NumCores);
+ ASSERT_RETURN_ERROR (Status);
// Check if ACPI Table Protocol has been installed
Status = gBS->LocateProtocol (
diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf
index 127eef029f3c..a58ebfaf76d5 100644
--- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf
+++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf
@@ -34,6 +34,7 @@
BaseLib
DebugLib
DxeServicesLib
+ FdtHelperLib
FdtLib
PcdLib
PrintLib
--
2.26.2
next prev parent reply other threads:[~2021-02-23 17:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-23 17:43 [edk2-platforms PATCH v5 0/4] Platform/Qemu/SbsaQemu: Add SMBIOS tables Rebecca Cran
2021-02-23 17:43 ` [edk2-platforms PATCH v5 1/4] SbsaQemu: Add FdtHelperLib Rebecca Cran
2021-02-23 17:43 ` Rebecca Cran [this message]
2021-02-23 17:43 ` [edk2-platforms PATCH v5 3/4] Platform/Qemu/SbsaQemu: Add SMBIOS tables Rebecca Cran
2021-02-23 17:43 ` [edk2-platforms PATCH v5 4/4] Silicon/Qemu: Don't re-use NumCores as loop index in AddMadtTable Rebecca Cran
2021-02-23 18:41 ` [edk2-platforms PATCH v5 0/4] Platform/Qemu/SbsaQemu: Add SMBIOS tables Leif Lindholm
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210223174342.8572-3-rebecca@nuviainc.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox