Add helper function to find a Local APIC by ID in the device tree.
authorDuncan Laurie <dlaurie@chromium.org>
Mon, 18 Jul 2011 17:41:36 +0000 (10:41 -0700)
committerStefan Reinauer <stefan.reinauer@coreboot.org>
Fri, 9 Mar 2012 19:34:03 +0000 (20:34 +0100)
Change-Id: Ie2d7d8e1f647a0c92d2de09e32454fbea688b1e7
Signed-off-by: Duncan Laurie <dlaurie@google.com>
Reviewed-on: http://review.coreboot.org/695
Tested-by: build bot (Jenkins)
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
src/devices/device_util.c
src/include/device/device.h

index 84fb11505c26def8f937c1bf533ef7ea962a9d48..5b182e1e896e9ed156b9f3b4af422f554ac2b227 100644 (file)
@@ -109,6 +109,26 @@ struct device *dev_find_slot_on_smbus(unsigned int bus, unsigned int addr)
        return result;
 }
 
+/**
+ * Given a Local APIC ID, find the device structure.
+ *
+ * @param apic_id The Local APIC ID number.
+ * @return Pointer to the device structure (if found), 0 otherwise.
+ */
+device_t dev_find_lapic(unsigned apic_id)
+{
+       device_t dev, result = NULL;
+
+       for (dev = all_devices; dev; dev = dev->next) {
+               if (dev->path.type == DEVICE_PATH_APIC &&
+                   dev->path.apic.apic_id == apic_id) {
+                       result = dev;
+                       break;
+               }
+       }
+       return result;
+}
+
 /**
  * Find a device of a given vendor and type.
  *
index a7de0c9bb239402efe7b1d6703d7d96a1efce5e4..c097f5796b66b4578fac3761ff8c6f415be7e37f 100644 (file)
@@ -132,6 +132,7 @@ device_t dev_find_device (u16 vendor, u16 device, device_t from);
 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);
 
 /* Debug functions */
 void print_resource_tree(struct device * root, int debug_level,