Closed zeldin closed 3 years ago
Hm, so how do you find out whether or not the register exists? Is the only way trying to access it and handle the trap?
Is it ok to assume mstatush exists if pk is compiled as big endian? I'm guessing all those cores which lack mstatush are little-endian only... It's really only in that case where mstatush strictly needs to be written; if the core has configurable endianness it's supposed to go LE on reset, and if it's big endian only then writing mstatush will not do anything even if it exists... Or maybe the problem then would be SBE (if it exists), since only MBE is required to be cleared on reset IIRC.
Yes, @zeldin, I agree that’s a safe assumption, since the feature didn’t exist until the mstatush CSR also existed.
I updated the code to only write mstatush
when __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
. I also removed the clear of MBE
on RV64 little endian, for consistency.
This version looks good to me; thanks, @zeldin.
This is a regression. Most RV32 cores don’t have the mstatush register, and so this will break them.