Refactor EnableInterrupts and DisableInterrupts

Removes usage of AsmFull which required an optimization pass to remove the map parameter passed into it. This caused issues when compiling with -opt=0 where memory for the map was being allocated as an unintended side-effect of using AsmFull with no optimizations enabled.
Этот коммит содержится в:
Justin A. Wilson 2023-03-04 10:19:27 -06:00 коммит произвёл Ron Evans
родитель d87e3ce330
коммит 313c9e31dd
2 изменённых файлов: 29 добавлений и 11 удалений

Просмотреть файл

@ -29,6 +29,7 @@
// POSSIBILITY OF SUCH DAMAGE. // POSSIBILITY OF SUCH DAMAGE.
package arm package arm
import "C"
import ( import (
"errors" "errors"
"runtime/volatile" "runtime/volatile"
@ -174,20 +175,15 @@ func SetPriority(irq uint32, priority uint32) {
// DisableInterrupts disables all interrupts, and returns the old interrupt // DisableInterrupts disables all interrupts, and returns the old interrupt
// state. // state.
func DisableInterrupts() uintptr { //
return AsmFull(` //export DisableInterrupts
mrs {}, PRIMASK func DisableInterrupts() uintptr
cpsid i
`, 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.
func EnableInterrupts(mask uintptr) { //
AsmFull("msr PRIMASK, {mask}", map[string]interface{}{ //export EnableInterrupts
"mask": mask, func EnableInterrupts(mask uintptr)
})
}
// Set up the system timer to generate periodic tick events. // Set up the system timer to generate periodic tick events.
// This will cause SysTick_Handler to fire once per tick. // This will cause SysTick_Handler to fire once per tick.

22
src/device/arm/interrupts.c Обычный файл
Просмотреть файл

@ -0,0 +1,22 @@
#include <stdint.h>
void EnableInterrupts(uintptr_t mask) {
asm volatile(
"msr PRIMASK, %0"
:
: "r"(mask)
: "memory"
);
}
uintptr_t DisableInterrupts() {
uintptr_t mask;
asm volatile(
"mrs %0, PRIMASK\n\t"
"cpsid i"
: "=r"(mask)
:
: "memory"
);
return mask;
}