mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:27:34 +00:00
Kernel: Fix APIC timer calibration to be more accurate
We were calibrating it to 260 instead of 250 ticks per second (being off by one for the 1/10th second calibration time), resulting in ticks of only ~3.6 ms instead of ~4ms. This gets us closer to ~4ms, but because the APIC isn't nearly as precise as e.g. HPET, it will only be a best effort. Then, use the higher precision reference timer to more accurately calculate how many ticks we actually get each second. Also the frequency calculation was off, causing a "Frequency too slow" error with VMware. Fixes some problems observed in #5539
This commit is contained in:
parent
f66adbdd95
commit
cdbd878a14
7 changed files with 64 additions and 23 deletions
|
@ -46,6 +46,8 @@ public:
|
|||
static HPET& the();
|
||||
|
||||
u64 frequency() const { return m_frequency; }
|
||||
u64 raw_counter_ticks_to_ns(u64) const;
|
||||
u64 ns_to_raw_counter_ticks(u64) const;
|
||||
|
||||
const NonnullRefPtrVector<HPETComparator>& comparators() const { return m_comparators; }
|
||||
void disable(const HPETComparator&);
|
||||
|
@ -60,6 +62,7 @@ public:
|
|||
void disable_periodic_interrupt(const HPETComparator& comparator);
|
||||
|
||||
u64 update_time(u64& seconds_since_boot, u32& ticks_this_second, bool query_only);
|
||||
u64 read_main_counter_unsafe() const;
|
||||
u64 read_main_counter() const;
|
||||
|
||||
Vector<unsigned> capable_interrupt_numbers(u8 comparator_number);
|
||||
|
@ -75,7 +78,7 @@ private:
|
|||
bool is_periodic_capable(u8 comparator_number);
|
||||
void set_comparators_to_optimal_interrupt_state(size_t timers_count);
|
||||
|
||||
u64 calculate_ticks_in_nanoseconds() const;
|
||||
u64 nanoseconds_to_raw_ticks() const;
|
||||
|
||||
PhysicalAddress find_acpi_hpet_registers_block();
|
||||
explicit HPET(PhysicalAddress acpi_hpet);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue