]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Handle load from loader(8)
authormhorne <mhorne@FreeBSD.org>
Wed, 24 Jun 2020 15:20:00 +0000 (15:20 +0000)
committermhorne <mhorne@FreeBSD.org>
Wed, 24 Jun 2020 15:20:00 +0000 (15:20 +0000)
commit39ad001797e54b31c8ff06ddd573a36dc6f8db68
tree520408a90c591f58735687cec902b3e6c4e26cd6
parent199d753342e0ff436056a61404c86a0e87eea298
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