Changeset 104dc0b in mainline


Ignore:
Timestamp:
2005-09-18T21:39:56Z (19 years ago)
Author:
Sergey Bondari <bondari@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d9430f7
Parents:
650d976
Message:

built-in memcpy is not used anymore on IA-32.
IA-32 memcpy is now fast and inline.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • arch/ia32/include/asm.h

    r650d976 r104dc0b  
    139139        pri_t v;
    140140        __asm__ volatile (
    141                 "pushf\n"
    142                 "popl %0\n"
     141                "pushf\n\t"
     142                "popl %0\n\t"
    143143                "sti\n"
    144144                : "=r" (v)
     
    155155        pri_t v;
    156156        __asm__ volatile (
    157                 "pushf\n"
    158                 "popl %0\n"
     157                "pushf\n\t"
     158                "popl %0\n\t"
    159159                "cli\n"
    160160                : "=r" (v)
     
    169169static inline void cpu_priority_restore(pri_t pri) {
    170170        __asm__ volatile (
    171                 "pushl %0\n"
     171                "pushl %0\n\t"
    172172                "popf\n"
    173173                : : "r" (pri)
     
    182182        pri_t v;
    183183        __asm__ volatile (
    184                 "pushf\n"
     184                "pushf\n\t"
    185185                "popl %0\n"
    186186                : "=r" (v)
     
    213213}
    214214
     215/** Copy memory
     216 *
     217 * Copy a given number of bytes (3rd argument)
     218 * from the memory location defined by 2nd argument
     219 * to the memory location defined by 1st argument.
     220 * The memory areas cannot overlap.
     221 *
     222 * @param destination
     223 * @param source
     224 * @param number of bytes
     225 * @return destination
     226 */
     227static inline void * memcpy(void * dst, const void * src, size_t cnt)
     228{
     229        __u32 d0, d1, d2;
     230       
     231        __asm__ __volatile__(
     232                "rep movsl\n\t"
     233                "movl %4, %%ecx\n\t"
     234                "andl $3, %%ecx\n\t"
     235                "jz 1f\n\t"
     236                "rep movsb\n\t"
     237                "1:\n"
     238                : "=&c" (d0), "=&D" (d1), "=&S" (d2)
     239                : "0" (cnt / 4), "g" (cnt), "1" ((__u32) dst), "2" ((__u32) src)
     240                : "memory");
     241               
     242        return dst;
     243}
     244
    215245
    216246#endif
  • arch/ia32/src/asm.S

    r650d976 r104dc0b  
    3838.global enable_l_apic_in_msr
    3939.global interrupt_handlers
    40 .global memcpy
    4140.global memsetb
    4241.global memsetw
     
    153152#       handler 192 256
    154153h_end:
    155 
    156 
    157 ## Copy memory
    158 #
    159 # Copy a given number of bytes (3rd argument)
    160 # from the memory location defined by 2nd argument
    161 # to the memory location defined by 1st argument.
    162 # The memory areas cannot overlap.
    163 #
    164 SRC=16
    165 DST=12
    166 CNT=20
    167 memcpy:
    168         push %esi
    169         push %edi
    170 
    171         movl CNT(%esp),%ecx
    172         movl DST(%esp),%edi
    173         movl SRC(%esp),%esi
    174 
    175         rep movsb %ds:(%esi),%es:(%edi)
    176 
    177         pop %edi
    178         pop %esi
    179         ret
    180154
    181155
  • include/memstr.h

    r650d976 r104dc0b  
    3232#include <typedefs.h>
    3333#include <arch/types.h>
    34 
    35 #define memcpy(dst, src, cnt)   __builtin_memcpy((dst), (src), (cnt));
     34#include <arch/asm.h>
    3635
    3736extern void memsetw(__address dst, size_t cnt, __u16 x);
Note: See TracChangeset for help on using the changeset viewer.