summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiav A <liavalb@gmail.com>2021-06-05 07:50:27 +0300
committerAndreas Kling <kling@serenityos.org>2021-06-17 16:53:25 +0200
commit030999d26976972c676b38a11bcd7674cb3a5e13 (patch)
treefac819d9e1ce2b09de082afa8cf80d8a6dd15952
parentdcb55db99bcbf3855b0d7eadf79a0d9d356f4d2f (diff)
downloadserenity-030999d26976972c676b38a11bcd7674cb3a5e13.zip
Kernel/Interrupts: Enumerate nested handlers in a shared handler
When asked to enumerate all interrupt handlers, display all shared handlers within it instead of just returning the responsible handler of them.
-rw-r--r--Kernel/Interrupts/InterruptManagement.cpp5
-rw-r--r--Kernel/Interrupts/SharedIRQHandler.cpp8
-rw-r--r--Kernel/Interrupts/SharedIRQHandler.h2
3 files changed, 15 insertions, 0 deletions
diff --git a/Kernel/Interrupts/InterruptManagement.cpp b/Kernel/Interrupts/InterruptManagement.cpp
index c4747bf873..c55cb54a7b 100644
--- a/Kernel/Interrupts/InterruptManagement.cpp
+++ b/Kernel/Interrupts/InterruptManagement.cpp
@@ -13,6 +13,7 @@
#include <Kernel/Interrupts/IOAPIC.h>
#include <Kernel/Interrupts/InterruptManagement.h>
#include <Kernel/Interrupts/PIC.h>
+#include <Kernel/Interrupts/SharedIRQHandler.h>
#include <Kernel/Interrupts/SpuriousInterruptHandler.h>
#include <Kernel/Interrupts/UnhandledInterruptHandler.h>
#include <Kernel/VM/TypedMapping.h>
@@ -49,6 +50,10 @@ void InterruptManagement::enumerate_interrupt_handlers(Function<void(GenericInte
{
for (int i = 0; i < GENERIC_INTERRUPT_HANDLERS_COUNT; i++) {
auto& handler = get_interrupt_handler(i);
+ if (handler.type() == HandlerType::SharedIRQHandler) {
+ static_cast<SharedIRQHandler&>(handler).enumerate_handlers(callback);
+ continue;
+ }
if (handler.type() != HandlerType::UnhandledInterruptHandler)
callback(handler);
}
diff --git a/Kernel/Interrupts/SharedIRQHandler.cpp b/Kernel/Interrupts/SharedIRQHandler.cpp
index 652f0608df..8f2235fceb 100644
--- a/Kernel/Interrupts/SharedIRQHandler.cpp
+++ b/Kernel/Interrupts/SharedIRQHandler.cpp
@@ -42,6 +42,14 @@ bool SharedIRQHandler::eoi()
return true;
}
+void SharedIRQHandler::enumerate_handlers(Function<void(GenericInterruptHandler&)>& callback)
+{
+ for (auto* handler : m_handlers) {
+ VERIFY(handler);
+ callback(*handler);
+ }
+}
+
SharedIRQHandler::SharedIRQHandler(u8 irq)
: GenericInterruptHandler(irq)
, m_responsible_irq_controller(InterruptManagement::the().get_responsible_irq_controller(irq))
diff --git a/Kernel/Interrupts/SharedIRQHandler.h b/Kernel/Interrupts/SharedIRQHandler.h
index bb68075656..86272a1623 100644
--- a/Kernel/Interrupts/SharedIRQHandler.h
+++ b/Kernel/Interrupts/SharedIRQHandler.h
@@ -26,6 +26,8 @@ public:
virtual bool eoi() override;
+ void enumerate_handlers(Function<void(GenericInterruptHandler&)>&);
+
virtual size_t sharing_devices_count() const override { return m_handlers.size(); }
virtual bool is_shared_handler() const override { return true; }
virtual bool is_sharing_with_others() const override { return false; }