Kernel: Add Timer::ns_since_boot()

This commit is contained in:
2023-10-12 21:16:39 +03:00
parent b723ed5fd2
commit 75fdf4c3c6
6 changed files with 20 additions and 0 deletions

View File

@@ -148,6 +148,12 @@ namespace Kernel
return read_register(HPET_REG_COUNTER) * m_counter_tick_period_fs / FS_PER_MS;
}
uint64_t HPET::ns_since_boot() const
{
// FIXME: 32 bit CPUs should use 32 bit counter with 32 bit reads
return read_register(HPET_REG_COUNTER) * m_counter_tick_period_fs / FS_PER_NS;
}
timespec HPET::time_since_boot() const
{
uint64_t time_fs = read_register(HPET_REG_COUNTER) * m_counter_tick_period_fs;

View File

@@ -62,6 +62,11 @@ namespace Kernel
return m_system_time * (MS_PER_S / TICKS_PER_SECOND);
}
uint64_t PIT::ns_since_boot() const
{
return m_system_time * (NS_PER_S / TICKS_PER_SECOND);
}
timespec PIT::time_since_boot() const
{
uint64_t ticks = m_system_time;

View File

@@ -59,6 +59,11 @@ namespace Kernel
return m_timer->ms_since_boot();
}
uint64_t SystemTimer::ns_since_boot() const
{
return m_timer->ns_since_boot();
}
timespec SystemTimer::time_since_boot() const
{
return m_timer->time_since_boot();