[haiku-commits] haiku: hrev48200 - src/system/boot/arch/arm build/jam/board/overo src/system/boot/platform/u-boot src/system/boot/platform/u-boot/arch/arm

  • From: revol@xxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 1 Nov 2014 18:56:13 +0100 (CET)

hrev48200 adds 4 changesets to branch 'master'
old head: 5de5d59d785643fc6dacf2690eadf5890bdb0307
new head: 92fcf262ff40fce289b97998cbde6082314ce1e3
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=92fcf26+%5E5de5d59

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

d1ebf97: U-Boot: ARM: Add a linux entry point to asm shell code
  
  While the NetBSD entry point is handy as we can use a single uImage
  with all 3 blobs, it bypasses U-Boot's own patching of the FDT since
  it's not visible to it, so we won't get the RAM size and other things
  through it.

8d8bda0: U-Boot: generate a separate uImage for the boot tgz as well
  
  We need this when using the linux entry point.

49bb4c4: ARM: overo: Use the linux entry point version of the loader
  
  And load the boot tgz and FDT separately from the SD card.
  
  Hopefully U-Boot will now report available RAM size.

92fcf26: ARM: Check for RAM size in FDT
  
  We skip the check when we already have ranges inserted,
  like from the raspberry Pi start code, and we fall back to
  32MB at SDRAM_BASE is not found.

                                          [ François Revol <revol@xxxxxxx> ]

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

6 files changed, 133 insertions(+), 6 deletions(-)
build/jam/board/overo/BoardSetup                 |  10 +-
src/system/boot/arch/arm/Jamfile                 |   1 +
src/system/boot/arch/arm/arch_mmu.cpp            | 110 +++++++++++++++++++
src/system/boot/platform/u-boot/Jamfile          |   4 +
src/system/boot/platform/u-boot/arch/arm/shell.S |  10 ++
src/system/boot/platform/u-boot/start.cpp        |   4 -

############################################################################

Commit:      d1ebf9716d3226af9614ca240d398f96de676012
URL:         http://cgit.haiku-os.org/haiku/commit/?id=d1ebf97
Author:      François Revol <revol@xxxxxxx>
Date:        Sat Nov  1 16:09:09 2014 UTC

U-Boot: ARM: Add a linux entry point to asm shell code

While the NetBSD entry point is handy as we can use a single uImage
with all 3 blobs, it bypasses U-Boot's own patching of the FDT since
it's not visible to it, so we won't get the RAM size and other things
through it.

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

diff --git a/src/system/boot/platform/u-boot/arch/arm/shell.S 
b/src/system/boot/platform/u-boot/arch/arm/shell.S
index 5bac957..813a689 100644
--- a/src/system/boot/platform/u-boot/arch/arm/shell.S
+++ b/src/system/boot/platform/u-boot/arch/arm/shell.S
@@ -30,6 +30,14 @@ SYMBOL(_start_netbsd):
        b       _start_common
 SYMBOL_END(_start_netbsd)
 
+/*
+ * called from bootm with linux loader compatible args
+ */
+SYMBOL(_start_linux):
+       mov     r4,#2
+       b       _start_common
+SYMBOL_END(_start_linux)
+
 
 
 SYMBOL(_start_common):
@@ -63,6 +71,8 @@ SYMBOL(_start_common):
        beq     start_raw
        cmp     r4,#1
        beq     start_netbsd
+       cmp     r4,#2
+       beq     start_linux
        mov     pc,lr
 SYMBOL_END(_start_common)
 

############################################################################

Commit:      8d8bda071f3f1f80d1fd6a61b603e7c45ebd319b
URL:         http://cgit.haiku-os.org/haiku/commit/?id=8d8bda0
Author:      François Revol <revol@xxxxxxx>
Date:        Sat Nov  1 16:11:01 2014 UTC

U-Boot: generate a separate uImage for the boot tgz as well

We need this when using the linux entry point.

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

diff --git a/src/system/boot/platform/u-boot/Jamfile 
b/src/system/boot/platform/u-boot/Jamfile
index 48691a8..15e5602 100644
--- a/src/system/boot/platform/u-boot/Jamfile
+++ b/src/system/boot/platform/u-boot/Jamfile
@@ -212,6 +212,10 @@ BuildUImage haiku_loader.ub : haiku_loader :
 
 local tgzArchive = haiku-floppyboot.tgz ;
 
+BuildUImage $(tgzArchive).ub : $(tgzArchive) :
+       -A $(TARGET_ARCH) -O linux -T ramdisk -C none
+               -n '$(tgzArchive) $(TARGET_BOOT_BOARD)' ;
+
 BuildUImage haiku_loader_linux.ub : haiku_loader :
        -A $(TARGET_ARCH) -O linux -T kernel -C none
        -a $(HAIKU_BOARD_LOADER_BASE) -e $(HAIKU_BOARD_LOADER_ENTRY_LINUX)

############################################################################

Commit:      49bb4c467ca3d38c4fab092d12d70afc291a7166
URL:         http://cgit.haiku-os.org/haiku/commit/?id=49bb4c4
Author:      François Revol <revol@xxxxxxx>
Date:        Sat Nov  1 16:11:39 2014 UTC

ARM: overo: Use the linux entry point version of the loader

And load the boot tgz and FDT separately from the SD card.

Hopefully U-Boot will now report available RAM size.

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

diff --git a/build/jam/board/overo/BoardSetup b/build/jam/board/overo/BoardSetup
index 9bea4d6..3f90a2e 100644
--- a/build/jam/board/overo/BoardSetup
+++ b/build/jam/board/overo/BoardSetup
@@ -12,6 +12,7 @@ HAIKU_BOARD_LOADER_BASE = 0x80008000 ;
 # entry points (raw binary, and netbsd loader emulation)
 HAIKU_BOARD_LOADER_ENTRY_RAW = 0x80008000 ;
 HAIKU_BOARD_LOADER_ENTRY_NBSD = 0x80008008 ;
+HAIKU_BOARD_LOADER_ENTRY_LINUX = 0x80008010 ;
 
 HAIKU_BOARD_LOADER_ENTRY = $(HAIKU_BOARD_LOADER_ENTRY_NBSD) ;
 HAIKU_BOARD_LOADER_FAKE_OS = netbsd ;
@@ -71,8 +72,10 @@ HAIKU_BOARD_SDIMAGE_UBOOT_SCRIPT_NAME = boot.scr ;
 HAIKU_BOARD_SDIMAGE_UBOOT_SCRIPT = "\
 setenv bootargs debug_screen true; \
 if mmc rescan; then \
-       fatload mmc 0 $(HAIKU_BOARD_LOADER_UIBASE) haiku_loader_nbsd.ub; \
-       bootm $(HAIKU_BOARD_LOADER_UIBASE) ; \
+       fatload mmc 0 0x80100000 $(HAIKU_BOARD_FDT_NAME).dtb ; \
+       fatload mmc 0 0x80200000 haiku-floppyboot.tgz.ub; \
+       fatload mmc 0 $(HAIKU_BOARD_LOADER_UIBASE) haiku_loader_linux.ub; \
+       bootm $(HAIKU_BOARD_LOADER_UIBASE) 0x80200000 0x80100000; \
 fi" ;
 
 HAIKU_BOARD_SDIMAGE_FILES =
@@ -80,7 +83,10 @@ HAIKU_BOARD_SDIMAGE_FILES =
        $(ubootFile)
        haiku_loader
        haiku_loader.ub
+       haiku_loader_linux.ub
        haiku_loader_nbsd.ub
+       haiku-floppyboot.tgz.ub
+       $(HAIKU_BOARD_FDT_NAME).dtb
        $(HAIKU_BOARD_SDIMAGE_UBOOT_SCRIPT_NAME)
 ;
 

############################################################################

Revision:    hrev48200
Commit:      92fcf262ff40fce289b97998cbde6082314ce1e3
URL:         http://cgit.haiku-os.org/haiku/commit/?id=92fcf26
Author:      François Revol <revol@xxxxxxx>
Date:        Sat Nov  1 17:43:51 2014 UTC

ARM: Check for RAM size in FDT

We skip the check when we already have ranges inserted,
like from the raspberry Pi start code, and we fall back to
32MB at SDRAM_BASE is not found.

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

diff --git a/src/system/boot/arch/arm/Jamfile b/src/system/boot/arch/arm/Jamfile
index 2c667b3..31c6be1 100644
--- a/src/system/boot/arch/arm/Jamfile
+++ b/src/system/boot/arch/arm/Jamfile
@@ -2,6 +2,7 @@ SubDir HAIKU_TOP src system boot arch arm ;
 
 #XXX: should not be needed here
 UsePrivateHeaders [ FDirName kernel arch $(TARGET_KERNEL_ARCH) board 
$(TARGET_BOOT_BOARD) ] ;
+UseLibraryHeaders [ FDirName libfdt ] ;
 
 {
        local defines = _BOOT_MODE ;
diff --git a/src/system/boot/arch/arm/arch_mmu.cpp 
b/src/system/boot/arch/arm/arch_mmu.cpp
index c26893c..890526e 100644
--- a/src/system/boot/arch/arm/arch_mmu.cpp
+++ b/src/system/boot/arch/arm/arch_mmu.cpp
@@ -23,6 +23,12 @@
 
 #include <string.h>
 
+extern "C" {
+#include <fdt.h>
+#include <libfdt.h>
+#include <libfdt_env.h>
+};
+
 
 //#define TRACE_MMU
 #ifdef TRACE_MMU
@@ -37,6 +43,8 @@
        // You also need to define ENABLE_SERIAL in serial.cpp
        // for output to work.
 
+extern void *gFDT;
+
 
 /*
 TODO:
@@ -551,11 +559,113 @@ mmu_init_for_kernel(void)
 }
 
 
+//TODO:move this to generic/ ?
+static status_t
+find_physical_memory_ranges(uint64 &total)
+{
+       int node;
+       const void *prop;
+       int len;
+
+       dprintf("checking for memory...\n");
+       // let's just skip the OF way (prop memory on /chosen)
+       //node = fdt_path_offset(gFDT, "/chosen");
+       node = fdt_path_offset(gFDT, "/memory");
+       // TODO: check devicetype=="memory" ?
+
+       total = 0;
+
+       // 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
+       int root = fdt_path_offset(gFDT, "/");
+       int32 regAddressCells = 1;
+       int32 regSizeCells = 1;
+       prop = fdt_getprop(gFDT, root, "#address-cells", &len);
+       if (prop && len == sizeof(uint32))
+               regAddressCells = fdt32_to_cpu(*(uint32_t *)prop);
+       prop = fdt_getprop(gFDT, root, "#size-cells", &len);
+       if (prop && len == sizeof(uint32))
+               regSizeCells = fdt32_to_cpu(*(uint32_t *)prop);
+
+
+       // NOTE : Size Cells of 2 is possible in theory... but I haven't seen 
it yet.
+       if (regAddressCells > 2 || regSizeCells > 1) {
+               panic("%s: Unsupported FDT cell count detected.\n"
+               "Address Cells: %" B_PRId32 "; Size Cells: %" B_PRId32
+               " (CPU > 64bit?).\n", __func__, regAddressCells, regSizeCells);
+               return B_ERROR;
+       }
+
+       prop = fdt_getprop(gFDT, node, "reg", &len);
+       if (prop == NULL) {
+               panic("FDT /memory reg property not set");
+               return B_ERROR;
+       }
+
+       const uint32 *p = (const uint32 *)prop;
+       for (int32 i = 0; len; i++) {
+               uint64 base;
+               uint64 size;
+               if (regAddressCells == 2)
+                       base = fdt64_to_cpu(*(uint64_t *)p);
+               else
+                       base = fdt32_to_cpu(*(uint32_t *)p);
+               p += regAddressCells;
+               if (regSizeCells == 2)
+                       size = fdt64_to_cpu(*(uint64_t *)p);
+               else
+                       size = fdt32_to_cpu(*(uint32_t *)p);
+               p += regAddressCells;
+               len -= sizeof(uint32) * (regAddressCells + regSizeCells);
+
+               if (size <= 0) {
+                       dprintf("%ld: empty region\n", i);
+                       continue;
+               }
+               dprintf("%" B_PRIu32 ": base = %" B_PRIu64 ","
+                       "size = %" B_PRIu64 "\n", i, base, size);
+
+               total += size;
+
+               if (insert_physical_memory_range(base, size) != B_OK) {
+                       dprintf("cannot map physical memory range "
+                               "(num ranges = %" B_PRIu32 ")!\n",
+                               gKernelArgs.num_physical_memory_ranges);
+                       return B_ERROR;
+               }
+       }
+
+       return B_OK;
+}
+
+
 extern "C" void
 mmu_init(void)
 {
        TRACE(("mmu_init\n"));
 
+       // skip RAM check if already done (rPi)
+       if (gKernelArgs.num_physical_memory_ranges == 0) {
+               // get map of physical memory (fill in kernel_args structure)
+
+               uint64 total;
+               if (find_physical_memory_ranges(total) != B_OK) {
+                       dprintf("Error: could not find physical memory 
ranges!\n");
+
+#ifdef SDRAM_BASE
+                       dprintf("Defaulting to 32MB at %" B_PRIx64 "\n", 
(uint64)SDRAM_BASE);
+                       // specify available physical memory, using 32MB for 
now, since our
+                       // ARMv5 targets have very little by default.
+                       total = 32 * 1024 * 1024;
+                       insert_physical_memory_range(SDRAM_BASE, total);
+#else
+                       return /*B_ERROR*/;
+#endif
+               }
+               dprintf("total physical memory = %" B_PRId64 "MB\n", total / 
(1024 * 1024));
+       }
+
        // see if subpages are disabled
        if (mmu_read_C1() & (1 << 23))
                sSmallPageType = ARM_MMU_L2_TYPE_SMALLNEW;
diff --git a/src/system/boot/platform/u-boot/start.cpp 
b/src/system/boot/platform/u-boot/start.cpp
index 1481e41..6556675 100644
--- a/src/system/boot/platform/u-boot/start.cpp
+++ b/src/system/boot/platform/u-boot/start.cpp
@@ -277,10 +277,6 @@ start_gen(int argc, const char **argv, struct image_header 
*uimage, void *fdt)
                        args.platform.boot_tgz_size);
        }
 
-       // specify available physical memory, using 32MB for now, since our
-       // ARMv5 targets have very little by default. TODO get from FDT!
-       insert_physical_memory_range(SDRAM_BASE, 32 * 1024 * 1024);
-
        // save the size of the FDT so we can map it easily after mmu_init
        size_t fdtSize = gFDT ? fdt_totalsize(gFDT) : 0;
 


Other related posts:

  • » [haiku-commits] haiku: hrev48200 - src/system/boot/arch/arm build/jam/board/overo src/system/boot/platform/u-boot src/system/boot/platform/u-boot/arch/arm - revol