aboutsummaryrefslogtreecommitdiff
path: root/core/kernel
diff options
context:
space:
mode:
authorMarouene Boubakri <marouene.boubakri@nxp.com>2021-03-29 15:30:51 +0200
committerJérôme Forissier <jerome@forissier.org>2021-03-31 10:19:35 +0200
commit1bfc10827ef2ad1accf4f2c27fd12b9d70330f56 (patch)
treef7b4a1267d48fb0ce1fd0105e2396d98c07d04af /core/kernel
parenta54f2bb703cea069f79647bb5bf90ac7088bcb99 (diff)
core: kernel: move early_ta.c to core/tee
early_ta.c is not architecture-specific code, therefore move it to core/tee. Moves early_ta.h to core/include/kernel as well. Signed-off-by: Marouene Boubakri <marouene.boubakri@nxp.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Diffstat (limited to 'core/kernel')
-rw-r--r--core/kernel/early_ta.c64
-rw-r--r--core/kernel/sub.mk1
2 files changed, 65 insertions, 0 deletions
diff --git a/core/kernel/early_ta.c b/core/kernel/early_ta.c
new file mode 100644
index 00000000..5024c4e5
--- /dev/null
+++ b/core/kernel/early_ta.c
@@ -0,0 +1,64 @@
+// SPDX-License-Identifier: BSD-2-Clause
+/*
+ * Copyright (c) 2017, Linaro Limited
+ * Copyright (c) 2020, Arm Limited.
+ */
+#include <crypto/crypto.h>
+#include <initcall.h>
+#include <kernel/early_ta.h>
+#include <kernel/embedded_ts.h>
+#include <kernel/ts_store.h>
+#include <kernel/user_ta.h>
+#include <stdio.h>
+#include <string.h>
+#include <trace.h>
+#include <utee_defines.h>
+#include <util.h>
+#include <zlib.h>
+
+static const struct embedded_ts *find_early_ta(const TEE_UUID *uuid)
+{
+ const struct embedded_ts *ta = NULL;
+
+ for_each_early_ta(ta)
+ if (!memcmp(&ta->uuid, uuid, sizeof(*uuid)))
+ return ta;
+
+ return NULL;
+}
+
+static TEE_Result early_ta_open(const TEE_UUID *uuid,
+ struct ts_store_handle **h)
+{
+ return emb_ts_open(uuid, h, find_early_ta);
+}
+
+REGISTER_TA_STORE(2) = {
+ .description = "early TA",
+ .open = early_ta_open,
+ .get_size = emb_ts_get_size,
+ .get_tag = emb_ts_get_tag,
+ .read = emb_ts_read,
+ .close = emb_ts_close,
+};
+
+static TEE_Result early_ta_init(void)
+{
+ const struct embedded_ts *ta = NULL;
+ char __maybe_unused msg[60] = { '\0', };
+
+ for_each_early_ta(ta) {
+ if (ta->uncompressed_size)
+ snprintf(msg, sizeof(msg),
+ " (compressed, uncompressed %u)",
+ ta->uncompressed_size);
+ else
+ msg[0] = '\0';
+ DMSG("Early TA %pUl size %u%s", (void *)&ta->uuid, ta->size,
+ msg);
+ }
+
+ return TEE_SUCCESS;
+}
+
+service_init(early_ta_init);
diff --git a/core/kernel/sub.mk b/core/kernel/sub.mk
index 65f1e3eb..19a8e6db 100644
--- a/core/kernel/sub.mk
+++ b/core/kernel/sub.mk
@@ -30,6 +30,7 @@ srcs-y += wait_queue.c
ifeq ($(CFG_WITH_USER_TA),y)
srcs-y += user_ta.c
+srcs-$(CFG_EARLY_TA) += early_ta.c
endif
srcs-y += pseudo_ta.c