blob: 5a55fedcf3dfca11ea36c2ed3ad3e7f876131033 [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:
74 return ta_storage_cmd_open(nParamTypes, pParams);
75
76 case TA_STORAGE_CMD_CLOSE:
77 return ta_storage_cmd_close(nParamTypes, pParams);
78
79 case TA_STORAGE_CMD_READ:
80 return ta_storage_cmd_read(nParamTypes, pParams);
81
82 case TA_STORAGE_CMD_WRITE:
83 return ta_storage_cmd_write(nParamTypes, pParams);
84
85 case TA_STORAGE_CMD_CREATE:
86 return ta_storage_cmd_create(nParamTypes, pParams);
87
Pascal Brandeb84c442016-04-19 17:49:49 +020088 case TA_STORAGE_CMD_CREATE_OVERWRITE:
89 return ta_storage_cmd_create_overwrite(nParamTypes, pParams);
90
Pascal Brandc639ac82015-07-02 08:53:34 +020091 case TA_STORAGE_CMD_SEEK:
92 return ta_storage_cmd_seek(nParamTypes, pParams);
93
94 case TA_STORAGE_CMD_UNLINK:
95 return ta_storage_cmd_unlink(nParamTypes, pParams);
96
97 case TA_STORAGE_CMD_RENAME:
98 return ta_storage_cmd_rename(nParamTypes, pParams);
99
100 case TA_STORAGE_CMD_TRUNC:
101 return ta_storage_cmd_trunc(nParamTypes, pParams);
102
103 case TA_STORAGE_CMD_ALLOC_ENUM:
104 return ta_storage_cmd_alloc_enum(nParamTypes, pParams);
105
106 case TA_STORAGE_CMD_FREE_ENUM:
107 return ta_storage_cmd_free_enum(nParamTypes, pParams);
108
109 case TA_STORAGE_CMD_RESET_ENUM:
110 return ta_storage_cmd_reset_enum(nParamTypes, pParams);
111
112 case TA_STORAGE_CMD_START_ENUM:
113 return ta_storage_cmd_start_enum(nParamTypes, pParams);
114
115 case TA_STORAGE_CMD_NEXT_ENUM:
116 return ta_storage_cmd_next_enum(nParamTypes, pParams);
117
118 default:
119 return TEE_ERROR_BAD_PARAMETERS;
120 }
121}