2018-12-11 21:54:06 +08:00
|
|
|
RISC-V Open Source Supervisor Binary Interface (OpenSBI)
|
|
|
|
========================================================
|
|
|
|
|
2019-02-07 17:11:41 +08:00
|
|
|
The **RISC-V Supervisor Binary Interface (SBI)** is the recommended interface
|
2019-01-23 14:14:13 +08:00
|
|
|
between:
|
2018-12-11 21:54:06 +08:00
|
|
|
|
2019-02-07 17:11:41 +08:00
|
|
|
1. A platform specific firmware running in M-mode and bootloader, hypervisor or
|
|
|
|
a general purpose OS executing in S-mode or HS-mode.
|
|
|
|
2. A hypervisor running in HS-mode and a bootloader or a general purpose OS
|
|
|
|
executing in VS-mode.
|
2018-12-25 14:37:04 +08:00
|
|
|
|
2019-01-23 14:14:13 +08:00
|
|
|
The *RISC-V SBI specification* is maintained as an independent project by the
|
|
|
|
RISC-V Foundation in [Github].
|
2018-12-25 14:37:04 +08:00
|
|
|
|
2019-02-07 17:11:41 +08:00
|
|
|
The goal of the OpenSBI project is to provide an open-source reference
|
|
|
|
implementation of the RISC-V SBI specifications for platform specific firmwares
|
|
|
|
executing in M-mode (case 1 mentioned above). OpenSBI implementation can be
|
|
|
|
easily extended by RISC-V platform and system-on-chip vendors to fit a
|
2019-01-23 14:14:13 +08:00
|
|
|
particular hardware configuration.
|
2018-12-25 14:37:04 +08:00
|
|
|
|
2019-02-07 17:11:41 +08:00
|
|
|
The main component of OpenSBI is provided in the form of a platform independent
|
|
|
|
static library **libsbi.a** implementing the SBI interface. A firmware or
|
|
|
|
bootloader implementation can link against this library to ensure conformance
|
|
|
|
with the SBI interface specifications. *libsbi.a* also defines an interface for
|
|
|
|
integrating with platform specific operations provided by the platform firmware
|
|
|
|
implementation (e.g. console access functions, inter-processor interrupts
|
|
|
|
control, etc).
|
|
|
|
|
|
|
|
To illustrate the use of *libsbi.a* library, OpenSBI also provides a set of
|
|
|
|
platform specific support examples. For each example, a platform
|
|
|
|
specific static library *libplatsbi.a* can be compiled. This library implements
|
|
|
|
SBI calls processing by integrating *libsbi.a* with necessary platform dependent
|
|
|
|
hardware manipulation functions. For all supported platforms, OpenSBI also
|
|
|
|
provides several runtime firmware examples built using the platform
|
|
|
|
*libplatsbi.a*. These example firmwares can be used to replace the legacy
|
|
|
|
*riskv-pk* bootloader (aka BBL) and enable the use of well known bootloaders
|
|
|
|
such as [U-Boot].
|
|
|
|
|
|
|
|
Building and Installing OpenSBI Platform Independent Library
|
|
|
|
------------------------------------------------------------
|
|
|
|
|
|
|
|
OpenSBI platform independent static library *libsbi.a* can be natively compiled
|
|
|
|
or cross-compiled on a host with a different base architecture than RISC-V.
|
2018-12-25 14:37:04 +08:00
|
|
|
|
2019-01-23 14:14:13 +08:00
|
|
|
For cross-compiling, the environment variable *CROSS_COMPILE* must be defined
|
|
|
|
to specify the name prefix of the RISC-V compiler toolchain executables, e.g.
|
|
|
|
*riscv64-unknown-elf-* if the gcc executable used is *riscv64-unknown-elf-gcc*.
|
2018-12-25 14:37:04 +08:00
|
|
|
|
2019-02-07 17:11:41 +08:00
|
|
|
To build *libsbi.a* simply execute:
|
2018-12-25 14:37:04 +08:00
|
|
|
```
|
|
|
|
make
|
|
|
|
```
|
|
|
|
|
2019-01-23 14:14:13 +08:00
|
|
|
All compiled binaries as well as the result *libsbi.a* static library file will
|
|
|
|
be placed in the *build/lib* directory. To specify an alternate build root
|
|
|
|
directory path, run:
|
2018-12-25 14:37:04 +08:00
|
|
|
```
|
|
|
|
make O=<build_directory>
|
|
|
|
```
|
|
|
|
|
2019-01-23 14:14:13 +08:00
|
|
|
To generate files to be installed for using *libsbi.a* in other projects, run:
|
2018-12-25 14:37:04 +08:00
|
|
|
```
|
|
|
|
make install
|
|
|
|
```
|
2019-01-23 14:14:13 +08:00
|
|
|
|
2018-12-25 14:37:04 +08:00
|
|
|
This will create the *install* directory with all necessary include files
|
2019-01-23 14:14:13 +08:00
|
|
|
copied under the *install/include* directory and library file copied in the
|
|
|
|
*install/lib* directory. To specify an alternate installation root directory
|
|
|
|
path, run:
|
2018-12-25 14:37:04 +08:00
|
|
|
```
|
|
|
|
make I=<install_directory> install
|
|
|
|
```
|
|
|
|
|
2019-02-07 17:11:41 +08:00
|
|
|
Building and Installing a Reference Platform Static Library and Firmwares
|
|
|
|
-------------------------------------------------------------------------
|
2018-12-25 14:37:04 +08:00
|
|
|
|
2019-02-07 17:11:41 +08:00
|
|
|
When the *PLATFORM=<platform_subdir>* argument is specified on the make command
|
|
|
|
line, the platform specific static library *libplatsbi.a* and firmware examples
|
|
|
|
are built for the platform *<platform_subdir>* present in the directory
|
|
|
|
*platform* in OpenSBI top directory. For example, to compile the platform
|
|
|
|
library and firmware examples for QEMU RISC-V *virt* machine,
|
|
|
|
*<platform_subdir>* should be *qemu/virt*.
|
2018-12-25 14:37:04 +08:00
|
|
|
|
2019-02-07 17:11:41 +08:00
|
|
|
To build *libsbi.a*, *libplatsbi.a* and the firmwares for one of the supported
|
|
|
|
platform, run:
|
2018-12-25 14:37:04 +08:00
|
|
|
```
|
|
|
|
make PLATFORM=<platform_subdir>
|
2019-01-23 14:14:13 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
An alternate build directory path can also be specified.
|
|
|
|
```
|
2018-12-25 14:37:04 +08:00
|
|
|
make PLATFORM=<platform_subdir> O=<build_directory>
|
|
|
|
```
|
|
|
|
|
2019-01-23 14:14:13 +08:00
|
|
|
The platform specific library *libplatsbi.a* will be generated in the
|
2019-01-29 20:24:17 +08:00
|
|
|
*build/platform/<platform_subdir>/lib* directory. The platform firmware files
|
|
|
|
will be under the *build/platform/<platform_subdir>/firmware* directory.
|
2019-01-23 14:14:13 +08:00
|
|
|
The compiled firmwares will be available in two different format: an ELF file
|
|
|
|
and an expanded image file.
|
|
|
|
|
|
|
|
To install *libsbi.a*, *libplatsbi.a*, and the compiled firmwares, run:
|
2018-12-25 14:37:04 +08:00
|
|
|
```
|
|
|
|
make PLATFORM=<platform_subdir> install
|
2019-01-23 14:14:13 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
This will copy the compiled platform specific libraries and firmware files
|
2019-01-29 20:24:17 +08:00
|
|
|
under the *install/platform/<platform_subdir>/* directory. An alternate
|
2019-01-23 14:14:13 +08:00
|
|
|
install root directory path can be specified as follows.
|
|
|
|
```
|
2019-01-14 14:18:38 +08:00
|
|
|
make PLATFORM=<platform_subdir> I=<install_directory> install
|
2018-12-25 14:37:04 +08:00
|
|
|
```
|
|
|
|
|
2019-01-23 14:14:13 +08:00
|
|
|
In addition, platform specific configuration options can be specified with the
|
|
|
|
top-level make command line. These options, such as *PLATFORM_<xyz>* or
|
|
|
|
*FW_<abc>*, are platform specific and described in more details in the
|
|
|
|
*docs/platform/<platform_name>.md* files and
|
|
|
|
*docs/firmware/<firmware_name>.md* files.
|
2018-12-20 20:53:52 +08:00
|
|
|
|
2019-01-09 16:49:35 +08:00
|
|
|
License
|
2019-01-23 14:14:13 +08:00
|
|
|
-------
|
|
|
|
|
|
|
|
OpenSBI is distributed under the terms of the BSD 2-clause license
|
|
|
|
("Simplified BSD License" or "FreeBSD License", SPDX: *BSD-2-Clause*).
|
|
|
|
A copy of this license with OpenSBI copyright can be found in the file
|
|
|
|
[COPYING.BSD].
|
|
|
|
|
|
|
|
All source files in OpenSBI contain the 2-Clause BSD license SPDX short
|
|
|
|
indentifier in place of the full license text.
|
|
|
|
|
|
|
|
```
|
|
|
|
SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
```
|
|
|
|
|
|
|
|
This enables machine processing of license information based on the SPDX
|
|
|
|
License Identifiers that are available on the [SPDX] web site.
|
|
|
|
|
|
|
|
OpenSBI source code also contains code reused from other projects as listed
|
|
|
|
below. The original license text of these projects is included in the source
|
|
|
|
files where the reused code is present.
|
2019-01-09 16:49:35 +08:00
|
|
|
|
2019-01-23 14:14:13 +08:00
|
|
|
1. The libfdt source code is disjunctively dual licensed
|
|
|
|
(GPL-2.0+ OR BSD-2-Clause). Some of this project code is used in OpenSBI
|
|
|
|
under the terms of the BSD 2-Clause license. Any contributions to this
|
|
|
|
code must be made under the terms of both licenses.
|
2019-01-09 16:49:35 +08:00
|
|
|
|
2019-01-23 14:14:13 +08:00
|
|
|
Contributing to OpenSBI
|
|
|
|
-----------------------
|
|
|
|
|
|
|
|
The OpenSBI project encourages and welcomes contributions. Contributions should
|
|
|
|
follow the rules described in OpenSBI [Contribution Guideline] document.
|
|
|
|
In particular, all patches sent should contain a Signed-off-by tag.
|
2019-01-09 16:49:35 +08:00
|
|
|
|
2018-12-20 20:53:52 +08:00
|
|
|
Documentation
|
|
|
|
-------------
|
|
|
|
|
2019-01-23 14:14:13 +08:00
|
|
|
Detailed documentation of various aspects of OpenSBI can be found under the
|
|
|
|
*docs* directory. The documentation covers the following topics.
|
2018-12-25 14:37:04 +08:00
|
|
|
|
2019-01-23 14:14:13 +08:00
|
|
|
* [Contribution Guideline]: Guideline for contributing code to OpenSBI project
|
|
|
|
* [Library Usage]: API documentation of OpenSBI static library *libsbi.a*
|
2019-02-07 17:11:41 +08:00
|
|
|
* [Platform Support Guide]: Guideline for implementing support for new platforms
|
2019-01-23 14:14:13 +08:00
|
|
|
* [Platform Documentation]: Documentation of the platforms currently supported.
|
|
|
|
* [Firmware Documentation]: Documentation for the different types of firmware
|
2019-02-07 17:11:41 +08:00
|
|
|
examples build supported by OpenSBI.
|
2018-12-20 20:53:52 +08:00
|
|
|
|
2019-01-23 14:14:13 +08:00
|
|
|
OpenSBI source code is also well documented. For source level documentation,
|
2019-01-21 22:14:16 +08:00
|
|
|
doxygen style is used. Please refer to [Doxygen manual] for details on this
|
2018-12-25 14:37:04 +08:00
|
|
|
format.
|
2018-12-20 20:53:52 +08:00
|
|
|
|
2019-01-23 14:14:13 +08:00
|
|
|
Doxygen can be installed on Linux distributions using *.deb* packages using
|
|
|
|
the following command.
|
2019-01-14 14:18:38 +08:00
|
|
|
```
|
|
|
|
sudo apt-get install doxygen doxygen-latex doxygen-doc doxygen-gui graphviz
|
|
|
|
```
|
|
|
|
|
2019-01-23 14:14:13 +08:00
|
|
|
For *.rpm* based Linux distributions, the following commands can be used.
|
|
|
|
```
|
|
|
|
sudo yum install doxygen doxygen-latex doxywizard graphviz
|
|
|
|
```
|
|
|
|
or
|
|
|
|
```
|
|
|
|
sudo yum install doxygen doxygen-latex doxywizard graphviz
|
|
|
|
```
|
|
|
|
|
|
|
|
To build a consolidated *refman.pdf* of all documentation, run:
|
2019-01-14 14:18:38 +08:00
|
|
|
```
|
|
|
|
make docs
|
2019-01-23 14:14:13 +08:00
|
|
|
```
|
2019-01-14 14:18:38 +08:00
|
|
|
or
|
2019-01-23 14:14:13 +08:00
|
|
|
```
|
2019-01-14 14:18:38 +08:00
|
|
|
make O=<build_directory> docs
|
|
|
|
```
|
|
|
|
|
2019-01-23 14:14:13 +08:00
|
|
|
the resulting *refman.pdf* will be available under the directory
|
|
|
|
*<build_directory>/docs/latex*. To install this file, run:
|
2019-01-14 14:18:38 +08:00
|
|
|
```
|
|
|
|
make install_docs
|
2019-01-23 14:14:13 +08:00
|
|
|
```
|
2019-01-14 14:18:38 +08:00
|
|
|
or
|
2019-01-23 14:14:13 +08:00
|
|
|
```
|
2019-01-14 14:18:38 +08:00
|
|
|
make I=<install_directory> install_docs
|
|
|
|
```
|
|
|
|
|
2019-01-23 14:14:13 +08:00
|
|
|
*refman.pdf* will be installed under *<install_directory>/docs*.
|
|
|
|
|
|
|
|
[Github]: https://github.com/riscv/riscv-sbi-doc
|
2019-02-07 17:11:41 +08:00
|
|
|
[U-Boot]: https://www.denx.de/wiki/U-Boot/SourceCode
|
2019-01-23 14:14:13 +08:00
|
|
|
[COPYING.BSD]: COPYING.BSD
|
|
|
|
[SPDX]: http://spdx.org/licenses/
|
|
|
|
[Contribution Guideline]: docs/contributing.md
|
|
|
|
[Library Usage]: docs/library_usage.md
|
2019-02-07 17:11:41 +08:00
|
|
|
[Platform Support Guide]: docs/platform_guide.md
|
2019-01-23 14:14:13 +08:00
|
|
|
[Platform Documentation]: docs/platform/platform.md
|
|
|
|
[Firmware Documentation]: docs/firmware/fw.md
|
|
|
|
[Doxygen manual]: http://www.stack.nl/~dimitri/doxygen/manual.html
|
|
|
|
|