blob: 4bfd045e8253ada2dbb266a7652ace194cfa5a28 [file] [log] [blame]
Etienne Carriere75141172020-05-16 11:58:23 +02001// SPDX-License-Identifier: BSD-2-Clause
Pascal Brandc639ac82015-07-02 08:53:34 +02002/*
3 * Copyright (c) 2014, STMicroelectronics International N.V.
4 * All rights reserved.
Pascal Brandc639ac82015-07-02 08:53:34 +02005 */
6#include <stdint.h>
7#include <init.h>
8#include <os_test.h>
9#include <ta_os_test.h>
10#include <tee_internal_api_extensions.h>
11#include <tee_ta_api.h>
12
13/*
14 * Trusted Application Entry Points
15 */
16
17/* Called each time a new instance is created */
18TEE_Result TA_CreateEntryPoint(void)
19{
20 DMSG("TA_CreateEntryPoint");
21 return TEE_SUCCESS;
22}
23
24/* Called each time an instance is destroyed */
25void TA_DestroyEntryPoint(void)
26{
27 DMSG("TA_DestroyEntryPoint");
28}
29
30/* Called each time a session is opened */
31TEE_Result TA_OpenSessionEntryPoint(uint32_t nParamTypes,
32 TEE_Param pParams[4],
33 void **ppSessionContext)
34{
35 (void)nParamTypes;
36 (void)pParams;
37 (void)ppSessionContext;
38 DMSG("TA_OpenSessionEntryPoint");
39 TEE_UnmaskCancellation();
40 return TEE_SUCCESS;
41}
42
43/* Called each time a session is closed */
44void TA_CloseSessionEntryPoint(void *pSessionContext)
45{
46 (void)pSessionContext;
47 DMSG("TA_CloseSessionEntryPoint");
48}
49
50/* Called when a command is invoked */
51TEE_Result TA_InvokeCommandEntryPoint(void *pSessionContext,
52 uint32_t nCommandID, uint32_t nParamTypes,
53 TEE_Param pParams[4])
54{
55 (void)pSessionContext;
56
57 switch (nCommandID) {
58 case TA_OS_TEST_CMD_INIT:
59 return ta_entry_init(nParamTypes, pParams);
60
61 case TA_OS_TEST_CMD_CLIENT_WITH_TIMEOUT:
62 return ta_entry_client_with_timeout(nParamTypes, pParams);
63
64 case TA_OS_TEST_CMD_BASIC:
65 return ta_entry_basic(nParamTypes, pParams);
66
67 case TA_OS_TEST_CMD_PANIC:
68 return ta_entry_panic(nParamTypes, pParams);
69
70 case TA_OS_TEST_CMD_CLIENT:
71 return ta_entry_client(nParamTypes, pParams);
72
Etienne Carriere281065d2016-10-28 15:41:33 +020073 case TA_OS_TEST_CMD_PARAMS_ACCESS:
74 return ta_entry_params_access_rights(nParamTypes, pParams);
Pascal Brandc639ac82015-07-02 08:53:34 +020075
76 case TA_OS_TEST_CMD_WAIT:
77 return ta_entry_wait(nParamTypes, pParams);
78
79 case TA_OS_TEST_CMD_BAD_MEM_ACCESS:
80 return ta_entry_bad_mem_access(nParamTypes, pParams);
81
Jerome Forissiere916b102017-06-07 17:55:52 +020082 case TA_OS_TEST_CMD_TA2TA_MEMREF:
83 return ta_entry_ta2ta_memref(nParamTypes, pParams);
84
85 case TA_OS_TEST_CMD_TA2TA_MEMREF_MIX:
86 return ta_entry_ta2ta_memref_mix(nParamTypes, pParams);
87
Jens Wiklander87e81702018-03-20 12:00:00 +080088 case TA_OS_TEST_CMD_PARAMS:
89 return ta_entry_params(nParamTypes, pParams);
90
Cedric Neveux9f483bb2019-03-04 08:58:06 +010091 case TA_OS_TEST_CMD_NULL_MEMREF_PARAMS:
92 return ta_entry_null_memref(nParamTypes, pParams);
93
Jerome Forissier53bde722018-05-31 09:14:54 +020094 case TA_OS_TEST_CMD_CALL_LIB:
95 return ta_entry_call_lib(nParamTypes, pParams);
96
97 case TA_OS_TEST_CMD_CALL_LIB_PANIC:
98 return ta_entry_call_lib_panic(nParamTypes, pParams);
99
Jerome Forissiera9ab5d02019-03-17 21:14:06 +0100100 case TA_OS_TEST_CMD_CALL_LIB_DL:
101 return ta_entry_call_lib_dl(nParamTypes, pParams);
102
103 case TA_OS_TEST_CMD_CALL_LIB_DL_PANIC:
104 return ta_entry_call_lib_dl_panic(nParamTypes, pParams);
105
Jerome Forissiere9571e82020-02-18 15:26:20 +0100106 case TA_OS_TEST_CMD_GET_GLOBAL_VAR:
107 return ta_entry_get_global_var(nParamTypes, pParams);
108
Vesa Jääskeläinen41ff0802020-04-05 20:11:46 +0300109 case TA_OS_TEST_CMD_CLIENT_IDENTITY:
110 return ta_entry_client_identity(nParamTypes, pParams);
111
Jerome Forissier9a7101b2020-06-17 17:55:00 +0200112 case TA_OS_TEST_CMD_TLS_TEST_MAIN:
113 return ta_entry_tls_test_main();
114
115 case TA_OS_TEST_CMD_TLS_TEST_SHLIB:
116 return ta_entry_tls_test_shlib();
117
Jerome Forissier4565c452020-06-17 17:55:00 +0200118 case TA_OS_TEST_CMD_DL_PHDR:
119 return ta_entry_dl_phdr();
120
121 case TA_OS_TEST_CMD_DL_PHDR_DL:
122 return ta_entry_dl_phdr_dl();
123
Jerome Forissier5c20a5b2020-11-10 15:58:49 +0100124#if defined(WITH_CXX_TESTS)
Jerome Forissier1a205ae2020-06-17 17:55:00 +0200125 case TA_OS_TEST_CMD_CXX_CTOR_MAIN:
126 return ta_entry_cxx_ctor_main();
127
128 case TA_OS_TEST_CMD_CXX_CTOR_SHLIB:
129 return ta_entry_cxx_ctor_shlib();
130
131 case TA_OS_TEST_CMD_CXX_CTOR_SHLIB_DL:
132 return ta_entry_cxx_ctor_shlib_dl();
133
134 case TA_OS_TEST_CMD_CXX_EXC_MAIN:
135 return ta_entry_cxx_exc_main();
136
137 case TA_OS_TEST_CMD_CXX_EXC_MIXED:
138 return ta_entry_cxx_exc_mixed();
Jerome Forissier5c20a5b2020-11-10 15:58:49 +0100139#else
140 case TA_OS_TEST_CMD_CXX_CTOR_MAIN:
141 case TA_OS_TEST_CMD_CXX_CTOR_SHLIB:
142 case TA_OS_TEST_CMD_CXX_CTOR_SHLIB_DL:
143 case TA_OS_TEST_CMD_CXX_EXC_MAIN:
144 case TA_OS_TEST_CMD_CXX_EXC_MIXED:
145 return TEE_ERROR_NOT_SUPPORTED;
Jerome Forissier1a205ae2020-06-17 17:55:00 +0200146#endif
147
Pascal Brandc639ac82015-07-02 08:53:34 +0200148 default:
149 return TEE_ERROR_BAD_PARAMETERS;
150 }
151}