git: ea4e4449b855 - main - apic: add ioapic_get_dev() method
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 17 Oct 2024 14:32:14 UTC
The branch main has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=ea4e4449b85593025c2eb31bb642732971d96225
commit ea4e4449b85593025c2eb31bb642732971d96225
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-10-12 22:52:44 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-10-17 14:31:50 +0000
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
---
sys/x86/include/apicvar.h | 1 +
sys/x86/x86/io_apic.c | 16 ++++++++++++++++
2 files changed, 17 insertions(+)
diff --git a/sys/x86/include/apicvar.h b/sys/x86/include/apicvar.h
index ac6a82659e34..61c726f150df 100644
--- a/sys/x86/include/apicvar.h
+++ b/sys/x86/include/apicvar.h
@@ -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;
diff --git a/sys/x86/x86/io_apic.c b/sys/x86/x86/io_apic.c
index 4337d1adc8a9..525547f9482a 100644
--- a/sys/x86/x86/io_apic.c
+++ b/sys/x86/x86/io_apic.c
@@ -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