aboutsummaryrefslogtreecommitdiff
path: root/machine/mentry.S
diff options
context:
space:
mode:
Diffstat (limited to 'machine/mentry.S')
-rw-r--r--machine/mentry.S11
1 files changed, 11 insertions, 0 deletions
diff --git a/machine/mentry.S b/machine/mentry.S
index e71745c..4cf9685 100644
--- a/machine/mentry.S
+++ b/machine/mentry.S
@@ -255,6 +255,17 @@ do_reset:
li x31, 0
csrw mscratch, x0
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+ # fixup endianness before making any loads or stores
+#if __riscv_xlen == 32
+ li t0, MSTATUSH_MBE
+ csrs CSR_MSTATUSH, t0
+#else
+ li t0, MSTATUS_MBE
+ csrs CSR_MSTATUS, t0
+#endif
+#endif
+
# write mtvec and make sure it sticks
la t0, trap_vector
csrw mtvec, t0