From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f41.google.com (mail-ot1-f41.google.com [209.85.210.41]) by mx.groups.io with SMTP id smtpd.web09.63.1614102230309645950 for ; Tue, 23 Feb 2021 09:43:50 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@nuviainc-com.20150623.gappssmtp.com header.s=20150623 header.b=eBIUtE5y; spf=pass (domain: nuviainc.com, ip: 209.85.210.41, mailfrom: rebecca@nuviainc.com) Received: by mail-ot1-f41.google.com with SMTP id s6so16414318otk.4 for ; Tue, 23 Feb 2021 09:43:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuviainc-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YYOAR416WRstEXipl8BAsx00CynxwiErkhg1lgQ+/SU=; b=eBIUtE5yElbA2bozuKyZ02IvfUdXN9NouPlf/BhADDeHHTTPnx4txeGxBE9vVd41sk e8ftvu1NdchVFrgwf9MjCiNMEI8chKtQdzQRcVv17MOuyQbJkStaosZGuOfD4WUy3Azb Jpi5udcM+MP8l9ffkdIrG/n5YvCZGEhKpyqysow45PTEDej9zKvE5YVwUIrLu+V5TTPy NKc8O18GeMase/nlyM8IL6Ky9FCyGuAFpaa4MUuVHYx7spw/AFCtDSxtwaV8lMgmSa1k 0cua69uubkuNqAhC9xN/Ek5+DhNCx/ik+SeVQ+qnpKr8p6Wq2NcCUj/r2mwFgOSUjyPT dHTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YYOAR416WRstEXipl8BAsx00CynxwiErkhg1lgQ+/SU=; b=roGZdaTVjmoDA4udHuUutU3yWEg7xmvBTmbORKoPliiLR7eLBJV+aWzD2kgA+vfnF6 2S/GtD+BrTW1wz1RQaCmx3dGSlOxho0Il4AKeNXUfB+an09UyfF/++Oz/y44is54hkvo XmETLzOStI1XaqXyWNUATBpEdF8l10H4mdIx+mHDh1g5SyfUG0rauCV/8I9O4QqOx9gf fO3y91UhGY8L9HKPfqogW7/TSW03xoSSrfud3hYRqQaqJyiidlObtE89jpC4MNjwZxgA z7y2RjlgmM5jwksv8edKiI2rUsVNI+Y1LOxchgBEEa9hfoX2Wupn0NQXR8C92xyGemWP n8LQ== X-Gm-Message-State: AOAM531xxdwF9vOsNf5cDr2AEah+5IquRzXL2vMJ5B0IumDs227NtVzd eeZQ7382RiOp4FwXrEtIxb+2WUeuj5rPY2qOqALpQxzi8j6IGdmXXqig/LB2pS/kMmNzG+to+XS 32Wm6kmjh7K8AGbjxvBXyipsdgwyj0TN+CrxwpVH6G2B7eC8GJSVucWGI/ewZ4PaSjDPVrw== X-Google-Smtp-Source: ABdhPJzBh9eu4cZV0NKFzx3vySJe54xzr80tjRopXQZVRruciSCPzniagqn3Oj6dPj1koUOjvWnI8Q== X-Received: by 2002:a9d:709a:: with SMTP id l26mr6467214otj.178.1614102229154; Tue, 23 Feb 2021 09:43:49 -0800 (PST) Return-Path: Received: from cube.nuviainc.com (c-174-52-16-57.hsd1.ut.comcast.net. [174.52.16.57]) by smtp.gmail.com with ESMTPSA id s9sm4419918otb.11.2021.02.23.09.43.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Feb 2021 09:43:48 -0800 (PST) From: "Rebecca Cran" To: devel@edk2.groups.io Cc: Rebecca Cran , Ard Biesheuvel , Leif Lindholm , Graeme Gregory , Radoslaw Biernacki Subject: [edk2-platforms PATCH v5 2/4] SbsaQemu: Update SbsaQemuAcpiDxe to use FdtHelperLib Date: Tue, 23 Feb 2021 10:43:40 -0700 Message-Id: <20210223174342.8572-3-rebecca@nuviainc.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210223174342.8572-1-rebecca@nuviainc.com> References: <20210223174342.8572-1-rebecca@nuviainc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Use FdtHelperCountCpus from FdtHelperLib. Signed-off-by: Rebecca Cran --- 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 #include #include +#include #include #include #include @@ -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