1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) 2015 Regents of the University of California
4 * Copyright (c) 2020 Western Digital Corporation or its affiliates.
6 * Taken from Linux arch/riscv/include/asm/sbi.h
9 #ifndef _ASM_RISCV_SBI_H
10 #define _ASM_RISCV_SBI_H
12 #include <linux/types.h>
15 SBI_EXT_0_1_SET_TIMER = 0x0,
16 SBI_EXT_0_1_CONSOLE_PUTCHAR = 0x1,
17 SBI_EXT_0_1_CONSOLE_GETCHAR = 0x2,
18 SBI_EXT_0_1_CLEAR_IPI = 0x3,
19 SBI_EXT_0_1_SEND_IPI = 0x4,
20 SBI_EXT_0_1_REMOTE_FENCE_I = 0x5,
21 SBI_EXT_0_1_REMOTE_SFENCE_VMA = 0x6,
22 SBI_EXT_0_1_REMOTE_SFENCE_VMA_ASID = 0x7,
23 SBI_EXT_0_1_SHUTDOWN = 0x8,
27 enum sbi_ext_base_fid {
28 SBI_EXT_BASE_GET_SPEC_VERSION = 0,
29 SBI_EXT_BASE_GET_IMP_ID,
30 SBI_EXT_BASE_GET_IMP_VERSION,
31 SBI_EXT_BASE_PROBE_EXT,
32 SBI_EXT_BASE_GET_MVENDORID,
33 SBI_EXT_BASE_GET_MARCHID,
34 SBI_EXT_BASE_GET_MIMPID,
37 #define SBI_SPEC_VERSION_DEFAULT 0x1
38 #define SBI_SPEC_VERSION_MAJOR_SHIFT 24
39 #define SBI_SPEC_VERSION_MAJOR_MASK 0x7f
40 #define SBI_SPEC_VERSION_MINOR_MASK 0xffffff
42 /* SBI return error codes */
44 #define SBI_ERR_FAILURE -1
45 #define SBI_ERR_NOT_SUPPORTED -2
46 #define SBI_ERR_INVALID_PARAM -3
47 #define SBI_ERR_DENIED -4
48 #define SBI_ERR_INVALID_ADDRESS -5
50 extern unsigned long sbi_spec_version;
56 struct sbiret sbi_ecall(int ext, int fid, unsigned long arg0,
57 unsigned long arg1, unsigned long arg2,
58 unsigned long arg3, unsigned long arg4,
61 void sbi_console_putchar(int ch);
62 int sbi_console_getchar(void);
63 void sbi_clear_ipi(void);
64 void sbi_shutdown(void);
65 void sbi_set_timer(uint64_t stime_value);
66 void sbi_send_ipi(const unsigned long *hart_mask);
67 void sbi_remote_fence_i(const unsigned long *hart_mask);
68 void sbi_remote_sfence_vma(const unsigned long *hart_mask,
71 void sbi_remote_sfence_vma_asid(const unsigned long *hart_mask,
76 int sbi_probe_extension(int ext);