[PATCH v2 0/3] Support OpenSBI firmware header
Anup Patel
anup at brainfault.org
Fri Sep 18 04:28:59 PDT 2026
On Fri, Sep 18, 2026 at 1:43 PM Zong Li <zong.li at sifive.com> wrote:
>
> This series adds OpenSBI firmware header. The motivation is when a
> system where the previous booting stage runs on a dedicated boot
> processor, it can load and patch the OpenSBI image in DRAM and then
> release the application hart that runs OpenSBI, but it can never execute
> on that hart and therefore cannot place anything in its registers, such
> as $a0, $a1 and $a2
>
> Every OpenSBI firmware image, regardless of its type (FW_DYNAMIC,
> FW_JUMP or FW_PAYLOAD), starts with a fixed 128-byte header. The header
> serves two purposes:
>
> 1. it lets the previous booting stage recognize an OpenSBI firmware
> image and find out what it was built for, and
> 2. it gives the previous booting stage a well-known place inside the
> image to hand over the boot arguments by patching a few words,
> instead of setting up the *a0*, *a1* and *a2* registers.
>
> This series also provides a document 'docs/firmware/fw_header.md' to
> describe the layout of the 128-byte OpenSBI firmware header, the
> a0/a1/a2 override flags, what a previous booting stage is expected to put
> in each register, and an example of how to patch the header.
>
> Thanks Anup for discussing it and providing the ideas
>
> Changed in v1:
> - Remove _fw_header_override_a0
> - Use mhartid for a0 when FW_HEADER_FLAGS_OVERRIDE_A0 is set
> - Update fw.md for the changes above
>
> Zong Li (3):
> firmware: fw_base.S: add a formatted OpenSBI firmware header
> firmware: fw_base.S: override a0, a1 and a2 from the firmware header
> docs: firmware: document the OpenSBI firmware header
>
> docs/firmware/fw.md | 9 +++
> docs/firmware/fw_header.md | 137 +++++++++++++++++++++++++++++++++++++
> firmware/fw_base.S | 94 +++++++++++++++++++++++++
> 3 files changed, 240 insertions(+)
> create mode 100644 docs/firmware/fw_header.md
>
> --
> 2.43.7
>
LGTM.
Reviewed-by: Anup Patel <anup at brainfault.org>
Applied this series to the riscv/opensbi repo.
Thanks,
Anup
More information about the opensbi
mailing list