Etienne Carriere | 7514117 | 2020-05-16 11:58:23 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: BSD-2-Clause |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2014, STMicroelectronics International N.V. |
| 4 | * All rights reserved. |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 5 | */ |
| 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 */ |
| 17 | TEE_Result TA_CreateEntryPoint(void) |
| 18 | { |
| 19 | return TEE_SUCCESS; |
| 20 | } |
| 21 | |
| 22 | /* Called each time an instance is destroyed */ |
| 23 | void TA_DestroyEntryPoint(void) |
| 24 | { |
| 25 | } |
| 26 | |
| 27 | /* Called each time a session is opened */ |
| 28 | TEE_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 */ |
| 39 | void TA_CloseSessionEntryPoint(void *pSessionContext) |
| 40 | { |
| 41 | (void)pSessionContext; |
| 42 | } |
| 43 | |
| 44 | /* Called when a command is invoked */ |
| 45 | TEE_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 Carriere | 294ffbd | 2018-04-26 14:20:35 +0200 | [diff] [blame] | 53 | case TA_STORAGE_CMD_OPEN_ID_IN_SHM: |
| 54 | return ta_storage_cmd_open(nCommandID, nParamTypes, pParams); |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 55 | |
| 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 Carriere | 294ffbd | 2018-04-26 14:20:35 +0200 | [diff] [blame] | 66 | case TA_STORAGE_CMD_CREATE_ID_IN_SHM: |
| 67 | return ta_storage_cmd_create(nCommandID, nParamTypes, pParams); |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 68 | |
Pascal Brand | eb84c44 | 2016-04-19 17:49:49 +0200 | [diff] [blame] | 69 | case TA_STORAGE_CMD_CREATE_OVERWRITE: |
Etienne Carriere | 294ffbd | 2018-04-26 14:20:35 +0200 | [diff] [blame] | 70 | case TA_STORAGE_CMD_CREATEOVER_ID_IN_SHM: |
| 71 | return ta_storage_cmd_create_overwrite(nCommandID, nParamTypes, pParams); |
Pascal Brand | eb84c44 | 2016-04-19 17:49:49 +0200 | [diff] [blame] | 72 | |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 73 | 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 Carriere | 294ffbd | 2018-04-26 14:20:35 +0200 | [diff] [blame] | 80 | case TA_STORAGE_CMD_RENAME_ID_IN_SHM: |
| 81 | return ta_storage_cmd_rename(nCommandID, nParamTypes, pParams); |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 82 | |
| 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 Brand | 90f2335 | 2016-05-19 15:15:47 +0200 | [diff] [blame] | 101 | case TA_STORAGE_CMD_KEY_IN_PERSISTENT: |
| 102 | return ta_storage_cmd_key_in_persistent(nParamTypes, pParams); |
| 103 | |
Pascal Brand | 29ee18f | 2016-05-23 14:13:56 +0200 | [diff] [blame] | 104 | case TA_STORAGE_CMD_LOOP: |
| 105 | return ta_storage_cmd_loop(nParamTypes, pParams); |
| 106 | |
Jens Wiklander | e6d4ddd | 2016-09-14 15:50:48 +0200 | [diff] [blame] | 107 | 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 Liang | 31a9cbf | 2016-12-20 00:35:26 +0800 | [diff] [blame] | 119 | case TA_STORAGE_CMD_GET_OBJ_INFO: |
| 120 | return ta_storage_cmd_get_obj_info(nParamTypes, pParams); |
| 121 | |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 122 | default: |
| 123 | return TEE_ERROR_BAD_PARAMETERS; |
| 124 | } |
| 125 | } |