xref: /optee_os/core/arch/riscv/include/sbi.h (revision 286e0fd9f01ab8793f57aa9c3b7bda36b04ead15)
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3  * Copyright 2022 NXP
4  */
5 
6 #ifndef __SBI_H
7 #define __SBI_H
8 
9 #if defined(CFG_RISCV_SBI)
10 
11 /* SBI return error codes */
12 #define SBI_SUCCESS			 0
13 #define SBI_ERR_FAILURE			-1
14 #define SBI_ERR_NOT_SUPPORTED		-2
15 #define SBI_ERR_INVALID_PARAM		-3
16 #define SBI_ERR_DENIED			-4
17 #define SBI_ERR_INVALID_ADDRESS		-5
18 #define SBI_ERR_ALREADY_AVAILABLE	-6
19 #define SBI_ERR_ALREADY_STARTED		-7
20 #define SBI_ERR_ALREADY_STOPPED		-8
21 
22 /* SBI Extension IDs */
23 #define SBI_EXT_0_1_CONSOLE_PUTCHAR	0x01, 0
24 #define SBI_EXT_HSM			0x48534D
25 #define SBI_EXT_TEE			0x544545
26 
27 #ifndef __ASSEMBLER__
28 
29 /* SBI function IDs for HSM extension */
30 enum sbi_ext_hsm_fid {
31 	SBI_EXT_HSM_HART_START = 0,
32 	SBI_EXT_HSM_HART_STOP,
33 	SBI_EXT_HSM_HART_GET_STATUS,
34 	SBI_EXT_HSM_HART_SUSPEND,
35 };
36 
37 #include <compiler.h>
38 #include <encoding.h>
39 #include <stdint.h>
40 #include <sys/cdefs.h>
41 #include <types_ext.h>
42 #include <util.h>
43 
44 void sbi_console_putchar(int ch);
45 int sbi_hsm_hart_start(uint32_t hartid, paddr_t start_addr, unsigned long arg);
46 
47 #endif /*__ASSEMBLER__*/
48 #endif /*defined(CFG_RISCV_SBI)*/
49 #endif /*__SBI_H*/
50