riscv: use MSTATUS.MIE bit instead of MIE to disable interrupts

This should behave the same but is compatible with the ESP32-C3 which
lacks the MIE CSR (but does have the MSTATUS CSR).
Этот коммит содержится в:
Ayke van Laethem 2021-09-28 00:04:25 +02:00 коммит произвёл Ron Evans
родитель a6246e60f3
коммит b31d241388

Просмотреть файл

@ -25,13 +25,14 @@ func AsmFull(asm string, regs map[string]interface{}) uintptr
func DisableInterrupts() uintptr { func DisableInterrupts() uintptr {
// Note: this can be optimized with a CSRRW instruction, which atomically // Note: this can be optimized with a CSRRW instruction, which atomically
// swaps the value and returns the old value. // swaps the value and returns the old value.
mask := MIE.Get() mask := MSTATUS.Get()
MIE.Set(0) MSTATUS.ClearBits(1 << 3) // clear the MIE bit
return mask return mask
} }
// EnableInterrupts enables all interrupts again. The value passed in must be // EnableInterrupts enables all interrupts again. The value passed in must be
// the mask returned by DisableInterrupts. // the mask returned by DisableInterrupts.
func EnableInterrupts(mask uintptr) { func EnableInterrupts(mask uintptr) {
MIE.Set(mask) mask &= 1 << 3 // clear all bits except for the MIE bit
MSTATUS.SetBits(mask) // set the MIE bit, if it was previously cleared
} }