summaryrefslogtreecommitdiffhomepage
path: root/Private/Source/Timer.cxx
blob: a35cc06f551d030b6640596f4b955ea3c4d6832f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/* -------------------------------------------

    Copyright Mahrouss Logic

------------------------------------------- */

#include <KernelKit/Timer.hpp>

// bugs = 0

using namespace NewOS;

/// @brief Unimplemented as it is an interface.
Int32 HardwareTimerInterface::Wait() noexcept { return H_UNIMPLEMENTED; }

/// @brief HardwareTimer class, meant to be generic.

HardwareTimer::HardwareTimer(Int64 seconds) : fWaitFor(seconds) {}
HardwareTimer::~HardwareTimer() { fWaitFor = 0; }

Int32 HardwareTimer::Wait() noexcept {
  if (fWaitFor < 1) return -1;

  while (*fDigitalTimer < (*fDigitalTimer + fWaitFor)) {
  }

  return 0;
}