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