2016-01-12 23:55:28 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the coreboot project.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*/
|
|
|
|
|
2011-10-26 01:43:34 +02:00
|
|
|
#include <string.h>
|
|
|
|
|
2012-03-31 17:23:53 +02:00
|
|
|
void *memcpy(void *dest, const void *src, size_t n)
|
2011-10-26 01:43:34 +02:00
|
|
|
{
|
2012-03-31 17:23:53 +02:00
|
|
|
unsigned long d0, d1, d2;
|
|
|
|
|
|
|
|
asm volatile(
|
2015-06-18 01:09:10 +02:00
|
|
|
#ifdef __x86_64__
|
|
|
|
"rep ; movsd\n\t"
|
|
|
|
"mov %4,%%rcx\n\t"
|
|
|
|
#else
|
2012-08-23 02:01:08 +02:00
|
|
|
"rep ; movsl\n\t"
|
|
|
|
"movl %4,%%ecx\n\t"
|
2015-06-18 01:09:10 +02:00
|
|
|
#endif
|
2012-08-23 02:01:08 +02:00
|
|
|
"rep ; movsb\n\t"
|
|
|
|
: "=&c" (d0), "=&D" (d1), "=&S" (d2)
|
|
|
|
: "0" (n >> 2), "g" (n & 3), "1" (dest), "2" (src)
|
2012-03-31 17:23:53 +02:00
|
|
|
: "memory"
|
2012-08-23 02:01:08 +02:00
|
|
|
);
|
2012-03-31 17:23:53 +02:00
|
|
|
|
|
|
|
return dest;
|
2011-10-26 01:43:34 +02:00
|
|
|
}
|