File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import (
1414)
1515
1616const numCPU = 2
17+ const numSpinlocks = 32
1718
1819// machineTicks is provided by package machine.
1920func machineTicks () uint64
@@ -297,6 +298,13 @@ var (
297298 futexLock = spinLock {id : 23 }
298299)
299300
301+ func resetSpinLocks () {
302+ for i := uint8 (0 ); i < numSpinlocks ; i ++ {
303+ l := & spinLock {id : i }
304+ l .spinlock ().Set (0 )
305+ }
306+ }
307+
300308// A hardware spinlock, one of the 32 spinlocks defined in the SIO peripheral.
301309type spinLock struct {
302310 id uint8
@@ -357,9 +365,16 @@ func init() {
357365 machine .InitSerial ()
358366}
359367
368+ func prerun () {
369+ // Reset spinlocks before the full machineInit() so the scheduler doesn't
370+ // hang waiting for schedulerLock after a soft reset.
371+ resetSpinLocks ()
372+ }
373+
360374//export Reset_Handler
361375func main () {
362376 preinit ()
377+ prerun ()
363378 run ()
364379 exit (0 )
365380}
You can’t perform that action at this time.
0 commit comments