aboutsummaryrefslogtreecommitdiff
path: root/machine/mentry.S
diff options
context:
space:
mode:
authorMarcus Comstedt <marcus@mc.pp.se>2021-06-16 22:49:50 +0200
committerGitHub <noreply@github.com>2021-06-16 13:49:50 -0700
commitae7348b246bc091f5af844a7bdaf1044cac90635 (patch)
tree7c729bfdf5e1b53c4be56188d815e08cd3a932f8 /machine/mentry.S
parente8e6b3aaee44d43b48164fbd377864c3a682dbd3 (diff)
downloadpk-ae7348b246bc091f5af844a7bdaf1044cac90635.zip
pk-ae7348b246bc091f5af844a7bdaf1044cac90635.tar.gz
pk-ae7348b246bc091f5af844a7bdaf1044cac90635.tar.bz2
Set desired endianness at boot time (#247)
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