diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2026-03-26 16:35:32 +0100 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-03-27 07:02:35 +0100 |
| commit | 00a77644192642e06462c11479a5c0e9bd859e9a (patch) | |
| tree | d86cee8a0d7f4d2894ced16614fcd4554e10c327 /arch/x86_64/kapi/cpu | |
| parent | 2521d58e7a5c16595e401e1af7becb572ad35f53 (diff) | |
| download | teachos-00a77644192642e06462c11479a5c0e9bd859e9a.tar.xz teachos-00a77644192642e06462c11479a5c0e9bd859e9a.zip | |
kapi: extract interrupts API
Diffstat (limited to 'arch/x86_64/kapi/cpu')
| -rw-r--r-- | arch/x86_64/kapi/cpu/interrupts.cpp | 67 |
1 files changed, 0 insertions, 67 deletions
diff --git a/arch/x86_64/kapi/cpu/interrupts.cpp b/arch/x86_64/kapi/cpu/interrupts.cpp deleted file mode 100644 index b98595c..0000000 --- a/arch/x86_64/kapi/cpu/interrupts.cpp +++ /dev/null @@ -1,67 +0,0 @@ -#include "kapi/cpu.hpp" -#include "kapi/system.hpp" - -#include <kstd/print> -#include <kstd/vector> - -#include <array> -#include <cstdint> - -namespace kapi::cpu -{ - - namespace - { - constexpr auto irq_offset = 32uz; - auto constinit interrupt_handlers = std::array<kstd::vector<interrupt_handler *>, 256 - irq_offset>{}; - } // namespace - - auto enable_interrupts() -> void - { - asm volatile("sti"); - } - - auto disable_interrupts() -> void - { - asm volatile("cli"); - } - - auto register_interrupt_handler(std::uint32_t irq_number, interrupt_handler & handler) -> void - { - if (irq_number < irq_offset) - { - system::panic("[x86_64:CPU] IRQ number must be in range [32, 255]."); - } - - interrupt_handlers[irq_number - irq_offset].push_back(&handler); - } - - auto unregister_interrupt_handler(std::uint32_t irq_number, [[maybe_unused]] interrupt_handler & handler) -> void - { - if (irq_number < irq_offset) - { - system::panic("[x86_64:CPU] IRQ number must be in range [32, 255]."); - } - - kstd::println("[x86_64:CPU] TODO: support erasure from vector."); - } - - auto dispatch_interrupt(std::uint32_t irq_number) -> status - { - if (irq_number < irq_offset) - { - return status::unhandled; - } - - for (auto handler : interrupt_handlers[irq_number - irq_offset]) - { - if (handler && handler->handle_interrupt(irq_number) == status::handled) - { - return status::handled; - } - } - - return status::unhandled; - } - -} // namespace kapi::cpu
\ No newline at end of file |
