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 
26 /* SBI function IDs for HSM extension */
27 #define SBI_EXT_HSM_HART_START		U(0)
28 #define SBI_EXT_HSM_HART_STOP		U(1)
29 #define SBI_EXT_HSM_HART_GET_STATUS	U(2)
30 #define SBI_EXT_HSM_HART_SUSPEND	U(3)
31 
32 #ifndef __ASSEMBLER__
33 
34 #include <compiler.h>
35 #include <encoding.h>
36 #include <stdint.h>
37 #include <sys/cdefs.h>
38 #include <types_ext.h>
39 #include <util.h>
40 
41 void sbi_console_putchar(int ch);
42 int sbi_boot_hart(uint32_t hart_id, paddr_t start_addr, unsigned long arg);
43 
44 #endif /*__ASSEMBLER__*/
45 #endif /*defined(CFG_RISCV_SBI)*/
46 #endif /*SBI_H*/
47