]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Handle load from loader(8)
authorMitchell Horne <mhorne@FreeBSD.org>
Wed, 24 Jun 2020 15:20:00 +0000 (15:20 +0000)
committerMitchell Horne <mhorne@FreeBSD.org>
Wed, 24 Jun 2020 15:20:00 +0000 (15:20 +0000)
commitf7d2df2a8ae96a7158a4b0fbbd48011757155a9e
tree520408a90c591f58735687cec902b3e6c4e26cd6
parent27b3db97099344c0d8ee13510f493034836f93ed
Handle load from loader(8)

In locore, we must detect and handle different arguments passed by
loader(8) compared to what we recieve when booting directly via SBI
firmware. Currently we receive the hart ID in a0 and a pointer to the
device tree blob in a1. loader(8) provides only a pointer to its
metadata in a0.

The solution to this is to add an additional entry point, _alt_start.
This will be placed first in the .text section, so SBI firmware will
enter here, and jump to the common pagetable setup shortly after. Since
loader(8) understands our ELF kernel, it will enter at the ELF's entry
address, which points to _start. This approach leads to very little
guesswork as to which way we booted.

Fix-up initriscv() to parse the loader's metadata, continuing to use
fake_preload_metadata() in the SBI direct boot case.

Reviewed by: markj, jrtc27 (asm portion)
Differential Revision: https://reviews.freebsd.org/D24912
sys/riscv/include/machdep.h
sys/riscv/riscv/genassym.c
sys/riscv/riscv/locore.S
sys/riscv/riscv/machdep.c