SPM: Share 'memcpy' and 'memset' with partitions
TF-M applies isolation rule I3, which allows code-sharing between
cross-domain components. This makes separating fundamental APIs
such as memset/memcpy less significant. This patch shares these
two fundamental APIs memset/memcpy between SPM and partitions.
A slight optimization is made on the implementation - removes
unnecessary half-word copying.
Change-Id: I7d4c931aefd94d56468806ab768048da156e4656
Signed-off-by: Ken Liu <Ken.Liu@arm.com>
diff --git a/secure_fw/spm/include/tfm_core_utils.h b/secure_fw/spm/include/tfm_core_utils.h
deleted file mode 100644
index e916842..0000000
--- a/secure_fw/spm/include/tfm_core_utils.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- *
- */
-
-#ifndef __TFM_CORE_UTILS_H__
-#define __TFM_CORE_UTILS_H__
-
-#include <stddef.h>
-#include <stdint.h>
-
-/**
- * \brief Memory copy function for TF-M core
- *
- * \param[out] dest Destination address of memory
- * \param[in] src Source address of memory
- * \param[in] n Number of bytes to copy
- *
- * \retval Destination address of memory
- * \note The function is used for copying same-sized object
- * only.
- */
-void *spm_memcpy(void *dest, const void *src, size_t n);
-
-/**
- * \brief Memory set function for TF-M core
- *
- * \param[out] s Destination address of memory
- * \param[in] c Value to be written to memory
- * \param[in] n Number of bytes to be wirtten
- *
- * \retval Destination address of memory
- */
-void *spm_memset(void *s, int c, size_t n);
-
-#endif /* __TFM_CORE_UTILS_H__ */
diff --git a/secure_fw/spm/include/utilities.h b/secure_fw/spm/include/utilities.h
index 2f27487..71180c5 100644
--- a/secure_fw/spm/include/utilities.h
+++ b/secure_fw/spm/include/utilities.h
@@ -8,7 +8,7 @@
#define __TFM_UTILS_H__
#include <stdbool.h>
-#include <stdio.h>
+#include <string.h>
#include "tfm_spm_log.h"
/*
@@ -41,4 +41,8 @@
#define STRINGIFY_EXPAND(x) #x
#define M2S(m) STRINGIFY_EXPAND(m)
+/* Runtime memory operations forwarding */
+#define spm_memcpy memcpy
+#define spm_memset memset
+
#endif /* __TFM_UTILS_H__ */