Let the timer driver sets the timer frequency

This commit is contained in:
Baptiste Wicht 2016-08-06 15:45:04 +02:00
parent e99326db0e
commit a27d445ec2
3 changed files with 24 additions and 0 deletions

View File

@ -19,6 +19,16 @@ uint64_t seconds();
void tick(); 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 } //end of timer namespace
#endif #endif

View File

@ -28,6 +28,9 @@ bool pit::install(){
out_byte(0x40, static_cast<uint8_t>(divisor)); out_byte(0x40, static_cast<uint8_t>(divisor));
out_byte(0x40, static_cast<uint8_t>(divisor >> 8)); 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)){ if(!interrupt::register_irq_handler(0, timer_handler, nullptr)){
logging::logf(logging::log_level::ERROR, "Unable to register PIT 0\n"); logging::logf(logging::log_level::ERROR, "Unable to register PIT 0\n");

View File

@ -19,6 +19,7 @@ namespace {
uint64_t _timer_ticks = 0; uint64_t _timer_ticks = 0;
uint64_t _timer_seconds = 0; uint64_t _timer_seconds = 0;
uint64_t _timer_frequency = 0;
volatile uint64_t _timer_countdown = 0; volatile uint64_t _timer_countdown = 0;
@ -74,3 +75,13 @@ uint64_t timer::ticks(){
uint64_t timer::seconds(){ uint64_t timer::seconds(){
return _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);
}