2023-01-23 20:13:57 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2023-03-08 03:16:51 +02:00
|
|
|
#define DISABLE_INTERRUPTS() asm volatile("cli")
|
|
|
|
#define ENABLE_INTERRUPTS() asm volatile("sti")
|
|
|
|
|
2023-10-05 18:53:45 +03:00
|
|
|
namespace Kernel
|
2023-01-23 20:13:57 +02:00
|
|
|
{
|
|
|
|
|
2023-10-05 18:53:45 +03:00
|
|
|
class Interruptable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
void set_irq(int irq);
|
|
|
|
void enable_interrupt();
|
|
|
|
void disable_interrupt();
|
2023-09-28 12:30:27 +03:00
|
|
|
|
2023-10-05 18:53:45 +03:00
|
|
|
virtual void handle_irq() = 0;
|
2023-09-28 12:30:27 +03:00
|
|
|
|
2023-10-13 14:11:56 +03:00
|
|
|
protected:
|
|
|
|
Interruptable() = default;
|
|
|
|
~Interruptable() {}
|
|
|
|
|
2023-10-05 18:53:45 +03:00
|
|
|
private:
|
|
|
|
int m_irq { -1 };
|
|
|
|
};
|
2023-03-08 03:16:51 +02:00
|
|
|
|
2023-10-05 18:53:45 +03:00
|
|
|
class InterruptController
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~InterruptController() {}
|
|
|
|
|
|
|
|
virtual void eoi(uint8_t) = 0;
|
|
|
|
virtual void enable_irq(uint8_t) = 0;
|
|
|
|
virtual bool is_in_service(uint8_t) = 0;
|
|
|
|
|
|
|
|
static void initialize(bool force_pic);
|
|
|
|
static InterruptController& get();
|
|
|
|
|
2023-10-11 22:18:58 +03:00
|
|
|
bool is_using_apic() const { return m_using_apic; }
|
|
|
|
|
2023-10-05 18:53:45 +03:00
|
|
|
void enter_acpi_mode();
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool m_using_apic { false };
|
|
|
|
};
|
|
|
|
|
|
|
|
bool interrupts_enabled();
|
|
|
|
|
|
|
|
}
|