diff options
Diffstat (limited to 'core/kernel')
-rw-r--r-- | core/kernel/early_ta.c | 64 | ||||
-rw-r--r-- | core/kernel/sub.mk | 1 |
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 |