Skip to content

Commit e74b87f

Browse files
authored
Merge pull request #28 from Minres/feature/better_mstatus
reworks mstatus handling,
2 parents 31cedb7 + 2ca7c80 commit e74b87f

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

.github/workflows/ci-compile.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ jobs:
3131

3232
- name: Update submodules
3333
run: git submodule update --init --recursive
34+
35+
- name: Cache Conan
36+
uses: actions/cache@v4
37+
with:
38+
path: ~/.conan2
39+
key: conan-${{ runner.os }}-unit-cpp${{ matrix.cpp_std }}-${{ hashFiles('conanfile.py') }}
3440

3541
- name: Install dependencies
3642
run: |

src/iss/arch/mstatus.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ template <typename T> struct status<T, typename std::enable_if<std::is_same<T, u
7373
static inline unsigned FS(T v) { return bit_sub<13, 2>(v); };
7474
// machine previous privilege
7575
static inline unsigned MPP(T v) { return bit_sub<11, 2>(v); };
76+
// vector unit status Off/Initial/Clean/Dirty
77+
static inline unsigned VS(T v) { return bit_sub<9, 2>(v); };
7678
// supervisor previous privilege
7779
static inline unsigned SPP(T v) { return bit_sub<8, 1>(v); };
7880
// previous machine interrupt-enable
@@ -121,6 +123,8 @@ template <typename T> struct status<T, typename std::enable_if<std::is_same<T, u
121123
static inline unsigned FS(T v) { return bit_sub<13, 2>(v); };
122124
// machine previous privilege
123125
static inline unsigned MPP(T v) { return bit_sub<11, 2>(v); };
126+
// vector unit status Off/Initial/Clean/Dirty
127+
static inline unsigned VS(T v) { return bit_sub<9, 2>(v); };
124128
// supervisor previous privilege
125129
static inline unsigned SPP(T v) { return bit_sub<8, 1>(v); };
126130
// previous machine interrupt-enable
@@ -165,6 +169,8 @@ template <typename T> class hart_state<T, typename std::enable_if<std::is_same<T
165169
BF_FIELD(FS, 13, 2);
166170
// machine previous privilege
167171
BF_FIELD(MPP, 11, 2);
172+
// vector unit status Off/Initial/Clean/Dirty
173+
BF_FIELD(VS, 9, 2);
168174
// supervisor previous privilege
169175
BF_FIELD(SPP, 8, 1);
170176
// previous machine interrupt-enable
@@ -220,6 +226,8 @@ template <typename T> class hart_state<T, typename std::enable_if<std::is_same<T
220226
BF_FIELD(FS, 13, 2);
221227
// machine previous privilege
222228
BF_FIELD(MPP, 11, 2);
229+
// vector unit status Off/Initial/Clean/Dirty
230+
BF_FIELD(VS, 9, 2);
223231
// supervisor previous privilege
224232
BF_FIELD(SPP, 8, 1);
225233
// previous machine interrupt-enable
@@ -238,7 +246,7 @@ template <typename T> class hart_state<T, typename std::enable_if<std::is_same<T
238246

239247
mstatus_t mstatus;
240248

241-
static const T mstatus_reset_val = 0x500001800;
249+
static const T mstatus_reset_val = 0x1800;
242250
};
243251
} // namespace arch
244252
} // namespace iss

src/iss/arch/riscv_hart_msu_vp.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ template <typename BASE, features_e FEAT>
127127
riscv_hart_msu_vp<BASE, FEAT>::riscv_hart_msu_vp()
128128
: mmu(base::get_priv_if())
129129
, default_mem(base::get_priv_if()) {
130+
if constexpr(sizeof(reg_t) == 8)
131+
// set UXL and SXL to indicate 64 bits
132+
// FIXME: this value is not preserved in resets
133+
this->state.mstatus.backing.val |= 0x500000000;
130134
// common regs
131135
const std::array<unsigned, 16> rwaddrs{
132136
{mepc, mtvec, mscratch, mcause, mtval, sepc, stvec, sscratch, scause, stval, sscratch, uepc, utvec, uscratch, ucause, utval}};

0 commit comments

Comments
 (0)