1 RISC-V Open Source Supervisor Binary Interface (OpenSBI)
2 ========================================================
4 The **RISC-V Supervisor Binary Interface (SBI)** is the recommended interface
7 1. A platform specific firmware running in M-mode and bootloader, hypervisor or
8 a general purpose OS executing in S-mode or HS-mode.
9 2. A hypervisor running in HS-mode and a bootloader or a general purpose OS
12 The *RISC-V SBI specification* is maintained as an independent project by the
13 RISC-V Foundation in [Github].
15 The goal of the OpenSBI project is to provide an open-source reference
16 implementation of the RISC-V SBI specifications for platform specific firmwares
17 executing in M-mode (case 1 mentioned above). OpenSBI implementation can be
18 easily extended by RISC-V platform and system-on-chip vendors to fit a
19 particular hardware configuration.
21 The main component of OpenSBI is provided in the form of a platform independent
22 static library **libsbi.a** implementing the SBI interface. A firmware or
23 bootloader implementation can link against this library to ensure conformance
24 with the SBI interface specifications. *libsbi.a* also defines an interface for
25 integrating with platform specific operations provided by the platform firmware
26 implementation (e.g. console access functions, inter-processor interrupts
29 To illustrate the use of *libsbi.a* library, OpenSBI also provides a set of
30 platform specific support examples. For each example, a platform
31 specific static library *libplatsbi.a* can be compiled. This library implements
32 SBI calls processing by integrating *libsbi.a* with necessary platform dependent
33 hardware manipulation functions. For all supported platforms, OpenSBI also
34 provides several runtime firmware examples built using the platform
35 *libplatsbi.a*. These example firmwares can be used to replace the legacy
36 *riskv-pk* bootloader (aka BBL) and enable the use of well known bootloaders
42 OpenSBI can be compiled natively or cross-compiled on a x86 host. For
43 cross-compilation, you can build your tool chain or just download from
44 the [bootlin] (https://toolchains.bootlin.com/).
46 Please note that only 64bit version of toolchain is available in bootlin
49 Building and Installing OpenSBI Platform Independent Library
50 ------------------------------------------------------------
52 OpenSBI platform independent static library *libsbi.a* can be natively compiled
53 or cross-compiled on a host with a different base architecture than RISC-V.
55 For cross-compiling, the environment variable *CROSS_COMPILE* must be defined
56 to specify the name prefix of the RISC-V compiler toolchain executables, e.g.
57 *riscv64-unknown-elf-* if the gcc executable used is *riscv64-unknown-elf-gcc*.
59 To build *libsbi.a* simply execute:
64 All compiled binaries as well as the result *libsbi.a* static library file will
65 be placed in the *build/lib* directory. To specify an alternate build root
68 make O=<build_directory>
71 To generate files to be installed for using *libsbi.a* in other projects, run:
76 This will create the *install* directory with all necessary include files
77 copied under the *install/include* directory and library file copied in the
78 *install/lib* directory. To specify an alternate installation root directory
81 make I=<install_directory> install
84 Building and Installing a Reference Platform Static Library and Firmwares
85 -------------------------------------------------------------------------
87 When the *PLATFORM=<platform_subdir>* argument is specified on the make command
88 line, the platform specific static library *libplatsbi.a* and firmware examples
89 are built for the platform *<platform_subdir>* present in the directory
90 *platform* in OpenSBI top directory. For example, to compile the platform
91 library and firmware examples for QEMU RISC-V *virt* machine,
92 *<platform_subdir>* should be *qemu/virt*.
94 To build *libsbi.a*, *libplatsbi.a* and the firmwares for one of the supported
97 make PLATFORM=<platform_subdir>
100 An alternate build directory path can also be specified.
102 make PLATFORM=<platform_subdir> O=<build_directory>
105 The platform specific library *libplatsbi.a* will be generated in the
106 *build/platform/<platform_subdir>/lib* directory. The platform firmware files
107 will be under the *build/platform/<platform_subdir>/firmware* directory.
108 The compiled firmwares will be available in two different format: an ELF file
109 and an expanded image file.
111 To install *libsbi.a*, *libplatsbi.a*, and the compiled firmwares, run:
113 make PLATFORM=<platform_subdir> install
116 This will copy the compiled platform specific libraries and firmware files
117 under the *install/platform/<platform_subdir>/* directory. An alternate
118 install root directory path can be specified as follows.
120 make PLATFORM=<platform_subdir> I=<install_directory> install
123 In addition, platform specific configuration options can be specified with the
124 top-level make command line. These options, such as *PLATFORM_<xyz>* or
125 *FW_<abc>*, are platform specific and described in more details in the
126 *docs/platform/<platform_name>.md* files and
127 *docs/firmware/<firmware_name>.md* files.
132 OpenSBI is distributed under the terms of the BSD 2-clause license
133 ("Simplified BSD License" or "FreeBSD License", SPDX: *BSD-2-Clause*).
134 A copy of this license with OpenSBI copyright can be found in the file
137 All source files in OpenSBI contain the 2-Clause BSD license SPDX short
138 identifier in place of the full license text.
141 SPDX-License-Identifier: BSD-2-Clause
144 This enables machine processing of license information based on the SPDX
145 License Identifiers that are available on the [SPDX] web site.
147 OpenSBI source code also contains code reused from other projects as listed
148 below. The original license text of these projects is included in the source
149 files where the reused code is present.
151 1. The libfdt source code is disjunctively dual licensed
152 (GPL-2.0+ OR BSD-2-Clause). Some of this project code is used in OpenSBI
153 under the terms of the BSD 2-Clause license. Any contributions to this
154 code must be made under the terms of both licenses.
156 Contributing to OpenSBI
157 -----------------------
159 The OpenSBI project encourages and welcomes contributions. Contributions should
160 follow the rules described in OpenSBI [Contribution Guideline] document.
161 In particular, all patches sent should contain a Signed-off-by tag.
166 Detailed documentation of various aspects of OpenSBI can be found under the
167 *docs* directory. The documentation covers the following topics.
169 * [Contribution Guideline]: Guideline for contributing code to OpenSBI project
170 * [Library Usage]: API documentation of OpenSBI static library *libsbi.a*
171 * [Platform Support Guide]: Guideline for implementing support for new platforms
172 * [Platform Documentation]: Documentation of the platforms currently supported.
173 * [Firmware Documentation]: Documentation for the different types of firmware
174 examples build supported by OpenSBI.
176 OpenSBI source code is also well documented. For source level documentation,
177 doxygen style is used. Please refer to [Doxygen manual] for details on this
180 Doxygen can be installed on Linux distributions using *.deb* packages using
181 the following command.
183 sudo apt-get install doxygen doxygen-latex doxygen-doc doxygen-gui graphviz
186 For *.rpm* based Linux distributions, the following commands can be used.
188 sudo yum install doxygen doxygen-latex doxywizard graphviz
192 sudo yum install doxygen doxygen-latex doxywizard graphviz
195 To build a consolidated *refman.pdf* of all documentation, run:
201 make O=<build_directory> docs
204 the resulting *refman.pdf* will be available under the directory
205 *<build_directory>/docs/latex*. To install this file, run:
211 make I=<install_directory> install_docs
214 *refman.pdf* will be installed under *<install_directory>/docs*.
216 [Github]: https://github.com/riscv/riscv-sbi-doc
217 [U-Boot]: https://www.denx.de/wiki/U-Boot/SourceCode
218 [COPYING.BSD]: COPYING.BSD
219 [SPDX]: http://spdx.org/licenses/
220 [Contribution Guideline]: docs/contributing.md
221 [Library Usage]: docs/library_usage.md
222 [Platform Support Guide]: docs/platform_guide.md
223 [Platform Documentation]: docs/platform/platform.md
224 [Firmware Documentation]: docs/firmware/fw.md
225 [Doxygen manual]: http://www.stack.nl/~dimitri/doxygen/manual.html