diff options
author | Anup Patel <anup.patel@wdc.com> | 2020-06-10 18:39:53 +0530 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2020-06-20 10:36:13 +0530 |
commit | 2314101989684585f942b50a827aac4886825ba1 (patch) | |
tree | 37f1248c1c6272d5bb62a3c6e67a64cb215ce2d5 /include/sbi/sbi_error.h | |
parent | 9bd5f8f17d31f8989525643a04da87d090fe3033 (diff) |
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_error.h')
-rw-r--r-- | include/sbi/sbi_error.h | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/include/sbi/sbi_error.h b/include/sbi/sbi_error.h index 574a84d..3655d12 100644 --- a/include/sbi/sbi_error.h +++ b/include/sbi/sbi_error.h @@ -10,25 +10,28 @@ #ifndef __SBI_ERROR_H__ #define __SBI_ERROR_H__ +#include <sbi/sbi_ecall_interface.h> + /* clang-format off */ #define SBI_OK 0 -#define SBI_EFAIL -1 -#define SBI_ENOTSUPP -2 -#define SBI_EINVAL -3 -#define SBI_DENIED -4 -#define SBI_INVALID_ADDR -5 -#define SBI_ENODEV -6 -#define SBI_ENOSYS -7 -#define SBI_ETIMEDOUT -8 -#define SBI_EIO -9 -#define SBI_EILL -10 -#define SBI_ENOSPC -11 -#define SBI_ENOMEM -12 -#define SBI_ETRAP -13 -#define SBI_EUNKNOWN -14 -#define SBI_ENOENT -15 -#define SBI_EALREADY_STARTED -16 +#define SBI_EFAIL SBI_ERR_FAILED +#define SBI_ENOTSUPP SBI_ERR_NOT_SUPPORTED +#define SBI_EINVAL SBI_ERR_INVALID_PARAM +#define SBI_EDENIED SBI_ERR_DENIED +#define SBI_EINVALID_ADDR SBI_ERR_INVALID_ADDRESS +#define SBI_EALREADY SBI_ERR_ALREADY_AVAILABLE + +#define SBI_ENODEV -1000 +#define SBI_ENOSYS -1001 +#define SBI_ETIMEDOUT -1002 +#define SBI_EIO -1003 +#define SBI_EILL -1004 +#define SBI_ENOSPC -1005 +#define SBI_ENOMEM -1006 +#define SBI_ETRAP -1007 +#define SBI_EUNKNOWN -1008 +#define SBI_ENOENT -1009 /* clang-format on */ |