1 /* 2 * Copyright 2020, Data61, CSIRO (ABN 41 687 119 230) 3 * 4 * SPDX-License-Identifier: GPL-2.0-only 5 */ 6 7 #pragma once 8 9 #include <config.h> 10 #include <mode/machine.h> 11 12 /* ARM generic timer implementation */ 13 #ifdef CONFIG_KERNEL_MCS 14 #include <model/statedata.h> 15 #include <api/types.h> 16 /** DONT_TRANSLATE **/ getCurrentTime(void)17static inline ticks_t getCurrentTime(void) 18 { 19 ticks_t time; 20 SYSTEM_READ_64(CNT_CT, time); 21 return time; 22 } 23 24 /** DONT_TRANSLATE **/ setDeadline(ticks_t deadline)25static inline void setDeadline(ticks_t deadline) 26 { 27 assert(deadline >= NODE_STATE(ksCurTime)); 28 SYSTEM_WRITE_64(CNT_CVAL, deadline); 29 } 30 ackDeadlineIRQ(void)31static inline void ackDeadlineIRQ(void) 32 { 33 ticks_t deadline = UINT64_MAX; 34 setDeadline(deadline); 35 } 36 #else /* CONFIG_KERNEL_MCS */ 37 #include <arch/machine/timer.h> resetTimer(void)38static inline void resetTimer(void) 39 { 40 SYSTEM_WRITE_WORD(CNT_TVAL, TIMER_RELOAD); 41 SYSTEM_WRITE_WORD(CNT_CTL, BIT(0)); 42 } 43 #endif /* !CONFIG_KERNEL_MCS */ 44 45 BOOT_CODE void initGenericTimer(void); 46 47 #ifdef CONFIG_ARM_HYPERVISOR_SUPPORT 48 static uint64_t read_cntpct(void) UNUSED; 49 static void save_virt_timer(vcpu_t *vcpu); 50 static void restore_virt_timer(vcpu_t *vcpu); 51 #endif /* CONFIG_ARM_HYPERVISOR_SUPPORT */ 52 53