Remove OP-TEE dependency of SP heap
Remove OPTEE_ prefix from OPTEE_SP_HEAP_SIZE definition and move it to
the CMake file of the deployment. This is a preparation for having
generic format SPs.
Signed-off-by: Imre Kis <imre.kis@arm.com>
Change-Id: I73028dcbdf27a44285a1cd250cd242865bf6d119
diff --git a/deployments/attestation/opteesp/CMakeLists.txt b/deployments/attestation/opteesp/CMakeLists.txt
index eebf79d..6e22648 100644
--- a/deployments/attestation/opteesp/CMakeLists.txt
+++ b/deployments/attestation/opteesp/CMakeLists.txt
@@ -1,5 +1,5 @@
#-------------------------------------------------------------------------------
-# Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
+# Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -21,6 +21,7 @@
add_executable(attestation)
target_include_directories(attestation PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
set(SP_UUID "a1baf155-8876-4695-8f7c-54955e8db974")
+set(SP_HEAP_SIZE "32 * 1024" CACHE STRING "SP heap size in bytes")
set(TRACE_PREFIX "ATT" CACHE STRING "Trace prefix")
#-------------------------------------------------------------------------------
diff --git a/deployments/attestation/opteesp/optee_sp_user_defines.h b/deployments/attestation/opteesp/optee_sp_user_defines.h
index 23c67b6..95531fe 100644
--- a/deployments/attestation/opteesp/optee_sp_user_defines.h
+++ b/deployments/attestation/opteesp/optee_sp_user_defines.h
@@ -1,7 +1,6 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
/*
- * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved.
*/
#ifndef SP_HEADER_DEFINES_H
@@ -16,7 +15,4 @@
/* Provisioned stack size */
#define OPTEE_SP_STACK_SIZE (64 * 1024)
-/* Provisioned heap size */
-#define OPTEE_SP_HEAP_SIZE (32 * 1024)
-
#endif /* SP_HEADER_DEFINES_H */
diff --git a/deployments/crypto/opteesp/CMakeLists.txt b/deployments/crypto/opteesp/CMakeLists.txt
index 442c38e..8276e67 100644
--- a/deployments/crypto/opteesp/CMakeLists.txt
+++ b/deployments/crypto/opteesp/CMakeLists.txt
@@ -1,5 +1,5 @@
#-------------------------------------------------------------------------------
-# Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.
+# Copyright (c) 2020-2022, Arm Limited and Contributors. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -21,6 +21,7 @@
add_executable(crypto-sp)
target_include_directories(crypto-sp PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
set(SP_UUID "d9df52d5-16a2-4bb2-9aa4-d26d3b84e8c0")
+set(SP_HEAP_SIZE "490 * 1024" CACHE STRING "SP heap size in bytes")
set(TRACE_PREFIX "CRYPTO" CACHE STRING "Trace prefix")
#-------------------------------------------------------------------------------
diff --git a/deployments/crypto/opteesp/optee_sp_user_defines.h b/deployments/crypto/opteesp/optee_sp_user_defines.h
index 2d7ba50..dc40c5e 100644
--- a/deployments/crypto/opteesp/optee_sp_user_defines.h
+++ b/deployments/crypto/opteesp/optee_sp_user_defines.h
@@ -1,7 +1,6 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
/*
- * Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2020-2022, Arm Limited and Contributors. All rights reserved.
*/
#ifndef SP_HEADER_DEFINES_H
@@ -16,7 +15,4 @@
/* Provisioned stack size */
#define OPTEE_SP_STACK_SIZE (64 * 1024)
-/* Provisioned heap size */
-#define OPTEE_SP_HEAP_SIZE (490 * 1024)
-
#endif /* SP_HEADER_DEFINES_H */
diff --git a/deployments/env-test/opteesp/CMakeLists.txt b/deployments/env-test/opteesp/CMakeLists.txt
index 360d7d0..5377961 100644
--- a/deployments/env-test/opteesp/CMakeLists.txt
+++ b/deployments/env-test/opteesp/CMakeLists.txt
@@ -1,5 +1,5 @@
#-------------------------------------------------------------------------------
-# Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
+# Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -22,6 +22,7 @@
add_executable(env-test)
target_include_directories(env-test PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
set(SP_UUID "33c75baf-ac6a-4fe4-8ac7-e9909bee2d17")
+set(SP_HEAP_SIZE "32 * 1024" CACHE STRING "SP heap size in bytes")
set(TRACE_PREFIX "ENVTEST" CACHE STRING "Trace prefix")
#-------------------------------------------------------------------------------
diff --git a/deployments/env-test/opteesp/optee_sp_user_defines.h b/deployments/env-test/opteesp/optee_sp_user_defines.h
index a524a6e..ac429cf 100644
--- a/deployments/env-test/opteesp/optee_sp_user_defines.h
+++ b/deployments/env-test/opteesp/optee_sp_user_defines.h
@@ -1,7 +1,6 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
/*
- * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved.
*/
#ifndef SP_HEADER_DEFINES_H
@@ -16,7 +15,4 @@
/* Provisioned stack size */
#define OPTEE_SP_STACK_SIZE (64 * 1024)
-/* Provisioned heap size */
-#define OPTEE_SP_HEAP_SIZE (32 * 1024)
-
#endif /* SP_HEADER_DEFINES_H */
diff --git a/deployments/internal-trusted-storage/opteesp/CMakeLists.txt b/deployments/internal-trusted-storage/opteesp/CMakeLists.txt
index fb51b13..b5efc46 100644
--- a/deployments/internal-trusted-storage/opteesp/CMakeLists.txt
+++ b/deployments/internal-trusted-storage/opteesp/CMakeLists.txt
@@ -1,5 +1,5 @@
#-------------------------------------------------------------------------------
-# Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.
+# Copyright (c) 2020-2022, Arm Limited and Contributors. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -18,6 +18,7 @@
add_executable(internal-trusted-storage)
target_include_directories(internal-trusted-storage PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
set(SP_UUID "dc1eef48-b17a-4ccf-ac8b-dfcff7711b14")
+set(SP_HEAP_SIZE "32 * 1024" CACHE STRING "SP heap size in bytes")
set(TRACE_PREFIX "ITS" CACHE STRING "Trace prefix")
add_components(TARGET "internal-trusted-storage"
diff --git a/deployments/internal-trusted-storage/opteesp/optee_sp_user_defines.h b/deployments/internal-trusted-storage/opteesp/optee_sp_user_defines.h
index e773055..d86d29b 100644
--- a/deployments/internal-trusted-storage/opteesp/optee_sp_user_defines.h
+++ b/deployments/internal-trusted-storage/opteesp/optee_sp_user_defines.h
@@ -1,7 +1,6 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
/*
- * Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2020-2022, Arm Limited and Contributors. All rights reserved.
*/
#ifndef SP_HEADER_DEFINES_H
@@ -15,7 +14,4 @@
/* Provisioned stack size */
#define OPTEE_SP_STACK_SIZE (64 * 1024)
-/* Provisioned heap size */
-#define OPTEE_SP_HEAP_SIZE (32 * 1024)
-
#endif /* SP_HEADER_DEFINES_H */
diff --git a/deployments/protected-storage/opteesp/CMakeLists.txt b/deployments/protected-storage/opteesp/CMakeLists.txt
index 15fea17..7eb9532 100644
--- a/deployments/protected-storage/opteesp/CMakeLists.txt
+++ b/deployments/protected-storage/opteesp/CMakeLists.txt
@@ -1,5 +1,5 @@
#-------------------------------------------------------------------------------
-# Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.
+# Copyright (c) 2020-2022, Arm Limited and Contributors. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -18,6 +18,7 @@
add_executable(protected-storage)
target_include_directories(protected-storage PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
set(SP_UUID "751bf801-3dde-4768-a514-0f10aeed1790")
+set(SP_HEAP_SIZE "32 * 1024" CACHE STRING "SP heap size in bytes")
set(TRACE_PREFIX "PS" CACHE STRING "Trace prefix")
add_components(TARGET "protected-storage"
diff --git a/deployments/protected-storage/opteesp/optee_sp_user_defines.h b/deployments/protected-storage/opteesp/optee_sp_user_defines.h
index e773055..d86d29b 100644
--- a/deployments/protected-storage/opteesp/optee_sp_user_defines.h
+++ b/deployments/protected-storage/opteesp/optee_sp_user_defines.h
@@ -1,7 +1,6 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
/*
- * Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2020-2022, Arm Limited and Contributors. All rights reserved.
*/
#ifndef SP_HEADER_DEFINES_H
@@ -15,7 +14,4 @@
/* Provisioned stack size */
#define OPTEE_SP_STACK_SIZE (64 * 1024)
-/* Provisioned heap size */
-#define OPTEE_SP_HEAP_SIZE (32 * 1024)
-
#endif /* SP_HEADER_DEFINES_H */
diff --git a/deployments/se-proxy/opteesp/CMakeLists.txt b/deployments/se-proxy/opteesp/CMakeLists.txt
index 433323c..1d75963 100644
--- a/deployments/se-proxy/opteesp/CMakeLists.txt
+++ b/deployments/se-proxy/opteesp/CMakeLists.txt
@@ -1,5 +1,5 @@
#-------------------------------------------------------------------------------
-# Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
+# Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -22,6 +22,7 @@
add_executable(se-proxy)
target_include_directories(se-proxy PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
set(SP_UUID "46bb39d1-b4d9-45b5-88ff-040027dab249")
+set(SP_HEAP_SIZE "32 * 1024" CACHE STRING "SP heap size in bytes")
#-------------------------------------------------------------------------------
# Components that are specific to deployment in the opteesp environment.
diff --git a/deployments/se-proxy/opteesp/optee_sp_user_defines.h b/deployments/se-proxy/opteesp/optee_sp_user_defines.h
index 3c25e43..bdeada3 100644
--- a/deployments/se-proxy/opteesp/optee_sp_user_defines.h
+++ b/deployments/se-proxy/opteesp/optee_sp_user_defines.h
@@ -1,7 +1,6 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
/*
- * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved.
*/
#ifndef SP_HEADER_DEFINES_H
@@ -16,7 +15,4 @@
/* Provisioned stack size */
#define OPTEE_SP_STACK_SIZE (64 * 1024)
-/* Provisioned heap size */
-#define OPTEE_SP_HEAP_SIZE (32 * 1024)
-
#endif /* SP_HEADER_DEFINES_H */
diff --git a/deployments/sfs-demo/opteesp/CMakeLists.txt b/deployments/sfs-demo/opteesp/CMakeLists.txt
index e745a42..79539f6 100644
--- a/deployments/sfs-demo/opteesp/CMakeLists.txt
+++ b/deployments/sfs-demo/opteesp/CMakeLists.txt
@@ -1,5 +1,5 @@
#-------------------------------------------------------------------------------
-# Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.
+# Copyright (c) 2020-2022, Arm Limited and Contributors. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -17,6 +17,7 @@
project(trusted-services LANGUAGES C ASM)
add_executable(sfs-demo)
set(SP_UUID "01109cf8-e5ca-446f-9b55-f3cdc65110c8")
+set(SP_HEAP_SIZE "32 * 1024" CACHE STRING "SP heap size in bytes")
set(TRACE_PREFIX "SFSDEMO" CACHE STRING "Trace prefix")
add_components(TARGET "sfs-demo"
diff --git a/deployments/sfs-demo/opteesp/optee_sp_user_defines.h b/deployments/sfs-demo/opteesp/optee_sp_user_defines.h
index e773055..d86d29b 100644
--- a/deployments/sfs-demo/opteesp/optee_sp_user_defines.h
+++ b/deployments/sfs-demo/opteesp/optee_sp_user_defines.h
@@ -1,7 +1,6 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
/*
- * Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2020-2022, Arm Limited and Contributors. All rights reserved.
*/
#ifndef SP_HEADER_DEFINES_H
@@ -15,7 +14,4 @@
/* Provisioned stack size */
#define OPTEE_SP_STACK_SIZE (64 * 1024)
-/* Provisioned heap size */
-#define OPTEE_SP_HEAP_SIZE (32 * 1024)
-
#endif /* SP_HEADER_DEFINES_H */
diff --git a/deployments/smm-gateway/opteesp/CMakeLists.txt b/deployments/smm-gateway/opteesp/CMakeLists.txt
index 7cf6a7b..4a4d7ff 100644
--- a/deployments/smm-gateway/opteesp/CMakeLists.txt
+++ b/deployments/smm-gateway/opteesp/CMakeLists.txt
@@ -1,5 +1,5 @@
#-------------------------------------------------------------------------------
-# Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
+# Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -21,6 +21,7 @@
add_executable(smm-gateway)
target_include_directories(smm-gateway PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
set(SP_UUID "ed32d533-99e6-4209-9cc0-2d72cdd998a7")
+set(SP_HEAP_SIZE "32 * 1024" CACHE STRING "SP heap size in bytes")
# Setting the MM communication buffer parameters
set(MM_COMM_BUFFER_ADDRESS "0x00000008 0x81000000" CACHE STRING "Address of MM communicte buffer in 64 bit DTS format")
diff --git a/deployments/smm-gateway/opteesp/optee_sp_user_defines.h b/deployments/smm-gateway/opteesp/optee_sp_user_defines.h
index edcd469..dd257fa 100644
--- a/deployments/smm-gateway/opteesp/optee_sp_user_defines.h
+++ b/deployments/smm-gateway/opteesp/optee_sp_user_defines.h
@@ -1,7 +1,6 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
/*
- * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved.
*/
#ifndef SP_HEADER_DEFINES_H
@@ -16,7 +15,4 @@
/* Provisioned stack size */
#define OPTEE_SP_STACK_SIZE (64 * 1024)
-/* Provisioned heap size */
-#define OPTEE_SP_HEAP_SIZE (32 * 1024)
-
#endif /* SP_HEADER_DEFINES_H */
diff --git a/environments/opteesp/component.cmake b/environments/opteesp/component.cmake
index 1b7c418..86b1d19 100644
--- a/environments/opteesp/component.cmake
+++ b/environments/opteesp/component.cmake
@@ -1,5 +1,5 @@
#-------------------------------------------------------------------------------
-# Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.
+# Copyright (c) 2020-2022, Arm Limited and Contributors. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -25,9 +25,14 @@
set(TRACE_PREFIX "SP" CACHE STRING "Trace prefix")
set(TRACE_LEVEL "TRACE_LEVEL_ERROR" CACHE STRING "Trace level")
+if (NOT DEFINED SP_HEAP_SIZE)
+ message(FATAL_ERROR "SP_HEAP_SIZE is not defined")
+endif()
+
target_compile_definitions(${TGT} PRIVATE
TRACE_LEVEL=${TRACE_LEVEL}
TRACE_PREFIX="${TRACE_PREFIX}"
+ SP_HEAP_SIZE=${SP_HEAP_SIZE}
)
include(../../../external/newlib/newlib.cmake)
diff --git a/environments/opteesp/include/optee_sp_internal_api.h b/environments/opteesp/include/optee_sp_internal_api.h
index d275caa..1ffd4c1 100644
--- a/environments/opteesp/include/optee_sp_internal_api.h
+++ b/environments/opteesp/include/optee_sp_internal_api.h
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: BSD-3-Clause */
/*
- * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
+ * Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved.
*/
#ifndef OPTEE_SP_INTERNAL_API_H_
@@ -13,7 +13,6 @@
* The SP code base should also contain a header file named
* "optee_sp_user_defines.h" for passing the following definitions to the SP dev
* kit:
- * * OPTEE_SP_HEAP_SIZE: Heap size in bytes
* * OPTEE_SP_UUID: UUID of the SP as an sp_uuid structure
* * OPTEE_SP_STACK_SIZE: Stack size in bytes
* * OPTEE_SP_FLAGS: SP attributes (currently none available, set to zero)
diff --git a/external/newlib/newlib_sp_heap.c b/external/newlib/newlib_sp_heap.c
index 77a288a..20b9ce3 100644
--- a/external/newlib/newlib_sp_heap.c
+++ b/external/newlib/newlib_sp_heap.c
@@ -1,20 +1,19 @@
// SPDX-License-Identifier: BSD-3-Clause
/*
- * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
+ * Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved.
*/
#include "compiler.h"
-#include "optee_sp_user_defines.h"
#include <errno.h>
#include <stdint.h>
#include <unistd.h>
/* Allocating heap area */
-#ifndef OPTEE_SP_HEAP_SIZE
-#error "OPTEE_SP_HEAP_SIZE is not defined in SP"
+#ifndef SP_HEAP_SIZE
+#error "SP_HEAP_SIZE is undefined, please define it in the build system"
#endif
-static uint8_t sp_heap[OPTEE_SP_HEAP_SIZE] __aligned(16);
+static uint8_t sp_heap[SP_HEAP_SIZE] __aligned(16);
static uint8_t *program_break = sp_heap;
/**