summaryrefslogtreecommitdiff
path: root/arch/riscv/lib/semihosting.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2022-12-19 09:29:55 -0500
committerTom Rini <trini@konsulko.com>2022-12-21 13:09:01 -0500
commit14f43797d0a696248c09d298e2f2809dded345ba (patch)
tree23fc5bc462689f07f389cc0b8e7f7bedd35253ff /arch/riscv/lib/semihosting.c
parent9c955393f7a27ded250fef7688e0065b44a3343f (diff)
parent2243922edca9f56a9d5519b9d6e36f5d7a18434d (diff)
Merge tag 'v2023.01-rc4' into next
Prepare v2023.01-rc4 Signed-off-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'arch/riscv/lib/semihosting.c')
-rw-r--r--arch/riscv/lib/semihosting.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/arch/riscv/lib/semihosting.c b/arch/riscv/lib/semihosting.c
new file mode 100644
index 00000000000..d6593b02a6f
--- /dev/null
+++ b/arch/riscv/lib/semihosting.c
@@ -0,0 +1,24 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2022 Ventana Micro Systems Inc.
+ */
+
+#include <common.h>
+
+long smh_trap(int sysnum, void *addr)
+{
+ register int ret asm ("a0") = sysnum;
+ register void *param0 asm ("a1") = addr;
+
+ asm volatile (".align 4\n"
+ ".option push\n"
+ ".option norvc\n"
+
+ "slli zero, zero, 0x1f\n"
+ "ebreak\n"
+ "srai zero, zero, 7\n"
+ ".option pop\n"
+ : "+r" (ret) : "r" (param0) : "memory");
+
+ return ret;
+}