blob: 98e58b6d5cc91a14fa638ccd7e8b86b7bcc49fae [file] [log] [blame]
Andrew Walbran508e63c2018-12-20 17:02:37 +00001/*
Andrew Walbran692b3252019-03-07 15:51:31 +00002 * Copyright 2018 The Hafnium Authors.
Andrew Walbran508e63c2018-12-20 17:02:37 +00003 *
Andrew Walbrane959ec12020-06-17 15:01:09 +01004 * 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 Walbran508e63c2018-12-20 17:02:37 +00007 */
8
9#pragma once
10
Andrew Walbran508e63c2018-12-20 17:02:37 +000011#include <stdint.h>
12
13#include "hf/arch/types.h"
14
15/**
Madhukar Pappireddyd3ac7382024-09-25 14:29:03 -050016 * Checks whether the arch timer is enabled and its interrupt not masked.
Andrew Walbran508e63c2018-12-20 17:02:37 +000017 */
18bool arch_timer_enabled(struct arch_regs *regs);
19
20/**
Madhukar Pappireddyd3ac7382024-09-25 14:29:03 -050021 * Returns the number of nanoseconds remaining on the arch timer as stored in
Andrew Walbran508e63c2018-12-20 17:02:37 +000022 * the given `arch_regs`, or 0 if it has already expired. This is undefined if
23 * the timer is not enabled.
24 */
25uint64_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 Pappireddyd3ac7382024-09-25 14:29:03 -050031bool arch_timer_expired(struct arch_regs *regs);