SPM: Restructure memory operation functions

SPM calls spm_memcpy/spm_memset, and SP just calls memset, memcpy,
memmove and memcmp. SPM has its own header files for
spm_memcpy/spm_memset prototypes, while SP relies on toolchain headers
string.h for prototypes.
As -fno-builtin is applied, our memcpy would replace the same function
in toolchain library.

Change-Id: Iab240c96e06d55144daa0125b2d17574b648f9e1
Signed-off-by: Summer Qin <summer.qin@arm.com>
diff --git a/secure_fw/partitions/lib/sprt/crt_memcmp.c b/secure_fw/partitions/lib/sprt/crt_memcmp.c
new file mode 100644
index 0000000..0370ff0
--- /dev/null
+++ b/secure_fw/partitions/lib/sprt/crt_memcmp.c
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#include <stddef.h>
+#include <stdint.h>
+
+int memcmp(const void *s1, const void *s2, size_t n)
+{
+    int result = 0;
+    const uint8_t *p1 = (const uint8_t *)s1;
+    const uint8_t *p2 = (const uint8_t *)s2;
+    while (n--) {
+        if ((*p1 != *p2) && (result == 0)) {
+            result = *p1 - *p2;
+        } else {
+            p1++;
+            p2++;
+        }
+    }
+    return result;
+}