mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-12 06:53:40 +00:00
fix(rp2): reset spinlocks at startup
This commit is contained in:
@@ -14,6 +14,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const numCPU = 2
|
const numCPU = 2
|
||||||
|
const numSpinlocks = 32
|
||||||
|
|
||||||
// machineTicks is provided by package machine.
|
// machineTicks is provided by package machine.
|
||||||
func machineTicks() uint64
|
func machineTicks() uint64
|
||||||
@@ -297,6 +298,13 @@ var (
|
|||||||
futexLock = spinLock{id: 23}
|
futexLock = spinLock{id: 23}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func resetSpinLocks() {
|
||||||
|
for i := uint8(0); i < numSpinlocks; i++ {
|
||||||
|
l := &spinLock{id: i}
|
||||||
|
l.spinlock().Set(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// A hardware spinlock, one of the 32 spinlocks defined in the SIO peripheral.
|
// A hardware spinlock, one of the 32 spinlocks defined in the SIO peripheral.
|
||||||
type spinLock struct {
|
type spinLock struct {
|
||||||
id uint8
|
id uint8
|
||||||
@@ -357,9 +365,16 @@ func init() {
|
|||||||
machine.InitSerial()
|
machine.InitSerial()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func prerun() {
|
||||||
|
// Reset spinlocks before the full machineInit() so the scheduler doesn't
|
||||||
|
// hang waiting for schedulerLock after a soft reset.
|
||||||
|
resetSpinLocks()
|
||||||
|
}
|
||||||
|
|
||||||
//export Reset_Handler
|
//export Reset_Handler
|
||||||
func main() {
|
func main() {
|
||||||
preinit()
|
preinit()
|
||||||
|
prerun()
|
||||||
run()
|
run()
|
||||||
exit(0)
|
exit(0)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user