summaryrefslogtreecommitdiff
path: root/include/sbi/sbi_ecall_interface.h
diff options
context:
space:
mode:
authorAnup Patel <anup.patel@wdc.com>2020-06-10 16:09:53 +0300
committerAnup Patel <anup@brainfault.org>2020-06-20 08:06:13 +0300
commit2314101989684585f942b50a827aac4886825ba1 (patch)
tree37f1248c1c6272d5bb62a3c6e67a64cb215ce2d5 /include/sbi/sbi_ecall_interface.h
parent9bd5f8f17d31f8989525643a04da87d090fe3033 (diff)
downloadopensbi-2314101989684585f942b50a827aac4886825ba1.tar.xz
lib: Don't return any invalid error from SBI ecall
We should only return valid error codes from SBI ecalls as defined by the RISC-V SBI spec. To achieve this: 1. We use SBI_Exxxx defines for OpenSBI internal errors with error values starting from -1000 2. We use SBI_ERR_xxxx defines for errors defined by SBI spec 3. We map some of the SBI_Exxxx defines to SBI_ERR_xxxx defines which are semantically same 4. We throw a error print and force return error code to SBI_ERR_FAILED in sbi_ecall_handler() if we see an invalid error code being returned to S-mode Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
Diffstat (limited to 'include/sbi/sbi_ecall_interface.h')
-rw-r--r--include/sbi/sbi_ecall_interface.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/include/sbi/sbi_ecall_interface.h b/include/sbi/sbi_ecall_interface.h
index 0cdde39..af30500 100644
--- a/include/sbi/sbi_ecall_interface.h
+++ b/include/sbi/sbi_ecall_interface.h
@@ -13,7 +13,7 @@
/* clang-format off */
/* SBI Extension IDs */
-#define SBI_EXT_0_1_SET_TIMER 0x0
+#define SBI_EXT_0_1_SET_TIMER 0x0
#define SBI_EXT_0_1_CONSOLE_PUTCHAR 0x1
#define SBI_EXT_0_1_CONSOLE_GETCHAR 0x2
#define SBI_EXT_0_1_CLEAR_IPI 0x3
@@ -69,6 +69,18 @@
#define SBI_EXT_VENDOR_END 0x09FFFFFF
#define SBI_EXT_FIRMWARE_START 0x0A000000
#define SBI_EXT_FIRMWARE_END 0x0AFFFFFF
+
+/* SBI return error codes */
+#define SBI_SUCCESS 0
+#define SBI_ERR_FAILED -1
+#define SBI_ERR_NOT_SUPPORTED -2
+#define SBI_ERR_INVALID_PARAM -3
+#define SBI_ERR_DENIED -4
+#define SBI_ERR_INVALID_ADDRESS -5
+#define SBI_ERR_ALREADY_AVAILABLE -6
+
+#define SBI_LAST_ERR SBI_ERR_ALREADY_AVAILABLE
+
/* clang-format on */
#endif