2020-02-22 19:56:55 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020, Liav A. <liavalb@hotmail.co.il>
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-02-22 19:56:55 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/NonnullOwnPtr.h>
|
2020-02-28 22:33:41 +02:00
|
|
|
#include <AK/RefPtr.h>
|
2020-02-22 19:56:55 +02:00
|
|
|
#include <AK/Types.h>
|
|
|
|
#include <Kernel/Interrupts/GenericInterruptHandler.h>
|
2021-06-21 17:34:09 +02:00
|
|
|
#include <Kernel/Interrupts/IRQController.h>
|
2020-02-22 19:56:55 +02:00
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
class IRQHandler;
|
|
|
|
class SharedIRQHandler final : public GenericInterruptHandler {
|
|
|
|
public:
|
|
|
|
static void initialize(u8 interrupt_number);
|
|
|
|
virtual ~SharedIRQHandler();
|
2021-06-05 09:00:18 +03:00
|
|
|
virtual bool handle_interrupt(const RegisterState& regs) override;
|
2020-02-22 19:56:55 +02:00
|
|
|
|
|
|
|
void register_handler(GenericInterruptHandler&);
|
|
|
|
void unregister_handler(GenericInterruptHandler&);
|
|
|
|
|
|
|
|
virtual bool eoi() override;
|
|
|
|
|
2021-06-05 07:50:27 +03:00
|
|
|
void enumerate_handlers(Function<void(GenericInterruptHandler&)>&);
|
|
|
|
|
2021-07-21 20:21:29 +02:00
|
|
|
virtual size_t sharing_devices_count() const override { return m_handlers.size_slow(); }
|
2020-02-22 19:56:55 +02:00
|
|
|
virtual bool is_shared_handler() const override { return true; }
|
|
|
|
virtual bool is_sharing_with_others() const override { return false; }
|
|
|
|
|
2020-03-05 19:13:55 +02:00
|
|
|
virtual HandlerType type() const override { return HandlerType::SharedIRQHandler; }
|
2021-07-11 01:46:09 +02:00
|
|
|
virtual StringView purpose() const override { return "Shared IRQ Handler"; }
|
|
|
|
virtual StringView controller() const override { return m_responsible_irq_controller->model(); }
|
2020-02-22 19:56:55 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
void enable_interrupt_vector();
|
|
|
|
void disable_interrupt_vector();
|
|
|
|
explicit SharedIRQHandler(u8 interrupt_number);
|
2021-02-05 19:43:01 +01:00
|
|
|
bool m_enabled { true };
|
2021-07-21 20:21:29 +02:00
|
|
|
GenericInterruptHandler::List m_handlers;
|
2020-02-28 22:33:41 +02:00
|
|
|
RefPtr<IRQController> m_responsible_irq_controller;
|
2020-02-22 19:56:55 +02:00
|
|
|
};
|
|
|
|
}
|