summaryrefslogtreecommitdiffhomepage
path: root/Kernel/KernelKit/Timer.hxx
diff options
context:
space:
mode:
authorAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-08-02 20:11:24 +0200
committerAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-08-02 20:11:24 +0200
commit59578978610f6af245f571a011694a51d94dc530 (patch)
tree3553807ef1c8095248520ee823c1426aef8738d8 /Kernel/KernelKit/Timer.hxx
parent9afcd1c001703c32964fed5906f36a2d913e91e9 (diff)
[unstable] [META] refactor whole project.
Signed-off-by: Amlal EL Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'Kernel/KernelKit/Timer.hxx')
-rw-r--r--Kernel/KernelKit/Timer.hxx64
1 files changed, 64 insertions, 0 deletions
diff --git a/Kernel/KernelKit/Timer.hxx b/Kernel/KernelKit/Timer.hxx
new file mode 100644
index 00000000..014a504f
--- /dev/null
+++ b/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