Snitch Runtime
Loading...
Searching...
No Matches
riscv.h
1// Copyright 2023 ETH Zurich and University of Bologna.
2// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3// SPDX-License-Identifier: Apache-2.0
4
5#include "riscv_decls.h"
6
7#pragma once
8
9#include "../../deps/riscv-opcodes/encoding.h"
10
15inline void snrt_wfi() { asm volatile("wfi"); }
16
17inline void snrt_nop() { asm volatile("nop" : : :); }
18
19inline uint32_t snrt_mcycle() {
20 uint32_t register r;
21 asm volatile("csrr %0, mcycle" : "=r"(r) : : "memory");
22 return r;
23}
24
33inline void snrt_interrupt_enable(uint32_t irq) { set_csr(mie, 1 << irq); }
34
41inline void snrt_interrupt_disable(uint32_t irq) { clear_csr(mie, 1 << irq); }
42
49inline void snrt_interrupt_global_enable(void) {
50 set_csr(mstatus, MSTATUS_MIE); // set M global interrupt enable
51}
56inline void snrt_interrupt_global_disable(void) {
57 clear_csr(mstatus, MSTATUS_MIE);
58}