f7d2df2a8a
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