mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-07 12:33:42 +00:00
all: add support for multicore scheduler
This commit adds support for a scheduler that runs a scheduler on all available cores. It is meant to be used on baremetal systems with a fixed number of cores, such as the RP2040. The initial implementation adds support for multicore scheduling to the riscv-qemu target as a convenient testing target. This means that this new multicore scheduler is tested in CI, including a bunch of standard library tests (`make tinygo-test-baremetal`). This should ensure the new scheduler is reasonably well tested before trying to use it on harder-to-debug targets like the RP2040.
This commit is contained in:
committed by
Ron Evans
parent
0c7c2926f9
commit
60f8a62978
@@ -3,8 +3,47 @@
|
||||
.type _start,@function
|
||||
|
||||
_start:
|
||||
// If we're on a multicore system, we need to wait for hart 0 to wake us up.
|
||||
#if TINYGO_CORES > 1
|
||||
csrr a0, mhartid
|
||||
|
||||
// Hart 0 stack
|
||||
bnez a0, 1f
|
||||
la sp, _stack_top
|
||||
|
||||
1:
|
||||
// Hart 1 stack
|
||||
li a1, 1
|
||||
bne a0, a1, 2f
|
||||
la sp, _stack1_top
|
||||
|
||||
2:
|
||||
// Hart 2 stack
|
||||
#if TINYGO_CORES >= 3
|
||||
li a1, 2
|
||||
bne a0, a1, 3f
|
||||
la sp, _stack2_top
|
||||
#endif
|
||||
|
||||
3:
|
||||
// Hart 3 stack
|
||||
#if TINYGO_CORES >= 4
|
||||
li a1, 3
|
||||
bne a0, a1, 4f
|
||||
la sp, _stack3_top
|
||||
#endif
|
||||
|
||||
4:
|
||||
// done
|
||||
|
||||
#if TINYGO_CORES > 4
|
||||
#error only up to 4 cores are supported at the moment!
|
||||
#endif
|
||||
|
||||
#else
|
||||
// Load the stack pointer.
|
||||
la sp, _stack_top
|
||||
#endif
|
||||
|
||||
// Load the globals pointer. The program will load pointers relative to this
|
||||
// register, so it must be set to the right value on startup.
|
||||
|
||||
Reference in New Issue
Block a user