summaryrefslogtreecommitdiff
path: root/Kernel/Interrupts
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-07-21 20:21:29 +0200
committerAndreas Kling <kling@serenityos.org>2021-07-21 20:21:29 +0200
commit79745507a93c8788e4c8ee863368b95b7e993517 (patch)
tree520028e3fec592e8eb78301f556a7a67c860193a /Kernel/Interrupts
parenta9f76b82706597775a353725a4cdffb3d9e59dbd (diff)
downloadserenity-79745507a93c8788e4c8ee863368b95b7e993517.zip
Kernel: Use IntrusiveList for keeping track of GenericInterruptHandlers
Diffstat (limited to 'Kernel/Interrupts')
-rw-r--r--Kernel/Interrupts/GenericInterruptHandler.h8
-rw-r--r--Kernel/Interrupts/SharedIRQHandler.cpp18
-rw-r--r--Kernel/Interrupts/SharedIRQHandler.h5
3 files changed, 16 insertions, 15 deletions
diff --git a/Kernel/Interrupts/GenericInterruptHandler.h b/Kernel/Interrupts/GenericInterruptHandler.h
index 3f68ae8ee5..b4a96ec385 100644
--- a/Kernel/Interrupts/GenericInterruptHandler.h
+++ b/Kernel/Interrupts/GenericInterruptHandler.h
@@ -6,8 +6,7 @@
#pragma once
-#include <AK/HashTable.h>
-#include <AK/String.h>
+#include <AK/IntrusiveList.h>
#include <AK/Types.h>
#include <Kernel/Arch/x86/RegisterState.h>
@@ -65,5 +64,10 @@ private:
u8 m_interrupt_number { 0 };
bool m_disable_remap { false };
bool m_registered { false };
+
+ IntrusiveListNode<GenericInterruptHandler> m_list_node;
+
+public:
+ using List = IntrusiveList<GenericInterruptHandler, RawPtr<GenericInterruptHandler>, &GenericInterruptHandler::m_list_node>;
};
}
diff --git a/Kernel/Interrupts/SharedIRQHandler.cpp b/Kernel/Interrupts/SharedIRQHandler.cpp
index 25d065e2de..b35bba7ec6 100644
--- a/Kernel/Interrupts/SharedIRQHandler.cpp
+++ b/Kernel/Interrupts/SharedIRQHandler.cpp
@@ -24,13 +24,13 @@ UNMAP_AFTER_INIT void SharedIRQHandler::initialize(u8 interrupt_number)
void SharedIRQHandler::register_handler(GenericInterruptHandler& handler)
{
dbgln_if(INTERRUPT_DEBUG, "Interrupt Handler registered @ Shared Interrupt Handler {}", interrupt_number());
- m_handlers.set(&handler);
+ m_handlers.append(handler);
enable_interrupt_vector();
}
void SharedIRQHandler::unregister_handler(GenericInterruptHandler& handler)
{
dbgln_if(INTERRUPT_DEBUG, "Interrupt Handler unregistered @ Shared Interrupt Handler {}", interrupt_number());
- m_handlers.remove(&handler);
+ m_handlers.remove(handler);
if (m_handlers.is_empty())
disable_interrupt_vector();
}
@@ -44,9 +44,8 @@ bool SharedIRQHandler::eoi()
void SharedIRQHandler::enumerate_handlers(Function<void(GenericInterruptHandler&)>& callback)
{
- for (auto* handler : m_handlers) {
- VERIFY(handler);
- callback(*handler);
+ for (auto& handler : m_handlers) {
+ callback(handler);
}
}
@@ -69,15 +68,14 @@ bool SharedIRQHandler::handle_interrupt(const RegisterState& regs)
if constexpr (INTERRUPT_DEBUG) {
dbgln("Interrupt @ {}", interrupt_number());
- dbgln("Interrupt Handlers registered - {}", m_handlers.size());
+ dbgln("Interrupt Handlers registered - {}", m_handlers.size_slow());
}
int i = 0;
bool was_handled = false;
- for (auto* handler : m_handlers) {
+ for (auto& handler : m_handlers) {
dbgln_if(INTERRUPT_DEBUG, "Going for Interrupt Handling @ {}, Shared Interrupt {}", i, interrupt_number());
- VERIFY(handler != nullptr);
- if (handler->handle_interrupt(regs)) {
- handler->increment_invoking_counter();
+ if (handler.handle_interrupt(regs)) {
+ handler.increment_invoking_counter();
was_handled = true;
}
dbgln_if(INTERRUPT_DEBUG, "Going for Interrupt Handling @ {}, Shared Interrupt {} - End", i, interrupt_number());
diff --git a/Kernel/Interrupts/SharedIRQHandler.h b/Kernel/Interrupts/SharedIRQHandler.h
index de7e363fcb..389d7b6659 100644
--- a/Kernel/Interrupts/SharedIRQHandler.h
+++ b/Kernel/Interrupts/SharedIRQHandler.h
@@ -6,7 +6,6 @@
#pragma once
-#include <AK/HashTable.h>
#include <AK/NonnullOwnPtr.h>
#include <AK/RefPtr.h>
#include <AK/Types.h>
@@ -28,7 +27,7 @@ public:
void enumerate_handlers(Function<void(GenericInterruptHandler&)>&);
- virtual size_t sharing_devices_count() const override { return m_handlers.size(); }
+ virtual size_t sharing_devices_count() const override { return m_handlers.size_slow(); }
virtual bool is_shared_handler() const override { return true; }
virtual bool is_sharing_with_others() const override { return false; }
@@ -41,7 +40,7 @@ private:
void disable_interrupt_vector();
explicit SharedIRQHandler(u8 interrupt_number);
bool m_enabled { true };
- HashTable<GenericInterruptHandler*> m_handlers;
+ GenericInterruptHandler::List m_handlers;
RefPtr<IRQController> m_responsible_irq_controller;
};
}