From: Renaud Barbier <renaud.barbier@ge.com>
To: barebox@lists.infradead.org
Subject: [PATCH 3/4] ppc: bootm: relocate fdt to valid boot memory
Date: Fri, 30 Aug 2013 14:34:28 +0100 [thread overview]
Message-ID: <1377869669-27821-4-git-send-email-renaud.barbier@ge.com> (raw)
In-Reply-To: <1377869669-27821-1-git-send-email-renaud.barbier@ge.com>
For the MPC85xx family of SOCs Linux expects any boot firmware
information to be passed in the first 64MiB of memory. This adds support
to ensure that the device tree is relocated to a valid location if it is
outside that address range.
Signed-off-by: Renaud Barbier <renaud.barbier@ge.com>
---
arch/ppc/include/asm/processor.h | 1 +
arch/ppc/lib/ppclinux.c | 49 +++++++++++++++++++++++++++++++++++++-
2 files changed, 49 insertions(+), 1 deletions(-)
diff --git a/arch/ppc/include/asm/processor.h b/arch/ppc/include/asm/processor.h
index 04cfb60..6b9b7dd 100644
--- a/arch/ppc/include/asm/processor.h
+++ b/arch/ppc/include/asm/processor.h
@@ -966,6 +966,7 @@ struct cpu_type {
struct cpu_type *identify_cpu(u32 ver);
#if defined(CONFIG_MPC85xx)
+#define LINUX_TLB1_MAX_ADDR ((void *)(64 << 20))
#define CPU_TYPE_ENTRY(n, v, nc) \
{ .name = #n, .soc_ver = SVR_##v, .num_cores = (nc), }
#endif
diff --git a/arch/ppc/lib/ppclinux.c b/arch/ppc/lib/ppclinux.c
index ef69ead..e6cdcad 100644
--- a/arch/ppc/lib/ppclinux.c
+++ b/arch/ppc/lib/ppclinux.c
@@ -4,12 +4,45 @@
#include <command.h>
#include <image.h>
#include <init.h>
+#include <malloc.h>
#include <environment.h>
#include <asm/bitops.h>
+#include <asm/processor.h>
#include <boot.h>
#include <errno.h>
#include <fs.h>
+static int bootm_relocate_fdt(void *addr, struct image_data *data)
+{
+ if (addr < LINUX_TLB1_MAX_ADDR) {
+ /* The kernel is within the boot TLB mapping.
+ * Put the DTB above if there is no space
+ * below.
+ */
+ if (addr < (void *)data->oftree->totalsize) {
+ addr = (void *)PAGE_ALIGN((phys_addr_t)addr +
+ data->os->header.ih_size);
+ addr += data->oftree->totalsize;
+ if (addr < LINUX_TLB1_MAX_ADDR)
+ addr = LINUX_TLB1_MAX_ADDR;
+ }
+ }
+
+ if (addr > LINUX_TLB1_MAX_ADDR) {
+ pr_crit("Unable to relocate DTB to Linux TLB\n");
+ return 1;
+ }
+
+ addr = (void *)PAGE_ALIGN_DOWN((phys_addr_t)addr -
+ data->oftree->totalsize);
+ memcpy(addr, data->oftree, data->oftree->totalsize);
+ free(data->oftree);
+ data->oftree = addr;
+
+ pr_info("Relocating device tree to 0x%p\n", addr);
+ return 0;
+}
+
static int do_bootm_linux(struct image_data *data)
{
void (*kernel)(void *, void *, unsigned long,
@@ -24,6 +57,20 @@ static int do_bootm_linux(struct image_data *data)
return -EINVAL;
}
+ /* Relocate the device tree if outside the initial
+ * Linux mapped TLB.
+ */
+ if (IS_ENABLED(CONFIG_MPC85xx)) {
+ void *addr = data->oftree;
+
+ if ((addr + data->oftree->totalsize) > LINUX_TLB1_MAX_ADDR) {
+ addr = (void *)data->os_address;
+
+ if (bootm_relocate_fdt(addr, data))
+ goto error;
+ }
+ }
+
fdt_add_reserve_map(data->oftree);
kernel = (void *)(data->os_address + data->os_entry);
@@ -37,9 +84,9 @@ static int do_bootm_linux(struct image_data *data)
* r7: NULL
*/
kernel(data->oftree, kernel, 0, 0, 0);
-
reset_cpu(0);
+error:
/* not reached */
return -1;
}
--
1.7.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2013-08-30 13:35 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-30 13:34 [PATCH 0/4] Update P2020RDB board support to allow NFS booting Renaud Barbier
2013-08-30 13:34 ` [PATCH 1/4] of: base: import of_find_node_by_type Renaud Barbier
2013-08-30 13:34 ` [PATCH 2/4] ppc: add mpc85xx device tree fixup functions Renaud Barbier
2013-09-02 8:49 ` Sascha Hauer
2013-09-02 16:34 ` Renaud Barbier
2013-08-30 13:34 ` Renaud Barbier [this message]
2013-08-30 13:34 ` [PATCH 4/4] ppc: P2020RDB configuration update Renaud Barbier
2013-09-03 14:54 [PATCH v2 0/4] Update P2020RDB board support to allow NFS booting Renaud Barbier
2013-09-03 14:54 ` [PATCH 3/4] ppc: bootm: relocate fdt to valid boot memory Renaud Barbier
2013-09-05 12:21 ` Sascha Hauer
2013-09-06 10:53 ` Renaud Barbier
2013-09-09 15:08 ` Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1377869669-27821-4-git-send-email-renaud.barbier@ge.com \
--to=renaud.barbier@ge.com \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox