riscv: support sleeping in QEMU

QEMU doesn't support the RTC peripheral yet so work around it for now.

This makes the following command work:

    tinygo run -target=hifive1-qemu ./testdata/coroutines.go
This commit is contained in:
Ayke van Laethem
2019-12-25 17:48:23 +01:00
committed by Ron Evans
parent 14474e7099
commit 184827e4d8
3 changed files with 37 additions and 23 deletions
+12
View File
@@ -10,7 +10,19 @@ import (
// Special memory-mapped device to exit tests, created by SiFive.
var testExit = (*volatile.Register32)(unsafe.Pointer(uintptr(0x100000)))
var timestamp timeUnit
func abort() {
// Signal a successful exit.
testExit.Set(0x5555)
}
func ticks() timeUnit {
return timestamp
}
func sleepTicks(d timeUnit) {
// Note: QEMU doesn't seem to support the RTC peripheral at the time of
// writing so just simulate sleeping here.
timestamp += d
}