
This is only very minimal support. More support (such as tinygo flash, or peripheral access) should be added in later commits, to keep this one focused. Importantly, this commit changes the LLVM repo from llvm/llvm-project to tinygo-org/llvm-project. This provides a little bit of versioning in case something changes in the Espressif fork. If we want to upgrade to LLVM 11 it's easy to switch back to llvm/llvm-project until Espressif has updated their fork.
52 строки
1,4 КиБ
ArmAsm
52 строки
1,4 КиБ
ArmAsm
|
|
// The following definitions were copied from:
|
|
// esp-idf/components/xtensa/include/xtensa/corebits.h
|
|
#define PS_WOE_MASK 0x00040000
|
|
#define PS_OWB_MASK 0x00000F00
|
|
#define PS_CALLINC_MASK 0x00030000
|
|
#define PS_WOE PS_WOE_MASK
|
|
|
|
// Only calling it call_start_cpu0 for consistency with ESP-IDF.
|
|
.section .text.call_start_cpu0
|
|
1:
|
|
.long _stack_top
|
|
.global call_start_cpu0
|
|
call_start_cpu0:
|
|
// We need to set the stack pointer to a different value. This is somewhat
|
|
// complicated in the Xtensa architecture. The code below is a modified
|
|
// version of the following code:
|
|
// https://github.com/espressif/esp-idf/blob/c77c4ccf/components/xtensa/include/xt_instr_macros.h#L47
|
|
|
|
// Disable WOE.
|
|
rsr.ps a2
|
|
movi a3, ~(PS_WOE_MASK)
|
|
and a2, a2, a3
|
|
wsr.ps a2
|
|
rsync
|
|
|
|
// Set WINDOWBASE to 1 << WINDOWSTART.
|
|
rsr.windowbase a2
|
|
ssl a2
|
|
movi a2, 1
|
|
sll a2, a2
|
|
wsr.windowstart a2
|
|
rsync
|
|
|
|
// Load new stack pointer.
|
|
l32r sp, 1b
|
|
|
|
// Re-enable WOE.
|
|
rsr.ps a2
|
|
movi a3, PS_WOE
|
|
or a2, a2, a3
|
|
wsr.ps a2
|
|
rsync
|
|
|
|
// Jump to the runtime start function written in Go.
|
|
j main
|
|
|
|
.section .text.tinygo_scanCurrentStack
|
|
.global tinygo_scanCurrentStack
|
|
tinygo_scanCurrentStack:
|
|
// TODO: save callee saved registers on the stack
|
|
j tinygo_scanstack
|