test: run ESP32 programs in QEMU

This commit is contained in:
Jake Bailey
2026-08-10 11:22:49 -07:00
committed by Ron Evans
parent 1991b00395
commit 1958d6ff9d
10 changed files with 93 additions and 12 deletions
-6
View File
@@ -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.
+11
View File
@@ -0,0 +1,11 @@
//go:build esp32 && !qemu
package runtime
import "device"
func abort() {
for {
device.Asm("waiti 0")
}
}
+28
View File
@@ -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")
}
}
-4
View File
@@ -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)
}
+7
View File
@@ -0,0 +1,7 @@
//go:build (esp32 && !qemu) || esp32c3 || esp32c6
package runtime
func exit(code int) {
abort()
}