File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-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,14 @@ var (
297298 futexLock = spinLock {id : 23 }
298299)
299300
301+ func resetSpinLocks () {
302+ l := & spinLock {id : 0 }
303+ for i := uint8 (0 ); i < numSpinlocks ; i ++ {
304+ l .id = i
305+ l .spinlock ().Set (0 )
306+ }
307+ }
308+
300309// A hardware spinlock, one of the 32 spinlocks defined in the SIO peripheral.
301310type spinLock struct {
302311 id uint8
@@ -357,9 +366,16 @@ func init() {
357366 machine .InitSerial ()
358367}
359368
369+ func prerun () {
370+ // Reset spinlocks before the full machineInit() so the scheduler doesn't
371+ // hang waiting for schedulerLock after a soft reset.
372+ resetSpinLocks ()
373+ }
374+
360375//export Reset_Handler
361376func main () {
362377 preinit ()
378+ prerun ()
363379 run ()
364380 exit (0 )
365381}
You can’t perform that action at this time.
0 commit comments