github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/src/runtime/interrupt/interrupt_xtensa.go (about) 1 //go:build xtensa 2 3 package interrupt 4 5 import "device" 6 7 // State represents the previous global interrupt state. 8 type State uintptr 9 10 // Disable disables all interrupts and returns the previous interrupt state. It 11 // can be used in a critical section like this: 12 // 13 // state := interrupt.Disable() 14 // // critical section 15 // interrupt.Restore(state) 16 // 17 // Critical sections can be nested. Make sure to call Restore in the same order 18 // as you called Disable (this happens naturally with the pattern above). 19 func Disable() (state State) { 20 return State(device.AsmFull("rsil {}, 15", nil)) 21 } 22 23 // Restore restores interrupts to what they were before. Give the previous state 24 // returned by Disable as a parameter. If interrupts were disabled before 25 // calling Disable, this will not re-enable interrupts, allowing for nested 26 // cricital sections. 27 func Restore(state State) { 28 device.AsmFull("wsr {state}, PS", map[string]interface{}{ 29 "state": state, 30 }) 31 } 32 33 // In returns whether the system is currently in an interrupt. 34 // 35 // Warning: interrupts have not been implemented for Xtensa yet so this always 36 // returns false. 37 func In() bool { 38 return false 39 }