blob: c507c612c30968f95bc3bcfcec7b8d2df5dcfe9b [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
7#include <tee_ta_api.h>
8#include <ta_storage.h>
9
10#include "storage.h"
11
12/*
13 * Trusted Application Entry Points
14 */
15
16/* Called each time a new instance is created */
17TEE_Result TA_CreateEntryPoint(void)
18{
19 return TEE_SUCCESS;
20}
21
22/* Called each time an instance is destroyed */
23void TA_DestroyEntryPoint(void)
24{
25}
26
27/* Called each time a session is opened */
28TEE_Result TA_OpenSessionEntryPoint(uint32_t nParamTypes,
29 TEE_Param pParams[4],
30 void **ppSessionContext)
31{
32 (void)nParamTypes;
33 (void)pParams;
34 (void)ppSessionContext;
35 return TEE_SUCCESS;
36}
37
38/* Called each time a session is closed */
39void TA_CloseSessionEntryPoint(void *pSessionContext)
40{
41 (void)pSessionContext;
42}
43
44/* Called when a command is invoked */
45TEE_Result TA_InvokeCommandEntryPoint(void *pSessionContext,
46 uint32_t nCommandID, uint32_t nParamTypes,
47 TEE_Param pParams[4])
48{
49 (void)pSessionContext;
50
51 switch (nCommandID) {
52 case TA_STORAGE_CMD_OPEN:
Etienne Carriere294ffbd2018-04-26 14:20:35 +020053 case TA_STORAGE_CMD_OPEN_ID_IN_SHM:
54 return ta_storage_cmd_open(nCommandID, nParamTypes, pParams);
Pascal Brandc639ac82015-07-02 08:53:34 +020055
56 case TA_STORAGE_CMD_CLOSE:
57 return ta_storage_cmd_close(nParamTypes, pParams);
58
59 case TA_STORAGE_CMD_READ:
60 return ta_storage_cmd_read(nParamTypes, pParams);
61
62 case TA_STORAGE_CMD_WRITE:
63 return ta_storage_cmd_write(nParamTypes, pParams);
64
65 case TA_STORAGE_CMD_CREATE:
Etienne Carriere294ffbd2018-04-26 14:20:35 +020066 case TA_STORAGE_CMD_CREATE_ID_IN_SHM:
67 return ta_storage_cmd_create(nCommandID, nParamTypes, pParams);
Pascal Brandc639ac82015-07-02 08:53:34 +020068
Pascal Brandeb84c442016-04-19 17:49:49 +020069 case TA_STORAGE_CMD_CREATE_OVERWRITE:
Etienne Carriere294ffbd2018-04-26 14:20:35 +020070 case TA_STORAGE_CMD_CREATEOVER_ID_IN_SHM:
71 return ta_storage_cmd_create_overwrite(nCommandID, nParamTypes, pParams);
Pascal Brandeb84c442016-04-19 17:49:49 +020072
Pascal Brandc639ac82015-07-02 08:53:34 +020073 case TA_STORAGE_CMD_SEEK:
74 return ta_storage_cmd_seek(nParamTypes, pParams);
75
76 case TA_STORAGE_CMD_UNLINK:
77 return ta_storage_cmd_unlink(nParamTypes, pParams);
78
79 case TA_STORAGE_CMD_RENAME:
Etienne Carriere294ffbd2018-04-26 14:20:35 +020080 case TA_STORAGE_CMD_RENAME_ID_IN_SHM:
81 return ta_storage_cmd_rename(nCommandID, nParamTypes, pParams);
Pascal Brandc639ac82015-07-02 08:53:34 +020082
83 case TA_STORAGE_CMD_TRUNC:
84 return ta_storage_cmd_trunc(nParamTypes, pParams);
85
86 case TA_STORAGE_CMD_ALLOC_ENUM:
87 return ta_storage_cmd_alloc_enum(nParamTypes, pParams);
88
89 case TA_STORAGE_CMD_FREE_ENUM:
90 return ta_storage_cmd_free_enum(nParamTypes, pParams);
91
92 case TA_STORAGE_CMD_RESET_ENUM:
93 return ta_storage_cmd_reset_enum(nParamTypes, pParams);
94
95 case TA_STORAGE_CMD_START_ENUM:
96 return ta_storage_cmd_start_enum(nParamTypes, pParams);
97
98 case TA_STORAGE_CMD_NEXT_ENUM:
99 return ta_storage_cmd_next_enum(nParamTypes, pParams);
100
Pascal Brand90f23352016-05-19 15:15:47 +0200101 case TA_STORAGE_CMD_KEY_IN_PERSISTENT:
102 return ta_storage_cmd_key_in_persistent(nParamTypes, pParams);
103
Pascal Brand29ee18f2016-05-23 14:13:56 +0200104 case TA_STORAGE_CMD_LOOP:
105 return ta_storage_cmd_loop(nParamTypes, pParams);
106
Jens Wiklandere6d4ddd2016-09-14 15:50:48 +0200107 case TA_STORAGE_CMD_RESTRICT_USAGE:
108 return ta_storage_cmd_restrict_usage(nParamTypes, pParams);
109
110 case TA_STORAGE_CMD_ALLOC_OBJ:
111 return ta_storage_cmd_alloc_obj(nParamTypes, pParams);
112
113 case TA_STORAGE_CMD_FREE_OBJ:
114 return ta_storage_cmd_free_obj(nParamTypes, pParams);
115
116 case TA_STORAGE_CMD_RESET_OBJ:
117 return ta_storage_cmd_reset_obj(nParamTypes, pParams);
118
Guanchao Liang31a9cbf2016-12-20 00:35:26 +0800119 case TA_STORAGE_CMD_GET_OBJ_INFO:
120 return ta_storage_cmd_get_obj_info(nParamTypes, pParams);
121
Pascal Brandc639ac82015-07-02 08:53:34 +0200122 default:
123 return TEE_ERROR_BAD_PARAMETERS;
124 }
125}