mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-09-09 22:19:29 +00:00
test: run ESP32 programs in QEMU
This commit is contained in:
@@ -78,12 +78,6 @@ var _ebss [0]byte
|
||||
//go:extern _vector_table
|
||||
var _vector_table [0]uintptr
|
||||
|
||||
func abort() {
|
||||
for {
|
||||
device.Asm("waiti 0")
|
||||
}
|
||||
}
|
||||
|
||||
// interruptInit installs the Xtensa vector table by writing its address
|
||||
// to the VECBASE special register and ensures all CPU interrupts are
|
||||
// initially disabled.
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
//go:build esp32 && !qemu
|
||||
|
||||
package runtime
|
||||
|
||||
import "device"
|
||||
|
||||
func abort() {
|
||||
for {
|
||||
device.Asm("waiti 0")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
//go:build esp32 && qemu
|
||||
|
||||
package runtime
|
||||
|
||||
import "device"
|
||||
|
||||
func exit(code int) {
|
||||
qemuExit(code)
|
||||
}
|
||||
|
||||
func abort() {
|
||||
qemuExit(1)
|
||||
}
|
||||
|
||||
func qemuExit(code int) {
|
||||
// QEMU semihosting expects a2 = SYS_exit (1) and a3 = the exit code.
|
||||
// AsmFull cannot declare these clobbers, so no Go code may run afterward.
|
||||
device.AsmFull(
|
||||
"mov a3, {code}\n"+
|
||||
"movi a2, 1\n"+
|
||||
"simcall",
|
||||
map[string]interface{}{"code": code},
|
||||
)
|
||||
// This loop ensures the clobbered registers are never used again.
|
||||
for {
|
||||
device.Asm("waiti 0")
|
||||
}
|
||||
}
|
||||
@@ -55,10 +55,6 @@ func ticksToNanoseconds(ticks timeUnit) int64 {
|
||||
return int64(ticks) * 25
|
||||
}
|
||||
|
||||
func exit(code int) {
|
||||
abort()
|
||||
}
|
||||
|
||||
func putchar(c byte) {
|
||||
machine.Serial.WriteByte(c)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
//go:build (esp32 && !qemu) || esp32c3 || esp32c6
|
||||
|
||||
package runtime
|
||||
|
||||
func exit(code int) {
|
||||
abort()
|
||||
}
|
||||
Reference in New Issue
Block a user