1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:17:34 +00:00

Kernel: Fix HPET timer not firing in Bochs

* Change the register structures to use the volatile keyword explicitly
  on the register values. This avoids accidentally omitting it as any
  access will be guaranteed volatile.
* Don't assume we can read/write 64 bit value to the main counter and
  the comparator. Not all HPET implementations may support this. So,
  just use 32 bit words to access the registers. This ultimately works
  around a bug in Bochs 2.6.11 that loses 32 bits of a 64 bit write to
  a timer's comparator register (it internally writes one half and
  clears the Tn_VAL_SET_CNF bit, and then because it's cleared it
  fails to write the second half).
* Properly calculate the tick duration in calculate_ticks_in_nanoseconds
* As per specification, changing the frequency of one periodic timer
  requires a restart of all periodic timers as it requires the main
  counter to be reset.
This commit is contained in:
Tom 2020-11-03 13:19:42 -07:00 committed by Andreas Kling
parent 348cd0fdc1
commit d5bb5d109b
4 changed files with 158 additions and 95 deletions

View file

@ -45,15 +45,14 @@ public:
static bool check_for_exisiting_periodic_timers();
static HPET& the();
u64 main_counter_value() const;
u64 frequency() const;
const NonnullRefPtrVector<HPETComparator>& comparators() const { return m_comparators; }
void disable(const HPETComparator&);
void enable(const HPETComparator&);
void set_periodic_comparator_value(const HPETComparator& comparator, u64 value);
void set_non_periodic_comparator_value(const HPETComparator& comparator, u64 value);
void update_periodic_comparator_value();
void update_non_periodic_comparator_value(const HPETComparator& comparator);
void set_comparator_irq_vector(u8 comparator_number, u8 irq_vector);
@ -64,8 +63,8 @@ public:
Vector<unsigned> capable_interrupt_numbers(const HPETComparator&);
private:
const volatile HPETRegistersBlock& registers() const;
volatile HPETRegistersBlock& registers();
const HPETRegistersBlock& registers() const;
HPETRegistersBlock& registers();
void global_disable();
void global_enable();