From 4dcda853fd26623c09ce40cfb75e1e25c81434f1 Mon Sep 17 00:00:00 2001 From: Patrick Rudolph Date: Thu, 24 Oct 2024 12:49:02 +0200 Subject: device: Add helper to identify PCI IOAPICs Add a helper function to identify PCI IOAPICs. Will be used in the following commits. Change-Id: Ibe50934260b025575440fd52eace73fe2327a193 Signed-off-by: Patrick Rudolph Reviewed-on: https://review.coreboot.org/c/coreboot/+/84849 Tested-by: build bot (Jenkins) Reviewed-by: Shuo Liu --- src/device/device_util.c | 8 ++++++++ src/include/device/device.h | 1 + 2 files changed, 9 insertions(+) diff --git a/src/device/device_util.c b/src/device/device_util.c index f33c9250dc..ec2d1591ab 100644 --- a/src/device/device_util.c +++ b/src/device/device_util.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -969,3 +970,10 @@ bool is_pci_bridge(const struct device *pci) { return is_pci(pci) && ((pci->hdr_type & 0x7f) == PCI_HEADER_TYPE_BRIDGE); } + +bool is_pci_ioapic(const struct device *pci) +{ + return is_pci(pci) && ((pci->class >> 16) == PCI_BASE_CLASS_SYSTEM) && + ((pci->class >> 8) == PCI_CLASS_SYSTEM_PIC) && + ((pci->class & 0xff) >= 0x10); +} diff --git a/src/include/device/device.h b/src/include/device/device.h index f28a46b3bb..053138db99 100644 --- a/src/include/device/device.h +++ b/src/include/device/device.h @@ -195,6 +195,7 @@ bool is_pci(const struct device *pci); bool is_enabled_pci(const struct device *pci); bool is_pci_dev_on_bus(const struct device *pci, unsigned int bus); bool is_pci_bridge(const struct device *pci); +bool is_pci_ioapic(const struct device *pci); bool is_domain0(const struct device *dev); bool is_dev_on_domain0(const struct device *dev); -- cgit v1.2.3