From b3cd2bdfa756cb922fc35ccec3ab2d692a39bfbf Mon Sep 17 00:00:00 2001 From: Alexander von Gluck IV Date: Fri, 21 Aug 2020 18:07:33 -0500 Subject: [PATCH] riscv64: Generate a bootable EFI MMC image * mmc might be not ideal. But raw is just a single partition and anyboot is heavily x86. MMC will technically work for now to get bootable images. * floppyboot isn't used on EFI platforms, since we call two different actions, just drop floppyboot altogether on EFI SD Images. Change-Id: Idabb5483304007dd601bf8a1158036ffd24f73aa Reviewed-on: https://review.haiku-os.org/c/haiku/+/3165 Reviewed-by: Adrien Destugues --- build/jam/images/MMCImage | 18 ++++-- .../kernel/bus_managers/pci/arch/arm/Jamfile | 2 +- .../kernel/bus_managers/pci/arch/arm/pci_io.h | 22 +++---- .../bus_managers/pci/arch/riscv64/Jamfile | 10 +++ .../pci/arch/riscv64/pci_controller.cpp | 27 ++++++++ .../bus_managers/pci/arch/riscv64/pci_io.c | 61 +++++++++++++++++++ .../bus_managers/pci/arch/riscv64/pci_io.h | 11 ++++ src/system/boot/Jamfile | 5 +- 8 files changed, 134 insertions(+), 22 deletions(-) create mode 100644 src/add-ons/kernel/bus_managers/pci/arch/riscv64/Jamfile create mode 100644 src/add-ons/kernel/bus_managers/pci/arch/riscv64/pci_controller.cpp create mode 100644 src/add-ons/kernel/bus_managers/pci/arch/riscv64/pci_io.c create mode 100644 src/add-ons/kernel/bus_managers/pci/arch/riscv64/pci_io.h diff --git a/build/jam/images/MMCImage b/build/jam/images/MMCImage index 907e19f50a..b4bfff6ca8 100644 --- a/build/jam/images/MMCImage +++ b/build/jam/images/MMCImage @@ -38,6 +38,7 @@ rule BuildSDImage image : files } } +# Usage: image : loader floppyboot everything_else actions BuildUBootSDImage1 { $(RM) $(1) @@ -81,7 +82,7 @@ actions BuildUBootSDImage1 cat $(2[0]) >> $(1) } - +# Usage: image : loader everything_else actions BuildEfiSDImage1 { $(RM) $(1) @@ -110,9 +111,7 @@ actions BuildEfiSDImage1 MTOOLSRC=$(1).mtools mmd i:/EFI MTOOLSRC=$(1).mtools mmd i:/EFI/BOOT MTOOLSRC=$(1).mtools mcopy $(2[2-2]) i:/EFI/BOOT/$(EFINAME) - # Not really needed on EFI since we use EFI runtime services. - #MTOOLSRC=$(1).mtools mcopy $(2[3-3]) i:/haiku_floppyboot.ub - MTOOLSRC=$(1).mtools mcopy $(2[4-]) i: + MTOOLSRC=$(1).mtools mcopy $(2[3-]) i: MTOOLSRC=$(1).mtools mcopy uEnv.txt i: # populate fdts MTOOLSRC=$(1).mtools mmd i:/fdt @@ -133,8 +132,15 @@ for platform in [ MultiBootSubDirSetup ] { on $(platform) { # SD/mmc image targets if $(TARGET_BOOT_PLATFORM) = efi { - BuildSDImage $(HAIKU_MMC_NAME) : - $(HAIKU_IMAGE) haiku_loader.$(TARGET_BOOT_PLATFORM) haiku-floppyboot.tgz.$(TARGET_BOOT_PLATFORM) boot.scr ; + if $(TARGET_ARCH) = arm || $(TARGET_ARCH) = arm64 { + # These EFI platforms need u-boot to get them going + BuildSDImage $(HAIKU_MMC_NAME) : $(HAIKU_IMAGE) + haiku_loader.$(TARGET_BOOT_PLATFORM) + boot.scr ; + } else { + BuildSDImage $(HAIKU_MMC_NAME) : $(HAIKU_IMAGE) + haiku_loader.$(TARGET_BOOT_PLATFORM) ; + } } else { BuildSDImage $(HAIKU_MMC_NAME) : $(HAIKU_IMAGE) haiku_loader.$(TARGET_BOOT_PLATFORM) haiku-floppyboot.tgz.$(TARGET_BOOT_PLATFORM) boot.scr ; diff --git a/src/add-ons/kernel/bus_managers/pci/arch/arm/Jamfile b/src/add-ons/kernel/bus_managers/pci/arch/arm/Jamfile index 6d11b676a0..a09b7cbb37 100644 --- a/src/add-ons/kernel/bus_managers/pci/arch/arm/Jamfile +++ b/src/add-ons/kernel/bus_managers/pci/arch/arm/Jamfile @@ -1,7 +1,7 @@ SubDir HAIKU_TOP src add-ons kernel bus_managers pci arch $(TARGET_ARCH) ; SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) $(DOTDOT) ] ; -UsePrivateHeaders kernel [ FDirName kernel arch $(TARGET_ARCH) ] +UsePrivateHeaders kernel [ FDirName kernel arch $(TARGET_ARCH) ] [ FDirName kernel boot platform $(HAIKU_BOOT_PLATFORM) ] ; KernelStaticLibrary pci_arch_bus_manager : diff --git a/src/add-ons/kernel/bus_managers/pci/arch/arm/pci_io.h b/src/add-ons/kernel/bus_managers/pci/arch/arm/pci_io.h index c2aaf29028..d53afd0209 100644 --- a/src/add-ons/kernel/bus_managers/pci/arch/arm/pci_io.h +++ b/src/add-ons/kernel/bus_managers/pci/arch/arm/pci_io.h @@ -1,11 +1,11 @@ -/* - * Copyright 2009, Haiku Inc. - * All rights reserved. Distributed under the terms of the MIT License. - */ - -#ifndef PCI_BUS_MANAGER_ARM_IO_H -#define PCI_BUS_MANAGER_ARM_IO_H - -#include - -#endif // PCI_BUS_MANAGER_ARM_IO_H +/* + * Copyright 2009, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + */ + +#ifndef PCI_BUS_MANAGER_ARM_IO_H +#define PCI_BUS_MANAGER_ARM_IO_H + +#include + +#endif // PCI_BUS_MANAGER_ARM_IO_H diff --git a/src/add-ons/kernel/bus_managers/pci/arch/riscv64/Jamfile b/src/add-ons/kernel/bus_managers/pci/arch/riscv64/Jamfile new file mode 100644 index 0000000000..a09b7cbb37 --- /dev/null +++ b/src/add-ons/kernel/bus_managers/pci/arch/riscv64/Jamfile @@ -0,0 +1,10 @@ +SubDir HAIKU_TOP src add-ons kernel bus_managers pci arch $(TARGET_ARCH) ; + +SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) $(DOTDOT) ] ; +UsePrivateHeaders kernel [ FDirName kernel arch $(TARGET_ARCH) ] + [ FDirName kernel boot platform $(HAIKU_BOOT_PLATFORM) ] ; + +KernelStaticLibrary pci_arch_bus_manager : + pci_controller.cpp + pci_io.c +; diff --git a/src/add-ons/kernel/bus_managers/pci/arch/riscv64/pci_controller.cpp b/src/add-ons/kernel/bus_managers/pci/arch/riscv64/pci_controller.cpp new file mode 100644 index 0000000000..91f81c0169 --- /dev/null +++ b/src/add-ons/kernel/bus_managers/pci/arch/riscv64/pci_controller.cpp @@ -0,0 +1,27 @@ +/* + * Copyright 2009-2020, Haiku Inc., All rights reserved. + * Distributed under the terms of the MIT License. + */ + + +#include "pci_controller.h" + +//#include + +#include "pci_private.h" + + +status_t +pci_controller_init(void) +{ + /* no support yet */ +#warning RISCV64: WRITEME + return B_OK; +} + + +phys_addr_t +pci_ram_address(phys_addr_t physical_address_in_system_memory) +{ + return physical_address_in_system_memory; +} diff --git a/src/add-ons/kernel/bus_managers/pci/arch/riscv64/pci_io.c b/src/add-ons/kernel/bus_managers/pci/arch/riscv64/pci_io.c new file mode 100644 index 0000000000..79738743dd --- /dev/null +++ b/src/add-ons/kernel/bus_managers/pci/arch/riscv64/pci_io.c @@ -0,0 +1,61 @@ +/* + * Copyright 2009-2020, Haiku Inc., All rights reserved. + * Distributed under the terms of the MIT License. + */ + + +#include "pci_io.h" +#include "pci_private.h" +#warning RISCV64: WRITEME + + +status_t +pci_io_init() +{ + return B_OK; +} + + +uint8 +pci_read_io_8(int mapped_io_addr) +{ + /* NOT IMPLEMENTED */ + return 0; +} + + +void +pci_write_io_8(int mapped_io_addr, uint8 value) +{ + /* NOT IMPLEMENTED */ +} + + +uint16 +pci_read_io_16(int mapped_io_addr) +{ + /* NOT IMPLEMENTED */ + return 0; +} + + +void +pci_write_io_16(int mapped_io_addr, uint16 value) +{ + /* NOT IMPLEMENTED */ +} + + +uint32 +pci_read_io_32(int mapped_io_addr) +{ + /* NOT IMPLEMENTED */ + return 0; +} + + +void +pci_write_io_32(int mapped_io_addr, uint32 value) +{ + /* NOT IMPLEMENTED */ +} diff --git a/src/add-ons/kernel/bus_managers/pci/arch/riscv64/pci_io.h b/src/add-ons/kernel/bus_managers/pci/arch/riscv64/pci_io.h new file mode 100644 index 0000000000..5fa319961b --- /dev/null +++ b/src/add-ons/kernel/bus_managers/pci/arch/riscv64/pci_io.h @@ -0,0 +1,11 @@ +/* + * Copyright 2009-2020, Haiku Inc., All rights reserved. + * Distributed under the terms of the MIT License. + */ + +#ifndef PCI_BUS_MANAGER_RISCV64_IO_H +#define PCI_BUS_MANAGER_RISCV64_IO_H + +#include + +#endif // PCI_BUS_MANAGER_RISCV64_IO_H diff --git a/src/system/boot/Jamfile b/src/system/boot/Jamfile index f0bd545b83..84f2ca8f53 100644 --- a/src/system/boot/Jamfile +++ b/src/system/boot/Jamfile @@ -337,10 +337,7 @@ for platform in [ MultiBootSubDirSetup ] { case efi : BuildEFILoader haiku_loader.$(TARGET_BOOT_PLATFORM) : boot_loader_$(TARGET_BOOT_PLATFORM) ; if $(TARGET_ARCH) = arm || $(TARGET_ARCH) = arm64 { - # These platforms sometimes need u-boot to get them going - BuildUImage haiku-floppyboot.tgz.$(TARGET_BOOT_PLATFORM) : haiku-floppyboot.tgz : - -A $(TARGET_ARCH) -O linux -T ramdisk -C none - -n 'Haiku $(TARGET_KERNEL_ARCH) floppyboot' ; + # 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 ] ; }