mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-21 21:09:02 +00:00
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.
This commit is contained in:
committed by
Ron Evans
parent
d87e3ce330
commit
313c9e31dd
+7
-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.
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user