9#ifndef MAXOS_DRIVERS_CLOCK_CLOCK_H
10#define MAXOS_DRIVERS_CLOCK_CLOCK_H
21namespace MaxOS::drivers::clock {
51 INTERRUPT_ON_TERMINAL_COUNT,
99 uint64_t m_ticks { 0 };
110 void handle_interrupt()
final;
111 uint32_t ticks_per_ms();
126 uint64_t m_ticks { 0 };
128 bool m_binary =
true;
129 bool m_24_hour_clock =
true;
139 uint16_t m_ticks_between_events = 0;
140 uint16_t m_ticks_until_next_event = 1;
141 uint64_t m_pit_ticks_per_ms = 0;
144 void handle_interrupt()
final;
145 uint8_t read_hardware_clock(uint8_t address);
146 [[nodiscard]] uint8_t binary_representation(uint8_t number)
const;
148 inline static Clock* s_active_clock =
nullptr;
158 void delay(uint32_t milliseconds)
const;
160 void calibrate(uint64_t ms_per_tick = 1);
Defines classes and structures for handling the Advanced Programmable Interrupt Controller (APIC) in ...
base class for all drivers, handles the activation, deactivation, initialisation and reset of the dri...
Driver for the APIC clock.
common::time_t get_time()
Reads the current time from the APIC clock (in 24hr time)
void activate() override
Activates the clock, setting the binary coded decimal representation flag.
string device_name() final
Gets the name of the device.
void setup_apic_clock(hardwarecommunication::LocalAPIC *local_apic) const
Sets up the APIC clock to fire interrupts at the desired rate.
uint64_t clock_accuracy
How accurate the clock is in microseconds (how often should an interrupt be raised)
void delay(uint32_t milliseconds) const
Delays the program for a specified number of milliseconds (rounded up to the nearest degree of accura...
string vendor_name() final
Gets the vendor who created the device.
static Clock * active_clock()
Gets the currently active clock.
void calibrate(uint64_t ms_per_tick=1)
Configures the APIC clock to fire an interrupt at a specified interval in milliseconds.
Driver for the Programmable Interval Timer.
Handles both the Local APIC (boot core) and IO APIC.
Handles the IO APIC in the system (one per system)
Handles a certain interrupt number.
Handles the local APIC for the current core.
BCDMode
Specifies the data encoding mode used by the PIT.
constexpr uint16_t TICK_CALIBRATE_LENGTH
How many loops to spin for calibration.
OperatingMode
What should the PIT do.
Channel
Where should the PIT raise an event to.
AccessMode
What mode should the PIT use for the selected channel.
Defines a base Driver class and DriverManager for managing drivers.
Defines classes for handling events and event managers.
Defines a InterruptManager and InterruptHandler for managing hardware and software interrupts.
The command byte to send to the PIT, specifies the channel, access mode, operating mode and BCD mode.
uint8_t access_mode
How the data is accessed.
uint8_t bcd_mode
0 = binary, 1 = BCD
uint8_t operating_mode
What mode the PIT should operate in.
uint8_t channel
Which channel to configure.
Defines a Time struct for storing date and time information, along with functions for time manipulati...
Defines a Vector class for dynamically storing an array of elements.