Some work on CSR
This commit is contained in:
36
emulator/csr.h
Normal file
36
emulator/csr.h
Normal file
@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct Hart Hart;
|
||||
|
||||
#define CSR_CYCLE 0xC00
|
||||
#define CSR_CYCLEH 0xC80
|
||||
#define CSR_INSTRET 0xC02
|
||||
#define CSR_INSTRETH 0xC82
|
||||
#define CSR_TIME 0xC01
|
||||
#define CSR_TIMEH 0xC81
|
||||
|
||||
#define CSR_MVENDORID 0xF11
|
||||
#define CSR_MARCHID 0xF12
|
||||
#define CSR_MIMPID 0xF13
|
||||
#define CSR_MHARTID 0xF14
|
||||
|
||||
#define CSR_MISA 0x301
|
||||
|
||||
enum CsrAction
|
||||
{
|
||||
CSR_R = 0,
|
||||
CSR_W = 1,
|
||||
CSR_RW = 3,
|
||||
CSR_RC = 5,
|
||||
CSR_RS = 7,
|
||||
};
|
||||
|
||||
struct Csr
|
||||
{
|
||||
uint32_t (*action)(Hart* hart, uint32_t value_mask, enum CsrAction action);
|
||||
};
|
||||
typedef struct Csr Csr;
|
||||
|
||||
uint32_t csr_action(Hart* hart, uint16_t id, uint32_t value, enum CsrAction action);
|
Reference in New Issue
Block a user