Patchwork [U-Boot,06/17] x86: Rework relocation calcuations

login
register
mail settings
Submitter Graeme Russ
Date Jan. 2, 2012, 4:09 a.m.
Message ID <1325477374-6417-7-git-send-email-graeme.russ@gmail.com>
Download mbox | patch
Permalink /patch/133781/
State Accepted
Commit 240ab5aa2161df500e8950c2a4f392e84324f78a
Headers show

Comments

Graeme Russ - Jan. 2, 2012, 4:09 a.m.
Signed-off-by: Graeme Russ <graeme.russ@gmail.com>
---
 arch/x86/lib/board.c |   23 +++++++++++------------
 1 files changed, 11 insertions(+), 12 deletions(-)
Simon Glass - Jan. 4, 2012, 5:30 a.m.
Hi Graeme,

On Sun, Jan 1, 2012 at 8:09 PM, Graeme Russ <graeme.russ@gmail.com> wrote:
>
> Signed-off-by: Graeme Russ <graeme.russ@gmail.com>

I think all of these patches should have a commit message. Anyway:

Acked-by: Simon Glass <sjg@chromium.org>

Regards,
Simon

> ---
>  arch/x86/lib/board.c |   23 +++++++++++------------
>  1 files changed, 11 insertions(+), 12 deletions(-)
>
> diff --git a/arch/x86/lib/board.c b/arch/x86/lib/board.c
> index 978beaa..bc5027b 100644
> --- a/arch/x86/lib/board.c
> +++ b/arch/x86/lib/board.c
> @@ -164,24 +164,23 @@ static int calculate_relocation_address(void)
>        ulong text_start = (ulong)&__text_start;
>        ulong bss_end = (ulong)&__bss_end;
>        ulong dest_addr;
> -       ulong rel_offset;
> -
> -       /* Calculate destination RAM Address and relocation offset */
> -       dest_addr = gd->ram_size;
> -       dest_addr -= CONFIG_SYS_STACK_SIZE;
> -       dest_addr -= (bss_end - text_start);
>
>        /*
> -        * Round destination address down to 16-byte boundary to keep
> -        * IDT and GDT 16-byte aligned
> +        * NOTE: All destination address are rounded down to 16-byte
> +        *       boundary to satisfy various worst-case alignment
> +        *       requirements
>         */
> -       dest_addr &= ~15;
>
> -       rel_offset = dest_addr - text_start;
> +       /* Stack is at top of available memory */
> +       dest_addr = gd->ram_size;
> +       gd->start_addr_sp = dest_addr;
>
> -       gd->start_addr_sp = gd->ram_size;
> +       /* U-Boot is below the stack */
> +       dest_addr -= CONFIG_SYS_STACK_SIZE;
> +       dest_addr -= (bss_end - text_start);
> +       dest_addr &= ~15;
>        gd->relocaddr = dest_addr;
> -       gd->reloc_off = rel_offset;
> +       gd->reloc_off = (dest_addr - text_start);
>
>        return 0;
>  }
> --
> 1.7.5.2.317.g391b14
>
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot

Patch

diff --git a/arch/x86/lib/board.c b/arch/x86/lib/board.c
index 978beaa..bc5027b 100644
--- a/arch/x86/lib/board.c
+++ b/arch/x86/lib/board.c
@@ -164,24 +164,23 @@  static int calculate_relocation_address(void)
 	ulong text_start = (ulong)&__text_start;
 	ulong bss_end = (ulong)&__bss_end;
 	ulong dest_addr;
-	ulong rel_offset;
-
-	/* Calculate destination RAM Address and relocation offset */
-	dest_addr = gd->ram_size;
-	dest_addr -= CONFIG_SYS_STACK_SIZE;
-	dest_addr -= (bss_end - text_start);
 
 	/*
-	 * Round destination address down to 16-byte boundary to keep
-	 * IDT and GDT 16-byte aligned
+	 * NOTE: All destination address are rounded down to 16-byte
+	 *       boundary to satisfy various worst-case alignment
+	 *       requirements
 	 */
-	dest_addr &= ~15;
 
-	rel_offset = dest_addr - text_start;
+	/* Stack is at top of available memory */
+	dest_addr = gd->ram_size;
+	gd->start_addr_sp = dest_addr;
 
-	gd->start_addr_sp = gd->ram_size;
+	/* U-Boot is below the stack */
+	dest_addr -= CONFIG_SYS_STACK_SIZE;
+	dest_addr -= (bss_end - text_start);
+	dest_addr &= ~15;
 	gd->relocaddr = dest_addr;
-	gd->reloc_off = rel_offset;
+	gd->reloc_off = (dest_addr - text_start);
 
 	return 0;
 }