summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorMaciej Zygmanowski <sppmacd@pm.me>2021-01-23 20:23:00 +0100
committerAndreas Kling <kling@serenityos.org>2021-01-26 21:14:44 +0100
commitceb5682b5407f1606b4cbf712de86e1640446ed2 (patch)
tree473f2875938835447effb2d58519cbb6fb1c370f /Kernel
parent67e93745cb8173218e8e2c67f4e39c87a47d72f5 (diff)
downloadserenity-ceb5682b5407f1606b4cbf712de86e1640446ed2.zip
Kernel: Add HPET::read_main_counter()
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Time/HPET.cpp6
-rw-r--r--Kernel/Time/HPET.h1
2 files changed, 7 insertions, 0 deletions
diff --git a/Kernel/Time/HPET.cpp b/Kernel/Time/HPET.cpp
index f2659d6a7c..e534a7b974 100644
--- a/Kernel/Time/HPET.cpp
+++ b/Kernel/Time/HPET.cpp
@@ -271,6 +271,12 @@ u64 HPET::update_time(u64& seconds_since_boot, u32& ticks_this_second, bool quer
return (delta_ticks * 1000000000ull) / ticks_per_second;
}
+u64 HPET::read_main_counter() const
+{
+ auto& main_counter = registers().main_counter_value;
+ return ((u64)main_counter.high << 32) | (u64)main_counter.low;
+}
+
void HPET::enable_periodic_interrupt(const HPETComparator& comparator)
{
#if HPET_DEBUG
diff --git a/Kernel/Time/HPET.h b/Kernel/Time/HPET.h
index e9460d3484..696617bbbe 100644
--- a/Kernel/Time/HPET.h
+++ b/Kernel/Time/HPET.h
@@ -60,6 +60,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() const;
Vector<unsigned> capable_interrupt_numbers(u8 comparator_number);
Vector<unsigned> capable_interrupt_numbers(const HPETComparator&);