Skip to content

Commit

Permalink
feat(diff): support Zicbom & Zicboz extension and set m/henvcfg init
Browse files Browse the repository at this point in the history
  • Loading branch information
sinceforYy committed Sep 25, 2024
1 parent 60fcb37 commit 53ee7af
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
3 changes: 2 additions & 1 deletion difftest/difftest-def.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@
"_zknd_zkne_zknh_zksed_zksh" \
"_zfa_zfhmin" \
"_svinval_sscofpmf" \
"_svpbmt"
"_svpbmt" \
"_zicbom_zicboz"

#define CONFIG_MEMORY_SIZE (16 * 1024 * 1024 * 1024UL)
#define CONFIG_FLASH_BASE 0x10000000UL
Expand Down
13 changes: 10 additions & 3 deletions riscv/csr_init.cc
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,9 @@ void state_t::csr_init(processor_t* const proc, reg_t max_isa)
(proc->extension_enabled(EXT_ZICFILP) ? MENVCFG_LPE : 0) |
(proc->extension_enabled(EXT_ZICFISS) ? MENVCFG_SSE : 0) |
(proc->extension_enabled(EXT_SSDBLTRP) ? MENVCFG_DTE : 0);
menvcfg = std::make_shared<envcfg_csr_t>(proc, CSR_MENVCFG, menvcfg_mask, 0);
const reg_t menvcfg_init = (proc->extension_enabled(EXT_ZICBOM) ? MENVCFG_CBCFE | MENVCFG_CBIE : 0) |
(proc->extension_enabled(EXT_ZICBOZ) ? MENVCFG_CBZE : 0);
menvcfg = std::make_shared<envcfg_csr_t>(proc, CSR_MENVCFG, menvcfg_mask, menvcfg_init);
if (xlen == 32) {
add_user_csr(CSR_MENVCFG, std::make_shared<rv32_low_csr_t>(proc, CSR_MENVCFG, menvcfg));
add_user_csr(CSR_MENVCFGH, std::make_shared<rv32_high_csr_t>(proc, CSR_MENVCFGH, menvcfg));
Expand All @@ -280,7 +282,10 @@ void state_t::csr_init(processor_t* const proc, reg_t max_isa)
(proc->extension_enabled(EXT_SSNPM) ? SENVCFG_PMM : 0) |
(proc->extension_enabled(EXT_ZICFILP) ? SENVCFG_LPE : 0) |
(proc->extension_enabled(EXT_ZICFISS) ? SENVCFG_SSE : 0);
add_supervisor_csr(CSR_SENVCFG, senvcfg = std::make_shared<senvcfg_csr_t>(proc, CSR_SENVCFG, senvcfg_mask, 0));
const reg_t senvcfg_init = (proc->extension_enabled(EXT_ZICBOM) ? SENVCFG_CBCFE | SENVCFG_CBIE : 0) |
(proc->extension_enabled(EXT_ZICBOZ) ? SENVCFG_CBZE : 0);
add_supervisor_csr(CSR_SENVCFG, senvcfg = std::make_shared<senvcfg_csr_t>(proc, CSR_SENVCFG, senvcfg_mask, senvcfg_init));

const reg_t henvcfg_mask = (proc->extension_enabled(EXT_ZICBOM) ? HENVCFG_CBCFE | HENVCFG_CBIE : 0) |
(proc->extension_enabled(EXT_ZICBOZ) ? HENVCFG_CBZE : 0) |
(proc->extension_enabled(EXT_SSNPM) ? HENVCFG_PMM : 0) |
Expand All @@ -290,7 +295,9 @@ void state_t::csr_init(processor_t* const proc, reg_t max_isa)
(proc->extension_enabled(EXT_ZICFILP) ? HENVCFG_LPE : 0) |
(proc->extension_enabled(EXT_ZICFISS) ? HENVCFG_SSE : 0) |
(proc->extension_enabled(EXT_SSDBLTRP) ? HENVCFG_DTE : 0);
henvcfg = std::make_shared<henvcfg_csr_t>(proc, CSR_HENVCFG, henvcfg_mask, 0, menvcfg);
const reg_t henvcfg_init = (proc->extension_enabled(EXT_ZICBOM) ? HENVCFG_CBCFE | HENVCFG_CBIE : 0) |
(proc->extension_enabled(EXT_ZICBOZ) ? HENVCFG_CBZE : 0);
henvcfg = std::make_shared<henvcfg_csr_t>(proc, CSR_HENVCFG, henvcfg_mask, henvcfg_init, menvcfg);
if (xlen == 32) {
add_hypervisor_csr(CSR_HENVCFG, std::make_shared<rv32_low_csr_t>(proc, CSR_HENVCFG, henvcfg));
add_hypervisor_csr(CSR_HENVCFGH, std::make_shared<rv32_high_csr_t>(proc, CSR_HENVCFGH, henvcfg));
Expand Down

0 comments on commit 53ee7af

Please sign in to comment.