1/**
2 * \file
3 * \brief System time
4 */
5
6/*
7 * Copyright (c) 2016, ETH Zurich.
8 * All rights reserved.
9 *
10 * This file is distributed under the terms in the attached LICENSE file.
11 * If you do not find this file, copies can be found by writing to:
12 * ETH Zurich D-INFK, CAB F.78, Universitaetstrasse 6, CH-8092 Zurich,
13 * Attn: Systems Group.
14 */
15
16#ifndef BARRELFISH_SYSTIME_H
17#define BARRELFISH_SYSTIME_H
18
19#include <barrelfish_kpi/types.h> /* systime_t */
20#include <barrelfish_kpi/generic_arch.h>
21
22__BEGIN_DECLS
23
24/// Frequency of the system time ticks (systime)
25extern systime_t systime_frequency;
26
27/**
28 * Get the current system time from a hardware clock
29 */
30static inline systime_t systime_now(void)
31{
32    return rdtsc();
33}
34
35/**
36 * Convert nanoseconds to a system time ticks
37 */
38systime_t ns_to_systime(uint64_t nanoseconds);
39
40/**
41 * Convert microseconds to a system time ticks
42 */
43systime_t us_to_systime(uint64_t microseconds);
44
45/**
46 * Convert a system time ticks to nanoseconds
47 */
48uint64_t systime_to_ns(systime_t time);
49
50/**
51 * Convert a system time ticks to microseconds
52 */
53uint64_t systime_to_us(systime_t time);
54
55__END_DECLS
56
57#endif // BARRELFISH_SYSTIME_H
58