CHERIoT RTOS
A compartmentalised RTOS for CHERIoT hardware
Loading...
Searching...
No Matches
platform-rdcycle.h
1// Copyright Microsoft and CHERIoT Contributors.
2// SPDX-License-Identifier: MIT
3
4#pragma once
5
6#include <cdefs.h>
7
8/// Read the least significant word of the cycle counter.
9__always_inline static int rdcycle()
10{
11 int cycles;
12 // CHERIoT-Ibex does not yet implement the "cycle" CSR, so read mcycle.
13 __asm__ volatile("csrr %0, mcycle" : "=r"(cycles));
14 return cycles;
15}