Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2014, STMicroelectronics International N.V. |
| 3 | * All rights reserved. |
| 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions are met: |
| 7 | * |
| 8 | * 1. Redistributions of source code must retain the above copyright notice, |
| 9 | * this list of conditions and the following disclaimer. |
| 10 | * |
| 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
| 12 | * this list of conditions and the following disclaimer in the documentation |
| 13 | * and/or other materials provided with the distribution. |
| 14 | * |
| 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 25 | * POSSIBILITY OF SUCH DAMAGE. |
| 26 | */ |
| 27 | #include <stdint.h> |
| 28 | #include <init.h> |
| 29 | #include <os_test.h> |
| 30 | #include <ta_os_test.h> |
| 31 | #include <tee_internal_api_extensions.h> |
| 32 | #include <tee_ta_api.h> |
| 33 | |
| 34 | /* |
| 35 | * Trusted Application Entry Points |
| 36 | */ |
| 37 | |
| 38 | /* Called each time a new instance is created */ |
| 39 | TEE_Result TA_CreateEntryPoint(void) |
| 40 | { |
| 41 | DMSG("TA_CreateEntryPoint"); |
| 42 | return TEE_SUCCESS; |
| 43 | } |
| 44 | |
| 45 | /* Called each time an instance is destroyed */ |
| 46 | void TA_DestroyEntryPoint(void) |
| 47 | { |
| 48 | DMSG("TA_DestroyEntryPoint"); |
| 49 | } |
| 50 | |
| 51 | /* Called each time a session is opened */ |
| 52 | TEE_Result TA_OpenSessionEntryPoint(uint32_t nParamTypes, |
| 53 | TEE_Param pParams[4], |
| 54 | void **ppSessionContext) |
| 55 | { |
| 56 | (void)nParamTypes; |
| 57 | (void)pParams; |
| 58 | (void)ppSessionContext; |
| 59 | DMSG("TA_OpenSessionEntryPoint"); |
| 60 | TEE_UnmaskCancellation(); |
| 61 | return TEE_SUCCESS; |
| 62 | } |
| 63 | |
| 64 | /* Called each time a session is closed */ |
| 65 | void TA_CloseSessionEntryPoint(void *pSessionContext) |
| 66 | { |
| 67 | (void)pSessionContext; |
| 68 | DMSG("TA_CloseSessionEntryPoint"); |
| 69 | } |
| 70 | |
| 71 | /* Called when a command is invoked */ |
| 72 | TEE_Result TA_InvokeCommandEntryPoint(void *pSessionContext, |
| 73 | uint32_t nCommandID, uint32_t nParamTypes, |
| 74 | TEE_Param pParams[4]) |
| 75 | { |
| 76 | (void)pSessionContext; |
| 77 | |
| 78 | switch (nCommandID) { |
| 79 | case TA_OS_TEST_CMD_INIT: |
| 80 | return ta_entry_init(nParamTypes, pParams); |
| 81 | |
| 82 | case TA_OS_TEST_CMD_CLIENT_WITH_TIMEOUT: |
| 83 | return ta_entry_client_with_timeout(nParamTypes, pParams); |
| 84 | |
| 85 | case TA_OS_TEST_CMD_BASIC: |
| 86 | return ta_entry_basic(nParamTypes, pParams); |
| 87 | |
| 88 | case TA_OS_TEST_CMD_PANIC: |
| 89 | return ta_entry_panic(nParamTypes, pParams); |
| 90 | |
| 91 | case TA_OS_TEST_CMD_CLIENT: |
| 92 | return ta_entry_client(nParamTypes, pParams); |
| 93 | |
Etienne Carriere | 281065d | 2016-10-28 15:41:33 +0200 | [diff] [blame] | 94 | case TA_OS_TEST_CMD_PARAMS_ACCESS: |
| 95 | return ta_entry_params_access_rights(nParamTypes, pParams); |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 96 | |
| 97 | case TA_OS_TEST_CMD_WAIT: |
| 98 | return ta_entry_wait(nParamTypes, pParams); |
| 99 | |
| 100 | case TA_OS_TEST_CMD_BAD_MEM_ACCESS: |
| 101 | return ta_entry_bad_mem_access(nParamTypes, pParams); |
| 102 | |
Jerome Forissier | e916b10 | 2017-06-07 17:55:52 +0200 | [diff] [blame] | 103 | case TA_OS_TEST_CMD_TA2TA_MEMREF: |
| 104 | return ta_entry_ta2ta_memref(nParamTypes, pParams); |
| 105 | |
| 106 | case TA_OS_TEST_CMD_TA2TA_MEMREF_MIX: |
| 107 | return ta_entry_ta2ta_memref_mix(nParamTypes, pParams); |
| 108 | |
Jens Wiklander | 87e8170 | 2018-03-20 12:00:00 +0800 | [diff] [blame] | 109 | case TA_OS_TEST_CMD_PARAMS: |
| 110 | return ta_entry_params(nParamTypes, pParams); |
| 111 | |
Cedric Neveux | 9f483bb | 2019-03-04 08:58:06 +0100 | [diff] [blame] | 112 | case TA_OS_TEST_CMD_NULL_MEMREF_PARAMS: |
| 113 | return ta_entry_null_memref(nParamTypes, pParams); |
| 114 | |
Jerome Forissier | 53bde72 | 2018-05-31 09:14:54 +0200 | [diff] [blame] | 115 | case TA_OS_TEST_CMD_CALL_LIB: |
| 116 | return ta_entry_call_lib(nParamTypes, pParams); |
| 117 | |
| 118 | case TA_OS_TEST_CMD_CALL_LIB_PANIC: |
| 119 | return ta_entry_call_lib_panic(nParamTypes, pParams); |
| 120 | |
Jerome Forissier | a9ab5d0 | 2019-03-17 21:14:06 +0100 | [diff] [blame] | 121 | case TA_OS_TEST_CMD_CALL_LIB_DL: |
| 122 | return ta_entry_call_lib_dl(nParamTypes, pParams); |
| 123 | |
| 124 | case TA_OS_TEST_CMD_CALL_LIB_DL_PANIC: |
| 125 | return ta_entry_call_lib_dl_panic(nParamTypes, pParams); |
| 126 | |
Jerome Forissier | e9571e8 | 2020-02-18 15:26:20 +0100 | [diff] [blame] | 127 | case TA_OS_TEST_CMD_GET_GLOBAL_VAR: |
| 128 | return ta_entry_get_global_var(nParamTypes, pParams); |
| 129 | |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 130 | default: |
| 131 | return TEE_ERROR_BAD_PARAMETERS; |
| 132 | } |
| 133 | } |