HPET supports reading LAPIC counter without locks, so it can be done in parallel. This makes booting much faster. Previously initializing every timer took 100 ms, so 16 CPUs took total of 1.6 seconds. This allows doing it all in 100 ms.
35 lines
735 B
C++
35 lines
735 B
C++
#pragma once
|
|
|
|
#include <kernel/Interruptable.h>
|
|
#include <kernel/Lock/SpinLock.h>
|
|
#include <kernel/Timer/Timer.h>
|
|
|
|
namespace Kernel
|
|
{
|
|
|
|
class PIT final : public Timer, public Interruptable
|
|
{
|
|
public:
|
|
static BAN::ErrorOr<BAN::UniqPtr<PIT>> create();
|
|
|
|
virtual uint64_t ms_since_boot() const override;
|
|
virtual uint64_t ns_since_boot() const override;
|
|
virtual timespec time_since_boot() const override;
|
|
|
|
virtual bool pre_scheduler_sleep_needs_lock() const override { return true; }
|
|
virtual void pre_scheduler_sleep_ns(uint64_t) override;
|
|
|
|
virtual void handle_irq() override;
|
|
|
|
private:
|
|
void initialize();
|
|
|
|
uint64_t read_counter_ns() const;
|
|
|
|
private:
|
|
mutable SpinLock m_lock;
|
|
uint64_t m_system_time_ms { 0 };
|
|
};
|
|
|
|
}
|