forked from Mirrors/opensbi

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>
39 lines
849 B
C
39 lines
849 B
C
/*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*
|
|
* Copyright (c) 2019 Western Digital Corporation or its affiliates.
|
|
*
|
|
* Authors:
|
|
* Anup Patel <anup.patel@wdc.com>
|
|
*/
|
|
|
|
#ifndef __SBI_ERROR_H__
|
|
#define __SBI_ERROR_H__
|
|
|
|
#include <sbi/sbi_ecall_interface.h>
|
|
|
|
/* clang-format off */
|
|
|
|
#define SBI_OK 0
|
|
#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 */
|
|
|
|
#endif
|