OpenSBI provides two types of static libraries:
Implementations may choose either libsbi.a or libplatsbi.a to link with their firmware or bootloader. In the case of libsbi.a, platform-specific hooks in the form of a struct sbi_platform instance need to be provided.
The platform-specific example firmwares provided by OpenSBI are not mandatory. An implementation may choose to link the OpenSBI generic static library together with an M-mode firmware or bootloader providing the hardware-specific hooks. Since OpenSBI is a statically linked library, users must ensure that the license of these external components is compatible with the OpenSBI license.
Users have to ensure that an external firmware or bootloader linking against OpenSBI static libraries (libsbi.a or libplatsbi.a) is compiled with the same GCC target options -mabi, -march, and -mcmodel.
There are only two constraints on calling any OpenSBI library function from an external M-mode firmware or bootloader:
The most important functions from an external firmware or bootloader perspective are sbi_init() and sbi_trap_handler().
In addition to the above constraints, the external firmware or bootloader must ensure that interrupts are disabled in the MSTATUS and MIE CSRs when calling the functions sbi_init() and sbi_trap_handler().
The sbi_init() function should be called by the external firmware or bootloader for each HART that is powered-up at boot-time or in response to a CPU hotplug event.
The sbi_trap_handler() function should be called by the external firmware or bootloader to service the following interrupts and traps:
Note: external firmwares or bootloaders can be more conservative by forwarding all traps and interrupts to sbi_trap_handler().