summaryrefslogtreecommitdiff
path: root/Kernel/Time/HPET.h
diff options
context:
space:
mode:
authorTom <tomut@yahoo.com>2021-02-28 11:47:03 -0700
committerAndreas Kling <kling@serenityos.org>2021-03-01 11:11:09 +0100
commitcdbd878a145c97ffef9ba154071803fdc6c58ac3 (patch)
tree8b2ee260f5e0a2a84fc1af5ab271add3a58d03c3 /Kernel/Time/HPET.h
parentf66adbdd95bc587b9f7971af8b095e11cda0ce9e (diff)
downloadserenity-cdbd878a145c97ffef9ba154071803fdc6c58ac3.zip
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
Diffstat (limited to 'Kernel/Time/HPET.h')
-rw-r--r--Kernel/Time/HPET.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/Kernel/Time/HPET.h b/Kernel/Time/HPET.h
index 7cdc15fb74..a2d04dd774 100644
--- a/Kernel/Time/HPET.h
+++ b/Kernel/Time/HPET.h
@@ -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);