22#ifndef ZEPHYR_INCLUDE_ARCH_RISCV_SBI_H_
23#define ZEPHYR_INCLUDE_ARCH_RISCV_SBI_H_
30#define SBI_EXT_TIME 0x54494D45
33#define SBI_FUNC_SET_TIMER 0
36#define SBI_EXT_SRST 0x53525354
39#define SBI_FUNC_SYSTEM_RESET 0
42#define SBI_SRST_RESET_TYPE_SHUTDOWN 0
44#define SBI_SRST_RESET_TYPE_COLD_REBOOT 1
46#define SBI_SRST_RESET_TYPE_WARM_REBOOT 2
49#define SBI_SRST_RESET_REASON_NONE 0
52#define SBI_EXT_HSM 0x48534D
55#define SBI_FUNC_HART_START 0
57#define SBI_FUNC_HART_STOP 1
60#define SBI_EXT_IPI 0x735049
63#define SBI_FUNC_SEND_IPI 0
68#define SBI_ERR_FAILED -1
70#define SBI_ERR_NOT_SUPPORTED -2
72#define SBI_ERR_INVALID_PARAM -3
74#define SBI_ERR_DENIED -4
76#define SBI_ERR_INVALID_ADDRESS -5
78#define SBI_ERR_ALREADY_AVAILABLE -6
80#define SBI_ERR_ALREADY_STARTED -7
82#define SBI_ERR_ALREADY_STOPPED -8
84#define SBI_ERR_NO_SHMEM -9
86#define SBI_ERR_INVALID_STATE -10
88#define SBI_ERR_BAD_RANGE -11
90#define SBI_ERR_TIMEOUT -12
94#define SBI_ERR_DENIED_LOCKED -14
153 register unsigned long a0 __asm__(
"a0") = (arg0);
154 register unsigned long a1 __asm__(
"a1") = (arg1);
155 register unsigned long a2 __asm__(
"a2") = (arg2);
156 register unsigned long a3 __asm__(
"a3") = (arg3);
157 register unsigned long a4 __asm__(
"a4") = (arg4);
158 register unsigned long a5 __asm__(
"a5") = (arg5);
159 register unsigned long a6 __asm__(
"a6") = (fid);
160 register unsigned long a7 __asm__(
"a7") = (ext);
162 __asm__
volatile(
"ecall"
164 :
"r"(a2),
"r"(a3),
"r"(a4),
"r"(a5),
"r"(a6),
"r"(a7)
#define EINVAL
Invalid argument.
Definition errno.h:61
#define EFAULT
Bad address.
Definition errno.h:53
#define ETIMEDOUT
Connection timed out.
Definition errno.h:101
#define ENOMEM
Not enough core.
Definition errno.h:51
#define EIO
I/O error.
Definition errno.h:44
#define ENOTSUP
Unsupported value.
Definition errno.h:115
#define ERANGE
Result too large.
Definition errno.h:73
#define EALREADY
Operation already in progress.
Definition errno.h:105
#define EPERM
Not owner.
Definition errno.h:40
#define unsigned
Definition types.h:27
#define SBI_ERR_ALREADY_STOPPED
SBI return code: the target has already been stopped.
Definition sbi.h:82
#define SBI_ERR_IO
SBI return code: an I/O error occurred during the operation.
Definition sbi.h:92
#define SBI_ERR_ALREADY_STARTED
SBI return code: the target has already been started.
Definition sbi.h:80
static struct sbiret sbi_ecall(unsigned long arg0, unsigned long arg1, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5, unsigned long fid, unsigned long ext)
Definition sbi.h:147
#define SBI_ERR_FAILED
SBI return code: the call failed for an unspecified reason.
Definition sbi.h:68
#define SBI_ERR_DENIED
SBI return code: the caller is not permitted to perform the operation.
Definition sbi.h:74
#define SBI_ERR_DENIED_LOCKED
SBI return code: denied because the resource is locked.
Definition sbi.h:94
#define SBI_ERR_INVALID_STATE
SBI return code: the operation is not valid in the current state.
Definition sbi.h:86
#define SBI_ERR_BAD_RANGE
SBI return code: the supplied range is malformed or out of bounds.
Definition sbi.h:88
#define SBI_ERR_NO_SHMEM
SBI return code: no shared memory region has been set up.
Definition sbi.h:84
#define SBI_ERR_NOT_SUPPORTED
SBI return code: requested extension/function is not available.
Definition sbi.h:70
#define SBI_SUCCESS
SBI return code: call completed successfully.
Definition sbi.h:66
#define SBI_ERR_INVALID_ADDRESS
SBI return code: an address argument was invalid or inaccessible.
Definition sbi.h:76
#define SBI_ERR_TIMEOUT
SBI return code: the operation did not complete in time.
Definition sbi.h:90
#define SBI_ERR_ALREADY_AVAILABLE
SBI return code: the resource is already available.
Definition sbi.h:78
#define SBI_ERR_INVALID_PARAM
SBI return code: one or more arguments were invalid.
Definition sbi.h:72
static int sbi_err_to_errno(unsigned long err)
Translate an SBI return code into a negative errno value.
Definition sbi.h:106
long value
Definition sbi.h:142
long error
Definition sbi.h:140
unsigned long uvalue
Definition sbi.h:143