Subversion Repositories HelenOS-historic

Rev

Rev 359 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 359 Rev 361
Line 1... Line 1...
1
/*
1
/*
2
 * Copyright (C) 2001-2004 Jakub Jermar
2
 * Copyright (C) 2001-2004 Jakub Jermar
-
 
3
 * Copyright (C) 2005 HelenOS project
3
 * All rights reserved.
4
 * All rights reserved.
4
 *
5
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * are met:
Line 210... Line 211...
210
    __asm__ volatile("rdtsc\n" : "=A" (v));
211
    __asm__ volatile("rdtsc\n" : "=A" (v));
211
   
212
   
212
    return v;
213
    return v;
213
}
214
}
214
 
215
 
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
 */
-
 
227
static inline void * memcpy(void * dst, const void * src, size_t cnt)
-
 
228
{
-
 
229
    __u32 d0, d1, d2;
-
 
230
   
-
 
231
    __asm__ __volatile__(
-
 
232
        /* copy all full dwords */
-
 
233
        "rep movsl\n\t"
-
 
234
        /* load count again */
-
 
235
        "movl %4, %%ecx\n\t"
-
 
236
        /* ecx = ecx mod 4 */
-
 
237
        "andl $3, %%ecx\n\t"
-
 
238
        /* are there last <=3 bytes? */
-
 
239
        "jz 1f\n\t"
-
 
240
        /* copy last <=3 bytes */
-
 
241
        "rep movsb\n\t"
-
 
242
        /* exit from asm block */
-
 
243
        "1:\n"
-
 
244
        : "=&c" (d0), "=&D" (d1), "=&S" (d2)
-
 
245
        : "0" (cnt / 4), "g" (cnt), "1" ((__u32) dst), "2" ((__u32) src)
-
 
246
        : "memory");
-
 
247
       
-
 
248
    return dst;
-
 
249
}
-
 
250
 
-
 
251
 
-
 
252
#endif
216
#endif