Add a helper function to determine the number of enabled CPUs
authorStefan Reinauer <reinauer@chromium.org>
Fri, 30 Mar 2012 20:52:58 +0000 (13:52 -0700)
committerStefan Reinauer <stefan.reinauer@coreboot.org>
Mon, 2 Apr 2012 16:39:58 +0000 (18:39 +0200)
Change-Id: Ia72926002571e0f250849fa5db048bd8b2e92400
Signed-off-by: Duncan Laurie <dlaurie@google.com>
Reviewed-on: http://review.coreboot.org/821
Tested-by: build bot (Jenkins)
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
src/devices/device_util.c
src/include/device/device.h

index 526490a8c199ab132dcce9bb9adc382e89042cbb..5225938e192035ff385f7fda4edf65e2d6eda02e 100644 (file)
@@ -850,3 +850,21 @@ u32 find_pci_tolm(struct bus *bus)
 
        return tolm;
 }
+
+/* Count of enabled CPUs */
+int dev_count_cpu(void)
+{
+       device_t cpu;
+       int count = 0;
+
+       for (cpu = all_devices; cpu; cpu = cpu->next) {
+               if ((cpu->path.type != DEVICE_PATH_APIC) ||
+                   (cpu->bus->dev->path.type != DEVICE_PATH_APIC_CLUSTER))
+                       continue;
+               if (!cpu->enabled)
+                       continue;
+               count++;
+       }
+
+       return count;
+}
index c097f5796b66b4578fac3761ff8c6f415be7e37f..0aea1d6087ee3a3ec2be198719432fc6c5b75767 100644 (file)
@@ -133,6 +133,7 @@ device_t dev_find_class (unsigned int class, device_t from);
 device_t dev_find_slot (unsigned int bus, unsigned int devfn);
 device_t dev_find_slot_on_smbus (unsigned int bus, unsigned int addr);
 device_t dev_find_lapic(unsigned apic_id);
+int dev_count_cpu(void);
 
 /* Debug functions */
 void print_resource_tree(struct device * root, int debug_level,