From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-il1-f171.google.com (mail-il1-f171.google.com [209.85.166.171]) by mx.groups.io with SMTP id smtpd.web12.10433.1614090404609256359 for ; Tue, 23 Feb 2021 06:26:44 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@nuviainc-com.20150623.gappssmtp.com header.s=20150623 header.b=OlylQVoL; spf=pass (domain: nuviainc.com, ip: 209.85.166.171, mailfrom: rebecca@nuviainc.com) Received: by mail-il1-f171.google.com with SMTP id i18so1409060ilq.13 for ; Tue, 23 Feb 2021 06:26:44 -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=Rur2Xor4EQS098hFMGqdqfrm9s+PSTnJBC0x1vBzhFU=; b=OlylQVoLC36fr9R/NRfXyCMjnt3ZlH+lG41bVOts0T/4pxKyWqAfDPwxXjn0C96MTK pxXHbPuZUbw57vKGIx3vj+Uk9pauypBXoQxaH3RTfnL+TKrUv6OudCVQAxHho4M1XauA hFtcrjZb5NNgVxEpT9TekQUTh7LGPsKoiIouBKVz1cv1t6rV+jy/Z4bNQqnnPrTsQ+xW TsdCmGlt+HjPf7NLtSDsWHG9q08ot5fg1T1mbRg0V08wPygoqqF62veS68WhqXu1kLOl /ubFmRDE2GrGLZudELKYRzyRGkLKXfJWLbebjMu4XH+uL1ZSRZ87btskPRUbfc2533b0 srKg== 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=Rur2Xor4EQS098hFMGqdqfrm9s+PSTnJBC0x1vBzhFU=; b=jXzLjR3o1d9EGlJ3pPkx0EZ4/S7czLVz03rUp6/+btOnrdseCAdI/xLSZA59gqNLkD 1HQqqocbOzw2D5eyjJx/PqfpzpW7vDMoxDgy1v0IpyXe/HU38KhxLkIxc3K7MSb+VZxh 7W83trZm/PjeOxUhqzntYoejzUNrtF5nrW7G3ksVOv4GM3uXF2Onfo87IuCsYwG24u3O egNSINAmcu7vncq53X7TwvO6yRvz0nNRAjypaMnst1VHkAmKi5OUEJVNt3OwajEHWIm2 qMXabTvHxWplEZZ6W/0M/KQpL1r2S7Qm37itBfq1F2VP5V03Dr6dCnmBYa6bNAq0IJ3J T1FQ== X-Gm-Message-State: AOAM532LoI4rdpWH6hhzUiKKakDUx5M+wsv1SaAwTqTzkeERel7otQrZ WYeH6FudJLD3hP13JxMwPeLWLnAwtOb2ylPCjBXVkg9Lx6WkIaw8l5SnA+EogEupkX9ghxiDiwc a0TJvCNMyyFhbgDsd4xAzEHAFwu5fMYUqHJR2C3hZRcdyqOKJZVsk52PwJ9b9oVgmB0bV9Q== X-Google-Smtp-Source: ABdhPJyPwpVEOhgpsf1RekcYIWbitBBrqqb+vLgAYEKNcoVDW5YzGM7asJ8GRnXHQoSr6bccXMnQMw== X-Received: by 2002:a92:d7c7:: with SMTP id g7mr11976585ilq.305.1614090403801; Tue, 23 Feb 2021 06:26:43 -0800 (PST) Return-Path: Received: from cube.int.bluestop.org (c-174-52-16-57.hsd1.ut.comcast.net. [174.52.16.57]) by smtp.gmail.com with ESMTPSA id b9sm15391541ilo.41.2021.02.23.06.26.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Feb 2021 06:26:43 -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 v4 2/4] SbsaQemu: Update SbsaQemuAcpiDxe to use FdtHelperLib Date: Tue, 23 Feb 2021 07:26:33 -0700 Message-Id: <20210223142635.8807-3-rebecca@nuviainc.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210223142635.8807-1-rebecca@nuviainc.com> References: <20210223142635.8807-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 | 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 7bf60cd2ded1..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 */ 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