Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Kconfig): use RV_AIA instead of RV_IMSIC #513

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion configs/riscv64-dual-xs-ref_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ CONFIG_RVH=y
CONFIG_RV_SDTRIG=y
CONFIG_TRIGGER_NUM=4
CONFIG_RV_AIA=y
CONFIG_RV_IMSIC=y
CONFIG_RV_SSTC=y
CONFIG_RV_SMRNMI=y
# CONFIG_RV_SMDBLTRP is not set
Expand Down
1 change: 0 additions & 1 deletion configs/riscv64-xs-ref_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ CONFIG_RVH=y
CONFIG_RV_SDTRIG=y
CONFIG_TRIGGER_NUM=4
CONFIG_RV_AIA=y
CONFIG_RV_IMSIC=y
CONFIG_RV_SSTC=y
CONFIG_RV_SMRNMI=y
# CONFIG_RV_SMDBLTRP is not set
Expand Down
4 changes: 2 additions & 2 deletions src/cpu/difftest/ref.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,9 @@ void difftest_raise_nmi_intr(bool hasNMI) {
}

void difftest_virtual_interrupt_is_hvictl_inject(bool virtualInterruptIsHvictlInject) {
#ifdef CONFIG_RV_IMSIC
#ifdef CONFIG_RV_AIA
cpu.virtualInterruptIsHvictlInject = virtualInterruptIsHvictlInject;
#endif
#endif // CONFIG_RV_AIA
}

void difftest_enable_debug() {
Expand Down
5 changes: 0 additions & 5 deletions src/isa/riscv64/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,6 @@ config RV_AIA
depends on RVH
default n

config RV_IMSIC
bool "Incoming MSI Controller"
depends on RV_AIA
default n

config RV_SSTC
bool "RISC-V Sstc Extension for Supervisor-mode Timer Interrupts"
default n
Expand Down
4 changes: 2 additions & 2 deletions src/isa/riscv64/include/isa-def.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ typedef struct {
#ifdef CONFIG_RV_SMRNMI
bool hasNMI;
#endif
#ifdef CONFIG_RV_IMSIC
#ifdef CONFIG_RV_AIA
bool virtualInterruptIsHvictlInject;
#endif
#endif // CONFIG_RV_AIA

} riscv64_CPU_state;

Expand Down
4 changes: 2 additions & 2 deletions src/isa/riscv64/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void init_isa() {
#ifdef CONFIG_RVB
misa->extensions |= ext('b');
#endif // CONFIG_RVB
#ifdef CONFIG_RV_IMSIC
#ifdef CONFIG_RV_AIA
miselect->val = 0;
siselect->val = 0;
vsiselect->val = 0;
Expand All @@ -133,7 +133,7 @@ void init_isa() {
mtopei->val = 0;
stopei->val = 0;
vstopei->val = 0;
#endif // CONFIG_RV_IMSIC
#endif // CONFIG_RV_AIA

misa->mxl = 2; // XLEN = 64

Expand Down
28 changes: 14 additions & 14 deletions src/isa/riscv64/local-include/csr.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,13 @@


/** Supervisor Advanced Interrupt Architecture Registers **/
#ifdef CONFIG_RV_IMSIC
#ifdef CONFIG_RV_AIA
#define CSRS_S_AIA(f) \
f(siselect , 0x150) f(sireg , 0x151) \
f(stopei , 0x15C) f(stopi , 0xDB0)
#else
#define CSRS_S_AIA(f)
#endif // CONFIG_RV_IMSIC
#endif // CONFIG_RV_AIA

/** ALL **/
#define CSRS_S(f) \
Expand Down Expand Up @@ -247,15 +247,15 @@
f(vstval , 0x243) f(vsip , 0x244) f(vsatp , 0x280)

/** Hypervisor and VS AIA Registers **/
#ifdef CONFIG_RV_IMSIC
#ifdef CONFIG_RV_AIA
#define CSRS_H_VS_AIA(f) \
f(vsiselect , 0x250) f(vsireg , 0x251) \
f(vstopei , 0x25C) f(hvien , 0x608) \
f(hvictl , 0x609) f(hviprio1 , 0x646) \
f(hviprio2 , 0x647) f(vstopi , 0xEB0)
#else
#define CSRS_H_VS_AIA(f)
#endif // CONFIG_RV_IMSIC
#endif // CONFIG_RV_AIA

#ifdef CONFIG_RV_SSTC
#define CSRS_VS_SSTC(f) \
Expand Down Expand Up @@ -418,14 +418,14 @@
#endif // CONFIG_RV_SDEXT

/** Machine AIA Registers **/
#ifdef CONFIG_RV_IMSIC
#ifdef CONFIG_RV_AIA
#define CSRS_M_AIA(f) \
f(mvien , 0x308) f(mvip , 0x309) \
f(miselect , 0x350) f(mireg , 0x351) \
f(mtopei , 0x35C) f(mtopi , 0xFB0)
#else
#define CSRS_M_AIA(f)
#endif // CONFIG_RV_IMSIC
#endif // CONFIG_RV_AIA

/** Machine Non-Maskable Interrupt Handling **/
#ifdef CONFIG_RV_SMRNMI
Expand Down Expand Up @@ -806,7 +806,7 @@ CSR_STRUCT_END(mcontext)

#endif // CONFIG_RV_SDTRIG

#ifdef CONFIG_RV_IMSIC
#ifdef CONFIG_RV_AIA
CSR_STRUCT_START(miselect)
CSR_STRUCT_END(miselect)

Expand Down Expand Up @@ -844,7 +844,7 @@ CSR_STRUCT_START(mvip)
uint64_t pad2 : 3; // [8:6]
uint64_t seip : 1; // [9]
CSR_STRUCT_END(mvip)
#endif // CONFIG_RV_IMSIC
#endif // CONFIG_RV_AIA

/* Supervisor-level CSR */

Expand Down Expand Up @@ -968,7 +968,7 @@ CSR_STRUCT_END(stimecmp)
#endif

/** Supervisor Advanced Interrupt Architecture CSRs **/
#ifdef CONFIG_RV_IMSIC
#ifdef CONFIG_RV_AIA
CSR_STRUCT_START(siselect)
CSR_STRUCT_END(siselect)

Expand All @@ -986,7 +986,7 @@ CSR_STRUCT_START(stopi)
uint64_t pad : 8; // [15: 8]
uint64_t iid : 12; // [27:16]
CSR_STRUCT_END(stopi)
#endif // CONFIG_RV_IMSIC
#endif // CONFIG_RV_AIA

/* hypervisor and Virtual Supervisor CSR */

Expand Down Expand Up @@ -1178,7 +1178,7 @@ CSR_STRUCT_END(vsatp)
#endif // CONFIG_RVH

/** Hypervisor and VS AIA CSRs **/
#ifdef CONFIG_RV_IMSIC
#ifdef CONFIG_RV_AIA
CSR_STRUCT_START(hvien)
uint64_t pad : 13;
#ifdef CONFIG_RV_SSCOFPMF
Expand Down Expand Up @@ -1219,7 +1219,7 @@ CSR_STRUCT_START(vstopi)
uint64_t pad : 8; // [15: 8]
uint64_t iid : 12; // [27:16]
CSR_STRUCT_END(vstopi)
#endif // CONFIG_RV_IMSIC
#endif // CONFIG_RV_AIA

/* Unprivileged CSR */

Expand Down Expand Up @@ -1451,13 +1451,13 @@ MAP(CSRS, CSRS_DECL)
#define SSTATUS_RMASK (SSTATUS_BASE | SSTATUS_SDT)

/** AIA **/
#ifdef CONFIG_RV_IMSIC
#ifdef CONFIG_RV_AIA
#define ISELECT_2F_MASK 0x2F
#define ISELECT_3F_MASK 0x3F
#define ISELECT_6F_MASK 0x6F
#define ISELECT_MAX_MASK 0xFF
#define VSISELECT_MAX_MASK 0x1FF
#endif // CONFIG_RV_IMSIC
#endif // CONFIG_RV_AIA

/** Double Trap**/
#ifdef CONFIG_RV_SMRNMI
Expand Down
8 changes: 4 additions & 4 deletions src/isa/riscv64/reg.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ void isa_reg_display() {
mideleg->val, medeleg->val);
printf("mtval: " FMT_WORD " stval: " FMT_WORD " mtvec: " FMT_WORD " stvec: " FMT_WORD "\n",
mtval->val, stval->val, mtvec->val, stvec->val);
#ifdef CONFIG_RV_IMSIC
#ifdef CONFIG_RV_AIA
printf("miselect: " FMT_WORD " siselect: " FMT_WORD " mireg: " FMT_WORD " sireg: " FMT_WORD "\n",
miselect->val, siselect->val, mireg->val, sireg->val);
printf("mtopi: " FMT_WORD " stopi: " FMT_WORD " mvien: " FMT_WORD " mvip: " FMT_WORD "\n",
mtopi->val, stopi->val, mvien->val, mvip->val);
printf("mtopei: " FMT_WORD " stopei: " FMT_WORD "\n",
mtopei->val, stopei->val);
#endif // CONFIG_RV_IMSIC
#endif // CONFIG_RV_AIA
#ifndef CONFIG_FPU_NONE
printf("fcsr: " FMT_WORD "\n", cpu.fcsr);
#endif // CONFIG_FPU_NONE
Expand All @@ -83,13 +83,13 @@ void isa_reg_display() {
hgatp->val, vsscratch->val, cpu.vsstatus, vstvec->val);
printf("vsepc: " FMT_WORD " vscause: " FMT_WORD " vstval: " FMT_WORD " vsatp: " FMT_WORD "\n",
vsepc->val, vscause->val, vstval->val, vsatp->val);
#ifdef CONFIG_RV_IMSIC
#ifdef CONFIG_RV_AIA
printf("hvien: " FMT_WORD " hvictl: " FMT_WORD " hviprio1: " FMT_WORD " hviprio2: " FMT_WORD "\n",
hvien->val, hvictl->val, hviprio1->val, hviprio2->val);
printf("vsiselect: " FMT_WORD " vsireg: " FMT_WORD " vstopi: " FMT_WORD "\n",
vsiselect->val, vsireg->val, vstopi->val);
printf("vstopei: " FMT_WORD "\n", vstopei->val);
#endif // CONFIG_RV_IMSIC
#endif // CONFIG_RV_AIA
printf("virtualization mode: %ld\n", cpu.v);
#endif
printf("privilege mode:%ld\n", cpu.mode);
Expand Down
4 changes: 2 additions & 2 deletions src/isa/riscv64/system/intr.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ word_t raise_intr(word_t NO, vaddr_t epc) {
bool s_EX_DT = MUXDEF(CONFIG_RV_SSDBLTRP, delegS && mstatus->sdt, false);
bool m_EX_DT = MUXDEF(CONFIG_RV_SMDBLTRP, delegM && mstatus->mdt, false);
#ifdef CONFIG_RVH
bool virtualInterruptIsHvictlInject = MUXDEF(CONFIG_RV_IMSIC, cpu.virtualInterruptIsHvictlInject, false);
bool virtualInterruptIsHvictlInject = MUXDEF(CONFIG_RV_AIA, cpu.virtualInterruptIsHvictlInject, false);
extern bool hld_st;
int hld_st_temp = hld_st;
hld_st = 0;
Expand All @@ -116,7 +116,7 @@ word_t raise_intr(word_t NO, vaddr_t epc) {
if ((delegVS && !vs_EX_DT) || (virtualInterruptIsHvictlInject && !isNMI)){
if (virtualInterruptIsHvictlInject) {
vscause->val = NO | INTR_BIT;
#ifdef CONFIG_RV_IMSIC
#ifdef CONFIG_RV_AIA
cpu.virtualInterruptIsHvictlInject = 0;
#endif
} else {
Expand Down
10 changes: 5 additions & 5 deletions src/isa/riscv64/system/priv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1020,11 +1020,11 @@ static inline void csr_write(word_t *dest, word_t src) {
}
#endif // CONFIG_RV_SSDBLTRP
}
#ifdef CONFIG_RV_IMSIC
#ifdef CONFIG_RV_AIA
else if (is_write(mtopi)) { return; }
else if (is_write(stopi)) { return; }
else if (is_write(vstopi)) { return; }
#endif // CONFIG_RV_IMSIC
#endif // CONFIG_RV_AIA
#else
if (is_write(mstatus)) {
#ifndef CONFIG_RVH
Expand Down Expand Up @@ -1384,7 +1384,7 @@ static inline bool smstateen_extension_permit_check(const word_t *dest_access) {

// AIA extension check
// !!! Only support in RVH
#ifdef CONFIG_RV_IMSIC
#ifdef CONFIG_RV_AIA
static bool aia_extension_permit_check(const word_t *dest_access) {
bool has_vi = false;
if (is_access(stopei)) {
Expand Down Expand Up @@ -1450,7 +1450,7 @@ static bool aia_extension_permit_check(const word_t *dest_access) {
}
return has_vi;
}
#endif // CONFIG_RV_IMSIC
#endif // CONFIG_RV_AIA

// Fp Vec CSR check
/**
Expand Down Expand Up @@ -1499,7 +1499,7 @@ static inline void csr_permit_check(uint32_t addr, bool is_write) {
MUXDEF(CONFIG_RV_SMSTATEEN, has_vi |= smstateen_extension_permit_check(dest_access), );

// check aia
MUXDEF(CONFIG_RV_IMSIC, has_vi |= aia_extension_permit_check(dest_access), );
MUXDEF(CONFIG_RV_AIA, has_vi |= aia_extension_permit_check(dest_access), );

//check satp(satp & hgatp)
has_vi |= satp_permit_check(dest_access);
Expand Down