diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2026-07-24 12:36:04 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-07-24 12:36:04 +0200 |
| commit | c86b42b88659c50b6def9b5b52b4605b2a0e5d13 (patch) | |
| tree | 51e76a56280839bd2f620a920b7c719a4a16e55c /arch/x86_64 | |
| parent | 1c8e8faf1de6477b6a514817be8bb8ab4eef2960 (diff) | |
| download | kernel-c86b42b88659c50b6def9b5b52b4605b2a0e5d13.tar.xz kernel-c86b42b88659c50b6def9b5b52b4605b2a0e5d13.zip | |
kapi/interrupts: add ISR context
Diffstat (limited to 'arch/x86_64')
| -rw-r--r-- | arch/x86_64/arch/devices/legacy_pit.cpp | 15 | ||||
| -rw-r--r-- | arch/x86_64/arch/devices/legacy_pit.hpp | 3 |
2 files changed, 11 insertions, 7 deletions
diff --git a/arch/x86_64/arch/devices/legacy_pit.cpp b/arch/x86_64/arch/devices/legacy_pit.cpp index b2a30ef9..b24f87ea 100644 --- a/arch/x86_64/arch/devices/legacy_pit.cpp +++ b/arch/x86_64/arch/devices/legacy_pit.cpp @@ -63,7 +63,7 @@ namespace arch::devices auto divisor = static_cast<std::uint16_t>(base_frequency / data->frequency_in_hz); - kapi::interrupts::register_handler(data->irq_number, *this); + kapi::interrupts::register_handler(data->irq_number, *this, data); command_port::write<std::uint8_t>(square_wave_mode); io::wait(); @@ -89,17 +89,20 @@ namespace arch::devices return pit_names; } - auto pit_driver::handle_interrupt(std::uint32_t irq_number) -> kapi::interrupts::status + auto pit_driver::handle_interrupt(std::uint32_t irq_number, kstd::weak_ptr<void> context) -> kapi::interrupts::status { - // auto data = static_pointer_cast<driver_data>(device.driver_data()); + auto data = static_pointer_cast<driver_data>(context.lock()); + if (!data) + { + return kapi::interrupts::status::unhandled; + } - if (irq_number != 0) + if (irq_number != data->irq_number) { return kapi::interrupts::status::unhandled; } - // TODO: upgrade kapi interrupts to gain access to the device. - // ++m_ticks; + ++data->ticks; return kapi::interrupts::status::handled; } diff --git a/arch/x86_64/arch/devices/legacy_pit.hpp b/arch/x86_64/arch/devices/legacy_pit.hpp index f0a18ecb..31c02207 100644 --- a/arch/x86_64/arch/devices/legacy_pit.hpp +++ b/arch/x86_64/arch/devices/legacy_pit.hpp @@ -6,6 +6,7 @@ #include <kapi/devices.hpp> #include <kapi/interrupts.hpp> +#include <kstd/memory.hpp> #include <kstd/result.hpp> #include <cstdint> @@ -42,7 +43,7 @@ namespace arch::devices [[nodiscard]] auto supported_names() const -> std::span<std::string_view const> override; - auto handle_interrupt(std::uint32_t irq_number) -> kapi::interrupts::status override; + auto handle_interrupt(std::uint32_t irq_number, kstd::weak_ptr<void> context) -> kapi::interrupts::status override; protected: auto query_interface(kapi::devices::interface interface) -> void * override; |
