aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/src/devices/legacy_pit.cpp
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2026-04-29 09:36:43 +0200
committerFelix Morgner <felix.morgner@ost.ch>2026-04-29 09:36:43 +0200
commitd6ef2153fb32ee7ba04acdf37e7a535a855229db (patch)
treed2cd3275797208b1f78c44baa63739fa8645146f /arch/x86_64/src/devices/legacy_pit.cpp
parentd906d70c94c2a40d5fc6fd26056c7bc57d540002 (diff)
parentc3d5a155025b445ab9213f131681afe9410b4e66 (diff)
downloadteachos-d6ef2153fb32ee7ba04acdf37e7a535a855229db.tar.xz
teachos-d6ef2153fb32ee7ba04acdf37e7a535a855229db.zip
Merge branch 'fmorgner/develop-BA-FS26/x86-64-use-p1204-layout' into 'develop-BA-FS26'
chore: migrate 'arch' to p1204 project layout See merge request teachos/kernel!28
Diffstat (limited to 'arch/x86_64/src/devices/legacy_pit.cpp')
-rw-r--r--arch/x86_64/src/devices/legacy_pit.cpp60
1 files changed, 0 insertions, 60 deletions
diff --git a/arch/x86_64/src/devices/legacy_pit.cpp b/arch/x86_64/src/devices/legacy_pit.cpp
deleted file mode 100644
index d542d47..0000000
--- a/arch/x86_64/src/devices/legacy_pit.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-#include <arch/devices/legacy_pit.hpp>
-
-#include <arch/device_io/port_io.hpp>
-
-#include <kapi/devices.hpp>
-#include <kapi/devices/device.hpp>
-#include <kapi/interrupts.hpp>
-
-#include <cstddef>
-#include <cstdint>
-
-namespace arch::devices
-{
-
- namespace
- {
- using command_port = io::port<0x43, std::uint8_t, io::port_write>;
- using channel_0_port = io::port<0x40, std::uint8_t, io::port_write>;
- using channel_1_port = io::port<0x41, std::uint8_t, io::port_write>;
- using channel_2_port = io::port<0x42, std::uint8_t, io::port_write>;
-
- constexpr auto base_frequency = 1'193'182u;
- constexpr auto square_wave_mode = 0x36;
- } // namespace
-
- legacy_pit::legacy_pit(std::size_t major, std::uint32_t frequency_in_hz)
- : kapi::devices::device{major, 0, "legacy_pit"}
- , m_irq_number{0}
- , m_frequency_in_hz{frequency_in_hz}
- {}
-
- auto legacy_pit::init() -> bool
- {
- auto divisor = static_cast<std::uint16_t>(base_frequency / m_frequency_in_hz);
-
- kapi::interrupts::register_handler(m_irq_number, *this);
-
- command_port::write<std::uint8_t>(square_wave_mode);
- io::wait();
- channel_0_port::write<std::uint8_t>(divisor & 0xff);
- io::wait();
- channel_0_port::write<std::uint8_t>(divisor >> 8 & 0xff);
- io::wait();
-
- return true;
- }
-
- auto legacy_pit::handle_interrupt(std::uint32_t irq_number) -> kapi::interrupts::status
- {
- if (irq_number != m_irq_number)
- {
- return kapi::interrupts::status::unhandled;
- }
-
- ++m_ticks;
-
- return kapi::interrupts::status::handled;
- }
-
-} // namespace arch::devices \ No newline at end of file