[haiku-commits] haiku: hrev48904 - src/system/kernel/platform/u-boot src/system/boot/arch/arm headers/private/kernel/platform/u-boot src/system/boot/platform/u-boot

  • From: kallisti5@xxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 14 Mar 2015 15:50:48 +0100 (CET)

hrev48904 adds 1 changeset to branch 'master'
old head: cb4b4bc11571d6fb5ac6ac90bc4298df470ec7b5
new head: f121867b877df03246ef7c4ca3f168a17f2395a9
overview: 
http://cgit.haiku-os.org/haiku/log/?qt=range&q=f121867b877d+%5Ecb4b4bc11571

----------------------------------------------------------------------------

f121867b877d: arm/fdt: Initial reorg of fdt support code
  
  * Makes FDT support code useable by everyone
    without all of the externs
  * Further movement to be non-u-boot centic
    may still happen.

                          [ Alexander von Gluck IV <kallisti5@xxxxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev48904
Commit:      f121867b877df03246ef7c4ca3f168a17f2395a9
URL:         http://cgit.haiku-os.org/haiku/commit/?id=f121867b877d
Author:      Alexander von Gluck IV <kallisti5@xxxxxxxxxxx>
Date:        Sat Mar 14 14:50:46 2015 UTC

----------------------------------------------------------------------------

7 files changed, 80 insertions(+), 43 deletions(-)
.../private/kernel/platform/u-boot/fdt_support.h | 21 ++++++++
src/system/boot/arch/arm/Jamfile                 |  2 +
src/system/boot/arch/arm/arch_mmu.cpp            | 39 +-------------
src/system/boot/platform/u-boot/Jamfile          |  1 +
src/system/boot/platform/u-boot/start.cpp        |  2 +-
src/system/kernel/platform/u-boot/Jamfile        |  2 +
.../kernel/platform/u-boot/fdt_support.cpp       | 56 ++++++++++++++++++--

----------------------------------------------------------------------------

diff --git a/headers/private/kernel/platform/u-boot/fdt_support.h 
b/headers/private/kernel/platform/u-boot/fdt_support.h
new file mode 100644
index 0000000..4427f33
--- /dev/null
+++ b/headers/private/kernel/platform/u-boot/fdt_support.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2012-2015, Haiku, Inc.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors
+ *             Alexander von Gluck IV, kallisti5@xxxxxxxxxxx
+ */
+#ifndef __FDT_SUPPORT_H
+#define __FDT_SUPPORT_H
+
+
+#include <KernelExport.h>
+
+
+void dump_fdt(const void *fdt);
+status_t fdt_get_cell_count(int32 pathOffset,
+       int32 &addressCells, int32 &sizeCells);
+
+
+
+#endif /*__FDT_SUPPORT_H*/
diff --git a/src/system/boot/arch/arm/Jamfile b/src/system/boot/arch/arm/Jamfile
index e49296b..bea3428 100644
--- a/src/system/boot/arch/arm/Jamfile
+++ b/src/system/boot/arch/arm/Jamfile
@@ -1,5 +1,7 @@
 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 c72c26b..b2469f8 100644
--- a/src/system/boot/arch/arm/arch_mmu.cpp
+++ b/src/system/boot/arch/arm/arch_mmu.cpp
@@ -23,6 +23,8 @@
 
 #include <string.h>
 
+#include "fdt_support.h"
+
 extern "C" {
 #include <fdt.h>
 #include <libfdt.h>
@@ -580,43 +582,6 @@ mmu_init_for_kernel(void)
 }
 
 
-static status_t
-fdt_get_cell_count(int32 pathOffset, int32 &addressCells, int32 &sizeCells)
-{
-       // It would be nice if libfdt provided this.
-
-       // Memory base addresses are provided in 32 or 64 bit flavors
-       // #address-cells and #size-cells matches the number of 32-bit 'cells'
-       // representing the length of the base address and size fields
-
-       // TODO: assert !gFDT || !pathOffset?
-
-       int len;
-       if (!pathOffset) {
-               TRACE(("%s: Invalid FDT pathOffset provided!\n", __func__));
-               return B_ERROR;
-       }
-
-       const void *prop;
-       prop = fdt_getprop(gFDT, pathOffset, "#address-cells", &len);
-       if (prop && len == sizeof(uint32))
-               addressCells = fdt32_to_cpu(*(uint32_t *)prop);
-       prop = fdt_getprop(gFDT, pathOffset, "#size-cells", &len);
-       if (prop && len == sizeof(uint32))
-               sizeCells = fdt32_to_cpu(*(uint32_t *)prop);
-
-       // NOTE : Cells over 2 is possible in theory... 
-       if (addressCells > 2 || sizeCells > 2) {
-               panic("%s: Unsupported FDT cell count detected.\n"
-                       "Address Cells: %" B_PRId32 "; Size Cells: %" B_PRId32
-                       " (CPU > 64bit?).\n", __func__, addressCells, 
sizeCells);
-               return B_ERROR;
-       }
-
-       return B_OK;
-}
-
-
 //TODO:move this to generic/ ?
 static status_t
 find_physical_memory_ranges(uint64 &total)
diff --git a/src/system/boot/platform/u-boot/Jamfile 
b/src/system/boot/platform/u-boot/Jamfile
index a7bddfc..cd55c24 100644
--- a/src/system/boot/platform/u-boot/Jamfile
+++ b/src/system/boot/platform/u-boot/Jamfile
@@ -1,6 +1,7 @@
 SubDir HAIKU_TOP src system boot platform u-boot ;
 
 SubDirHdrs $(HAIKU_TOP) headers private kernel boot platform 
$(TARGET_BOOT_PLATFORM) ;
+SubDirHdrs $(HAIKU_TOP) headers private kernel platform 
$(TARGET_BOOT_PLATFORM) ;
 
 SubDirHdrs $(HAIKU_TOP) src system boot arch $(TARGET_KERNEL_ARCH) ;
 
diff --git a/src/system/boot/platform/u-boot/start.cpp 
b/src/system/boot/platform/u-boot/start.cpp
index b9faf9f..b459782 100644
--- a/src/system/boot/platform/u-boot/start.cpp
+++ b/src/system/boot/platform/u-boot/start.cpp
@@ -7,6 +7,7 @@
 #include "serial.h"
 #include "console.h"
 #include "cpu.h"
+#include "fdt_support.h"
 #include "mmu.h"
 #include "smp.h"
 #include "uimage.h"
@@ -59,7 +60,6 @@ extern "C" void _start(void);
 extern "C" int start_gen(int argc, const char **argv,
        struct image_header *uimage=NULL, void *fdt=NULL);
 extern "C" void dump_uimage(struct image_header *image);
-extern "C" void dump_fdt(const void *fdt);
 #if defined(__ARM__)
 extern "C" status_t arch_mailbox_init();
 #endif
diff --git a/src/system/kernel/platform/u-boot/Jamfile 
b/src/system/kernel/platform/u-boot/Jamfile
index 4cfa6e4..a46b7b9 100644
--- a/src/system/kernel/platform/u-boot/Jamfile
+++ b/src/system/kernel/platform/u-boot/Jamfile
@@ -1,5 +1,7 @@
 SubDir HAIKU_TOP src system kernel platform u-boot ;
 
+SubDirHdrs $(HAIKU_TOP) headers private kernel platform 
$(TARGET_BOOT_PLATFORM) ;
+
 SubDirCcFlags $(TARGET_KERNEL_PIC_CCFLAGS) ;
 SubDirC++Flags $(TARGET_KERNEL_PIC_CCFLAGS) ;
 
diff --git a/src/system/kernel/platform/u-boot/fdt_support.cpp 
b/src/system/kernel/platform/u-boot/fdt_support.cpp
index d917f0b..2c0f8ea 100644
--- a/src/system/kernel/platform/u-boot/fdt_support.cpp
+++ b/src/system/kernel/platform/u-boot/fdt_support.cpp
@@ -3,6 +3,8 @@
  * Distributed under the terms of the MIT License.
  */
 
+#include "fdt_support.h"
+
 #include <KernelExport.h>
 #include <ByteOrder.h>
 #include <ctype.h>
@@ -15,13 +17,13 @@ extern "C" {
 #include <libfdt_env.h>
 };
 
-#ifndef _BOOT_MODE
-/* the bootloader has it in asm code to avoid it ending up in .bss */
-void *gFDT;
+//#define TRACE_FDT
+#ifdef TRACE_FDT
+#   define TRACE(x) dprintf x
+#else
+#   define TRACE(x) ;
 #endif
 
-extern "C" void dump_fdt(const void *fdt);
-
 //#define FDT_DUMP_NODES
 //#define FDT_DUMP_PROPS
 //#define FDT_DUMP_PROP_VALUES
@@ -34,6 +36,14 @@ static const char *sTabTab = 
"\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
 #endif
 
 
+#ifndef _BOOT_MODE
+/* the bootloader has it in asm code to avoid it ending up in .bss */
+void *gFDT;
+#else
+extern void *gFDT;
+#endif
+
+
 #ifdef FDT_DUMP_PROP_VALUES
 static void dump_hex(const char *data, int32 len, int depth)
 {
@@ -116,3 +126,39 @@ void dump_fdt(const void *fdt)
 #endif
 }
 
+
+status_t
+fdt_get_cell_count(int32 pathOffset, int32 &addressCells, int32 &sizeCells)
+{
+       // It would be nice if libfdt provided this.
+
+       // Memory base addresses are provided in 32 or 64 bit flavors
+       // #address-cells and #size-cells matches the number of 32-bit 'cells'
+       // representing the length of the base address and size fields
+
+       // TODO: assert !gFDT || !pathOffset?
+
+       int len;
+       if (!pathOffset) {
+               TRACE(("%s: Invalid FDT pathOffset provided!\n", __func__));
+               return B_ERROR;
+       }
+
+       const void *prop;
+       prop = fdt_getprop(gFDT, pathOffset, "#address-cells", &len);
+       if (prop && len == sizeof(uint32))
+               addressCells = fdt32_to_cpu(*(uint32_t *)prop);
+       prop = fdt_getprop(gFDT, pathOffset, "#size-cells", &len);
+       if (prop && len == sizeof(uint32))
+               sizeCells = fdt32_to_cpu(*(uint32_t *)prop);
+
+       // NOTE : Cells over 2 is possible in theory... 
+       if (addressCells > 2 || sizeCells > 2) {
+               panic("%s: Unsupported FDT cell count detected.\n"
+                       "Address Cells: %" B_PRId32 "; Size Cells: %" B_PRId32
+                       " (CPU > 64bit?).\n", __func__, addressCells, 
sizeCells);
+               return B_ERROR;
+       }
+
+       return B_OK;
+}


Other related posts:

  • » [haiku-commits] haiku: hrev48904 - src/system/kernel/platform/u-boot src/system/boot/arch/arm headers/private/kernel/platform/u-boot src/system/boot/platform/u-boot - kallisti5