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
@@ -50,3 +50,13 @@ func Disable() (state State) {
func Restore(state State) {
arm.EnableInterrupts(uintptr(state))
}
// In returns whether the system is currently in an interrupt.
func In() bool {
// The VECTACTIVE field gives the instruction vector that is currently
// active (in handler mode), or 0 if not in an interrupt.
// Documentation:
// https://developer.arm.com/documentation/dui0497/a/cortex-m0-peripherals/system-control-block/interrupt-control-and-state-register
vectactive := uint8(arm.SCB.ICSR.Get())
return vectactive != 0
}