summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/soc/intel/denverton_ns/cpu.c27
-rw-r--r--src/soc/intel/denverton_ns/include/soc/cpu.h1
2 files changed, 9 insertions, 19 deletions
diff --git a/src/soc/intel/denverton_ns/cpu.c b/src/soc/intel/denverton_ns/cpu.c
index ef1140b76a..fb4923f7e1 100644
--- a/src/soc/intel/denverton_ns/cpu.c
+++ b/src/soc/intel/denverton_ns/cpu.c
@@ -15,7 +15,7 @@
#include <device/device.h>
#include <device/pci.h>
#include <intelblocks/cpulib.h>
-
+#include <lib.h>
#include <soc/msr.h>
#include <soc/cpu.h>
#include <soc/iomap.h>
@@ -182,28 +182,19 @@ static unsigned int detect_num_cpus_via_cpuid(void)
}
}
-static int detect_num_cpus_via_mch(void)
+/* Assumes that FSP has already programmed the cores disabled register */
+static unsigned int detect_num_cpus_via_mch(void)
{
- /* Assumes that FSP has already programmed the cores disabled register
- */
- u32 core_exists_mask, active_cores_mask;
- u32 core_disable_mask;
- register int active_cores = 0, total_cores = 0;
- register int counter = 0;
-
/* Get Masks for Total Existing SOC Cores and Core Disable Mask */
- core_exists_mask = MMIO32(DEFAULT_MCHBAR + MCH_BAR_CORE_EXISTS_MASK);
- core_disable_mask = MMIO32(DEFAULT_MCHBAR + MCH_BAR_CORE_DISABLE_MASK);
- active_cores_mask = (~core_disable_mask) & core_exists_mask;
+ const u32 core_exists_mask = MMIO32(DEFAULT_MCHBAR + MCH_BAR_CORE_EXISTS_MASK);
+ const u32 core_disable_mask = MMIO32(DEFAULT_MCHBAR + MCH_BAR_CORE_DISABLE_MASK);
+ const u32 active_cores_mask = ~core_disable_mask & core_exists_mask;
/* Calculate Number of Active Cores */
- for (; counter < CONFIG_MAX_CPUS;
- counter++, active_cores_mask >>= 1, core_exists_mask >>= 1) {
- active_cores += (active_cores_mask & CORE_BIT_MSK);
- total_cores += (core_exists_mask & CORE_BIT_MSK);
- }
+ const unsigned int active_cores = popcnt(active_cores_mask);
+ const unsigned int total_cores = popcnt(core_exists_mask);
- printk(BIOS_DEBUG, "Number of Active Cores: %d of %d total.\n",
+ printk(BIOS_DEBUG, "Number of Active Cores: %u of %u total.\n",
active_cores, total_cores);
return active_cores;
diff --git a/src/soc/intel/denverton_ns/include/soc/cpu.h b/src/soc/intel/denverton_ns/include/soc/cpu.h
index a714764767..a8af626500 100644
--- a/src/soc/intel/denverton_ns/include/soc/cpu.h
+++ b/src/soc/intel/denverton_ns/include/soc/cpu.h
@@ -11,7 +11,6 @@ int get_cpu_count(void);
#ifndef __ACPI__
#define MSR_CORE_THREAD_COUNT 0x35
-#define CORE_BIT_MSK 0x1
#define MCH_BAR_CORE_EXISTS_MASK 0x7164
#define MCH_BAR_CORE_DISABLE_MASK 0x7168