1/*
2 * Copyright 2014, General Dynamics C4 Systems
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 */
6
7#pragma once
8
9#include <config.h>
10#ifdef CONFIG_ENABLE_BENCHMARKS
11
12static inline uint64_t timestamp(void)
13{
14    uint32_t low, high;
15
16    asm volatile(
17        "movl $0, %%eax \n"
18        "movl $0, %%ecx \n"
19        "cpuid          \n"
20        "rdtsc          \n"
21        "movl %%edx, %0 \n"
22        "movl %%eax, %1 \n"
23        "movl $0, %%eax \n"
24        "movl $0, %%ecx \n"
25        "cpuid          \n"
26        : "=r"(high), "=r"(low)
27        : /* no inputs */
28        : "eax", "ebx", "ecx", "edx"
29    );
30
31    return ((uint64_t) high) << 32llu | (uint64_t) low;
32}
33
34static inline void benchmark_arch_utilisation_reset(void)
35{
36}
37
38#endif /* CONFIG_ENABLE_BENCHMARKS */
39
40