summaryrefslogtreecommitdiffhomepage
path: root/Kernel/Sources/Timer.cxx
blob: 7b840a110a0f8d3bc98c5abbf6dc89d0ec9db683 (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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* -------------------------------------------

	Copyright ZKA Technologies

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

#include <KernelKit/Timer.hxx>

///! BUGS: 0
///! @file Timer.cxx

using namespace Kernel;

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

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

HardwareTimer::HardwareTimer(Int64 seconds)
	: fWaitFor(seconds)
{
	MUST_PASS(fWaitFor > 0);
}

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

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

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

	return 0;
}