summaryrefslogtreecommitdiffstats
path: root/ArmPkg/Library/CompilerIntrinsicsLib/memcpy.c
diff options
context:
space:
mode:
authorArd Biesheuvel <ard.biesheuvel@linaro.org>2016-08-11 16:01:24 +0200
committerArd Biesheuvel <ard.biesheuvel@linaro.org>2016-09-01 14:51:18 +0100
commita0cf6b8d93d7fab44f8bcb850ebbe696d0c3d4bd (patch)
treee7d35db10ee7a5f9cf2c16dd9c96381431666e9d /ArmPkg/Library/CompilerIntrinsicsLib/memcpy.c
parent00afc8f82061677fedc86cb05e3b8c75a3c986ff (diff)
downloadedk2-a0cf6b8d93d7fab44f8bcb850ebbe696d0c3d4bd.tar.gz
edk2-a0cf6b8d93d7fab44f8bcb850ebbe696d0c3d4bd.tar.bz2
edk2-a0cf6b8d93d7fab44f8bcb850ebbe696d0c3d4bd.zip
ArmPkg/CompilerIntrinsicsLib: replace memcpy and memset with C code
This replaces the various implementations of memset and memcpy, including the ARM RTABI ones (__aeabi_mem[set|clr]_[|4|8]) with a single C implementation for each. The ones we have are either not very sophisticated (ARM), or they are too sophisticated (memcpy() on AARCH64, which may perform unaligned accesses) or already coded in C (memset on AArch64). The Tianocore codebase mandates the explicit use of its SetMem() and CopyMem() equivalents, of which various implementations exist for use in different contexts (PEI, DXE). Few compiler generated references to these functions should remain, and so our implementations in this BASE library should be small and usable with the MMU off. So replace them with a simple C implementation that builds correctly on GCC/AARCH64, CLANG/AARCH64, GCC/ARM, CLANG/ARM and RVCT/ARM. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
Diffstat (limited to 'ArmPkg/Library/CompilerIntrinsicsLib/memcpy.c')
-rw-r--r--ArmPkg/Library/CompilerIntrinsicsLib/memcpy.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memcpy.c b/ArmPkg/Library/CompilerIntrinsicsLib/memcpy.c
new file mode 100644
index 0000000000..a944e00b89
--- /dev/null
+++ b/ArmPkg/Library/CompilerIntrinsicsLib/memcpy.c
@@ -0,0 +1,44 @@
+//------------------------------------------------------------------------------
+//
+// Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
+//
+// This program and the accompanying materials are licensed and made
+// available under the terms and conditions of the BSD License which
+// accompanies this distribution. The full text of the license may be
+// found at http://opensource.org/licenses/bsd-license.php
+//
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR
+// IMPLIED.
+//
+//------------------------------------------------------------------------------
+
+typedef __SIZE_TYPE__ size_t;
+
+static __attribute__((__used__))
+void *__memcpy(void *dest, const void *src, size_t n)
+{
+ unsigned char *d = dest;
+ unsigned char const *s = src;
+
+ while (n--)
+ *d++ = *s++;
+
+ return dest;
+}
+
+__attribute__((__alias__("__memcpy")))
+void *memcpy(void *dest, const void *src, size_t n);
+
+#ifdef __arm__
+
+__attribute__((__alias__("__memcpy")))
+void __aeabi_memcpy(void *dest, const void *src, size_t n);
+
+__attribute__((__alias__("__memcpy")))
+void __aeabi_memcpy4(void *dest, const void *src, size_t n);
+
+__attribute__((__alias__("__memcpy")))
+void __aeabi_memcpy8(void *dest, const void *src, size_t n);
+
+#endif