![]() |
Max OS 0.3
|
Driver for the APIC clock. More...
#include <clock.h>
Public Member Functions | |
| Clock (hardwarecommunication::AdvancedProgrammableInterruptController *apic, uint16_t time_between_events=10) | |
| Constructor for the Clock class. | |
| void | activate () override |
| Activates the clock, setting the binary coded decimal representation flag. | |
| 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 (hardwarecommunication::LocalAPIC *local_apic) const |
| Sets up the APIC clock to fire interrupts at the desired rate. | |
| string | vendor_name () final |
| Gets the vendor who created the device. | |
| string | device_name () final |
| Gets the name of the device. | |
| common::time_t | get_time () |
| Reads the current time from the APIC clock (in 24hr time) | |
Public Member Functions inherited from MaxOS::drivers::Driver | |
| virtual void | deactivate () |
| Deactivate the driver. | |
| virtual void | initialise () |
| Initialise the driver. | |
| virtual uint32_t | reset () |
| Reset the driver. | |
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. | |
| ~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 24 of file clock.cpp.
References MaxOS::Logger::INFO().
|
overridevirtual |
Activates the clock, setting the binary coded decimal representation flag.
Reimplemented from MaxOS::drivers::Driver.
Definition at line 88 of file clock.cpp.
|
static |
Gets the currently active clock.
Definition at line 208 of file clock.cpp.
Referenced by MaxOS::filesystem::format::ext2::Ext2Volume::create_inode(), MaxOS::system::Core::init(), MaxOS::system::Core::wake_up(), and MaxOS::filesystem::format::ext2::Ext2File::write().
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 144 of file clock.cpp.
References clock_accuracy, MaxOS::Logger::DEBUG(), MaxOS::Logger::INFO(), MaxOS::hardwarecommunication::AdvancedProgrammableInterruptController::local_apic(), and setup_apic_clock().
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 110 of file clock.cpp.
References clock_accuracy.
|
finalvirtual |
Gets the name of the device.
Reimplemented from MaxOS::drivers::Driver.
Definition at line 135 of file clock.cpp.
| common::time_t Clock::get_time | ( | ) |
Reads the current time from the APIC clock (in 24hr time)
Definition at line 182 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 163 of file clock.cpp.
References clock_accuracy, and MaxOS::hardwarecommunication::LocalAPIC::write().
Referenced by calibrate().
|
finalvirtual |
Gets the vendor who created the device.
Reimplemented from MaxOS::drivers::Driver.
Definition at line 126 of file clock.cpp.
| uint64_t MaxOS::drivers::clock::Clock::clock_accuracy = 1 |
How accurate the clock is in microseconds (how often should an interrupt be raised)
Definition at line 155 of file clock.h.
Referenced by calibrate(), delay(), and setup_apic_clock().