Etienne Carriere | 7514117 | 2020-05-16 11:58:23 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: BSD-2-Clause |
Igor Opaniuk | 44aff4b | 2016-09-16 10:18:00 +0300 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2015, Linaro Limited |
| 4 | * All rights reserved. |
Igor Opaniuk | 44aff4b | 2016-09-16 10:18:00 +0300 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <tee_ta_api.h> |
Jerome Forissier | 24ce5ab | 2017-09-25 12:44:22 -0700 | [diff] [blame] | 8 | #include <trace.h> |
Igor Opaniuk | 44aff4b | 2016-09-16 10:18:00 +0300 | [diff] [blame] | 9 | |
| 10 | #include "ta_aes_perf.h" |
| 11 | #include "ta_aes_perf_priv.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 | return TEE_SUCCESS; |
| 21 | } |
| 22 | |
| 23 | /* Called each time an instance is destroyed */ |
| 24 | void TA_DestroyEntryPoint(void) |
| 25 | { |
| 26 | } |
| 27 | |
| 28 | /* Called each time a session is opened */ |
| 29 | TEE_Result TA_OpenSessionEntryPoint(uint32_t nParamTypes, |
| 30 | TEE_Param pParams[4], |
| 31 | void **ppSessionContext) |
| 32 | { |
| 33 | (void)nParamTypes; |
| 34 | (void)pParams; |
| 35 | (void)ppSessionContext; |
| 36 | return TEE_SUCCESS; |
| 37 | } |
| 38 | |
| 39 | /* Called each time a session is closed */ |
| 40 | void TA_CloseSessionEntryPoint(void *pSessionContext) |
| 41 | { |
| 42 | (void)pSessionContext; |
| 43 | |
| 44 | cmd_clean_res(); |
| 45 | } |
| 46 | |
| 47 | /* Called when a command is invoked */ |
| 48 | TEE_Result TA_InvokeCommandEntryPoint(void *pSessionContext, |
| 49 | uint32_t nCommandID, uint32_t nParamTypes, |
| 50 | TEE_Param pParams[4]) |
| 51 | { |
| 52 | (void)pSessionContext; |
| 53 | |
| 54 | switch (nCommandID) { |
| 55 | case TA_AES_PERF_CMD_PREPARE_KEY: |
| 56 | return cmd_prepare_key(nParamTypes, pParams); |
| 57 | |
| 58 | case TA_AES_PERF_CMD_PROCESS: |
Etienne Carriere | b85a5f9 | 2017-05-03 18:21:56 +0200 | [diff] [blame] | 59 | return cmd_process(nParamTypes, pParams, false); |
| 60 | case TA_AES_PERF_CMD_PROCESS_SDP: |
| 61 | #ifdef CFG_SECURE_DATA_PATH |
| 62 | return cmd_process(nParamTypes, pParams, true); |
| 63 | #else |
| 64 | EMSG("Invalid SDP commands: TA was built without SDP support"); |
| 65 | return TEE_ERROR_NOT_SUPPORTED; |
| 66 | #endif |
Igor Opaniuk | 44aff4b | 2016-09-16 10:18:00 +0300 | [diff] [blame] | 67 | |
| 68 | default: |
| 69 | return TEE_ERROR_BAD_PARAMETERS; |
| 70 | } |
| 71 | } |