adds WT cache functionality as mixin
This commit is contained in:
@ -449,6 +449,16 @@ protected:
|
||||
feature_config cfg;
|
||||
unsigned mcause_max_irq{(FEAT&features_e::FEAT_CLIC)?4096:16};
|
||||
inline bool debug_mode_active() {return this->reg.PRIV&0x4;}
|
||||
|
||||
std::pair<std::function<mem_read_f>, std::function<mem_write_f>>
|
||||
replace_mem_access(std::function<mem_read_f> rd, std::function<mem_write_f> wr){
|
||||
std::pair<std::function<mem_read_f>, std::function<mem_write_f>> ret{hart_mem_rd_delegate, hart_mem_wr_delegate};
|
||||
hart_mem_rd_delegate = rd;
|
||||
hart_mem_wr_delegate = wr;
|
||||
return ret;
|
||||
}
|
||||
std::function<mem_read_f> hart_mem_rd_delegate;
|
||||
std::function<mem_write_f> hart_mem_wr_delegate;
|
||||
};
|
||||
|
||||
template <typename BASE, features_e FEAT>
|
||||
@ -612,6 +622,12 @@ riscv_hart_mu_p<BASE, FEAT>::riscv_hart_mu_p(feature_config cfg)
|
||||
csr_wr_cb[dcsr] = &this_class::write_dcsr_dcsr;
|
||||
csr_rd_cb[dcsr] = &this_class::read_dcsr_reg;
|
||||
}
|
||||
hart_mem_rd_delegate = [this](phys_addr_t a, unsigned l, uint8_t* const d) -> iss::status {
|
||||
return this->read_mem(a, l, d);
|
||||
};
|
||||
hart_mem_wr_delegate = [this](phys_addr_t a, unsigned l, uint8_t const* const d) -> iss::status {
|
||||
return this->write_mem(a, l, d);
|
||||
};
|
||||
}
|
||||
|
||||
template <typename BASE, features_e FEAT> std::pair<uint64_t, bool> riscv_hart_mu_p<BASE, FEAT>::load_file(std::string name, int type) {
|
||||
@ -829,9 +845,9 @@ iss::status riscv_hart_mu_p<BASE, FEAT>::read(const address_type type, const acc
|
||||
auto idx = std::distance(std::begin(memfn_range), it);
|
||||
res = memfn_read[idx](phys_addr, length, data);
|
||||
} else
|
||||
res = read_mem( phys_addr, length, data);
|
||||
res = hart_mem_rd_delegate( phys_addr, length, data);
|
||||
} else {
|
||||
res = read_mem( phys_addr, length, data);
|
||||
res = hart_mem_rd_delegate( phys_addr, length, data);
|
||||
}
|
||||
if (unlikely(res != iss::Ok)){
|
||||
this->trap_state = (1UL << 31) | (5 << 16); // issue trap 5 (load access fault
|
||||
@ -930,9 +946,9 @@ iss::status riscv_hart_mu_p<BASE, FEAT>::write(const address_type type, const ac
|
||||
auto idx = std::distance(std::begin(memfn_range), it);
|
||||
res = memfn_write[idx]( phys_addr, length, data);
|
||||
} else
|
||||
res = write_mem( phys_addr, length, data);
|
||||
res = hart_mem_wr_delegate( phys_addr, length, data);
|
||||
} else {
|
||||
res = write_mem( phys_addr, length, data);
|
||||
res = hart_mem_wr_delegate( phys_addr, length, data);
|
||||
}
|
||||
if (unlikely(res != iss::Ok)) {
|
||||
this->trap_state = (1UL << 31) | (7 << 16); // issue trap 7 (Store/AMO access fault)
|
||||
|
Reference in New Issue
Block a user