riscv64/boot: Add same u-boot potential that arm has, drop L_DYNAMIC

* Tianocore is still in an early state for RISCV64 with a lot of work
  needed around qemu support.
* u-boot however is working, and can load EFI binaries... so follow the
  arm model for now. (EFI via u-boot, or EFI via EFI Bios)

Change-Id: I3dfde25db17b114aedce6faefc58d7556e17a46a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3176
Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
This commit is contained in:
Alexander von Gluck IV 2020-08-27 09:59:29 -05:00 committed by Alex von Gluck IV
parent fc1ace1563
commit b24dbf95d0
4 changed files with 35 additions and 11 deletions

View File

@ -132,7 +132,7 @@ for platform in [ MultiBootSubDirSetup ] {
on $(platform) {
# SD/mmc image targets
if $(TARGET_BOOT_PLATFORM) = efi {
if $(TARGET_ARCH) = arm || $(TARGET_ARCH) = arm64 {
if $(TARGET_ARCH) = arm || $(TARGET_ARCH) = arm64 || $(TARGET_ARCH) = riscv64 {
# These EFI platforms need u-boot to get them going
BuildSDImage $(HAIKU_MMC_NAME) : $(HAIKU_IMAGE)
haiku_loader.$(TARGET_BOOT_PLATFORM)

View File

@ -0,0 +1,17 @@
echo "Haiku u-boot script entry"
test -e mmc 0 uEnv.txt && setenv media mmc
test -e virtio 0 uEnv.txt && setenv media virtio
test -e nvme 0 uEnv.txt && setenv media nvme
env exists media || echo "ERROR: Unable to locate uEnv.txt on any known media!" && exit
test -e ${media} 0 uEnv.txt && fatload ${media} 0 ${scriptaddr} uEnv.txt && env import -t ${scriptaddr} ${filesize}
env exists loader || echo "ERROR: uEnv.txt doesn't specify bootloader!" && exit
env exists platform || echo "ERROR: uEnv.txt doesn't specify platform!" && exit
echo "uEnv.txt says to look for ${platform} bootloader named ${loader} on ${media} 0!"
test -e ${media} 0 ${loader} && echo "Found ${loader} on ${media} 0!"
echo "Loading bootloader..."
fatload ${media} 0 ${kernel_addr_r} ${loader}
test -e ${media} 0 haiku_floppyboot.ub && fatload ${media} 0 ${ramdisk_addr_r} haiku_floppyboot.ub
env exists dtb && echo "Using custom DTB..." && fatload ${media} 0 ${fdt_addr_r} ${dtb} && fdt addr ${fdt_addr_r}
env exists dtb || echo "Using internal DTB..." && fdt addr ${fdtcontroladdr}
test "${platform}" = "efi" && echo "Launching EFI loader..." && bootefi ${kernel_addr_r}
echo "Haiku u-boot script fell through!" && exit

View File

@ -167,13 +167,19 @@ rule BuildUImageScript script : source
LocalClean clean : $(script) ;
SCRIPTNAME on $(script) = $(script) ;
FAKEOS on $(script) = "linux" ;
ARCH on $(script) = $(TARGET_ARCH) ;
if $(TARGET_ARCH) = "riscv64" || $(TARGET_ARCH) = "riscv32" {
ARCH on $(script) = "riscv" ;
}
BuildUImageScript1 $(script) : $(source) ;
}
actions BuildUImageScript1
{
rm -f $(1)
mkimage -A $(TARGET_ARCH) -O $(FAKEOS) -T script -C none -n $(SCRIPTNAME) \
mkimage -A $(ARCH) -O $(FAKEOS) -T script -C none -n $(SCRIPTNAME) \
-d $(2) $(1)
}
@ -336,7 +342,7 @@ for platform in [ MultiBootSubDirSetup ] {
switch $(TARGET_BOOT_PLATFORM) {
case efi :
BuildEFILoader haiku_loader.$(TARGET_BOOT_PLATFORM) : boot_loader_$(TARGET_BOOT_PLATFORM) ;
if $(TARGET_ARCH) = arm || $(TARGET_ARCH) = arm64 {
if $(TARGET_ARCH) = arm || $(TARGET_ARCH) = arm64 || $(TARGET_ARCH) = riscv64 {
# These EFI platforms need u-boot to get them going
BuildUImageScript boot.scr
: [ FDirName $(HAIKU_TOP) data boot u-boot boot-$(TARGET_ARCH).scr.txt ] ;

View File

@ -45,7 +45,7 @@ coff_header:
.short 2 // nr_sections
.long 0 // TimeDateStamp
.long 0 // PointerToSymbolTable
.long 1 // NumberOfSymbols
.long 0 // NumberOfSymbols
.short section_table - optional_header // SizeOfOptionalHeader
.short 0x206 // Characteristics.
// IMAGE_FILE_DEBUG_STRIPPED |
@ -135,22 +135,23 @@ section_table:
.globl _start
_start:
/* Save boot parameters to the stack */
addi sp, sp, -16
addi sp, sp, -24
sd a0, 0(sp)
sd a1, 8(sp)
sd ra, 16(sp)
/* Run relocation */
lla a0, ImageBase
lla a1, .L_DYNAMIC
lla a1, _DYNAMIC
call _relocate
bne a0, zero, 0f
/* Call EFI code */
ld a1, 8(sp)
ld a0, 0(sp)
tail efi_main
call efi_main
2: wfi
j 2b
ld ra, 16(sp)
.L_DYNAMIC:
.word _DYNAMIC - .
0: addi sp, sp, 24
ret