aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/runtime/runtime_mimxrt1062.go
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2021-08-14 01:41:01 +0200
committerRon Evans <[email protected]>2021-10-06 09:04:06 +0200
commit98f84a497da93b9cf9d09e74edfbfb0a1bdebaf9 (patch)
tree793f17deb5b1cf48b84f37b1c7ea0b6c16bb23c7 /src/runtime/runtime_mimxrt1062.go
parent00c73d62ad1361ab5a814ab8844f13217027112a (diff)
downloadtinygo-98f84a497da93b9cf9d09e74edfbfb0a1bdebaf9.tar.gz
tinygo-98f84a497da93b9cf9d09e74edfbfb0a1bdebaf9.zip
qemu: signal correct exit code to QEMU
There were a few issues that were causing qemu-system-arm and qemu-system-riscv to give the wrong exit codes. They are in fact capable of exiting with 0 or 1 signalled from the running application, but this functionality wasn't used. This commit changes this in the following ways: * It fixes SemiHosting codes, which were incorrectly written in decimal while they should have been written in hexadecimal (oops!). * It modifies all the baremetal main functions (aka reset handlers) to exit with `exit(0)` instead of `abort()`. * It changes `syscall.Exit` to call `exit(code)` instead of `abort()` on baremetal targets. * It adds these new exit functions where necessary, implemented in a way that signals the correct exit status if running under QEMU. All in all, this means that `tinygo test` doesn't have to look at the output of a test to determine the outcome. It can simply look at the exit code.
Diffstat (limited to 'src/runtime/runtime_mimxrt1062.go')
-rw-r--r--src/runtime/runtime_mimxrt1062.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/runtime/runtime_mimxrt1062.go b/src/runtime/runtime_mimxrt1062.go
index a9cc063df..6c1212cba 100644
--- a/src/runtime/runtime_mimxrt1062.go
+++ b/src/runtime/runtime_mimxrt1062.go
@@ -43,7 +43,7 @@ func main() {
arm.EnableInterrupts(irq)
run()
- abort()
+ exit(0)
}
func getRamSizeConfig(itcmKB, dtcmKB uint32) uint32 {
@@ -127,6 +127,10 @@ func putchar(c byte) {
machine.UART1.WriteByte(c)
}
+func exit(code int) {
+ abort()
+}
+
func abort() {
for {
arm.Asm("wfe")