xref: /kvm-unit-tests/lib/riscv/asm/sbi.h (revision 6b801c8981f74d75419d77e031dd37f5ad356efe)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 #ifndef _ASMRISCV_SBI_H_
3 #define _ASMRISCV_SBI_H_
4 
5 #define SBI_SUCCESS			0
6 #define SBI_ERR_FAILURE			-1
7 #define SBI_ERR_NOT_SUPPORTED		-2
8 #define SBI_ERR_INVALID_PARAM		-3
9 #define SBI_ERR_DENIED			-4
10 #define SBI_ERR_INVALID_ADDRESS		-5
11 #define SBI_ERR_ALREADY_AVAILABLE	-6
12 #define SBI_ERR_ALREADY_STARTED		-7
13 #define SBI_ERR_ALREADY_STOPPED		-8
14 
15 #ifndef __ASSEMBLY__
16 
17 enum sbi_ext_id {
18 	SBI_EXT_BASE = 0x10,
19 	SBI_EXT_TIME = 0x54494d45,
20 	SBI_EXT_HSM = 0x48534d,
21 	SBI_EXT_SRST = 0x53525354,
22 	SBI_EXT_DBCN = 0x4442434E,
23 };
24 
25 enum sbi_ext_base_fid {
26 	SBI_EXT_BASE_GET_SPEC_VERSION = 0,
27 	SBI_EXT_BASE_GET_IMP_ID,
28 	SBI_EXT_BASE_GET_IMP_VERSION,
29 	SBI_EXT_BASE_PROBE_EXT,
30 	SBI_EXT_BASE_GET_MVENDORID,
31 	SBI_EXT_BASE_GET_MARCHID,
32 	SBI_EXT_BASE_GET_MIMPID,
33 };
34 
35 enum sbi_ext_hsm_fid {
36 	SBI_EXT_HSM_HART_START = 0,
37 	SBI_EXT_HSM_HART_STOP,
38 	SBI_EXT_HSM_HART_STATUS,
39 	SBI_EXT_HSM_HART_SUSPEND,
40 };
41 
42 enum sbi_ext_time_fid {
43 	SBI_EXT_TIME_SET_TIMER = 0,
44 };
45 
46 enum sbi_ext_dbcn_fid {
47 	SBI_EXT_DBCN_CONSOLE_WRITE = 0,
48 	SBI_EXT_DBCN_CONSOLE_READ,
49 	SBI_EXT_DBCN_CONSOLE_WRITE_BYTE,
50 };
51 
52 struct sbiret {
53 	long error;
54 	long value;
55 };
56 
57 struct sbiret sbi_ecall(int ext, int fid, unsigned long arg0,
58 			unsigned long arg1, unsigned long arg2,
59 			unsigned long arg3, unsigned long arg4,
60 			unsigned long arg5);
61 
62 void sbi_shutdown(void);
63 struct sbiret sbi_hart_start(unsigned long hartid, unsigned long entry, unsigned long sp);
64 long sbi_probe(int ext);
65 
66 #endif /* !__ASSEMBLY__ */
67 #endif /* _ASMRISCV_SBI_H_ */
68