xref: /kvm-unit-tests/lib/riscv/asm/sbi.h (revision a1418d6dbe810aded6885366cc6e782caa21a2cc)
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 };
23 
24 enum sbi_ext_base_fid {
25 	SBI_EXT_BASE_GET_SPEC_VERSION = 0,
26 	SBI_EXT_BASE_GET_IMP_ID,
27 	SBI_EXT_BASE_GET_IMP_VERSION,
28 	SBI_EXT_BASE_PROBE_EXT,
29 	SBI_EXT_BASE_GET_MVENDORID,
30 	SBI_EXT_BASE_GET_MARCHID,
31 	SBI_EXT_BASE_GET_MIMPID,
32 };
33 
34 enum sbi_ext_hsm_fid {
35 	SBI_EXT_HSM_HART_START = 0,
36 	SBI_EXT_HSM_HART_STOP,
37 	SBI_EXT_HSM_HART_STATUS,
38 	SBI_EXT_HSM_HART_SUSPEND,
39 };
40 
41 enum sbi_ext_time_fid {
42 	SBI_EXT_TIME_SET_TIMER = 0,
43 };
44 
45 struct sbiret {
46 	long error;
47 	long value;
48 };
49 
50 struct sbiret sbi_ecall(int ext, int fid, unsigned long arg0,
51 			unsigned long arg1, unsigned long arg2,
52 			unsigned long arg3, unsigned long arg4,
53 			unsigned long arg5);
54 
55 void sbi_shutdown(void);
56 struct sbiret sbi_hart_start(unsigned long hartid, unsigned long entry, unsigned long sp);
57 long sbi_probe(int ext);
58 
59 #endif /* !__ASSEMBLY__ */
60 #endif /* _ASMRISCV_SBI_H_ */
61