mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2026-09-20 15:21:42 +01:00
Add a fixed 128-byte header at the very beginning of every OpenSBI
firmware image, regardless of the firmware type. The header lets the
previous booting stage identify an OpenSBI image and, more importantly,
gives it a well-known place inside the image to hand over information
to OpenSBI by patching a few words instead of setting up registers.
This first patch only introduces the layout:
- a 4-byte jump over the header to _start_real, so that _start stays
the entry point of the image. The jump is assembled with
'.option norvc' so that the fields behind it are always at a fixed
offset, even for a build with compressed instructions enabled,
- the 'OSBI' magic, a header version, the XLEN the firmware was built
for and the size of the firmware image, so that the previous booting
stage can validate the image and figure out how much memory it
occupies,
- a flags word and three 8-byte override values, which are unused
(and zero) for now and are wired up by the next patch.
The layout is deliberately identical for RV32 and RV64 so that the
previous booting stage can parse the header without knowing the XLEN of
the firmware upfront. Each override value is followed by a reserved
8-byte slot so that the same layout can be extended to RV128 later.
Suggested-by: Anup Patel <anup@brainfault.org>
Signed-off-by: Zong Li <zong.li@sifive.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260918081313.659655-2-zong.li@sifive.com
Signed-off-by: Anup Patel <anup@brainfault.org>