1/**
2 * \file
3 * \brief Bench library initialization.
4 */
5
6/*
7 * Copyright (c) 2007, 2008, 2009, 2010, 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, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
13 */
14
15#include <barrelfish/barrelfish.h>
16#include <bench/bench.h>
17#include <bench/bench_arch.h>
18#include <barrelfish/sys_debug.h>
19
20
21uint64_t tsc_hz;
22static uint64_t tscperms;
23static uint64_t tscperus;
24
25void bench_arch_init(void)
26{
27    errval_t err = sys_debug_hardware_timer_hertz_read((uintptr_t *)&tsc_hz);
28    assert(err_is_ok(err));
29    tscperms = tsc_hz / 1000;
30    tscperus = tscperms / 1000;
31}
32
33uint64_t bench_tsc_to_ms(cycles_t tsc)
34{
35    return tsc / tscperms;
36}
37uint64_t bench_tsc_to_us(cycles_t tsc)
38{
39    return tsc / tscperus;
40}
41uint64_t bench_tsc_per_us(void)
42{
43    return tscperus;
44}
45uint64_t bench_tsc_per_ms(void)
46{
47    return tscperms;
48}
49
50