From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f170.google.com (mail-qk1-f170.google.com [209.85.222.170]) by mx.groups.io with SMTP id smtpd.web09.4172.1613707073461455061 for ; Thu, 18 Feb 2021 19:57:53 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@nuviainc-com.20150623.gappssmtp.com header.s=20150623 header.b=NYYy6jPs; spf=pass (domain: nuviainc.com, ip: 209.85.222.170, mailfrom: rebecca@nuviainc.com) Received: by mail-qk1-f170.google.com with SMTP id w19so4390353qki.13 for ; Thu, 18 Feb 2021 19:57:53 -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=XgbpIs3/2OLQBWIBBMZiM1G76+I+6Jqbsb0CxZq8Nc8=; b=NYYy6jPs6SrbKWbV/DASic246agDmS51KcmbfyfOHp0ZaQuhO64UOXlNwGG75NyqKH yZzRiDmkCYZ4/uRTPHheRTfhOFeVaH/S73eE0kP9rhuqOkFrP+nDkuzLkejyROwl7Sob XG/yjnDYKvN/MGCDl0IjRw1BGAe6LfwLH/ofe/dfeugxQAMyL/aK/8gR122OFRgPa4cc GJsvk+aI87vuv8UEW75AgdYUL3jK2ku6gbAZUy7Bz8Al6oc78iXSV75L9PlX5ycxtJx+ XbrKriKrvuKqd0nJqTzHeTo+gpRzZLJjCPY5ggRhZvzOm/Y+LsBkuo1i6y0JEEoraYEi z2PA== 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=XgbpIs3/2OLQBWIBBMZiM1G76+I+6Jqbsb0CxZq8Nc8=; b=rUZMnXzKlY9MQvqc6nE2tNIOgENB6xq85JlRF7G+I9c2kLSjMpOqetdD2ol/x+Ckal 7Hn1wZ61b+mKB3nYAFikuFG9qdGvewR21PrAQKu/FZeNNMB/o+V21dMBBiDCAvFENo7+ zp8UuvYZNGJXrpBeEduy6JKHbCguLyocbDaNK3EUjmcKfinHCjJtb+JfcgEU0RUchWFY ecfyMzOQS2NNeILbx2DWrkwU73MMoneYSd+jGB30HmElxfjBuM/hCRKL0nmNKu7Uu5Uq TdchcDsOYM+nnoaQsJkZylGnLuTbsiIp/S81/vYqVixIgM7FJ6jtcNgj4Ii3M/nOWxUZ lAqg== X-Gm-Message-State: AOAM531GFikzWyE5tgaU5MCA7fmDJ2gSDu5N+MwZ0gaJgplc6UiZ+CiV Po+Jzwl5jQbFIHGXiSKyG5P0PyOyUWfdWkuYvlejZ93RI6EXjxG1J/mEE99+WGoRGBoemPxJ7Db KHbqBllkRZowCCjezgQWM3gYMPt0XvB9tGetaQveZlS96UqiWeMuxqXIA3tyIYsxGj+bj/g== X-Google-Smtp-Source: ABdhPJxqhlvrkApioqgPzAYvHlK43UQfDIYwHivTuN6EJAm2dVydHsMxgMS+/Y2Vq9nZ9tNPZVW2pg== X-Received: by 2002:a37:434c:: with SMTP id q73mr7984599qka.170.1613707072394; Thu, 18 Feb 2021 19:57:52 -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 z28sm5633919qkj.72.2021.02.18.19.57.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Feb 2021 19:57:52 -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 v3 2/3] SbsaQemu: Update SbsaQemuAcpiDxe to use FdtHelperLib Date: Thu, 18 Feb 2021 20:57:40 -0700 Message-Id: <20210219035741.1467-3-rebecca@nuviainc.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210219035741.1467-1-rebecca@nuviainc.com> References: <20210219035741.1467-1-rebecca@nuviainc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Use the copy of the CountCpusFromFdt function from FdtHelperLib. Signed-off-by: Rebecca Cran --- Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c | 50 +------------------- Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf | 1 + 2 files changed, 2 insertions(+), 49 deletions(-) diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c index fb7c1835c3d7..02ba3e452c06 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 */ 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