mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Renaud Barbier <renaud.barbier@ge.com>
To: barebox@lists.infradead.org
Subject: [PATCH 3/5] ppc: mpc85xx: change bss relocation
Date: Wed, 15 Jan 2014 11:47:42 +0000	[thread overview]
Message-ID: <1389786464-22085-4-git-send-email-renaud.barbier@ge.com> (raw)
In-Reply-To: <1389786464-22085-1-git-send-email-renaud.barbier@ge.com>

The linker script and start up code are updated so that the bss
section is located above the barebox binary in memory. This removes
the reliance on a hard-coded value.

Signed-off-by: Renaud Barbier <renaud.barbier@ge.com>
---
 arch/ppc/cpu-85xx/start.S           | 36 ++++++++++++++----------------------
 arch/ppc/mach-mpc85xx/barebox.lds.S |  7 +++++--
 2 files changed, 19 insertions(+), 24 deletions(-)

diff --git a/arch/ppc/cpu-85xx/start.S b/arch/ppc/cpu-85xx/start.S
index 5bcba5f..638b6b8 100644
--- a/arch/ppc/cpu-85xx/start.S
+++ b/arch/ppc/cpu-85xx/start.S
@@ -52,8 +52,8 @@
 	GOT_ENTRY(_end_of_vectors)
 	GOT_ENTRY(transfer_to_handler)
 	GOT_ENTRY(__init_end)
-	GOT_ENTRY(_end)
 	GOT_ENTRY(__bss_start)
+	GOT_ENTRY(__bss_stop)
 	END_GOT
 
 /*
@@ -775,27 +775,19 @@ e500_write_tlb:
 relocate_code:
 	mr	r9, r3			/* Save end of RAM 	*/
 
-	lis	r10, (_end - _start)@h	/* Size			*/
-	ori	r10, r10, (_end - _start)@l
-	sub	r3,  r3, r10
-
-	/* 64KB aligned */
-	lis	r10, 0xffff0000@h
-	ori	r10, r10, 0xffff0000@l
-	and	r3, r3, r10
-
-	mr	r1, r3		/* Set new stack just below barebox code */
-	mr	r10, r3 	/* Save copy of Destination Address */
-
-	bl 	calc_source
-calc_source:
-	mfspr	r4, LR	/* r4 = address in memory (flash, RAM) */
-	subi	r4, r4, (calc_source - _start)
-
 	GET_GOT
-	lis	r5, __init_size@h
-	ori	r5, r5, __init_size@l
-
+	lis	r4,TEXT_BASE@h
+	ori	r4,r4,TEXT_BASE@l
+	lwz	r5,GOT(__bss_stop)	/* size */
+	sub	r5,r5,r4
+	sub	r3, r3, r5
+	lwz	r5,GOT(__init_end)	/* Copy to init_end only */
+	sub	r5,r5,r4
+	lis	r10, 0xffff0000@h	/* Round down to 64KB */
+	ori	r10, r10, 0xffff0000@l
+	and	r3, r3, r10		/* Destination */
+	mr	r1, r3
+	mr	r10, r3
 	li	r6,CACHELINE_SIZE
 
 	/*
@@ -921,7 +913,7 @@ clear_bss:
 	 * Now clear BSS segment
 	 */
 	lwz	r3,GOT(__bss_start)
-	lwz	r4,GOT(_end)
+	lwz	r4,GOT(__bss_stop)
 
 	cmplw	0,r3,r4
 	beq	6f
diff --git a/arch/ppc/mach-mpc85xx/barebox.lds.S b/arch/ppc/mach-mpc85xx/barebox.lds.S
index 4d156e8..980359e 100644
--- a/arch/ppc/mach-mpc85xx/barebox.lds.S
+++ b/arch/ppc/mach-mpc85xx/barebox.lds.S
@@ -20,7 +20,6 @@
 #else
 #define RESET_VECTOR_ADDRESS    0xfffffffc
 #endif
-#define BSS_START_ADDRESS       0x2000
 
 OUTPUT_ARCH("powerpc")
 
@@ -143,7 +142,11 @@ SECTIONS
 
   . = RESET_VECTOR_ADDRESS + 0x4;
 
-  . = BSS_START_ADDRESS;
+#if (RESET_VECTOR_ADDRESS == 0xfffffffc)
+  /* This avoids wrapping around to offset 0 */
+  . |= 0x10;
+#endif
+
   __bss_start = .;
   .bss        :
   {
-- 
1.8.4.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2014-01-15 11:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-15 11:47 [PATCH 0/5] ppc: Import latest U-Boot code Renaud Barbier
2014-01-15 11:47 ` [PATCH 1/5] ppc: cpu-85xx: upgrade MMU support to v2 pages sizes Renaud Barbier
2014-01-15 11:47 ` [PATCH 2/5] ppc: mpc85xx: use common linker script Renaud Barbier
2014-01-15 11:47 ` Renaud Barbier [this message]
2014-01-15 11:47 ` [PATCH 4/5] ppc: cpu-85xx: import U-Boot start-up code Renaud Barbier
2014-01-15 11:47 ` [PATCH 5/5] cpu-85xx: start.S: clean up imported code Renaud Barbier
2014-01-16 13:30 ` [PATCH 0/5] ppc: Import latest U-Boot code 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=1389786464-22085-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