blob: edab315797328344461d5f6f686606b801d37529 [file] [log] [blame]
Pascal Brandc639ac82015-07-02 08:53:34 +02001/*
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
28#include <tee_ta_api.h>
29#include <ta_storage.h>
30
31#include "storage.h"
32
33/*
34 * Trusted Application Entry Points
35 */
36
37/* Called each time a new instance is created */
38TEE_Result TA_CreateEntryPoint(void)
39{
40 return TEE_SUCCESS;
41}
42
43/* Called each time an instance is destroyed */
44void TA_DestroyEntryPoint(void)
45{
46}
47
48/* Called each time a session is opened */
49TEE_Result TA_OpenSessionEntryPoint(uint32_t nParamTypes,
50 TEE_Param pParams[4],
51 void **ppSessionContext)
52{
53 (void)nParamTypes;
54 (void)pParams;
55 (void)ppSessionContext;
56 return TEE_SUCCESS;
57}
58
59/* Called each time a session is closed */
60void TA_CloseSessionEntryPoint(void *pSessionContext)
61{
62 (void)pSessionContext;
63}
64
65/* Called when a command is invoked */
66TEE_Result TA_InvokeCommandEntryPoint(void *pSessionContext,
67 uint32_t nCommandID, uint32_t nParamTypes,
68 TEE_Param pParams[4])
69{
70 (void)pSessionContext;
71
72 switch (nCommandID) {
73 case TA_STORAGE_CMD_OPEN:
Etienne Carriere294ffbd2018-04-26 14:20:35 +020074 case TA_STORAGE_CMD_OPEN_ID_IN_SHM:
75 return ta_storage_cmd_open(nCommandID, nParamTypes, pParams);
Pascal Brandc639ac82015-07-02 08:53:34 +020076
77 case TA_STORAGE_CMD_CLOSE:
78 return ta_storage_cmd_close(nParamTypes, pParams);
79
80 case TA_STORAGE_CMD_READ:
81 return ta_storage_cmd_read(nParamTypes, pParams);
82
83 case TA_STORAGE_CMD_WRITE:
84 return ta_storage_cmd_write(nParamTypes, pParams);
85
86 case TA_STORAGE_CMD_CREATE:
Etienne Carriere294ffbd2018-04-26 14:20:35 +020087 case TA_STORAGE_CMD_CREATE_ID_IN_SHM:
88 return ta_storage_cmd_create(nCommandID, nParamTypes, pParams);
Pascal Brandc639ac82015-07-02 08:53:34 +020089
Pascal Brandeb84c442016-04-19 17:49:49 +020090 case TA_STORAGE_CMD_CREATE_OVERWRITE:
Etienne Carriere294ffbd2018-04-26 14:20:35 +020091 case TA_STORAGE_CMD_CREATEOVER_ID_IN_SHM:
92 return ta_storage_cmd_create_overwrite(nCommandID, nParamTypes, pParams);
Pascal Brandeb84c442016-04-19 17:49:49 +020093
Pascal Brandc639ac82015-07-02 08:53:34 +020094 case TA_STORAGE_CMD_SEEK:
95 return ta_storage_cmd_seek(nParamTypes, pParams);
96
97 case TA_STORAGE_CMD_UNLINK:
98 return ta_storage_cmd_unlink(nParamTypes, pParams);
99
100 case TA_STORAGE_CMD_RENAME:
Etienne Carriere294ffbd2018-04-26 14:20:35 +0200101 case TA_STORAGE_CMD_RENAME_ID_IN_SHM:
102 return ta_storage_cmd_rename(nCommandID, nParamTypes, pParams);
Pascal Brandc639ac82015-07-02 08:53:34 +0200103
104 case TA_STORAGE_CMD_TRUNC:
105 return ta_storage_cmd_trunc(nParamTypes, pParams);
106
107 case TA_STORAGE_CMD_ALLOC_ENUM:
108 return ta_storage_cmd_alloc_enum(nParamTypes, pParams);
109
110 case TA_STORAGE_CMD_FREE_ENUM:
111 return ta_storage_cmd_free_enum(nParamTypes, pParams);
112
113 case TA_STORAGE_CMD_RESET_ENUM:
114 return ta_storage_cmd_reset_enum(nParamTypes, pParams);
115
116 case TA_STORAGE_CMD_START_ENUM:
117 return ta_storage_cmd_start_enum(nParamTypes, pParams);
118
119 case TA_STORAGE_CMD_NEXT_ENUM:
120 return ta_storage_cmd_next_enum(nParamTypes, pParams);
121
Pascal Brand90f23352016-05-19 15:15:47 +0200122 case TA_STORAGE_CMD_KEY_IN_PERSISTENT:
123 return ta_storage_cmd_key_in_persistent(nParamTypes, pParams);
124
Pascal Brand29ee18f2016-05-23 14:13:56 +0200125 case TA_STORAGE_CMD_LOOP:
126 return ta_storage_cmd_loop(nParamTypes, pParams);
127
Jens Wiklandere6d4ddd2016-09-14 15:50:48 +0200128 case TA_STORAGE_CMD_RESTRICT_USAGE:
129 return ta_storage_cmd_restrict_usage(nParamTypes, pParams);
130
131 case TA_STORAGE_CMD_ALLOC_OBJ:
132 return ta_storage_cmd_alloc_obj(nParamTypes, pParams);
133
134 case TA_STORAGE_CMD_FREE_OBJ:
135 return ta_storage_cmd_free_obj(nParamTypes, pParams);
136
137 case TA_STORAGE_CMD_RESET_OBJ:
138 return ta_storage_cmd_reset_obj(nParamTypes, pParams);
139
Guanchao Liang31a9cbf2016-12-20 00:35:26 +0800140 case TA_STORAGE_CMD_GET_OBJ_INFO:
141 return ta_storage_cmd_get_obj_info(nParamTypes, pParams);
142
Pascal Brandc639ac82015-07-02 08:53:34 +0200143 default:
144 return TEE_ERROR_BAD_PARAMETERS;
145 }
146}