From e40cea64bdee754f86920a53239e5fa7aec8cc6c Mon Sep 17 00:00:00 2001 From: Alexander von Gluck IV Date: Sun, 9 Jul 2017 22:51:50 -0500 Subject: [PATCH] u-boot/arm: Initial steps to drop target board requirements --- build/jam/ArchitectureRules | 51 ++++--------------- src/system/boot/arch/arm/Jamfile | 1 - src/system/boot/arch/arm/arch_mmu.cpp | 6 +-- .../boot/platform/u-boot/arch/arm/Jamfile | 1 - .../platform/u-boot/arch/arm/arch_mailbox.cpp | 11 ++-- .../boot/platform/u-boot/arch/ppc/Jamfile | 1 + src/system/boot/platform/u-boot/serial.cpp | 14 +---- src/system/boot/platform/u-boot/start.cpp | 1 - src/system/boot/platform/u-boot/video.cpp | 3 +- src/system/kernel/arch/arm/arch_uart_8250.cpp | 3 +- 10 files changed, 22 insertions(+), 70 deletions(-) diff --git a/build/jam/ArchitectureRules b/build/jam/ArchitectureRules index e0528fdfc0..706e61d552 100644 --- a/build/jam/ArchitectureRules +++ b/build/jam/ArchitectureRules @@ -233,48 +233,8 @@ rule KernelArchitectureSetup architecture HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET = 192 ; # in kB - unused yet case arm : - switch $(HAIKU_BOOT_BOARD) { - case beagleboard : - { - HAIKU_BOOT_PLATFORM ?= u-boot ; - HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 1440 ; - } - case beaglebone : - { - HAIKU_BOOT_PLATFORM ?= u-boot ; - HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 1440 ; - } - case neo_freerunner : - { - HAIKU_BOOT_PLATFORM ?= u-boot ; - HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 1440 ; - } - case overo : - { - HAIKU_BOOT_PLATFORM ?= u-boot ; - HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 1440 ; - } - case rpi2 : - { - HAIKU_BOOT_PLATFORM ?= u-boot ; - HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 1440 ; - } - case cubieboard4 : - { - HAIKU_BOOT_PLATFORM ?= u-boot ; - HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 1440 ; - } - case verdex : - { - HAIKU_BOOT_PLATFORM ?= u-boot ; - HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 1440 ; - } - case * : - { - Exit "Set HAIKU_BOOT_BOARD for your target ARM device!" ; - } - } - + HAIKU_BOOT_PLATFORM ?= u-boot ; + HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 1440 ; # offset in floppy image (>= sizeof(haiku_loader)) HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET = 192 ; # in kB - unused yet @@ -376,6 +336,13 @@ rule KernelArchitectureSetup architecture } switch $(cpu) { + case arm : + # Workaround for ld using 32k for alignment despite forcing it in the config... + # should definitely not be needed! + HAIKU_KERNEL_LINKFLAGS += + -Wl,-z -Wl,max-page-size=0x1000 + -Wl,-z -Wl,common-page-size=0x1000 ; + case ppc : # Build a position independent PPC kernel. We need to be able to # relocate the kernel, since the virtual address space layout at diff --git a/src/system/boot/arch/arm/Jamfile b/src/system/boot/arch/arm/Jamfile index c03776717b..d65f88ecab 100644 --- a/src/system/boot/arch/arm/Jamfile +++ b/src/system/boot/arch/arm/Jamfile @@ -3,7 +3,6 @@ SubDir HAIKU_TOP src system boot arch arm ; UsePrivateHeaders [ FDirName kernel platform $(TARGET_BOOT_PLATFORM) ] ; #XXX: should not be needed here -UsePrivateHeaders [ FDirName kernel arch $(TARGET_KERNEL_ARCH) board $(TARGET_BOOT_BOARD) ] ; UseLibraryHeaders [ FDirName libfdt ] ; { diff --git a/src/system/boot/arch/arm/arch_mmu.cpp b/src/system/boot/arch/arm/arch_mmu.cpp index 4ffa3dd25d..fe35bc76e8 100644 --- a/src/system/boot/arch/arm/arch_mmu.cpp +++ b/src/system/boot/arch/arm/arch_mmu.cpp @@ -17,8 +17,6 @@ #include #include -#include - #include #include @@ -88,13 +86,16 @@ struct memblock { }; +#warning TODO: Plot pref. base from fdt! static struct memblock LOADER_MEMORYMAP[] = { +/* { "devices", DEVICE_BASE, DEVICE_BASE + DEVICE_SIZE - 1, ARM_MMU_L2_FLAG_B, }, +*/ { "RAM_kernel", // 8MB space for kernel, drivers etc KERNEL_LOAD_BASE, @@ -112,7 +113,6 @@ static struct memblock LOADER_MEMORYMAP[] = { #endif }; - //static const uint32 kDefaultPageTableFlags = MMU_FLAG_READWRITE; // not cached not buffered, R/W diff --git a/src/system/boot/platform/u-boot/arch/arm/Jamfile b/src/system/boot/platform/u-boot/arch/arm/Jamfile index 8a7939a5f1..8765581c31 100644 --- a/src/system/boot/platform/u-boot/arch/arm/Jamfile +++ b/src/system/boot/platform/u-boot/arch/arm/Jamfile @@ -7,7 +7,6 @@ UsePrivateSystemHeaders ; UsePrivateHeaders kernel [ FDirName kernel platform u-boot ] ; UsePrivateHeaders kernel [ FDirName kernel arch $(TARGET_KERNEL_ARCH) ] [ FDirName kernel boot platform $(HAIKU_BOOT_PLATFORM) ] ; -UsePrivateHeaders [ FDirName kernel arch $(TARGET_KERNEL_ARCH) board $(TARGET_BOOT_BOARD) ] ; SubDirC++Flags -fno-rtti ; diff --git a/src/system/boot/platform/u-boot/arch/arm/arch_mailbox.cpp b/src/system/boot/platform/u-boot/arch/arm/arch_mailbox.cpp index dc9c5b8bfa..19ecd91f35 100644 --- a/src/system/boot/platform/u-boot/arch/arm/arch_mailbox.cpp +++ b/src/system/boot/platform/u-boot/arch/arm/arch_mailbox.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 Haiku, Inc. All rights reserved. + * Copyright 2012-2016 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -9,8 +9,6 @@ #include "arch_mailbox.h" -#include - #include "fdt_support.h" ArchMailbox *gMailbox = NULL; @@ -19,12 +17,11 @@ extern void* gFDT; extern "C" status_t arch_mailbox_init() { - #if defined(BOARD_CPU_BCM2835) || defined(BOARD_CPU_BCM2836) extern ArchMailbox *arch_get_mailbox_arm_bcm2835(addr_t base); phys_addr_t mboxBase = fdt_get_device_reg_byname(gFDT, "/axi/mbox"); - if (mboxBase) { - gMailbox = arch_get_mailbox_arm_bcm2835(mboxBase); + if (!mboxBase) { + return B_ERROR; } - #endif + gMailbox = arch_get_mailbox_arm_bcm2835(mboxBase); return B_OK; } diff --git a/src/system/boot/platform/u-boot/arch/ppc/Jamfile b/src/system/boot/platform/u-boot/arch/ppc/Jamfile index d7dbefb5d2..8c6361ef30 100644 --- a/src/system/boot/platform/u-boot/arch/ppc/Jamfile +++ b/src/system/boot/platform/u-boot/arch/ppc/Jamfile @@ -4,6 +4,7 @@ SubDirHdrs $(HAIKU_TOP) src system boot platform $(TARGET_BOOT_PLATFORM) ; UsePrivateSystemHeaders ; UsePrivateHeaders kernel [ FDirName kernel arch $(TARGET_KERNEL_ARCH) ] [ FDirName kernel boot platform $(HAIKU_BOOT_PLATFORM) ] ; + UsePrivateHeaders [ FDirName kernel arch $(TARGET_KERNEL_ARCH) board $(TARGET_BOOT_BOARD) ] ; UseLibraryHeaders [ FDirName libfdt ] ; diff --git a/src/system/boot/platform/u-boot/serial.cpp b/src/system/boot/platform/u-boot/serial.cpp index fd57e86687..e78c5af4f0 100644 --- a/src/system/boot/platform/u-boot/serial.cpp +++ b/src/system/boot/platform/u-boot/serial.cpp @@ -19,7 +19,6 @@ #include #endif -#include #include #include #include @@ -124,17 +123,8 @@ serial_init(const void *fdt) // first try with hints from the FDT gUART = debug_uart_from_fdt(fdt); - // fallback to known board UARTs - #if defined(BOARD_UART_DEBUG) && defined(BOARD_UART_CLOCK) - if (gUART == NULL) { - #ifdef BOARD_UART_PL011 - gUART = arch_get_uart_pl011(BOARD_UART_DEBUG, BOARD_UART_CLOCK); - #else - gUART = arch_get_uart_8250(BOARD_UART_DEBUG, BOARD_UART_CLOCK); - #endif - } - #endif - + // Do we can some kind of direct fallback here + // (aka, guess arch_get_uart_pl011 or arch_get_uart_8250?) if (gUART == NULL) return; diff --git a/src/system/boot/platform/u-boot/start.cpp b/src/system/boot/platform/u-boot/start.cpp index 07776176c0..a631076cdf 100644 --- a/src/system/boot/platform/u-boot/start.cpp +++ b/src/system/boot/platform/u-boot/start.cpp @@ -20,7 +20,6 @@ #include #include #include -#include #include diff --git a/src/system/boot/platform/u-boot/video.cpp b/src/system/boot/platform/u-boot/video.cpp index babb638946..1c245f439a 100644 --- a/src/system/boot/platform/u-boot/video.cpp +++ b/src/system/boot/platform/u-boot/video.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include #include @@ -104,6 +103,8 @@ platform_switch_to_text_mode(void) extern "C" status_t platform_init_video(void) { + +#warning TODO: Fix u-boot arm framebuffer location from fdt! #ifdef __ARM__ #if defined(BOARD_CPU_ARM920T) extern ArchFramebuffer *arch_get_fb_arm_920(addr_t base); diff --git a/src/system/kernel/arch/arm/arch_uart_8250.cpp b/src/system/kernel/arch/arm/arch_uart_8250.cpp index aa8fb1e7ee..ef3d06d0e7 100644 --- a/src/system/kernel/arch/arm/arch_uart_8250.cpp +++ b/src/system/kernel/arch/arm/arch_uart_8250.cpp @@ -9,7 +9,6 @@ #include #include -#include #include #include @@ -42,7 +41,7 @@ void ArchUART8250::InitEarly() { // Perform special hardware UART configuration - +#warning TODO: Detect OMAP3 from fdt! #if BOARD_CPU_OMAP3 /* UART1 */ RMWREG32(CM_FCLKEN1_CORE, 13, 1, 1);