Skip to content

Commit 714d983

Browse files
aykevldeadprogram
authored andcommitted
arm: provide intrinsics to disable/enable interrupts
1 parent 6e8df2f commit 714d983

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/device/arm/arm.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,21 @@ func SetPriority(irq uint32, priority uint32) {
118118
priority = priority << (regpos * 8) // bits to set
119119
NVIC.IPR[regnum] = RegValue((uint32(NVIC.IPR[regnum]) &^ mask) | priority)
120120
}
121+
122+
// DisableInterrupts disables all interrupts, and returns the old state.
123+
//
124+
// TODO: it doesn't actually return the old state, meaning that it cannot be
125+
// nested.
126+
func DisableInterrupts() uintptr {
127+
Asm("cpsid if")
128+
return 0
129+
}
130+
131+
// EnableInterrupts enables all interrupts again. The value passed in must be
132+
// the mask returned by DisableInterrupts.
133+
//
134+
// TODO: it doesn't actually use the old state, meaning that it cannot be
135+
// nested.
136+
func EnableInterrupts(mask uintptr) {
137+
Asm("cpsie if")
138+
}

0 commit comments

Comments
 (0)