arm: allow nesting in DisableInterrupts and EnableInterrupts
This finally fixes a TODO left in the code.
Этот коммит содержится в:
родитель
6389e45d99
коммит
23e88bfb15
1 изменённых файлов: 9 добавлений и 10 удалений
|
@ -191,22 +191,21 @@ func SetPriority(irq uint32, priority uint32) {
|
||||||
NVIC.IPR[regnum].Set((uint32(NVIC.IPR[regnum].Get()) &^ mask) | priority)
|
NVIC.IPR[regnum].Set((uint32(NVIC.IPR[regnum].Get()) &^ mask) | priority)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DisableInterrupts disables all interrupts, and returns the old state.
|
// DisableInterrupts disables all interrupts, and returns the old interrupt
|
||||||
//
|
// state.
|
||||||
// TODO: it doesn't actually return the old state, meaning that it cannot be
|
|
||||||
// nested.
|
|
||||||
func DisableInterrupts() uintptr {
|
func DisableInterrupts() uintptr {
|
||||||
Asm("cpsid if")
|
return AsmFull(`
|
||||||
return 0
|
mrs {}, PRIMASK
|
||||||
|
cpsid if
|
||||||
|
`, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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.
|
||||||
//
|
|
||||||
// TODO: it doesn't actually use the old state, meaning that it cannot be
|
|
||||||
// nested.
|
|
||||||
func EnableInterrupts(mask uintptr) {
|
func EnableInterrupts(mask uintptr) {
|
||||||
Asm("cpsie if")
|
AsmFull("msr PRIMASK, {mask}", map[string]interface{}{
|
||||||
|
"mask": mask,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// SystemReset performs a hard system reset.
|
// SystemReset performs a hard system reset.
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче