Andrew Walbran | 508e63c | 2018-12-20 17:02:37 +0000 | [diff] [blame] | 1 | /* |
Andrew Walbran | 692b325 | 2019-03-07 15:51:31 +0000 | [diff] [blame] | 2 | * Copyright 2018 The Hafnium Authors. |
Andrew Walbran | 508e63c | 2018-12-20 17:02:37 +0000 | [diff] [blame] | 3 | * |
Andrew Walbran | e959ec1 | 2020-06-17 15:01:09 +0100 | [diff] [blame] | 4 | * Use of this source code is governed by a BSD-style |
| 5 | * license that can be found in the LICENSE file or at |
| 6 | * https://opensource.org/licenses/BSD-3-Clause. |
Andrew Walbran | 508e63c | 2018-12-20 17:02:37 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #pragma once |
| 10 | |
Andrew Walbran | 508e63c | 2018-12-20 17:02:37 +0000 | [diff] [blame] | 11 | #include <stdint.h> |
| 12 | |
| 13 | #include "hf/arch/types.h" |
| 14 | |
| 15 | /** |
Madhukar Pappireddy | d3ac738 | 2024-09-25 14:29:03 -0500 | [diff] [blame] | 16 | * Checks whether the arch timer is enabled and its interrupt not masked. |
Andrew Walbran | 508e63c | 2018-12-20 17:02:37 +0000 | [diff] [blame] | 17 | */ |
| 18 | bool arch_timer_enabled(struct arch_regs *regs); |
| 19 | |
| 20 | /** |
Madhukar Pappireddy | d3ac738 | 2024-09-25 14:29:03 -0500 | [diff] [blame] | 21 | * Returns the number of nanoseconds remaining on the arch timer as stored in |
Andrew Walbran | 508e63c | 2018-12-20 17:02:37 +0000 | [diff] [blame] | 22 | * the given `arch_regs`, or 0 if it has already expired. This is undefined if |
| 23 | * the timer is not enabled. |
| 24 | */ |
| 25 | uint64_t arch_timer_remaining_ns(struct arch_regs *regs); |
| 26 | |
| 27 | /** |
| 28 | * Returns whether the timer is ready to fire: i.e. it is enabled, not masked, |
| 29 | * and the condition is met. |
| 30 | */ |
Madhukar Pappireddy | d3ac738 | 2024-09-25 14:29:03 -0500 | [diff] [blame] | 31 | bool arch_timer_expired(struct arch_regs *regs); |