aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Wiklander <jens.wiklander@linaro.org>2015-07-23 17:01:43 +0200
committerJens Wiklander <jens.wiklander@linaro.org>2015-11-05 10:16:14 +0100
commit5c781c55e9768a91eca25d004e9ae1a8adeebe89 (patch)
treec58eadc585326bf377c1de23ab9f1a3b6438d339
parent9bdc34f232fcac3c42210f9ae8fa0c54fc44ddb2 (diff)
core: split tee/entry.c
Split core/arch/arm/tee/entry.c into entry_fast.c and entry_std.c to separate fast call code from standard call code. Fast call code must not be paged, but standard code should be paged if possible. The pager can only handle page faults for active threads. Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Tested-by: Jens Wiklander <jens.wiklander@linaro.org> (QEMU) Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
-rw-r--r--core/arch/arm/include/tee/entry_fast.h (renamed from core/arch/arm/include/tee/entry.h)11
-rw-r--r--core/arch/arm/include/tee/entry_std.h38
-rw-r--r--core/arch/arm/kernel/link.mk4
-rw-r--r--core/arch/arm/plat-hikey/main.c7
-rw-r--r--core/arch/arm/plat-imx/main.c7
-rw-r--r--core/arch/arm/plat-ls/main.c7
-rw-r--r--core/arch/arm/plat-mediatek/main.c7
-rw-r--r--core/arch/arm/plat-stm/main.c7
-rw-r--r--core/arch/arm/plat-sunxi/main.c27
-rw-r--r--core/arch/arm/plat-sunxi/platform.c1
-rw-r--r--core/arch/arm/plat-ti/main.c7
-rw-r--r--core/arch/arm/plat-vexpress/main.c7
-rw-r--r--core/arch/arm/tee/entry_fast.c156
-rw-r--r--core/arch/arm/tee/entry_std.c (renamed from core/arch/arm/tee/entry.c)164
-rw-r--r--core/arch/arm/tee/sub.mk3
15 files changed, 270 insertions, 183 deletions
diff --git a/core/arch/arm/include/tee/entry.h b/core/arch/arm/include/tee/entry_fast.h
index 57be56aa..a9951f2f 100644
--- a/core/arch/arm/include/tee/entry.h
+++ b/core/arch/arm/include/tee/entry_fast.h
@@ -1,4 +1,6 @@
/*
+ * Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
* Copyright (c) 2014, STMicroelectronics International N.V.
* All rights reserved.
*
@@ -25,8 +27,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef TEE_ENTRY_H
-#define TEE_ENTRY_H
+#ifndef TEE_ENTRY_FAST_H
+#define TEE_ENTRY_FAST_H
#include <kernel/thread.h>
@@ -44,6 +46,7 @@ void tee_entry_get_os_revision(struct thread_smc_args *args);
*/
size_t tee_entry_generic_get_api_call_count(void);
-void tee_entry(struct thread_smc_args *args);
+/* Fast call entry */
+void tee_entry_fast(struct thread_smc_args *args);
-#endif /* TEE_ENTRY_H */
+#endif /* TEE_ENTRY_FAST_H */
diff --git a/core/arch/arm/include/tee/entry_std.h b/core/arch/arm/include/tee/entry_std.h
new file mode 100644
index 00000000..d5459123
--- /dev/null
+++ b/core/arch/arm/include/tee/entry_std.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ * Copyright (c) 2014, STMicroelectronics International N.V.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef TEE_ENTRY_STD_H
+#define TEE_ENTRY_STD_H
+
+#include <kernel/thread.h>
+
+/* Standard call entry */
+void tee_entry_std(struct thread_smc_args *args);
+
+#endif /* TEE_ENTRY_STD_H */
diff --git a/core/arch/arm/kernel/link.mk b/core/arch/arm/kernel/link.mk
index bc863ad1..2f82219c 100644
--- a/core/arch/arm/kernel/link.mk
+++ b/core/arch/arm/kernel/link.mk
@@ -34,7 +34,7 @@ entries-unpaged += generic_boot_get_handlers
entries-unpaged += tee_pager_release_zi
entries-unpaged += tee_pager_request_zi
-objs-unpaged-rem += core/arch/arm/tee/entry.o
+objs-unpaged-rem += core/arch/arm/tee/entry_std.o
objs-unpaged-rem += core/arch/arm/tee/arch_svc.o
objs-unpaged := \
$(filter-out $(addprefix $(out-dir)/, $(objs-unpaged-rem)), $(objs))
@@ -60,7 +60,7 @@ $(link-out-dir)/rodata_unpaged.ld.S: $(link-out-dir)/unpaged.o
objs-init-rem += core/arch/arm/tee/arch_svc.o
objs-init-rem += core/arch/arm/tee/arch_svc_asm.o
objs-init-rem += core/arch/arm/tee/init.o
-objs-init-rem += core/arch/arm/tee/entry.o
+objs-init-rem += core/arch/arm/tee/entry_std.o
entries-init += _start
objs-init := \
$(filter-out $(addprefix $(out-dir)/, $(objs-init-rem)), $(objs) \
diff --git a/core/arch/arm/plat-hikey/main.c b/core/arch/arm/plat-hikey/main.c
index b29064bc..9d6c66f3 100644
--- a/core/arch/arm/plat-hikey/main.c
+++ b/core/arch/arm/plat-hikey/main.c
@@ -34,13 +34,14 @@
#include <platform_config.h>
#include <stdint.h>
#include <tee/arch_svc.h>
-#include <tee/entry.h>
+#include <tee/entry_std.h>
+#include <tee/entry_fast.h>
static void main_fiq(void);
static const struct thread_handlers handlers = {
- .std_smc = tee_entry,
- .fast_smc = tee_entry,
+ .std_smc = tee_entry_std,
+ .fast_smc = tee_entry_fast,
.fiq = main_fiq,
.svc = tee_svc_handler,
.abort = tee_pager_abort_handler,
diff --git a/core/arch/arm/plat-imx/main.c b/core/arch/arm/plat-imx/main.c
index de0143a8..9c896f95 100644
--- a/core/arch/arm/plat-imx/main.c
+++ b/core/arch/arm/plat-imx/main.c
@@ -34,13 +34,14 @@
#include <platform_config.h>
#include <stdint.h>
#include <tee/arch_svc.h>
-#include <tee/entry.h>
+#include <tee/entry_std.h>
+#include <tee/entry_fast.h>
static void main_fiq(void);
static const struct thread_handlers handlers = {
- .std_smc = tee_entry,
- .fast_smc = tee_entry,
+ .std_smc = tee_entry_std,
+ .fast_smc = tee_entry_fast,
.fiq = main_fiq,
.svc = tee_svc_handler,
.abort = tee_pager_abort_handler,
diff --git a/core/arch/arm/plat-ls/main.c b/core/arch/arm/plat-ls/main.c
index 2d806743..8dc5e86f 100644
--- a/core/arch/arm/plat-ls/main.c
+++ b/core/arch/arm/plat-ls/main.c
@@ -34,14 +34,15 @@
#include <kernel/panic.h>
#include <kernel/pm_stubs.h>
#include <mm/tee_pager.h>
-#include <tee/entry.h>
+#include <tee/entry_std.h>
+#include <tee/entry_fast.h>
#include <tee/arch_svc.h>
static void main_fiq(void);
static const struct thread_handlers handlers = {
- .std_smc = tee_entry,
- .fast_smc = tee_entry,
+ .std_smc = tee_entry_std,
+ .fast_smc = tee_entry_fast,
.fiq = main_fiq,
.svc = tee_svc_handler,
.abort = tee_pager_abort_handler,
diff --git a/core/arch/arm/plat-mediatek/main.c b/core/arch/arm/plat-mediatek/main.c
index b520ec74..c815f36b 100644
--- a/core/arch/arm/plat-mediatek/main.c
+++ b/core/arch/arm/plat-mediatek/main.c
@@ -34,13 +34,14 @@
#include <platform_config.h>
#include <stdint.h>
#include <tee/arch_svc.h>
-#include <tee/entry.h>
+#include <tee/entry_std.h>
+#include <tee/entry_fast.h>
static void main_fiq(void);
static const struct thread_handlers handlers = {
- .std_smc = tee_entry,
- .fast_smc = tee_entry,
+ .std_smc = tee_entry_std,
+ .fast_smc = tee_entry_fast,
.fiq = main_fiq,
.svc = tee_svc_handler,
.abort = tee_pager_abort_handler,
diff --git a/core/arch/arm/plat-stm/main.c b/core/arch/arm/plat-stm/main.c
index ba6ef6ae..f70c895f 100644
--- a/core/arch/arm/plat-stm/main.c
+++ b/core/arch/arm/plat-stm/main.c
@@ -34,14 +34,15 @@
#include <platform_config.h>
#include <stdint.h>
#include <tee/arch_svc.h>
-#include <tee/entry.h>
+#include <tee/entry_std.h>
+#include <tee/entry_fast.h>
#include <asc.h>
static void main_fiq(void);
static const struct thread_handlers handlers = {
- .std_smc = tee_entry,
- .fast_smc = tee_entry,
+ .std_smc = tee_entry_std,
+ .fast_smc = tee_entry_fast,
.fiq = main_fiq,
.svc = tee_svc_handler,
.abort = tee_pager_abort_handler,
diff --git a/core/arch/arm/plat-sunxi/main.c b/core/arch/arm/plat-sunxi/main.c
index 7b6ab00e..5469f55b 100644
--- a/core/arch/arm/plat-sunxi/main.c
+++ b/core/arch/arm/plat-sunxi/main.c
@@ -46,7 +46,8 @@
#include <mm/tee_mmu.h>
#include <mm/core_mmu.h>
#include <mm/tee_mmu_defs.h>
-#include <tee/entry.h>
+#include <tee/entry_std.h>
+#include <tee/entry_fast.h>
#include <tee/arch_svc.h>
#include <platform.h>
#include <util.h>
@@ -58,11 +59,12 @@ extern unsigned char teecore_heap_start;
extern unsigned char teecore_heap_end;
static void main_fiq(void);
-static void main_tee_entry(struct thread_smc_args *args);
+static void main_tee_entry_std(struct thread_smc_args *args);
+static void main_tee_entry_fast(struct thread_smc_args *args);
static const struct thread_handlers handlers = {
- .std_smc = main_tee_entry,
- .fast_smc = main_tee_entry,
+ .std_smc = main_tee_entry_std,
+ .fast_smc = main_tee_entry_fast,
.fiq = main_fiq,
.svc = tee_svc_handler,
.abort = tee_pager_abort_handler,
@@ -132,7 +134,7 @@ static void main_fiq(void)
panic();
}
-static void main_tee_entry(struct thread_smc_args *args)
+static void main_tee_entry_fast(struct thread_smc_args *args)
{
/* TODO move to main_init() */
if (init_teecore() != TEE_SUCCESS)
@@ -159,10 +161,21 @@ static void main_tee_entry(struct thread_smc_args *args)
return;
}
- tee_entry(args);
+ tee_entry_fast(args);
}
-/* main_tee_entry() supports 3 platform-specific functions */
+
+
+static void main_tee_entry_std(struct thread_smc_args *args)
+{
+ /* TODO move to main_init() */
+ if (init_teecore() != TEE_SUCCESS)
+ panic();
+
+ tee_entry_std(args);
+}
+
+/* main_tee_entry_fast() supports 3 platform-specific functions */
void tee_entry_get_api_call_count(struct thread_smc_args *args)
{
args->a0 = tee_entry_generic_get_api_call_count() + 3;
diff --git a/core/arch/arm/plat-sunxi/platform.c b/core/arch/arm/plat-sunxi/platform.c
index 2671f865..d04f1b98 100644
--- a/core/arch/arm/plat-sunxi/platform.c
+++ b/core/arch/arm/plat-sunxi/platform.c
@@ -39,7 +39,6 @@
#include <kernel/misc.h>
#include <mm/tee_pager.h>
#include <mm/core_mmu.h>
-#include <tee/entry.h>
#include <drivers/gic.h>
#include <drivers/sunxi_uart.h>
diff --git a/core/arch/arm/plat-ti/main.c b/core/arch/arm/plat-ti/main.c
index aeb23bf4..15f3fa98 100644
--- a/core/arch/arm/plat-ti/main.c
+++ b/core/arch/arm/plat-ti/main.c
@@ -42,7 +42,8 @@
#include <kernel/tee_time.h>
#include <mm/tee_pager.h>
#include <mm/core_mmu.h>
-#include <tee/entry.h>
+#include <tee/entry_std.h>
+#include <tee/entry_fast.h>
#include <tee/arch_svc.h>
#include <console.h>
#include <sm/sm.h>
@@ -50,8 +51,8 @@
static void main_fiq(void);
static const struct thread_handlers handlers = {
- .std_smc = tee_entry,
- .fast_smc = tee_entry,
+ .std_smc = tee_entry_std,
+ .fast_smc = tee_entry_fast,
.fiq = main_fiq,
.svc = tee_svc_handler,
.abort = tee_pager_abort_handler,
diff --git a/core/arch/arm/plat-vexpress/main.c b/core/arch/arm/plat-vexpress/main.c
index 66988480..323da21d 100644
--- a/core/arch/arm/plat-vexpress/main.c
+++ b/core/arch/arm/plat-vexpress/main.c
@@ -40,15 +40,16 @@
#include <kernel/misc.h>
#include <kernel/tee_time.h>
#include <mm/tee_pager.h>
-#include <tee/entry.h>
+#include <tee/entry_fast.h>
+#include <tee/entry_std.h>
#include <tee/arch_svc.h>
#include <console.h>
static void main_fiq(void);
static const struct thread_handlers handlers = {
- .std_smc = tee_entry,
- .fast_smc = tee_entry,
+ .std_smc = tee_entry_std,
+ .fast_smc = tee_entry_fast,
.fiq = main_fiq,
.svc = tee_svc_handler,
.abort = tee_pager_abort_handler,
diff --git a/core/arch/arm/tee/entry_fast.c b/core/arch/arm/tee/entry_fast.c
new file mode 100644
index 00000000..f6613771
--- /dev/null
+++ b/core/arch/arm/tee/entry_fast.c
@@ -0,0 +1,156 @@
+/*
+ * Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ * Copyright (c) 2014, STMicroelectronics International N.V.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <tee/entry_fast.h>
+#include <sm/teesmc.h>
+#include <sm/teesmc_optee.h>
+#include <kernel/tee_l2cc_mutex.h>
+#include <kernel/panic.h>
+#include <mm/core_mmu.h>
+
+#include <assert.h>
+
+static void tee_entry_get_shm_config(struct thread_smc_args *args)
+{
+ args->a0 = TEESMC_RETURN_OK;
+ args->a1 = default_nsec_shm_paddr;
+ args->a2 = default_nsec_shm_size;
+ /* Should this be TEESMC cache attributes instead? */
+ args->a3 = core_mmu_is_shm_cached();
+}
+
+static void tee_entry_fastcall_l2cc_mutex(struct thread_smc_args *args)
+{
+ TEE_Result ret;
+
+#ifdef ARM32
+ switch (args->a1) {
+ case TEESMC_OPTEE_L2CC_MUTEX_GET_ADDR:
+ ret = tee_get_l2cc_mutex(&args->a2);
+ break;
+ case TEESMC_OPTEE_L2CC_MUTEX_SET_ADDR:
+ ret = tee_set_l2cc_mutex(&args->a2);
+ break;
+ case TEESMC_OPTEE_L2CC_MUTEX_ENABLE:
+ ret = tee_enable_l2cc_mutex();
+ break;
+ case TEESMC_OPTEE_L2CC_MUTEX_DISABLE:
+ ret = tee_disable_l2cc_mutex();
+ break;
+ default:
+ args->a0 = TEESMC_RETURN_EBADCMD;
+ return;
+ }
+#else
+ ret = TEE_ERROR_NOT_SUPPORTED;
+#endif
+ if (ret == TEE_ERROR_NOT_SUPPORTED)
+ args->a0 = TEESMC_RETURN_UNKNOWN_FUNCTION;
+ else if (ret)
+ args->a0 = TEESMC_RETURN_EBADADDR;
+ else
+ args->a0 = TEESMC_RETURN_OK;
+}
+
+void tee_entry_fast(struct thread_smc_args *args)
+{
+ switch (args->a0) {
+
+ /* Generic functions */
+ case TEESMC32_CALLS_COUNT:
+ tee_entry_get_api_call_count(args);
+ break;
+ case TEESMC32_CALLS_UID:
+ tee_entry_get_api_uuid(args);
+ break;
+ case TEESMC32_CALLS_REVISION:
+ tee_entry_get_api_revision(args);
+ break;
+ case TEESMC32_CALL_GET_OS_UUID:
+ tee_entry_get_os_uuid(args);
+ break;
+ case TEESMC32_CALL_GET_OS_REVISION:
+ tee_entry_get_os_revision(args);
+ break;
+
+ /* OP-TEE specific SMC functions */
+ case TEESMC32_OPTEE_FASTCALL_GET_SHM_CONFIG:
+ tee_entry_get_shm_config(args);
+ break;
+ case TEESMC32_OPTEE_FASTCALL_L2CC_MUTEX:
+ tee_entry_fastcall_l2cc_mutex(args);
+ break;
+ default:
+ args->a0 = TEESMC_RETURN_UNKNOWN_FUNCTION;
+ break;
+ }
+}
+
+size_t tee_entry_generic_get_api_call_count(void)
+{
+ /*
+ * All the different calls handled in this file. If the specific
+ * target has additional calls it will call this function and
+ * add the number of calls the target has added.
+ */
+ return 9;
+}
+
+void __weak tee_entry_get_api_call_count(struct thread_smc_args *args)
+{
+ args->a0 = tee_entry_generic_get_api_call_count();
+}
+
+void __weak tee_entry_get_api_uuid(struct thread_smc_args *args)
+{
+ args->a0 = TEESMC_OPTEE_UID_R0;
+ args->a1 = TEESMC_OPTEE_UID_R1;
+ args->a2 = TEESMC_OPTEE_UID_R2;
+ args->a3 = TEESMC_OPTEE_UID32_R3;
+}
+
+void __weak tee_entry_get_api_revision(struct thread_smc_args *args)
+{
+ args->a0 = TEESMC_OPTEE_REVISION_MAJOR;
+ args->a1 = TEESMC_OPTEE_REVISION_MINOR;
+}
+
+void __weak tee_entry_get_os_uuid(struct thread_smc_args *args)
+{
+ args->a0 = TEESMC_OS_OPTEE_UUID_R0;
+ args->a1 = TEESMC_OS_OPTEE_UUID_R1;
+ args->a2 = TEESMC_OS_OPTEE_UUID_R2;
+ args->a3 = TEESMC_OS_OPTEE_UUID_R3;
+}
+
+void __weak tee_entry_get_os_revision(struct thread_smc_args *args)
+{
+ args->a0 = TEESMC_OS_OPTEE_REVISION_MAJOR;
+ args->a1 = TEESMC_OS_OPTEE_REVISION_MINOR;
+}
diff --git a/core/arch/arm/tee/entry.c b/core/arch/arm/tee/entry_std.c
index 25a146db..c81e03b9 100644
--- a/core/arch/arm/tee/entry.c
+++ b/core/arch/arm/tee/entry_std.c
@@ -1,4 +1,6 @@
/*
+ * Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
* Copyright (c) 2014, STMicroelectronics International N.V.
* All rights reserved.
*
@@ -25,12 +27,10 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <tee/entry.h>
+#include <tee/entry_std.h>
#include <sm/teesmc.h>
-#include <sm/teesmc_optee.h>
#include <kernel/tee_common_unpg.h>
#include <kernel/tee_dispatch.h>
-#include <kernel/tee_l2cc_mutex.h>
#include <kernel/panic.h>
#include <mm/core_mmu.h>
@@ -257,17 +257,15 @@ static void entry_cancel(struct thread_smc_args *args,
args->a0 = TEESMC_RETURN_OK;
}
-static void tee_entry_call_with_arg(struct thread_smc_args *args)
+void tee_entry_std(struct thread_smc_args *args)
{
paddr_t arg_pa;
struct teesmc32_arg *arg32 = NULL; /* fix gcc warning */
uint32_t num_params;
- if (args->a0 != TEESMC32_CALL_WITH_ARG &&
- args->a0 != TEESMC32_FASTCALL_WITH_ARG) {
+ if (args->a0 != TEESMC32_CALL_WITH_ARG) {
EMSG("Unknown SMC 0x%" PRIx64, (uint64_t)args->a0);
- DMSG("Expected 0x%x or 0x%x\n",
- TEESMC32_CALL_WITH_ARG, TEESMC32_FASTCALL_WITH_ARG);
+ DMSG("Expected 0x%x\n", TEESMC32_CALL_WITH_ARG);
args->a0 = TEESMC_RETURN_UNKNOWN_FUNCTION;
return;
}
@@ -288,150 +286,22 @@ static void tee_entry_call_with_arg(struct thread_smc_args *args)
return;
}
- if (args->a0 == TEESMC32_CALL_WITH_ARG) {
- thread_set_irq(true); /* Enable IRQ for STD calls */
- switch (arg32->cmd) {
- case TEESMC_CMD_OPEN_SESSION:
- entry_open_session(args, arg32, num_params);
- break;
- case TEESMC_CMD_CLOSE_SESSION:
- entry_close_session(args, arg32, num_params);
- break;
- case TEESMC_CMD_INVOKE_COMMAND:
- entry_invoke_command(args, arg32, num_params);
- break;
- case TEESMC_CMD_CANCEL:
- entry_cancel(args, arg32, num_params);
- break;
- default:
- EMSG("Unknown cmd 0x%x\n", arg32->cmd);
- args->a0 = TEESMC_RETURN_EBADCMD;
- }
- } else {
- EMSG("Unknown fastcall cmd 0x%x\n", arg32->cmd);
- args->a0 = TEESMC_RETURN_EBADCMD;
- }
-}
-
-static void tee_entry_get_shm_config(struct thread_smc_args *args)
-{
- args->a0 = TEESMC_RETURN_OK;
- args->a1 = default_nsec_shm_paddr;
- args->a2 = default_nsec_shm_size;
- /* Should this be TEESMC cache attributes instead? */
- args->a3 = core_mmu_is_shm_cached();
-}
-
-static void tee_entry_fastcall_l2cc_mutex(struct thread_smc_args *args)
-{
- TEE_Result ret;
-
-#ifdef ARM32
- switch (args->a1) {
- case TEESMC_OPTEE_L2CC_MUTEX_GET_ADDR:
- ret = tee_get_l2cc_mutex(&args->a2);
+ thread_set_irq(true); /* Enable IRQ for STD calls */
+ switch (arg32->cmd) {
+ case TEESMC_CMD_OPEN_SESSION:
+ entry_open_session(args, arg32, num_params);
break;
- case TEESMC_OPTEE_L2CC_MUTEX_SET_ADDR:
- ret = tee_set_l2cc_mutex(&args->a2);
+ case TEESMC_CMD_CLOSE_SESSION:
+ entry_close_session(args, arg32, num_params);
break;
- case TEESMC_OPTEE_L2CC_MUTEX_ENABLE:
- ret = tee_enable_l2cc_mutex();
+ case TEESMC_CMD_INVOKE_COMMAND:
+ entry_invoke_command(args, arg32, num_params);
break;
- case TEESMC_OPTEE_L2CC_MUTEX_DISABLE:
- ret = tee_disable_l2cc_mutex();
+ case TEESMC_CMD_CANCEL:
+ entry_cancel(args, arg32, num_params);
break;
default:
+ EMSG("Unknown cmd 0x%x\n", arg32->cmd);
args->a0 = TEESMC_RETURN_EBADCMD;
- return;
}
-#else
- ret = TEE_ERROR_NOT_SUPPORTED;
-#endif
- if (ret == TEE_ERROR_NOT_SUPPORTED)
- args->a0 = TEESMC_RETURN_UNKNOWN_FUNCTION;
- else if (ret)
- args->a0 = TEESMC_RETURN_EBADADDR;
- else
- args->a0 = TEESMC_RETURN_OK;
-}
-
-void tee_entry(struct thread_smc_args *args)
-{
- switch (args->a0) {
-
- /* Generic functions */
- case TEESMC32_CALLS_COUNT:
- tee_entry_get_api_call_count(args);
- break;
- case TEESMC32_CALLS_UID:
- tee_entry_get_api_uuid(args);
- break;
- case TEESMC32_CALLS_REVISION:
- tee_entry_get_api_revision(args);
- break;
- case TEESMC32_CALL_GET_OS_UUID:
- tee_entry_get_os_uuid(args);
- break;
- case TEESMC32_CALL_GET_OS_REVISION:
- tee_entry_get_os_revision(args);
- break;
- case TEESMC32_CALL_WITH_ARG:
- case TEESMC64_CALL_WITH_ARG:
- tee_entry_call_with_arg(args);
- break;
-
- /* OP-TEE specific SMC functions */
- case TEESMC32_OPTEE_FASTCALL_GET_SHM_CONFIG:
- tee_entry_get_shm_config(args);
- break;
- case TEESMC32_OPTEE_FASTCALL_L2CC_MUTEX:
- tee_entry_fastcall_l2cc_mutex(args);
- break;
- default:
- args->a0 = TEESMC_RETURN_UNKNOWN_FUNCTION;
- break;
- }
-}
-
-size_t tee_entry_generic_get_api_call_count(void)
-{
- /*
- * All the different calls handled in this file. If the specific
- * target has additional calls it will call this function and
- * add the number of calls the target has added.
- */
- return 9;
-}
-
-void __weak tee_entry_get_api_call_count(struct thread_smc_args *args)
-{
- args->a0 = tee_entry_generic_get_api_call_count();
-}
-
-void __weak tee_entry_get_api_uuid(struct thread_smc_args *args)
-{
- args->a0 = TEESMC_OPTEE_UID_R0;
- args->a1 = TEESMC_OPTEE_UID_R1;
- args->a2 = TEESMC_OPTEE_UID_R2;
- args->a3 = TEESMC_OPTEE_UID32_R3;
-}
-
-void __weak tee_entry_get_api_revision(struct thread_smc_args *args)
-{
- args->a0 = TEESMC_OPTEE_REVISION_MAJOR;
- args->a1 = TEESMC_OPTEE_REVISION_MINOR;
-}
-
-void __weak tee_entry_get_os_uuid(struct thread_smc_args *args)
-{
- args->a0 = TEESMC_OS_OPTEE_UUID_R0;
- args->a1 = TEESMC_OS_OPTEE_UUID_R1;
- args->a2 = TEESMC_OS_OPTEE_UUID_R2;
- args->a3 = TEESMC_OS_OPTEE_UUID_R3;
-}
-
-void __weak tee_entry_get_os_revision(struct thread_smc_args *args)
-{
- args->a0 = TEESMC_OS_OPTEE_REVISION_MAJOR;
- args->a1 = TEESMC_OS_OPTEE_REVISION_MINOR;
}
diff --git a/core/arch/arm/tee/sub.mk b/core/arch/arm/tee/sub.mk
index 786def58..60e15ce4 100644
--- a/core/arch/arm/tee/sub.mk
+++ b/core/arch/arm/tee/sub.mk
@@ -3,5 +3,6 @@ srcs-y += tee_rpmb.c
srcs-$(CFG_ARM32_core) += arch_svc_a32.S
srcs-$(CFG_ARM64_core) += arch_svc_a64.S
srcs-y += arch_svc.c
-srcs-y += entry.c
+srcs-y += entry_std.c
+srcs-y += entry_fast.c
srcs-y += init.c