Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 2 additions & 17 deletions src/runtime/runtime_rp2.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"internal/task"
"machine"
_ "machine/usb/cdc"
"runtime/interrupt"
"runtime/volatile"
"unsafe"
)
Expand Down Expand Up @@ -140,14 +139,7 @@ func startSecondaryCores() {
// Enable the FIFO interrupt for the GC stop the world phase.
// We can only do this after we don't need the FIFO anymore for starting the
// second core.
intr := interrupt.New(sioIrqFifoProc0, func(intr interrupt.Interrupt) {
switch rp.SIO.FIFO_RD.Get() {
case 1:
gcInterruptHandler(0)
}
})
intr.Enable()
intr.SetPriority(0xff)
enableSIOFifoInterruptCore0()
}

var core1StartSequence = [...]uint32{
Expand All @@ -174,14 +166,7 @@ func runCore1() {
// the GC.
// Use the lowest possible priority (highest priority value), so that other
// interrupts can still happen while the GC is running.
intr := interrupt.New(sioIrqFifoProc1, func(intr interrupt.Interrupt) {
switch rp.SIO.FIFO_RD.Get() {
case 1:
gcInterruptHandler(1)
}
})
intr.Enable()
intr.SetPriority(0xff)
enableSIOFifoInterruptCore1()

// Now start running the scheduler on this core.
schedulerLock.Lock()
Expand Down
23 changes: 23 additions & 0 deletions src/runtime/runtime_rp2040.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,32 @@ package runtime

import (
"device/rp"
"runtime/interrupt"
)

const (
sioIrqFifoProc0 = rp.IRQ_SIO_IRQ_PROC0
sioIrqFifoProc1 = rp.IRQ_SIO_IRQ_PROC1
)

func enableSIOFifoInterruptCore0() {
intr := interrupt.New(sioIrqFifoProc0, func(intr interrupt.Interrupt) {
switch rp.SIO.FIFO_RD.Get() {
case 1:
gcInterruptHandler(0)
}
})
intr.Enable()
intr.SetPriority(0xff)
}

func enableSIOFifoInterruptCore1() {
intr := interrupt.New(sioIrqFifoProc1, func(intr interrupt.Interrupt) {
switch rp.SIO.FIFO_RD.Get() {
case 1:
gcInterruptHandler(1)
}
})
intr.Enable()
intr.SetPriority(0xff)
}
20 changes: 20 additions & 0 deletions src/runtime/runtime_rp2350.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package runtime

import (
"device/rp"
"runtime/interrupt"
)

const (
Expand All @@ -14,3 +15,22 @@ const (
sioIrqFifoProc0 = rp.IRQ_SIO_IRQ_FIFO
sioIrqFifoProc1 = rp.IRQ_SIO_IRQ_FIFO
)

var sioFifoInterrupt = interrupt.New(sioIrqFifoProc0, handleSIOFifoInterrupt)

func enableSIOFifoInterruptCore0() {
sioFifoInterrupt.Enable()
sioFifoInterrupt.SetPriority(0xff)
}

func enableSIOFifoInterruptCore1() {
sioFifoInterrupt.Enable()
sioFifoInterrupt.SetPriority(0xff)
}

func handleSIOFifoInterrupt(intr interrupt.Interrupt) {
switch rp.SIO.FIFO_RD.Get() {
case 1:
gcInterruptHandler(currentCPU())
}
}
Loading