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