ia64/xen-unstable

changeset 15388:896b536d66c9

ioemu: Assembler memcpy() for x86, and lowest-common-denominator
memcpy() function for all others, avoiding noisy longword copies on
ia64.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Tue Jun 19 16:08:15 2007 +0100 (2007-06-19)
parents cb747a35e057
children 865c4ae59be3
files tools/ioemu/target-i386-dm/exec-dm.c
line diff
     1.1 --- a/tools/ioemu/target-i386-dm/exec-dm.c	Tue Jun 19 15:55:13 2007 +0100
     1.2 +++ b/tools/ioemu/target-i386-dm/exec-dm.c	Tue Jun 19 16:08:15 2007 +0100
     1.3 @@ -443,19 +443,40 @@ extern unsigned long logdirty_bitmap_siz
     1.4   * Forcing a word-sized read/write prevents the guest from seeing a partially
     1.5   * written word-sized atom.
     1.6   */
     1.7 -void memcpy_words(void *dst, void *src, size_t n)
     1.8 +#if defined(__x86_64__) || defined(__i386__)
     1.9 +static void memcpy_words(void *dst, void *src, size_t n)
    1.10  {
    1.11 -    while (n >= sizeof(long)) {
    1.12 -        *((long *)dst) = *((long *)src);
    1.13 -        dst = ((long *)dst) + 1;
    1.14 -        src = ((long *)src) + 1;
    1.15 -        n -= sizeof(long);
    1.16 -    }
    1.17 -
    1.18 -    if (n & 4) {
    1.19 +    asm (
    1.20 +        "   movl %%edx,%%ecx \n"
    1.21 +#ifdef __x86_64
    1.22 +        "   shrl $3,%%ecx    \n"
    1.23 +        "   andl $7,%%edx    \n"
    1.24 +        "   rep  movsq       \n"
    1.25 +        "   test $4,%%edx    \n"
    1.26 +        "   jz   1f          \n"
    1.27 +        "   movsl            \n"
    1.28 +#else /* __i386__ */
    1.29 +        "   shrl $2,%%ecx    \n"
    1.30 +        "   andl $3,%%edx    \n"
    1.31 +        "   rep  movsl       \n"
    1.32 +#endif
    1.33 +        "1: test $2,%%edx    \n"
    1.34 +        "   jz   1f          \n"
    1.35 +        "   movsw            \n"
    1.36 +        "1: test $1,%%edx    \n"
    1.37 +        "   jz   1f          \n"
    1.38 +        "   movsb            \n"
    1.39 +        "1:                  \n"
    1.40 +        : : "S" (src), "D" (dst), "d" (n) : "ecx" );
    1.41 +}
    1.42 +#else
    1.43 +static void memcpy_words(void *dst, void *src, size_t n)
    1.44 +{
    1.45 +    while (n >= sizeof(uint32_t)) {
    1.46          *((uint32_t *)dst) = *((uint32_t *)src);
    1.47          dst = ((uint32_t *)dst) + 1;
    1.48          src = ((uint32_t *)src) + 1;
    1.49 +        n -= sizeof(uint32_t);
    1.50      }
    1.51  
    1.52      if (n & 2) {
    1.53 @@ -470,6 +491,7 @@ void memcpy_words(void *dst, void *src, 
    1.54          src = ((uint8_t *)src) + 1;
    1.55      }
    1.56  }
    1.57 +#endif
    1.58  
    1.59  void cpu_physical_memory_rw(target_phys_addr_t addr, uint8_t *buf, 
    1.60                              int len, int is_write)