mb/google/skyrim: Enable Chrome EC
[coreboot.git] / src / arch / x86 / memcpy.c
blob93002cdd27574f955b837d3d649cf699072ddf72
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <string.h>
4 #include <stdbool.h>
5 #include <asan.h>
7 void *memcpy(void *dest, const void *src, size_t n)
9 unsigned long d0, d1, d2;
11 #if (ENV_ROMSTAGE && CONFIG(ASAN_IN_ROMSTAGE)) || \
12 (ENV_RAMSTAGE && CONFIG(ASAN_IN_RAMSTAGE))
13 check_memory_region((unsigned long)src, n, false, _RET_IP_);
14 check_memory_region((unsigned long)dest, n, true, _RET_IP_);
15 #endif
17 asm volatile(
18 #if ENV_X86_64
19 "rep ; movsd\n\t"
20 "mov %4,%%rcx\n\t"
21 #else
22 "rep ; movsl\n\t"
23 "movl %4,%%ecx\n\t"
24 #endif
25 "rep ; movsb\n\t"
26 : "=&c" (d0), "=&D" (d1), "=&S" (d2)
27 : "0" (n >> 2), "g" (n & 3), "1" (dest), "2" (src)
28 : "memory"
31 return dest;