summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorNick Kossifidis <mickflemm@gmail.com>2019-02-17 05:02:15 +0300
committerAnup Patel <anup@brainfault.org>2019-02-18 06:51:58 +0300
commit51e543511a7425da1a5378e149de0b45928c7111 (patch)
tree009d721dac74267a56069473cce5212224aaf004 /platform
parentb44878b773698f08b4c08b9e43e26917950a7618 (diff)
downloadopensbi-51e543511a7425da1a5378e149de0b45928c7111.tar.xz
platform: qemu-virt: Implement system shutdown
In order for QEMU to be compatible with Spike, it implements a simple protocol used for reporting back the simulation's status, through the memory-mapped "test finisher" device. We use that protocol to make QEMU exit on system shutdown. Signed-off-by: Nick Kossifidis <mick@ics.forth.gr>
Diffstat (limited to 'platform')
-rw-r--r--platform/qemu/virt/platform.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/platform/qemu/virt/platform.c b/platform/qemu/virt/platform.c
index 9dfd4d6..ab40b93 100644
--- a/platform/qemu/virt/platform.c
+++ b/platform/qemu/virt/platform.c
@@ -5,9 +5,11 @@
*
* Authors:
* Anup Patel <anup.patel@wdc.com>
+ * Nick Kossifidis <mick@ics.forth.gr>
*/
#include <sbi/riscv_encoding.h>
+#include <sbi/riscv_io.h>
#include <sbi/sbi_const.h>
#include <sbi/sbi_hart.h>
#include <sbi/sbi_platform.h>
@@ -19,6 +21,8 @@
#define VIRT_HART_STACK_SIZE 8192
#define VIRT_TEST_ADDR 0x100000
+#define VIRT_TEST_FINISHER_FAIL 0x3333
+#define VIRT_TEST_FINISHER_PASS 0x5555
#define VIRT_CLINT_ADDR 0x2000000
@@ -122,7 +126,11 @@ static int virt_timer_init(bool cold_boot)
static int virt_system_down(u32 type)
{
- /* For now nothing to do. */
+ /* Tell the "finisher" that the simulation
+ * was successful so that QEMU exits
+ */
+ writew(VIRT_TEST_FINISHER_PASS, (void *)VIRT_TEST_ADDR);
+
return 0;
}