summaryrefslogtreecommitdiffhomepage
path: root/NewKernel/KernelKit/Timer.hpp
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-05-08 12:32:41 +0200
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-05-08 12:32:41 +0200
commit09dd11ddf800898c00ecb04a65fb5cd10fb481fa (patch)
treeeda0b4e23d6a71da7de3a78f0bb76ec3201dd2f9 /NewKernel/KernelKit/Timer.hpp
parentca83108fd138cc0398f900e6a6c0a53ad51aee31 (diff)
MHR-23: :boom: changes, reworked project tree.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'NewKernel/KernelKit/Timer.hpp')
-rw-r--r--NewKernel/KernelKit/Timer.hpp64
1 files changed, 64 insertions, 0 deletions
diff --git a/NewKernel/KernelKit/Timer.hpp b/NewKernel/KernelKit/Timer.hpp
new file mode 100644
index 00000000..5f133dfe
--- /dev/null
+++ b/NewKernel/KernelKit/Timer.hpp
@@ -0,0 +1,64 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+#pragma once
+
+#include <ArchKit/ArchKit.hpp>
+#include <CompilerKit/CompilerKit.hxx>
+#include <KernelKit/HError.hpp>
+
+namespace NewOS
+{
+ 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 NewOS