mirror of
https://github.com/wichtounet/thor-os.git
synced 2025-09-10 13:04:53 -04:00
Let the timer driver sets the timer frequency
This commit is contained in:
parent
e99326db0e
commit
a27d445ec2
@ -19,6 +19,16 @@ uint64_t seconds();
|
||||
|
||||
void tick();
|
||||
|
||||
/*!
|
||||
* \brief Return the frequency in Hz of the current timer system.
|
||||
*/
|
||||
uint64_t frequency();
|
||||
|
||||
/*!
|
||||
* \brief Sets the frequency in Hz of the current timer system.
|
||||
*/
|
||||
void frequency(uint64_t freq);
|
||||
|
||||
} //end of timer namespace
|
||||
|
||||
#endif
|
||||
|
@ -28,6 +28,9 @@ bool pit::install(){
|
||||
out_byte(0x40, static_cast<uint8_t>(divisor));
|
||||
out_byte(0x40, static_cast<uint8_t>(divisor >> 8));
|
||||
|
||||
// Indicate the timer frequency
|
||||
timer::frequency(1000);
|
||||
|
||||
if(!interrupt::register_irq_handler(0, timer_handler, nullptr)){
|
||||
logging::logf(logging::log_level::ERROR, "Unable to register PIT 0\n");
|
||||
|
||||
|
@ -19,6 +19,7 @@ namespace {
|
||||
|
||||
uint64_t _timer_ticks = 0;
|
||||
uint64_t _timer_seconds = 0;
|
||||
uint64_t _timer_frequency = 0;
|
||||
|
||||
volatile uint64_t _timer_countdown = 0;
|
||||
|
||||
@ -74,3 +75,13 @@ uint64_t timer::ticks(){
|
||||
uint64_t timer::seconds(){
|
||||
return _timer_seconds;
|
||||
}
|
||||
|
||||
uint64_t timer::frequency(){
|
||||
return _timer_frequency;
|
||||
}
|
||||
|
||||
void timer::frequency(uint64_t freq){
|
||||
_timer_frequency = freq;
|
||||
|
||||
logging::logf(logging::log_level::DEBUG, "timer: Frequency set to %u Hz\n", freq);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user