1/*
2 * Copyright 2022 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef ARCH_ARM_TIMER_GENERIC_H
6#define ARCH_ARM_TIMER_GENERIC_H
7
8#include <new>
9#include <SupportDefs.h>
10
11#include "soc.h"
12
13class ARMGenericTimer : public HardwareTimer {
14public:
15	void SetTimeout(bigtime_t timeout);
16	void Clear();
17	bigtime_t Time();
18
19	static status_t Init() {
20		ARMGenericTimer *timer = new(std::nothrow) ARMGenericTimer();
21		return timer != NULL ? B_OK : B_NO_MEMORY;
22	}
23
24	static bool IsAvailable();
25protected:
26	ARMGenericTimer();
27
28private:
29	static int32 _InterruptWrapper(void *data);
30	int32 HandleInterrupt();
31
32	uint32_t fTimerFrequency;
33	uint32_t fTimerFrequencyMHz;
34};
35
36#endif /* ARCH_ARM_TIMER_GENERIC_H */
37