mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:57:44 +00:00
Kernel: Take into account the time keeper's frequency (if no HPET)
The PIT is now also running at a rate of ~250 ticks/second, so rather than assuming there are 1000 ticks/second we need to query the timer being used for the actual frequency. Fixes #4508
This commit is contained in:
parent
0e2b7f9c9a
commit
f1534ff36e
2 changed files with 7 additions and 3 deletions
|
@ -58,6 +58,7 @@ public:
|
||||||
virtual void set_periodic() = 0;
|
virtual void set_periodic() = 0;
|
||||||
virtual void set_non_periodic() = 0;
|
virtual void set_non_periodic() = 0;
|
||||||
virtual void disable() = 0;
|
virtual void disable() = 0;
|
||||||
|
virtual u32 frequency() const = 0;
|
||||||
|
|
||||||
virtual size_t ticks_per_second() const = 0;
|
virtual size_t ticks_per_second() const = 0;
|
||||||
|
|
||||||
|
@ -88,6 +89,8 @@ public:
|
||||||
return previous_callback;
|
return previous_callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual u32 frequency() const override { return (u32)m_frequency; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
HardwareTimer(u8 irq_number, Function<void(const RegisterState&)> callback = nullptr)
|
HardwareTimer(u8 irq_number, Function<void(const RegisterState&)> callback = nullptr)
|
||||||
: IRQHandler(irq_number)
|
: IRQHandler(irq_number)
|
||||||
|
@ -131,6 +134,8 @@ public:
|
||||||
virtual const char* controller() const override { return nullptr; }
|
virtual const char* controller() const override { return nullptr; }
|
||||||
virtual bool eoi() override;
|
virtual bool eoi() override;
|
||||||
|
|
||||||
|
virtual u32 frequency() const override { return (u32)m_frequency; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
HardwareTimer(u8 irq_number, Function<void(const RegisterState&)> callback = nullptr)
|
HardwareTimer(u8 irq_number, Function<void(const RegisterState&)> callback = nullptr)
|
||||||
: GenericInterruptHandler(irq_number)
|
: GenericInterruptHandler(irq_number)
|
||||||
|
|
|
@ -366,9 +366,8 @@ void TimeManagement::increment_time_since_boot()
|
||||||
// Compute time adjustment for adjtime. Let the clock run up to 1% fast or slow.
|
// Compute time adjustment for adjtime. Let the clock run up to 1% fast or slow.
|
||||||
// That way, adjtime can adjust up to 36 seconds per hour, without time getting very jumpy.
|
// That way, adjtime can adjust up to 36 seconds per hour, without time getting very jumpy.
|
||||||
// Once we have a smarter NTP service that also adjusts the frequency instead of just slewing time, maybe we can lower this.
|
// Once we have a smarter NTP service that also adjusts the frequency instead of just slewing time, maybe we can lower this.
|
||||||
constexpr long NanosPerTick = 1'000'000; // FIXME: Don't assume that one tick is 1 ms.
|
long NanosPerTick = 1'000'000'000 / m_time_keeper_timer->frequency();
|
||||||
constexpr time_t MaxSlewNanos = NanosPerTick / 100;
|
time_t MaxSlewNanos = NanosPerTick / 100;
|
||||||
static_assert(MaxSlewNanos < NanosPerTick);
|
|
||||||
|
|
||||||
u32 update_iteration = m_update1.fetch_add(1, AK::MemoryOrder::memory_order_acquire);
|
u32 update_iteration = m_update1.fetch_add(1, AK::MemoryOrder::memory_order_acquire);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue