Karg v0.2.0
The kernel of CargOS
Loading...
Searching...
No Matches
csr.h
Go to the documentation of this file.
1#pragma once
2
3#include <types.h>
4
5#define csr_read(reg) \
6 ({ \
7 usize val; \
8 asm volatile("csrr %0, " #reg : "=r"(val)); \
9 val; \
10 })
11#define csr_write(reg, val) asm volatile("csrw " #reg ", %0" : : "r"(val))
12#define csr_set_bits(reg, bits) asm volatile("csrs " #reg ", %0" : : "r"(bits))
13#define csr_clear_bits(reg, bits) \
14 asm volatile("csrc " #reg ", %0" : : "r"(bits))
15
16#define CSR_SSTATUS_SPIE 0x20
17#define CSR_SSTATUS_SPP 0x100
18
19#define CSR_SIE_STIE 0x20
20#define CSR_SIE_SEIE 0x200
21
22#define CSR_SCAUSE_INTR 0x8000000000000000
23#define CSR_SCAUSE_TIMER_INTR 5
24#define CSR_SCAUSE_EXT_INTR 9
25#define CSR_SCAUSE_ECALL_U 8