]> git.sur5r.net Git - u-boot/commitdiff
x86: Speed up copy-to-RAM and clear BSS operations
authorGraeme Russ <graeme.russ@gmail.com>
Tue, 27 Dec 2011 11:46:41 +0000 (22:46 +1100)
committerGraeme Russ <graeme.russ@gmail.com>
Wed, 4 Jan 2012 10:05:00 +0000 (21:05 +1100)
The implementations of memcpy and memset are now the optimised versions
from glibc, so use them instead of simple copy loops

--
Changes for v2:
 - Removed unneeded brackets

arch/x86/lib/board.c

index d742fec928b9e7e549a45ea4166bfa70190ea903..f9eb15bed365457fd95ee2356a9ca34a9830cf97 100644 (file)
@@ -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;
 }