summaryrefslogtreecommitdiffhomepage
path: root/dev/Kernel/KernelKit/Timer.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'dev/Kernel/KernelKit/Timer.hxx')
-rw-r--r--dev/Kernel/KernelKit/Timer.hxx64
1 files changed, 64 insertions, 0 deletions
diff --git a/dev/Kernel/KernelKit/Timer.hxx b/dev/Kernel/KernelKit/Timer.hxx
new file mode 100644
index 00000000..e6ef5d03
--- /dev/null
+++ b/dev/Kernel/KernelKit/Timer.hxx
@@ -0,0 +1,64 @@
+/* -------------------------------------------
+
+ Copyright ZKA Technologies.
+
+------------------------------------------- */
+
+#pragma once
+
+#include <ArchKit/ArchKit.hxx>
+#include <CompilerKit/CompilerKit.hxx>
+#include <KernelKit/LPC.hxx>
+
+namespace Kernel
+{
+ class HardwareTimer;
+ class HardwareTimerInterface;
+
+ class HardwareTimerInterface
+ {
+ public:
+ /// @brief Default constructor
+ explicit HardwareTimerInterface() = default;
+ virtual ~HardwareTimerInterface() = default;
+
+ public:
+ NEWOS_COPY_DEFAULT(HardwareTimerInterface);
+
+ public:
+ virtual Int32 Wait() noexcept;
+ };
+
+ class HardwareTimer final : public HardwareTimerInterface
+ {
+ public:
+ explicit HardwareTimer(Int64 seconds);
+ ~HardwareTimer() override;
+
+ public:
+ NEWOS_COPY_DEFAULT(HardwareTimer);
+
+ public:
+ Int32 Wait() noexcept override;
+
+ public:
+ IntPtr* fDigitalTimer{nullptr};
+ Int64 fWaitFor{0};
+ };
+
+ inline Int64 Seconds(Int64 time)
+ {
+ if (time < 0)
+ return 0;
+
+ return 1000 / time;
+ }
+
+ inline Int64 Milliseconds(Int64 time)
+ {
+ if (time < 0)
+ return 0;
+
+ return 1000 / Seconds(time);
+ }
+} // namespace Kernel