diff options
author | Pankaj Raghav <p.raghav@samsung.com> | 2023-04-12 18:49:43 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-04-25 10:18:39 +0200 |
commit | fd8a154f8cfe64cf8b0055969ccee1d33a8c6344 (patch) | |
tree | 5543a45f9cde5b1304a829fe98c61f39bf6d6915 | |
parent | 868a3912f470c57181ef19ce0f83351f1e2ae5b3 (diff) | |
download | serenity-fd8a154f8cfe64cf8b0055969ccee1d33a8c6344.zip |
Kernel: Set IRQHandler m_shared_with_others when the irq is shared
If IRQHandler's IRQ is shared, then disable_irq() should not call the
controller to disable that IRQ as some other device might be using it.
IRQHandler had a private variable to indicate if it is being shared:
m_shared_with_others but it was never modified even if the IRQ was
shared.
Add a new member function set_shared_with_others() to enable/disable
m_shared_with_others member of IRQHandler class. This function is
called when an IRQHandler is being added/removed as a part of
SharedIRQHandler.
-rw-r--r-- | Kernel/Arch/x86_64/Interrupts.cpp | 3 | ||||
-rw-r--r-- | Kernel/Interrupts/IRQHandler.h | 1 |
2 files changed, 4 insertions, 0 deletions
diff --git a/Kernel/Arch/x86_64/Interrupts.cpp b/Kernel/Arch/x86_64/Interrupts.cpp index eedb7097c6..e316dfda43 100644 --- a/Kernel/Arch/x86_64/Interrupts.cpp +++ b/Kernel/Arch/x86_64/Interrupts.cpp @@ -11,6 +11,7 @@ #include <Kernel/Arch/Interrupts.h> #include <Kernel/Arch/x86_64/Interrupts/PIC.h> #include <Kernel/Interrupts/GenericInterruptHandler.h> +#include <Kernel/Interrupts/IRQHandler.h> #include <Kernel/Interrupts/SharedIRQHandler.h> #include <Kernel/Interrupts/SpuriousInterruptHandler.h> #include <Kernel/Interrupts/UnhandledInterruptHandler.h> @@ -371,6 +372,7 @@ void register_generic_interrupt_handler(u8 interrupt_number, GenericInterruptHan return; } VERIFY(handler_slot->type() == HandlerType::IRQHandler); + static_cast<IRQHandler*>(handler_slot)->set_shared_with_others(true); auto& previous_handler = *handler_slot; handler_slot = nullptr; SharedIRQHandler::initialize(interrupt_number); @@ -400,6 +402,7 @@ void unregister_generic_interrupt_handler(u8 interrupt_number, GenericInterruptH } if (!handler_slot->is_shared_handler()) { VERIFY(handler_slot->type() == HandlerType::IRQHandler); + static_cast<IRQHandler*>(handler_slot)->set_shared_with_others(false); handler_slot = nullptr; revert_to_unused_handler(interrupt_number); return; diff --git a/Kernel/Interrupts/IRQHandler.h b/Kernel/Interrupts/IRQHandler.h index c8b0eb2dd4..f21a524b42 100644 --- a/Kernel/Interrupts/IRQHandler.h +++ b/Kernel/Interrupts/IRQHandler.h @@ -32,6 +32,7 @@ public: virtual size_t sharing_devices_count() const override { return 0; } virtual bool is_shared_handler() const override { return false; } virtual bool is_sharing_with_others() const override { return m_shared_with_others; } + void set_shared_with_others(bool status) { m_shared_with_others = status; } protected: void change_irq_number(u8 irq); |