drivers/wifi: Remove unnecessary data structure copy
[coreboot2.git] / src / arch / x86 / memcpy.c
blob9da2a7512e8e734f97759b20e899a2f48523dc50
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_SEPARATE_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 #if ENV_X86_64
18 asm volatile(
19 "rep ; movsq\n\t"
20 "mov %4,%%rcx\n\t"
21 "rep ; movsb\n\t"
22 : "=&c" (d0), "=&D" (d1), "=&S" (d2)
23 : "0" (n >> 3), "g" (n & 7), "1" (dest), "2" (src)
24 : "memory"
26 #else
27 asm volatile(
28 "rep ; movsl\n\t"
29 "movl %4,%%ecx\n\t"
30 "rep ; movsb\n\t"
31 : "=&c" (d0), "=&D" (d1), "=&S" (d2)
32 : "0" (n >> 2), "g" (n & 3), "1" (dest), "2" (src)
33 : "memory"
35 #endif
38 return dest;