summaryrefslogtreecommitdiff
path: root/Kernel/Arch
diff options
context:
space:
mode:
authorDaniel Bertalan <dani@danielbertalan.dev>2023-05-15 07:46:26 +0200
committerAndrew Kaster <andrewdkaster@gmail.com>2023-05-17 01:32:43 -0600
commit3beb488887b689bafc885efdf5bf3cc0719c218f (patch)
tree112b9d5ad5914e9fa50499e63c62cbe6cf12312b /Kernel/Arch
parentd9c557d0b48c944798b94d888dc72e7601c4fcf4 (diff)
downloadserenity-3beb488887b689bafc885efdf5bf3cc0719c218f.zip
Kernel: Add `RPi::Timer::get_clock_rate()`
Diffstat (limited to 'Kernel/Arch')
-rw-r--r--Kernel/Arch/aarch64/RPi/Timer.cpp31
-rw-r--r--Kernel/Arch/aarch64/RPi/Timer.h1
2 files changed, 32 insertions, 0 deletions
diff --git a/Kernel/Arch/aarch64/RPi/Timer.cpp b/Kernel/Arch/aarch64/RPi/Timer.cpp
index afec4c7654..f39977a0aa 100644
--- a/Kernel/Arch/aarch64/RPi/Timer.cpp
+++ b/Kernel/Arch/aarch64/RPi/Timer.cpp
@@ -151,4 +151,35 @@ u32 Timer::set_clock_rate(ClockID clock_id, u32 rate_hz, bool skip_setting_turbo
return message_queue.set_clock_rate.rate_hz;
}
+class GetClockRateMboxMessage : Mailbox::Message {
+public:
+ u32 clock_id;
+ u32 rate_hz;
+
+ GetClockRateMboxMessage()
+ : Mailbox::Message(0x0003'0002, 8)
+ {
+ clock_id = 0;
+ rate_hz = 0;
+ }
+};
+
+u32 Timer::get_clock_rate(ClockID clock_id)
+{
+ struct __attribute__((aligned(16))) {
+ Mailbox::MessageHeader header;
+ GetClockRateMboxMessage get_clock_rate;
+ Mailbox::MessageTail tail;
+ } message_queue;
+
+ message_queue.get_clock_rate.clock_id = static_cast<u32>(clock_id);
+
+ if (!Mailbox::the().send_queue(&message_queue, sizeof(message_queue))) {
+ dbgln("Timer::get_clock_rate() failed!");
+ return 0;
+ }
+
+ return message_queue.get_clock_rate.rate_hz;
+}
+
}
diff --git a/Kernel/Arch/aarch64/RPi/Timer.h b/Kernel/Arch/aarch64/RPi/Timer.h
index bfac7242e2..1ec0816075 100644
--- a/Kernel/Arch/aarch64/RPi/Timer.h
+++ b/Kernel/Arch/aarch64/RPi/Timer.h
@@ -63,6 +63,7 @@ public:
PIXEL_BVB = 14,
};
static u32 set_clock_rate(ClockID, u32 rate_hz, bool skip_setting_turbo = true);
+ static u32 get_clock_rate(ClockID);
private:
Timer();