2020-02-22 17:40:15 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 08:24:48 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-02-22 17:40:15 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/Types.h>
|
2022-05-30 07:04:37 +00:00
|
|
|
#include <Kernel/Arch/IRQController.h>
|
2020-02-22 17:40:15 +00:00
|
|
|
#include <Kernel/Interrupts/GenericInterruptHandler.h>
|
2022-08-19 18:53:40 +00:00
|
|
|
#include <Kernel/Library/LockRefPtr.h>
|
2020-02-22 17:40:15 +00:00
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
|
|
|
class IRQHandler : public GenericInterruptHandler {
|
|
|
|
public:
|
|
|
|
virtual ~IRQHandler();
|
|
|
|
|
2022-04-01 17:58:27 +00:00
|
|
|
virtual bool handle_interrupt(RegisterState const& regs) override { return handle_irq(regs); }
|
|
|
|
virtual bool handle_irq(RegisterState const&) = 0;
|
2020-02-22 17:40:15 +00:00
|
|
|
|
|
|
|
void enable_irq();
|
|
|
|
void disable_irq();
|
|
|
|
|
|
|
|
virtual bool eoi() override;
|
|
|
|
|
2020-03-05 17:13:55 +00:00
|
|
|
virtual HandlerType type() const override { return HandlerType::IRQHandler; }
|
2021-10-02 22:30:23 +00:00
|
|
|
virtual StringView purpose() const override { return "IRQ Handler"sv; }
|
2021-07-10 23:46:09 +00:00
|
|
|
virtual StringView controller() const override { return m_responsible_irq_controller->model(); }
|
2020-02-22 17:40:15 +00:00
|
|
|
|
2020-02-23 12:14:01 +00:00
|
|
|
virtual size_t sharing_devices_count() const override { return 0; }
|
2020-02-22 17:40:15 +00:00
|
|
|
virtual bool is_shared_handler() const override { return false; }
|
2023-04-12 16:49:43 +00:00
|
|
|
void set_shared_with_others(bool status) { m_shared_with_others = status; }
|
2020-02-22 17:40:15 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void change_irq_number(u8 irq);
|
2020-08-27 21:28:07 +00:00
|
|
|
explicit IRQHandler(u8 irq);
|
2020-02-22 17:40:15 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool m_shared_with_others { false };
|
|
|
|
bool m_enabled { false };
|
2022-09-25 12:25:14 +00:00
|
|
|
NonnullLockRefPtr<IRQController> m_responsible_irq_controller;
|
2020-02-22 17:40:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|