runtime: check for heap allocations inside interrupts

This is unsafe and should never be done.
This commit is contained in:
Ayke van Laethem
2020-10-25 14:58:56 +01:00
committed by Ron Evans
parent e066e67baf
commit f41b6a3b96
9 changed files with 77 additions and 0 deletions
+10
View File
@@ -31,6 +31,12 @@ func main() {
kendryte.PLIC.PRIORITY[i].Set(0)
}
// Zero MCAUSE, which is set to the reset reason on reset. It must be zeroed
// to make interrupt.In() work.
// This would also be a good time to save the reset reason, but that hasn't
// been implemented yet.
riscv.MCAUSE.Set(0)
// Set the interrupt address.
// Note that this address must be aligned specially, otherwise the MODE bits
// of MTVEC won't be zero.
@@ -93,6 +99,10 @@ func handleInterrupt() {
// misaligned loads). However, for now we'll just print a fatal error.
handleException(code)
}
// Zero MCAUSE so that it can later be used to see whether we're in an
// interrupt or not.
riscv.MCAUSE.Set(0)
}
// initPeripherals configures periperhals the way the runtime expects them.