diff options
author | Damien Le Moal <damien.lemoal@wdc.com> | 2019-01-18 10:28:32 +0300 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2019-01-21 07:28:33 +0300 |
commit | b5be19f9e5c8f25b07375429aa5d00895a8645cc (patch) | |
tree | e78983b31b70140c056596b6c805ae391f7acf75 /include | |
parent | 42283461d3f236881f67d8aa9bb8bc96decdacae (diff) | |
download | opensbi-b5be19f9e5c8f25b07375429aa5d00895a8645cc.tar.xz |
sbi: Add ecall helpers
Define sbi_ecall_console_puts() using sbi_ecall_console_putchar()
renamed as sbi_ecall_console_putc() and remove the hardcoded version
of the same funtion in the test payload code.
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/sbi/sbi_ecall_interface.h | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/include/sbi/sbi_ecall_interface.h b/include/sbi/sbi_ecall_interface.h index 53de6a4..1ea2676 100644 --- a/include/sbi/sbi_ecall_interface.h +++ b/include/sbi/sbi_ecall_interface.h @@ -24,7 +24,7 @@ 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 a7 asm ("a7") = (unsigned long)(__num); \ asm volatile ("ecall" \ : "+r" (a0) \ : "r" (a1), "r" (a2), "r" (a7) \ @@ -36,4 +36,13 @@ #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_console_putc(c) \ + SBI_ECALL_1(SBI_ECALL_CONSOLE_PUTCHAR, (c)); + +static inline void sbi_ecall_console_puts(const char *str) +{ + while (str && *str) + sbi_ecall_console_putc(*str++); +} + #endif |