Fukurō
A highly portable microkernel
Loading...
Searching...
No Matches
sbi.h
Go to the documentation of this file.
1/*
2 * Copyright © 2023, d0p1
3 *
4 * This file is part of Fukurō.
5 *
6 * This software is governed by the CeCILL license under French law and
7 * abiding by the rules of distribution of free software. You can use,
8 * modify and/ or redistribute the software under the terms of the CeCILL
9 * license as circulated by CEA, CNRS and INRIA at the following URL
10 * "http://cecill.info".
11 *
12 * As a counterpart to the access to the source code and rights to copy,
13 * modify and redistribute granted by the license, users are provided only
14 * with a limited warranty and the software's author, the holder of the
15 * economic rights, and the successive licensors have only limited
16 * liability.
17 *
18 * In this respect, the user's attention is drawn to the risks associated
19 * with loading, using, modifying and/or developing or reproducing the
20 * software by the user in light of its specific status of free software,
21 * that may mean that it is complicated to manipulate, and that also
22 * therefore means that it is reserved for developers and experienced
23 * professionals having in-depth computer knowledge. Users are therefore
24 * encouraged to load and test the software's suitability as regards their
25 * requirements in conditions enabling the security of their systems and/or
26 * data to be ensured and, more generally, to use and operate it in the
27 * same conditions as regards security.
28 *
29 * The fact that you are presently reading this means that you have had
30 * knowledge of the CeCILL license and that you accept its terms.
31 */
32#ifndef FUKURO_SYS_RISCV_SBI_H
33# define FUKURO_SYS_RISCV_SBI_H 1
34
35# define SBI_SUCCESS 0
36# define SBI_ERR_FAILED -1
37# define SBI_ERR_NOT_SUPPORTED -2
38# define SBI_ERR_INVALID_PARAM -3
39# define SBI_ERR_DENIED -4
40# define SBI_ERR_INVALID_ADDRESS -5
41# define SBI_ERR_ALREADY_AVAILABLE -6
42# define SBI_ERR_ALREADY_STARTED -7
43# define SBI_ERR_ALREADY_STOPPED -8
44# define SBI_ERR_NO_SHMEM -9
45
46typedef struct
47{
48 long error;
49 long value;
50} SbiRet;
51
52# define SBI_EID_BASE_EXT 0x10
53# define SBI_FID_GET_SPEC_VERSION 0x0
54# define SBI_FID_GET_IMPLEM_ID 0x1
55# define SBI_FID_GET_IMPLEM_VERSION 0x2
56# define SBI_FID_PROBE_EXTENSION 0x3
57# define SBI_FID_GET_MACHINE_VENDOR 0x4
58# define SBI_FID_GET_MACHINE_ARCH 0x5
59# define SBI_FID_GET_MACHINE_IMPLEM 0x6
60
61enum
62{
72};
73
74# define SBI_EID_LEGACY_SET_TIMER 0x00
75# define SBI_EID_LEGACY_PUTCHAR 0x01
76# define SBI_EID_LEGACY_GETCHAR 0x02
77# define SBI_EID_LEGACY_CLEAR_IPI 0x03
78# define SBI_EID_LEGACY_SHUTDOWN 0x08
79
80# define SBI_EID_TIMER_EXT 0x54494D45
81# define SBI_FID_SET_TIMER 0x0
82
83# define SBI_EID_DEBUG_CONSOLE_EXT 0x4442434E
84# define SBI_FID_CONSOLE_WRITE 0x0
85# define SBI_FID_CONSOLE_READ 0x1
86# define SBI_FID_CONSOLE_WRITE_BYTE 0x2
87
88# define SBI_EID_SYSTEM_SUSPEND_EXT 0x53555350
89# define SBI_FID_SYSTEM_SUSPEND 0x0
90
91inline SbiRet
92sbi_call(long arg0, long arg1, long arg2, long arg3, long arg4,
93 long arg5, long fid, long eid)
94{
95 SbiRet ret;
96 register long a0 __asm__("a0") = arg0;
97 register long a1 __asm__("a1") = arg1;
98 register long a2 __asm__("a2") = arg2;
99 register long a3 __asm__("a3") = arg3;
100 register long a4 __asm__("a4") = arg4;
101 register long a5 __asm__("a5") = arg5;
102 register long a6 __asm__("a6") = fid;
103 register long a7 __asm__("a7") = eid;
104
105 __asm__ __volatile__("ecall"
106 : "=r"(a0), "=r"(a1)
107 : "r"(a0), "r"(a1), "r"(a2), "r"(a3), "r"(a4), "r"(a5),
108 "r"(a6), "r"(a7)
109 : "memory");
110 ret.error = a0;
111 ret.value = a1;
112 return (ret);
113}
114
115
116
117#endif /* !FUKURO_SYS_RISCV_SBI_H */
@ SBI_IMPLEM_XVISOR
Definition sbi.h:65
@ SBI_IMPLEM_OPENSBI
Definition sbi.h:64
@ SBI_IMPLEM_XEN
Definition sbi.h:70
@ SBI_IMPLEM_DIOSIX
Definition sbi.h:68
@ SBI_IMPLEM_RUSTSBI
Definition sbi.h:67
@ SBI_IMPLEM_COFFER
Definition sbi.h:69
@ SBI_IMPLEM_KVM
Definition sbi.h:66
@ SBI_IMPLEM_BBL
Definition sbi.h:63
@ SBI_IMPLEM_POLAFIRE
Definition sbi.h:71
SbiRet sbi_call(long arg0, long arg1, long arg2, long arg3, long arg4, long arg5, long fid, long eid)
Definition sbi.h:92
Definition sbi.h:47
long error
Definition sbi.h:48
long value
Definition sbi.h:49