applies clang format
This commit is contained in:
parent
63d0162119
commit
31c6bb55f4
@ -35,9 +35,10 @@
|
||||
#ifndef _RISCV_HART_COMMON
|
||||
#define _RISCV_HART_COMMON
|
||||
|
||||
#include "iss/arch/traits.h"
|
||||
#include "iss/log_categories.h"
|
||||
#include "iss/vm_types.h"
|
||||
#include <iss/arch/traits.h>
|
||||
#include <iss/log_categories.h>
|
||||
#include <iss/mem/memory_if.h>
|
||||
#include <iss/vm_types.h>
|
||||
#include "mstatus.h"
|
||||
#include "util/delegate.h"
|
||||
#include <array>
|
||||
@ -53,7 +54,6 @@
|
||||
#include <unordered_map>
|
||||
#include <util/logging.h>
|
||||
#include <util/sparse_array.h>
|
||||
#include "../mem/memory_if.h"
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define likely(x) ::__builtin_expect(!!(x), 1)
|
||||
@ -688,10 +688,10 @@ template <typename BASE, typename LOGCAT = logging::disass> struct riscv_hart_co
|
||||
return priv_if<reg_t>{.read_csr = [this](unsigned addr, reg_t& val) -> iss::status { return read_csr(addr, val); },
|
||||
.write_csr = [this](unsigned addr, reg_t val) -> iss::status { return write_csr(addr, val); },
|
||||
.exec_htif = [this](uint8_t const* data) -> iss::status { return execute_htif(data); },
|
||||
.raise_trap = [this](uint16_t trap_id, uint16_t cause, reg_t fault_data){
|
||||
.raise_trap =
|
||||
[this](uint16_t trap_id, uint16_t cause, reg_t fault_data) {
|
||||
this->reg.trap_state = 0x80ULL << 24 | (cause << 16) | trap_id;
|
||||
this->fault_data = fault_data;
|
||||
|
||||
},
|
||||
.csr_rd_cb{this->csr_rd_cb},
|
||||
.csr_wr_cb{csr_wr_cb},
|
||||
|
@ -45,10 +45,10 @@
|
||||
#ifndef FMT_HEADER_ONLY
|
||||
#define FMT_HEADER_ONLY
|
||||
#endif
|
||||
#include <iss/mem/memory_with_htif.h>
|
||||
#include <array>
|
||||
#include <elfio/elfio.hpp>
|
||||
#include <fmt/format.h>
|
||||
#include "../mem/memory_with_htif.h"
|
||||
#include <unordered_map>
|
||||
|
||||
namespace iss {
|
||||
@ -157,12 +157,7 @@ protected:
|
||||
template <typename BASE, features_e FEAT, typename LOGCAT>
|
||||
riscv_hart_m_p<BASE, FEAT, LOGCAT>::riscv_hart_m_p()
|
||||
: default_mem(base::get_priv_if()) {
|
||||
const std::array<unsigned, 4> rwaddrs{{
|
||||
mepc,
|
||||
mtvec,
|
||||
mscratch,
|
||||
mtval
|
||||
}};
|
||||
const std::array<unsigned, 4> rwaddrs{{mepc, mtvec, mscratch, mtval}};
|
||||
for(auto addr : rwaddrs) {
|
||||
this->csr_rd_cb[addr] = MK_CSR_RD_CB(read_plain);
|
||||
this->csr_wr_cb[addr] = MK_CSR_WR_CB(write_plain);
|
||||
|
@ -40,24 +40,25 @@
|
||||
#include "riscv_hart_common.h"
|
||||
#include "util/logging.h"
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <elfio/elf_types.hpp>
|
||||
#include <elfio/elfio.hpp>
|
||||
#include <limits>
|
||||
#ifndef FMT_HEADER_ONLY
|
||||
#define FMT_HEADER_ONLY
|
||||
#endif
|
||||
#include <iss/mem/memory_with_htif.h>
|
||||
#include <iss/mem/mmu.h>
|
||||
#include <fmt/format.h>
|
||||
#include <type_traits>
|
||||
#include <unordered_map>
|
||||
#include "../mem/mmu.h"
|
||||
#include "../mem/memory_with_htif.h"
|
||||
|
||||
namespace iss {
|
||||
namespace arch {
|
||||
|
||||
template <typename BASE, features_e FEAT = FEAT_NONE, typename LOGCAT = logging::disass> class riscv_hart_msu_vp : public riscv_hart_common<BASE> {
|
||||
template <typename BASE, features_e FEAT = FEAT_NONE, typename LOGCAT = logging::disass>
|
||||
class riscv_hart_msu_vp : public riscv_hart_common<BASE> {
|
||||
public:
|
||||
using core = BASE;
|
||||
using base = riscv_hart_common<BASE>;
|
||||
@ -171,25 +172,8 @@ riscv_hart_msu_vp<BASE, FEAT, LOGCAT>::riscv_hart_msu_vp()
|
||||
, mmu(base::get_priv_if())
|
||||
, default_mem(base::get_priv_if()) {
|
||||
// common regs
|
||||
const std::array<unsigned, 17> rwaddrs{{
|
||||
mepc,
|
||||
mtvec,
|
||||
mscratch,
|
||||
mtval,
|
||||
mscratch,
|
||||
sepc,
|
||||
stvec,
|
||||
sscratch,
|
||||
scause,
|
||||
stval,
|
||||
sscratch,
|
||||
uepc,
|
||||
utvec,
|
||||
uscratch,
|
||||
ucause,
|
||||
utval,
|
||||
uscratch
|
||||
}};
|
||||
const std::array<unsigned, 17> rwaddrs{{mepc, mtvec, mscratch, mtval, mscratch, sepc, stvec, sscratch, scause, stval, sscratch, uepc,
|
||||
utvec, uscratch, ucause, utval, uscratch}};
|
||||
for(auto addr : rwaddrs) {
|
||||
this->csr_rd_cb[addr] = MK_CSR_RD_CB(read_plain);
|
||||
this->csr_wr_cb[addr] = MK_CSR_WR_CB(write_plain);
|
||||
@ -328,8 +312,8 @@ iss::status riscv_hart_msu_vp<BASE, FEAT, LOGCAT>::read(const address_type type,
|
||||
}
|
||||
|
||||
template <typename BASE, features_e FEAT, typename LOGCAT>
|
||||
iss::status riscv_hart_msu_vp<BASE, FEAT, LOGCAT>::write(const address_type type, const access_type access, const uint32_t space, const uint64_t addr,
|
||||
const unsigned length, const uint8_t* const data) {
|
||||
iss::status riscv_hart_msu_vp<BASE, FEAT, LOGCAT>::write(const address_type type, const access_type access, const uint32_t space,
|
||||
const uint64_t addr, const unsigned length, const uint8_t* const data) {
|
||||
#ifndef NDEBUG
|
||||
const char* prefix = (access && iss::access_type::DEBUG) ? "debug " : "";
|
||||
switch(length) {
|
||||
@ -417,25 +401,29 @@ iss::status riscv_hart_msu_vp<BASE, FEAT, LOGCAT>::write(const address_type type
|
||||
}
|
||||
}
|
||||
|
||||
template <typename BASE, features_e FEAT, typename LOGCAT> iss::status riscv_hart_msu_vp<BASE, FEAT, LOGCAT>::read_status(unsigned addr, reg_t& val) {
|
||||
template <typename BASE, features_e FEAT, typename LOGCAT>
|
||||
iss::status riscv_hart_msu_vp<BASE, FEAT, LOGCAT>::read_status(unsigned addr, reg_t& val) {
|
||||
auto req_priv_lvl = (addr >> 8) & 0x3;
|
||||
val = state.mstatus & get_mstatus_mask(req_priv_lvl);
|
||||
return iss::Ok;
|
||||
}
|
||||
|
||||
template <typename BASE, features_e FEAT, typename LOGCAT> iss::status riscv_hart_msu_vp<BASE, FEAT, LOGCAT>::write_status(unsigned addr, reg_t val) {
|
||||
template <typename BASE, features_e FEAT, typename LOGCAT>
|
||||
iss::status riscv_hart_msu_vp<BASE, FEAT, LOGCAT>::write_status(unsigned addr, reg_t val) {
|
||||
auto req_priv_lvl = (addr >> 8) & 0x3;
|
||||
write_mstatus(val, req_priv_lvl);
|
||||
check_interrupt();
|
||||
return iss::Ok;
|
||||
}
|
||||
|
||||
template <typename BASE, features_e FEAT, typename LOGCAT> iss::status riscv_hart_msu_vp<BASE, FEAT, LOGCAT>::write_cause(unsigned addr, reg_t val) {
|
||||
template <typename BASE, features_e FEAT, typename LOGCAT>
|
||||
iss::status riscv_hart_msu_vp<BASE, FEAT, LOGCAT>::write_cause(unsigned addr, reg_t val) {
|
||||
this->csr[addr] = val & ((1UL << (traits<BASE>::XLEN - 1)) | 0xf); // TODO: make exception code size configurable
|
||||
return iss::Ok;
|
||||
}
|
||||
|
||||
template <typename BASE, features_e FEAT, typename LOGCAT> iss::status riscv_hart_msu_vp<BASE, FEAT, LOGCAT>::read_ie(unsigned addr, reg_t& val) {
|
||||
template <typename BASE, features_e FEAT, typename LOGCAT>
|
||||
iss::status riscv_hart_msu_vp<BASE, FEAT, LOGCAT>::read_ie(unsigned addr, reg_t& val) {
|
||||
val = this->csr[mie];
|
||||
if(addr < mie)
|
||||
val &= this->csr[mideleg];
|
||||
@ -444,7 +432,8 @@ template <typename BASE, features_e FEAT, typename LOGCAT> iss::status riscv_har
|
||||
return iss::Ok;
|
||||
}
|
||||
|
||||
template <typename BASE, features_e FEAT, typename LOGCAT> iss::status riscv_hart_msu_vp<BASE, FEAT, LOGCAT>::write_ie(unsigned addr, reg_t val) {
|
||||
template <typename BASE, features_e FEAT, typename LOGCAT>
|
||||
iss::status riscv_hart_msu_vp<BASE, FEAT, LOGCAT>::write_ie(unsigned addr, reg_t val) {
|
||||
auto req_priv_lvl = (addr >> 8) & 0x3;
|
||||
auto mask = get_irq_mask(req_priv_lvl);
|
||||
this->csr[mie] = (this->csr[mie] & ~mask) | (val & mask);
|
||||
@ -452,7 +441,8 @@ template <typename BASE, features_e FEAT, typename LOGCAT> iss::status riscv_har
|
||||
return iss::Ok;
|
||||
}
|
||||
|
||||
template <typename BASE, features_e FEAT, typename LOGCAT> iss::status riscv_hart_msu_vp<BASE, FEAT, LOGCAT>::read_ip(unsigned addr, reg_t& val) {
|
||||
template <typename BASE, features_e FEAT, typename LOGCAT>
|
||||
iss::status riscv_hart_msu_vp<BASE, FEAT, LOGCAT>::read_ip(unsigned addr, reg_t& val) {
|
||||
val = this->csr[mip];
|
||||
if(addr < mip)
|
||||
val &= this->csr[mideleg];
|
||||
@ -494,8 +484,8 @@ template <typename BASE, features_e FEAT, typename LOGCAT> void riscv_hart_msu_v
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <typename BASE, features_e FEAT, typename LOGCAT> uint64_t riscv_hart_msu_vp<BASE, FEAT, LOGCAT>::enter_trap(uint64_t flags, uint64_t addr, uint64_t instr) {
|
||||
template <typename BASE, features_e FEAT, typename LOGCAT>
|
||||
uint64_t riscv_hart_msu_vp<BASE, FEAT, LOGCAT>::enter_trap(uint64_t flags, uint64_t addr, uint64_t instr) {
|
||||
// flags are ACTIVE[31:31], CAUSE[30:16], TRAPID[15:0]
|
||||
// calculate and write mcause val
|
||||
if(flags == std::numeric_limits<uint64_t>::max())
|
||||
|
@ -40,15 +40,15 @@
|
||||
#include "riscv_hart_common.h"
|
||||
#include "util/logging.h"
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <elfio/elf_types.hpp>
|
||||
#include <elfio/elfio.hpp>
|
||||
#ifndef FMT_HEADER_ONLY
|
||||
#define FMT_HEADER_ONLY
|
||||
#endif
|
||||
#include <iss/mem/memory_with_htif.h>
|
||||
#include <fmt/format.h>
|
||||
#include "../mem/memory_with_htif.h"
|
||||
#include <unordered_map>
|
||||
|
||||
namespace iss {
|
||||
|
@ -62,8 +62,7 @@ using tgc5d_plat_type = iss::arch::riscv_hart_mu_p<iss::arch::tgc5d, (iss::arch:
|
||||
#ifdef CORE_TGC5D_XRB_MAC
|
||||
#include "riscv_hart_mu_p.h"
|
||||
#include <iss/arch/tgc5d_xrb_mac.h>
|
||||
using tgc5d_xrb_mac_plat_type =
|
||||
iss::arch::riscv_hart_mu_p<iss::arch::tgc5d_xrb_mac (iss::arch::features_e)(iss::arch::FEAT_EXT_N)>;
|
||||
using tgc5d_xrb_mac_plat_type = iss::arch::riscv_hart_mu_p<iss::arch::tgc5d_xrb_mac(iss::arch::features_e)(iss::arch::FEAT_EXT_N)>;
|
||||
#endif
|
||||
#ifdef CORE_TGC5D_XRB_NN
|
||||
#include "hwl.h"
|
||||
|
@ -32,10 +32,10 @@
|
||||
* eyck@minres.com - initial implementation
|
||||
******************************************************************************/
|
||||
|
||||
#include "memory_if.h"
|
||||
#include "iss/arch/riscv_hart_common.h"
|
||||
#include "iss/vm_types.h"
|
||||
#include <util/logging.h>
|
||||
#include "../mem/memory_if.h"
|
||||
|
||||
namespace iss {
|
||||
namespace mem {
|
||||
|
@ -57,7 +57,8 @@ void memory_hierarchy::insert_before(memory_elem&) {}
|
||||
void memory_hierarchy::insert_after(memory_elem&) {}
|
||||
void memory_hierarchy::replace_last(memory_elem& e) {
|
||||
auto old = hierarchy.back();
|
||||
auto it = std::find_if(std::begin(owned_elems), std::end(owned_elems), [old](std::unique_ptr<memory_elem> const& p) {return p.get()==old;});
|
||||
auto it = std::find_if(std::begin(owned_elems), std::end(owned_elems),
|
||||
[old](std::unique_ptr<memory_elem> const& p) { return p.get() == old; });
|
||||
hierarchy.pop_back();
|
||||
if(it != std::end(owned_elems))
|
||||
owned_elems.erase(it);
|
||||
|
@ -37,11 +37,11 @@
|
||||
|
||||
#include "iss/vm_types.h"
|
||||
#include <deque>
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
#include <limits>
|
||||
#include <util/delegate.h>
|
||||
#include <memory>
|
||||
#include <util/delegate.h>
|
||||
#include <vector>
|
||||
|
||||
namespace iss {
|
||||
namespace mem {
|
||||
|
@ -35,11 +35,11 @@
|
||||
#ifndef _MEMORY_WITH_HTIF_
|
||||
#define _MEMORY_WITH_HTIF_
|
||||
|
||||
#include "memory_if.h"
|
||||
#include "iss/arch/riscv_hart_common.h"
|
||||
#include "iss/vm_types.h"
|
||||
#include <util/logging.h>
|
||||
#include <util/sparse_array.h>
|
||||
#include "../mem/memory_if.h"
|
||||
|
||||
namespace iss {
|
||||
namespace mem {
|
||||
|
@ -32,10 +32,10 @@
|
||||
* eyck@minres.com - initial implementation
|
||||
******************************************************************************/
|
||||
|
||||
#include "memory_if.h"
|
||||
#include "iss/arch/riscv_hart_common.h"
|
||||
#include "iss/vm_types.h"
|
||||
#include <util/logging.h>
|
||||
#include "../mem/memory_if.h"
|
||||
|
||||
namespace iss {
|
||||
namespace mem {
|
||||
@ -54,7 +54,6 @@ enum {
|
||||
PTE_SOFT = 0x300 // Reserved for Software
|
||||
};
|
||||
|
||||
|
||||
template <typename T> inline bool PTE_TABLE(T PTE) { return (((PTE) & (PTE_V | PTE_R | PTE_W | PTE_X)) == PTE_V); }
|
||||
|
||||
struct vm_info {
|
||||
@ -115,8 +114,6 @@ template <typename WORD_TYPE> struct mmu : public memory_elem {
|
||||
constexpr static reg_t PGSIZE = 1 << PGSHIFT;
|
||||
constexpr static reg_t PGMASK = PGSIZE - 1;
|
||||
|
||||
|
||||
|
||||
mmu(arch::priv_if<WORD_TYPE> hart_if)
|
||||
: hart_if(hart_if) {
|
||||
hart_if.csr_rd_cb[satp] = MK_CSR_RD_CB(read_satp);
|
||||
@ -290,8 +287,7 @@ template <typename WORD_TYPE> uint64_t mmu<WORD_TYPE>::virt2phys(iss::access_ty
|
||||
|
||||
// check that physical address of PTE is legal
|
||||
reg_t pte = 0;
|
||||
const uint8_t res = down_stream_mem.rd_mem(iss::access_type::READ, base + idx * vm.ptesize, vm.ptesize,
|
||||
(uint8_t*)&pte);
|
||||
const uint8_t res = down_stream_mem.rd_mem(iss::access_type::READ, base + idx * vm.ptesize, vm.ptesize, (uint8_t*)&pte);
|
||||
if(res != 0)
|
||||
throw arch::trap_load_access_fault(addr);
|
||||
const reg_t ppn = pte >> PTE_PPN_SHIFT;
|
||||
@ -353,6 +349,5 @@ template <typename WORD_TYPE> inline void mmu<WORD_TYPE>::update_vm_info() {
|
||||
ptw.clear();
|
||||
}
|
||||
|
||||
|
||||
} // namespace mem
|
||||
} // namespace iss
|
||||
|
@ -32,10 +32,10 @@
|
||||
* eyck@minres.com - initial implementation
|
||||
******************************************************************************/
|
||||
|
||||
#include "memory_if.h"
|
||||
#include "iss/arch/riscv_hart_common.h"
|
||||
#include "iss/vm_types.h"
|
||||
#include <util/logging.h>
|
||||
#include "../mem/memory_if.h"
|
||||
|
||||
namespace iss {
|
||||
namespace mem {
|
||||
|
@ -38,10 +38,10 @@
|
||||
#include "sc_core_adapter_if.h"
|
||||
#include <iostream>
|
||||
#include <iss/iss.h>
|
||||
#include <iss/mem/memory_if.h>
|
||||
#include <iss/vm_types.h>
|
||||
#include <scc/report.h>
|
||||
#include <util/ities.h>
|
||||
#include <iss/mem/memory_if.h>
|
||||
|
||||
namespace sysc {
|
||||
template <typename PLAT> class sc_core_adapter : public PLAT, public sc_core_adapter_if {
|
||||
@ -94,8 +94,7 @@ public:
|
||||
};
|
||||
|
||||
iss::mem::memory_if get_mem_if() override {
|
||||
return iss::mem::memory_if{
|
||||
.rd_mem{util::delegate<iss::mem::rd_mem_func_sig>::from<this_class, &this_class::read_mem>(this)},
|
||||
return iss::mem::memory_if{.rd_mem{util::delegate<iss::mem::rd_mem_func_sig>::from<this_class, &this_class::read_mem>(this)},
|
||||
.wr_mem{util::delegate<iss::mem::wr_mem_func_sig>::from<this_class, &this_class::write_mem>(this)}};
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user