diff mbox

[U-Boot,v2,02/17] x86: Speed up copy-to-RAM and clear BSS operations

Message ID 1325707195-3218-2-git-send-email-graeme.russ@gmail.com
State Awaiting Upstream
Delegated to: Graeme Russ
Headers show

Commit Message

Graeme Russ Jan. 4, 2012, 7:59 p.m. UTC
The implementations of memcpy and memset are now the optimised versions
from glibc, so use them instead of simple copy loops

Signed-off-by: Graeme Russ <graeme.russ@gmail.com>
---
Changes for v2:
 - Removed unneeded brackets

 arch/x86/lib/board.c |   17 +++++------------
 1 files changed, 5 insertions(+), 12 deletions(-)

--
1.7.5.2.317.g391b14

Comments

Graeme Russ Jan. 4, 2012, 8:04 p.m. UTC | #1
Oops, after painstakingly setting In-Reply-To: I've gone and left
git-send-email chain-reply on :(

Sorry 'bout that

Regards,

Graeme
Simon Glass Jan. 12, 2012, 4:45 a.m. UTC | #2
On Wed, Jan 4, 2012 at 11:59 AM, Graeme Russ <graeme.russ@gmail.com> wrote:
> The implementations of memcpy and memset are now the optimised versions
> from glibc, so use them instead of simple copy loops
>
> Signed-off-by: Graeme Russ <graeme.russ@gmail.com>

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

> ---
> Changes for v2:
>  - Removed unneeded brackets
>
>  arch/x86/lib/board.c |   17 +++++------------
>  1 files changed, 5 insertions(+), 12 deletions(-)
>
> diff --git a/arch/x86/lib/board.c b/arch/x86/lib/board.c
> index d742fec..f9eb15b 100644
> --- a/arch/x86/lib/board.c
> +++ b/arch/x86/lib/board.c
> @@ -188,26 +188,19 @@ static int calculate_relocation_address(void)
>
>  static int copy_uboot_to_ram(void)
>  {
> -       ulong *dst_addr = (ulong *)gd->relocaddr;
> -       ulong *src_addr = (ulong *)&__text_start;
> -       ulong *end_addr = (ulong *)&__data_end;
> +       size_t len = (size_t)&__data_end - (size_t)&__text_start;
>
> -       while (src_addr < end_addr)
> -               *dst_addr++ = *src_addr++;
> +       memcpy((void *)gd->relocaddr, (void *)&__text_start, len);
>
>        return 0;
>  }
>
>  static int clear_bss(void)
>  {
> -       void *bss_start = &__bss_start;
> -       void *bss_end = &__bss_end;
> +       ulong dst_addr = (ulong)&__bss_start + gd->reloc_off;
> +       size_t len = (size_t)&__bss_end - (size_t)&__bss_start;
>
> -       ulong *dst_addr = (ulong *)(bss_start + gd->reloc_off);
> -       ulong *end_addr = (ulong *)(bss_end + gd->reloc_off);
> -
> -       while (dst_addr < end_addr)
> -               *dst_addr++ = 0x00000000;
> +       memset((void *)dst_addr, 0x00, len);
>
>        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
diff mbox

Patch

diff --git a/arch/x86/lib/board.c b/arch/x86/lib/board.c
index d742fec..f9eb15b 100644
--- a/arch/x86/lib/board.c
+++ b/arch/x86/lib/board.c
@@ -188,26 +188,19 @@  static int calculate_relocation_address(void)

 static int copy_uboot_to_ram(void)
 {
-	ulong *dst_addr = (ulong *)gd->relocaddr;
-	ulong *src_addr = (ulong *)&__text_start;
-	ulong *end_addr = (ulong *)&__data_end;
+	size_t len = (size_t)&__data_end - (size_t)&__text_start;

-	while (src_addr < end_addr)
-		*dst_addr++ = *src_addr++;
+	memcpy((void *)gd->relocaddr, (void *)&__text_start, len);

 	return 0;
 }

 static int clear_bss(void)
 {
-	void *bss_start = &__bss_start;
-	void *bss_end = &__bss_end;
+	ulong dst_addr = (ulong)&__bss_start + gd->reloc_off;
+	size_t len = (size_t)&__bss_end - (size_t)&__bss_start;

-	ulong *dst_addr = (ulong *)(bss_start + gd->reloc_off);
-	ulong *end_addr = (ulong *)(bss_end + gd->reloc_off);
-
-	while (dst_addr < end_addr)
-		*dst_addr++ = 0x00000000;
+	memset((void *)dst_addr, 0x00, len);

 	return 0;
 }