Skip to content

Commit

Permalink
rv64: fixed is_access micro in csrrw (#384)
Browse files Browse the repository at this point in the history
  • Loading branch information
wissygh committed Jul 9, 2024
1 parent 24be240 commit ca25408
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/isa/riscv64/system/priv.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ static inline word_t* csr_decode(uint32_t addr) {

#define is_read(csr) (src == (void *)(csr))
#define is_write(csr) (dest == (void *)(csr))
#define is_access(csr) (src != NULL)?(is_read(csr)):(is_write(csr))
#define is_access(csr) (dest_access == (void *)(csr))
#define mask_bitset(old, mask, new) (((old) & ~(mask)) | ((new) & (mask)))

#define is_pmpcfg(p) (p >= &(csr_array[CSR_PMPCFG_BASE]) && p < &(csr_array[CSR_PMPCFG_BASE + CSR_PMPCFG_MAX_NUM]))
Expand Down Expand Up @@ -872,7 +872,7 @@ word_t csrid_read(uint32_t csrid) {
// If smstateen check after csr_is_legal, the exception type will be wrong.
// todo: should finish all csr read/write exception checking before read/write.
#ifdef CONFIG_RV_SMSTATEEN
static inline void smstateen_extension_permit_check(word_t *dest, const word_t *src, uint32_t csrid) {
static inline void smstateen_extension_permit_check(word_t *dest_access) {
if (is_access(sstateen0)) {
if ((cpu.mode < MODE_M) && (!mstateen0->se0)) { longjmp_exception(EX_II); }
#ifdef CONFIG_RVH
Expand All @@ -891,7 +891,7 @@ static inline void smstateen_extension_permit_check(word_t *dest, const word_t *
// AIA extension check
// !!! Only support in RVH
#ifdef CONFIG_RV_IMSIC
static void aia_extension_permit_check(word_t *dest, const word_t *src, uint32_t csrid) {
static void aia_extension_permit_check(word_t *dest_access) {
if (is_access(stopei)) {
if (!cpu.v && (cpu.mode == MODE_S) && mvien->seie) {
longjmp_exception(EX_II);
Expand Down Expand Up @@ -957,18 +957,18 @@ static void aia_extension_permit_check(word_t *dest, const word_t *src, uint32_t
#endif // CONFIG_RV_IMSIC

static void csrrw(rtlreg_t *dest, const rtlreg_t *src, uint32_t csrid) {
word_t *csr = csr_decode(csrid);
#ifdef CONFIG_RV_SMSTATEEN
smstateen_extension_permit_check(dest, src, csrid);
smstateen_extension_permit_check(csr);
#endif // CONFIG_RV_SMSTATEEN
#ifdef CONFIG_RV_IMSIC
aia_extension_permit_check(dest, src, csrid);
aia_extension_permit_check(csr);
#endif // CONFIG_RV_IMSIC
if (!csr_is_legal(csrid, src != NULL)) {
Logti("Illegal csr id %u", csrid);
longjmp_exception(EX_II);
return;
}
word_t *csr = csr_decode(csrid);
// Log("Decoding csr id %u to %p", csrid, csr);
word_t tmp = (src != NULL ? *src : 0);
if (dest != NULL) { *dest = csr_read(csr); }
Expand Down

0 comments on commit ca25408

Please sign in to comment.