Etienne Carriere | 7514117 | 2020-05-16 11:58:23 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: BSD-2-Clause |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2014, STMicroelectronics International N.V. |
| 4 | * All rights reserved. |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 5 | */ |
| 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 */ |
| 18 | TEE_Result TA_CreateEntryPoint(void) |
| 19 | { |
| 20 | DMSG("TA_CreateEntryPoint"); |
| 21 | return TEE_SUCCESS; |
| 22 | } |
| 23 | |
| 24 | /* Called each time an instance is destroyed */ |
| 25 | void TA_DestroyEntryPoint(void) |
| 26 | { |
| 27 | DMSG("TA_DestroyEntryPoint"); |
| 28 | } |
| 29 | |
| 30 | /* Called each time a session is opened */ |
| 31 | TEE_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 */ |
| 44 | void TA_CloseSessionEntryPoint(void *pSessionContext) |
| 45 | { |
| 46 | (void)pSessionContext; |
| 47 | DMSG("TA_CloseSessionEntryPoint"); |
| 48 | } |
| 49 | |
| 50 | /* Called when a command is invoked */ |
| 51 | TEE_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 Carriere | 281065d | 2016-10-28 15:41:33 +0200 | [diff] [blame] | 73 | case TA_OS_TEST_CMD_PARAMS_ACCESS: |
| 74 | return ta_entry_params_access_rights(nParamTypes, pParams); |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 75 | |
| 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 Forissier | e916b10 | 2017-06-07 17:55:52 +0200 | [diff] [blame] | 82 | 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 Wiklander | 87e8170 | 2018-03-20 12:00:00 +0800 | [diff] [blame] | 88 | case TA_OS_TEST_CMD_PARAMS: |
| 89 | return ta_entry_params(nParamTypes, pParams); |
| 90 | |
Cedric Neveux | 9f483bb | 2019-03-04 08:58:06 +0100 | [diff] [blame] | 91 | case TA_OS_TEST_CMD_NULL_MEMREF_PARAMS: |
| 92 | return ta_entry_null_memref(nParamTypes, pParams); |
| 93 | |
Jerome Forissier | 53bde72 | 2018-05-31 09:14:54 +0200 | [diff] [blame] | 94 | 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 Forissier | a9ab5d0 | 2019-03-17 21:14:06 +0100 | [diff] [blame] | 100 | 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 Forissier | e9571e8 | 2020-02-18 15:26:20 +0100 | [diff] [blame] | 106 | case TA_OS_TEST_CMD_GET_GLOBAL_VAR: |
| 107 | return ta_entry_get_global_var(nParamTypes, pParams); |
| 108 | |
Vesa Jääskeläinen | 41ff080 | 2020-04-05 20:11:46 +0300 | [diff] [blame] | 109 | case TA_OS_TEST_CMD_CLIENT_IDENTITY: |
| 110 | return ta_entry_client_identity(nParamTypes, pParams); |
| 111 | |
Jerome Forissier | 9a7101b | 2020-06-17 17:55:00 +0200 | [diff] [blame] | 112 | 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 Forissier | 4565c45 | 2020-06-17 17:55:00 +0200 | [diff] [blame] | 118 | 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 Forissier | 5c20a5b | 2020-11-10 15:58:49 +0100 | [diff] [blame] | 124 | #if defined(WITH_CXX_TESTS) |
Jerome Forissier | 1a205ae | 2020-06-17 17:55:00 +0200 | [diff] [blame] | 125 | 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 Forissier | 5c20a5b | 2020-11-10 15:58:49 +0100 | [diff] [blame] | 139 | #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 Forissier | 1a205ae | 2020-06-17 17:55:00 +0200 | [diff] [blame] | 146 | #endif |
| 147 | |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 148 | default: |
| 149 | return TEE_ERROR_BAD_PARAMETERS; |
| 150 | } |
| 151 | } |