fix(rp2): reset spinlocks at startup

This commit is contained in:
Michael Smith
2025-09-17 10:14:17 -04:00
committed by Ron Evans
parent b9387febe0
commit 310df7acb5
+15
View File
@@ -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)
} }