Zheng Bao ([email protected]) just uploaded a new patch set to gerrit, which 
you can find at http://review.coreboot.org/805

-gerrit

commit 30e98f64a8f049649b714d1cf198377f029685d4
Author: zbao <[email protected]>
Date:   Thu Mar 22 18:47:15 2012 +0800

    Add memcopy_fast
    
    It is for S3 resume. Before the stack is ok, we should use the inlined 
memcopy.
    
    Change-Id: I66484802367dea19a22a292830485ff0b7ba8e23
    Signed-off-by: Zheng Bao <[email protected]>
    Signed-off-by: zbao <[email protected]>
---
 src/include/string.h |    1 +
 src/lib/memcpy.c     |   15 +++++++++++++++
 2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/src/include/string.h b/src/include/string.h
index 708961b..b6a0183 100644
--- a/src/include/string.h
+++ b/src/include/string.h
@@ -9,6 +9,7 @@ void *memmove(void *dest, const void *src, size_t n);
 void *memset(void *s, int c, size_t n);
 int memcmp(const void *s1, const void *s2, size_t n);
 void *memchr(const void *s, int c, size_t n);
+void inline __attribute__((always_inline))  memcopy_fast(void *dest, const 
void *src, unsigned long bytes);
 #if !defined(__PRE_RAM__)
 int sprintf(char * buf, const char *fmt, ...);
 #endif
diff --git a/src/lib/memcpy.c b/src/lib/memcpy.c
index 1053a53..217f73b 100644
--- a/src/lib/memcpy.c
+++ b/src/lib/memcpy.c
@@ -10,3 +10,18 @@ void *memcpy(void *vdest, const void *vsrc, size_t bytes)
 
        return vdest;
 }
+
+/* from linux kernel 2.6.32 asm/string_32.h */
+void inline __attribute__((always_inline))  memcopy_fast(void *dest, const 
void *src, unsigned long bytes)
+{
+       int d0, d1, d2;
+       asm volatile("cld ; rep ; movsl\n\t"
+                       "movl %4,%%ecx\n\t"
+                       "andl $3,%%ecx\n\t"
+                       "jz 1f\n\t"
+                       "rep ; movsb\n\t"
+                       "1:"
+                       : "=&c" (d0), "=&D" (d1), "=&S" (d2)
+                       : "0" (bytes / 4), "g" (bytes), "1" ((long)dest), "2" 
((long)src)
+                       : "memory", "cc");
+}

-- 
coreboot mailing list: [email protected]
http://www.coreboot.org/mailman/listinfo/coreboot

Reply via email to