![]() |
Max OS 0.3
|
Driver for the APIC clock. More...
#include <clock.h>
Public Member Functions | |
| Clock (AdvancedProgrammableInterruptController *apic, uint16_t time_between_events=10) | |
| Constructor for the Clock class. | |
| void | delay (uint32_t milliseconds) const |
| Delays the program for a specified number of milliseconds (rounded up to the nearest degree of accuracy - ensured the delay is at least the specified number of milliseconds). This on the kernel level is a busy wait, for user level see the sleep function in the Thread class. | |
| void | calibrate (uint64_t ms_per_tick=1) |
| Configures the APIC clock to fire an interrupt at a specified interval in milliseconds. | |
| void | setup_apic_clock (LocalAPIC *local_apic) const |
| Sets up the APIC clock to fire interrupts at the desired rate. | |
| common::time_t | get_time () |
| Reads the current time from the APIC clock (in 24hr time) | |
Public Member Functions inherited from MaxOS::hardwarecommunication::InterruptHandler | |
| virtual system::cpu_status_t * | handle_interrupt (system::cpu_status_t *status) |
| Handles an interrupt and returns the status. | |
Static Public Member Functions | |
| static Clock * | active_clock () |
| Gets the currently active clock. | |
Public Attributes | |
| uint64_t | clock_accuracy = 1 |
| How accurate the clock is in microseconds (how often should an interrupt be raised) | |
Additional Inherited Members | |
Protected Member Functions inherited from MaxOS::hardwarecommunication::InterruptHandler | |
| InterruptHandler (uint8_t interrupt_number, int64_t redirect=-1, uint64_t redirect_index=0) | |
| Creates a new interrupt handler and registers it with the interrupt manager. | |
| virtual | ~InterruptHandler () |
| Destroys the interrupt handler and unregisters it from the interrupt manager. | |
Protected Attributes inherited from MaxOS::hardwarecommunication::InterruptHandler | |
| uint8_t | m_interrupt_number |
| The interrupt number this handler handles. | |
|
explicit |
Constructor for the Clock class.
| apic | The apic controller for this core |
| time_between_events | The time between events in 10ths of a second |
Definition at line 22 of file clock.cpp.
References MaxOS::Logger::INFO().
|
static |
Gets the currently active clock.
Definition at line 182 of file clock.cpp.
Referenced by MaxOS::system::Core::init(), and MaxOS::system::Core::wake_up().
| void Clock::calibrate | ( | uint64_t | ms_per_tick = 1 | ) |
Configures the APIC clock to fire an interrupt at a specified interval in milliseconds.
| ms_per_tick | How many milliseconds per interrupt |
Definition at line 118 of file clock.cpp.
References clock_accuracy, MaxOS::Logger::DEBUG(), MaxOS::Logger::INFO(), MaxOS::hardwarecommunication::AdvancedProgrammableInterruptController::local_apic(), and setup_apic_clock().
Referenced by kernel_main().
| void Clock::delay | ( | uint32_t | milliseconds | ) | const |
Delays the program for a specified number of milliseconds (rounded up to the nearest degree of accuracy - ensured the delay is at least the specified number of milliseconds). This on the kernel level is a busy wait, for user level see the sleep function in the Thread class.
| milliseconds | How many milliseconds to delay the program for. |
Definition at line 102 of file clock.cpp.
References clock_accuracy.
Referenced by MaxOS::system::Core::wake_up().
| common::time_t Clock::get_time | ( | ) |
Reads the current time from the APIC clock (in 24hr time)
Definition at line 156 of file clock.cpp.
| void Clock::setup_apic_clock | ( | hardwarecommunication::LocalAPIC * | local_apic | ) | const |
Sets up the APIC clock to fire interrupts at the desired rate.
| local_apic | The local APIC to setup the clock on |
Definition at line 137 of file clock.cpp.
References clock_accuracy, and MaxOS::hardwarecommunication::LocalAPIC::write().
Referenced by calibrate(), and MaxOS::system::Core::init().
| uint64_t MaxOS::hardwarecommunication::Clock::clock_accuracy = 1 |
How accurate the clock is in microseconds (how often should an interrupt be raised)
Definition at line 156 of file clock.h.
Referenced by calibrate(), delay(), and setup_apic_clock().