summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorSamuel Holland <samuel@sholland.org>2021-08-14 16:52:10 +0300
committerAnup Patel <anup@brainfault.org>2021-08-20 07:18:45 +0300
commitb1d3e91e9a69595119e3da19ca175145d2a1b8d6 (patch)
tree89f19d82a4a9504983ef7982f9a28d227e5707ec /firmware
parentee274377b2a0f26400281a2ccb00b6e15c3f5716 (diff)
downloadopensbi-b1d3e91e9a69595119e3da19ca175145d2a1b8d6.tar.xz
payloads/test: Add support for SBI v0.2 ecalls
It can be useful to make SBI v0.2 or newer ecalls from this payload for testing purposes. To support this, convert the macros to use the extension/function parameter convention. Signed-off-by: Samuel Holland <samuel@sholland.org> Reviewed-by: Atish Patra <atish.patra@wdc.com>
Diffstat (limited to 'firmware')
-rw-r--r--firmware/payloads/test_main.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/firmware/payloads/test_main.c b/firmware/payloads/test_main.c
index 0d65930..ae2ed4f 100644
--- a/firmware/payloads/test_main.c
+++ b/firmware/payloads/test_main.c
@@ -9,24 +9,25 @@
#include <sbi/sbi_ecall_interface.h>
-#define SBI_ECALL(__num, __a0, __a1, __a2) \
+#define SBI_ECALL(__eid, __fid, __a0, __a1, __a2) \
({ \
register unsigned long a0 asm("a0") = (unsigned long)(__a0); \
register unsigned long a1 asm("a1") = (unsigned long)(__a1); \
register unsigned long a2 asm("a2") = (unsigned long)(__a2); \
- register unsigned long a7 asm("a7") = (unsigned long)(__num); \
+ register unsigned long a6 asm("a6") = (unsigned long)(__fid); \
+ register unsigned long a7 asm("a7") = (unsigned long)(__eid); \
asm volatile("ecall" \
: "+r"(a0) \
- : "r"(a1), "r"(a2), "r"(a7) \
+ : "r"(a1), "r"(a2), "r"(a6), "r"(a7) \
: "memory"); \
a0; \
})
-#define SBI_ECALL_0(__num) SBI_ECALL(__num, 0, 0, 0)
-#define SBI_ECALL_1(__num, __a0) SBI_ECALL(__num, __a0, 0, 0)
-#define SBI_ECALL_2(__num, __a0, __a1) SBI_ECALL(__num, __a0, __a1, 0)
+#define SBI_ECALL_0(__eid, __fid) SBI_ECALL(__eid, __fid, 0, 0, 0)
+#define SBI_ECALL_1(__eid, __fid, __a0) SBI_ECALL(__eid, __fid, __a0, 0, 0)
+#define SBI_ECALL_2(__eid, __fid, __a0, __a1) SBI_ECALL(__eid, __fid, __a0, __a1, 0)
-#define sbi_ecall_console_putc(c) SBI_ECALL_1(SBI_EXT_0_1_CONSOLE_PUTCHAR, (c))
+#define sbi_ecall_console_putc(c) SBI_ECALL_1(SBI_EXT_0_1_CONSOLE_PUTCHAR, 0, (c))
static inline void sbi_ecall_console_puts(const char *str)
{