1 // SPDX-License-Identifier: BSD-2-Clause
2 /*
3 * Copyright (c) 2014, STMicroelectronics International N.V.
4 * All rights reserved.
5 */
6
7 #include <tee_ta_api.h>
8 #include <user_ta_header_defines.h>
9 #include <ta_sims.h>
10
11 /*
12 * Trusted Application Entry Points
13 */
14
15 /* Called each time a new instance is created */
TA_CreateEntryPoint(void)16 TEE_Result TA_CreateEntryPoint(void)
17 {
18 return TEE_SUCCESS;
19 }
20
21 /* Called each time an instance is destroyed */
TA_DestroyEntryPoint(void)22 void TA_DestroyEntryPoint(void)
23 {
24 }
25
26 /* Called each time a session is opened */
TA_OpenSessionEntryPoint(uint32_t nParamTypes,TEE_Param pParams[4],void ** ppSessionContext)27 TEE_Result TA_OpenSessionEntryPoint(uint32_t nParamTypes, TEE_Param pParams[4],
28 void **ppSessionContext)
29 {
30 (void)nParamTypes;
31 (void)pParams;
32 return sims_open_session(ppSessionContext);
33 }
34
35 /* Called each time a session is closed */
TA_CloseSessionEntryPoint(void * pSessionContext)36 void TA_CloseSessionEntryPoint(void *pSessionContext)
37 {
38 sims_close_session(pSessionContext);
39 }
40
41 /* Called when a command is invoked */
TA_InvokeCommandEntryPoint(void * pSessionContext,uint32_t nCommandID,uint32_t nParamTypes,TEE_Param pParams[4])42 TEE_Result TA_InvokeCommandEntryPoint(void *pSessionContext,
43 uint32_t nCommandID, uint32_t nParamTypes,
44 TEE_Param pParams[4])
45 {
46 switch (nCommandID) {
47 case TA_SIMS_OPEN_TA_SESSION:
48 return sims_open_ta_session(pSessionContext,
49 nParamTypes, pParams);
50
51 case TA_SIMS_CMD_READ:
52 return sims_read(nParamTypes, pParams);
53
54 case TA_SIMS_CMD_WRITE:
55 return sims_write(nParamTypes, pParams);
56
57 case TA_SIMS_CMD_GET_COUNTER:
58 return sims_get_counter(pSessionContext, nParamTypes, pParams);
59
60 case TA_SIMS_CMD_PANIC:
61 return sims_entry_panic(pSessionContext, nParamTypes, pParams);
62
63 default:
64 return TEE_ERROR_BAD_PARAMETERS;
65 }
66 }
67