summaryrefslogtreecommitdiffhomepage
path: root/KernelKit/Timer.hpp
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-01-06 09:14:11 +0100
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-01-06 09:14:11 +0100
commit5339d016c07bf717ee388f4feb73544087324af0 (patch)
tree94be6f67ed626091f24aee24ec3b3be03d01e4e7 /KernelKit/Timer.hpp
git: port from mercurial repo.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'KernelKit/Timer.hpp')
-rw-r--r--KernelKit/Timer.hpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/KernelKit/Timer.hpp b/KernelKit/Timer.hpp
new file mode 100644
index 00000000..81be74a0
--- /dev/null
+++ b/KernelKit/Timer.hpp
@@ -0,0 +1,69 @@
+/*
+ * ========================================================
+ *
+ * hCore
+ * Copyright Mahrouss Logic, all rights reserved.
+ *
+ * ========================================================
+ */
+
+#pragma once
+
+#include <CompilerKit/Compiler.hpp>
+#include <ArchKit/Arch.hpp>
+
+#include <NewKit/ErrorID.hpp>
+
+namespace hCore
+{
+ class ITimer;
+ class HardwareTimer;
+
+ class ITimer
+ {
+ public:
+ ITimer() = default;
+ virtual ~ITimer() = default;
+
+ public:
+ HCORE_COPY_DEFAULT(ITimer);
+
+ public:
+ virtual Int32 Wait() { return ME_UNIMPLEMENTED; }
+
+ };
+
+ class HardwareTimer final : public ITimer
+ {
+ public:
+ explicit HardwareTimer(Int64 seconds);
+ ~HardwareTimer() override;
+
+ public:
+ HCORE_COPY_DEFAULT(HardwareTimer);
+
+ public:
+ Int32 Wait() 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);
+ }
+}