From 115ac6bcaebba8001e476265d74cc2aa34e8c65b Mon Sep 17 00:00:00 2001 From: Alexander von Gluck IV Date: Sat, 28 Mar 2015 16:56:38 -0500 Subject: [PATCH] arm/mailbox: Load mailbox base from FDT in loader --- src/system/boot/platform/u-boot/arch/arm/Jamfile | 1 + .../platform/u-boot/arch/arm/arch_mailbox.cpp | 8 ++++++-- src/system/boot/platform/u-boot/start.cpp | 15 +++++++++------ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/system/boot/platform/u-boot/arch/arm/Jamfile b/src/system/boot/platform/u-boot/arch/arm/Jamfile index 620056b206..7463dc9a49 100644 --- a/src/system/boot/platform/u-boot/arch/arm/Jamfile +++ b/src/system/boot/platform/u-boot/arch/arm/Jamfile @@ -4,6 +4,7 @@ SubDirHdrs $(HAIKU_TOP) src system boot platform $(TARGET_BOOT_PLATFORM) ; SubDirHdrs $(HAIKU_TOP) src system boot arch $(TARGET_KERNEL_ARCH) ; 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) ] ; 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 418dffc5dc..dc9c5b8bfa 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 @@ -11,16 +11,20 @@ #include +#include "fdt_support.h" ArchMailbox *gMailbox = NULL; - +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); - gMailbox = arch_get_mailbox_arm_bcm2835(DEVICE_BASE + ARM_CTRL_0_MAILBOX_BASE); + phys_addr_t mboxBase = fdt_get_device_reg_byname(gFDT, "/axi/mbox"); + if (mboxBase) { + gMailbox = arch_get_mailbox_arm_bcm2835(mboxBase); + } #endif return B_OK; } diff --git a/src/system/boot/platform/u-boot/start.cpp b/src/system/boot/platform/u-boot/start.cpp index 2a0aba9104..c86bc9bd72 100644 --- a/src/system/boot/platform/u-boot/start.cpp +++ b/src/system/boot/platform/u-boot/start.cpp @@ -217,16 +217,17 @@ start_gen(int argc, const char **argv, struct image_header *uimage, void *fdt) // We have to cpu_init *before* calling FDT functions cpu_init(); + serial_init(gFDT); + #if defined(__ARM__) arch_mailbox_init(); #endif - console_init(); - serial_init(gFDT); - // initialize the OpenFirmware wrapper of_init(NULL); + console_init(); + // if we get passed an FDT, check /chosen for initrd and bootargs if (gFDT != NULL) { int node = fdt_path_offset(gFDT, "/chosen"); @@ -267,9 +268,10 @@ start_gen(int argc, const char **argv, struct image_header *uimage, void *fdt) dprintf("argv[%d] @%lx = '%s'\n", i, (uint32)argv[i], argv[i]); dprintf("os: %d\n", (int)gUBootOS); dprintf("gd @ %p\n", gUBootGlobalData); - if (gUBootGlobalData) + if (gUBootGlobalData) { dprintf("gd->bd @ %p\n", gUBootGlobalData->bd); - //dprintf("fb_base %p\n", (void*)gUBootGlobalData->fb_base); + dprintf("gd->fb_base @ %p\n", (void*)gUBootGlobalData->fb_base); + } if (gUImage) dump_uimage(gUImage); if (gFDT) @@ -283,6 +285,7 @@ start_gen(int argc, const char **argv, struct image_header *uimage, void *fdt) // save the size of the FDT so we can map it easily after mmu_init size_t fdtSize = gFDT ? fdt_totalsize(gFDT) : 0; + dprintf("fdtSize: 0x%" B_PRIxSIZE "\n", fdtSize); mmu_init(); @@ -314,7 +317,7 @@ start_gen(int argc, const char **argv, struct image_header *uimage, void *fdt) args.arguments_count = 1; } } - dprintf("args.arguments_count = %d\n", args.arguments_count); + dprintf("args.arguments_count = %" B_PRId32 "\n", args.arguments_count); for (int i = 0; i < args.arguments_count; i++) dprintf("args.arguments[%d] @%lx = '%s'\n", i, (uint32)args.arguments[i], args.arguments[i]);