apic: add ioapic_get_dev() method

which returns apic device_t by apic_id, if there exists the pci representer

Sponsored by:	Advanced Micro Devices (AMD)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
This commit is contained in:
Konstantin Belousov 2024-10-13 01:52:44 +03:00
parent cc7ec8fe3b
commit ea4e4449b8
2 changed files with 17 additions and 0 deletions

View file

@ -258,6 +258,7 @@ void lapic_handle_intr(int vector, struct trapframe *frame);
void lapic_handle_timer(struct trapframe *frame);
int ioapic_get_rid(u_int apic_id, uint16_t *ridp);
device_t ioapic_get_dev(u_int apic_id);
extern int x2apic_mode;
extern int lapic_eoi_suppression;

View file

@ -1081,6 +1081,22 @@ ioapic_get_rid(u_int apic_id, uint16_t *ridp)
return (0);
}
device_t
ioapic_get_dev(u_int apic_id)
{
struct ioapic *io;
mtx_lock_spin(&icu_lock);
STAILQ_FOREACH(io, &ioapic_list, io_next) {
if (io->io_hw_apic_id == apic_id)
break;
}
mtx_unlock_spin(&icu_lock);
if (io != NULL)
return (io->pci_dev);
return (NULL);
}
/*
* A new-bus driver to consume the memory resources associated with
* the APICs in the system. On some systems ACPI or PnPBIOS system