diff options
author | Mark Rutland <mark.rutland@arm.com> | 2014-04-15 16:02:02 +0100 |
---|---|---|
committer | Mark Rutland <mark.rutland@arm.com> | 2014-04-15 16:08:19 +0100 |
commit | 80a9599916b0cd2222d7fba0beb3909c967e6604 (patch) | |
tree | 88460b1eb43b7c8c36385b7d88ff3dbc4ae518ad | |
parent | 000a66b55f725918f55d40515bae5c400a969cad (diff) | |
download | boot-wrapper-aarch64-80a9599916b0cd2222d7fba0beb3909c967e6604.tar.gz |
Discover memory from the DTB
In case the start of physical memory happens to be different on some
model variant, this patch adds the necessary tooling to detect the base
address of said memory and ensure that the kernel and wrapper get loaded
at appropriate addresses.
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
-rw-r--r-- | Makefile.am | 2 | ||||
-rwxr-xr-x | findmem.pl | 33 |
2 files changed, 34 insertions, 1 deletions
diff --git a/Makefile.am b/Makefile.am index 41adf14..2f69061 100644 --- a/Makefile.am +++ b/Makefile.am @@ -8,7 +8,7 @@ # found in the LICENSE.txt file. # VE -PHYS_OFFSET := 0x80000000 +PHYS_OFFSET := $(shell $(top_srcdir)/findmem.pl $(KERNEL_DTB)) UART_BASE := $(shell $(top_srcdir)/findbase.pl $(KERNEL_DTB) 0 'arm,pl011') SYSREGS_BASE := $(shell $(top_srcdir)/findbase.pl $(KERNEL_DTB) 0 'arm,vexpress-sysreg') GIC_DIST_BASE := $(shell $(top_srcdir)/findbase.pl $(KERNEL_DTB) 0 'arm,cortex-a15-gic') diff --git a/findmem.pl b/findmem.pl new file mode 100755 index 0000000..ae75a8c --- /dev/null +++ b/findmem.pl @@ -0,0 +1,33 @@ +#!/usr/bin/perl -w +# Find the start of physical memory +# +# Usage: ./$0 <DTB> +# +# Copyright (C) 2014 ARM Limited. All rights reserved. +# +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE.txt file. + +use warnings; +use strict; + +use FDT; + +my $filename = shift; +die("No filename provided") unless defined($filename); + +open (my $fh, "<:raw", $filename) or die("Unable to open file '$filename'"); + +my $fdt = FDT->parse($fh) or die("Unable to parse DTB"); + +my $root = $fdt->get_root(); + +# We assume the memory nodes and their reg entries are ordered by address. +my @mems = $root->find_by_device_type("memory"); +my $mem = shift @mems; +die("Unable to find memory") unless defined($mem); + +my ($addr, $size) = $mem->get_translated_reg(0); +die("Cannot find first memory bank") unless (defined($addr) && defined($size)); + +printf("0x%016x\n", $addr); |