1*b0104773SPascal Brand /* 2*b0104773SPascal Brand * Copyright (c) 2014, STMicroelectronics International N.V. 3*b0104773SPascal Brand * All rights reserved. 4*b0104773SPascal Brand * 5*b0104773SPascal Brand * Redistribution and use in source and binary forms, with or without 6*b0104773SPascal Brand * modification, are permitted provided that the following conditions are met: 7*b0104773SPascal Brand * 8*b0104773SPascal Brand * 1. Redistributions of source code must retain the above copyright notice, 9*b0104773SPascal Brand * this list of conditions and the following disclaimer. 10*b0104773SPascal Brand * 11*b0104773SPascal Brand * 2. Redistributions in binary form must reproduce the above copyright notice, 12*b0104773SPascal Brand * this list of conditions and the following disclaimer in the documentation 13*b0104773SPascal Brand * and/or other materials provided with the distribution. 14*b0104773SPascal Brand * 15*b0104773SPascal Brand * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16*b0104773SPascal Brand * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17*b0104773SPascal Brand * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18*b0104773SPascal Brand * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19*b0104773SPascal Brand * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20*b0104773SPascal Brand * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21*b0104773SPascal Brand * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22*b0104773SPascal Brand * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23*b0104773SPascal Brand * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24*b0104773SPascal Brand * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25*b0104773SPascal Brand * POSSIBILITY OF SUCH DAMAGE. 26*b0104773SPascal Brand */ 27*b0104773SPascal Brand 28*b0104773SPascal Brand #ifndef USER_TA_HEADER_H 29*b0104773SPascal Brand #define USER_TA_HEADER_H 30*b0104773SPascal Brand 31*b0104773SPascal Brand #include <tee_api_types.h> 32*b0104773SPascal Brand 33*b0104773SPascal Brand /* 34*b0104773SPascal Brand signed_header 35*b0104773SPascal Brand ta_head_t 36*b0104773SPascal Brand ta_func_head_t (1) 37*b0104773SPascal Brand ta_func_head_t (2) 38*b0104773SPascal Brand ... 39*b0104773SPascal Brand ta_func_head_t (N) N = ta_head(_t).nbr_func 40*b0104773SPascal Brand func_1 41*b0104773SPascal Brand func_1 42*b0104773SPascal Brand ... 43*b0104773SPascal Brand func_N 44*b0104773SPascal Brand hash_1 45*b0104773SPascal Brand hash_2 46*b0104773SPascal Brand ... 47*b0104773SPascal Brand hash_M 48*b0104773SPascal Brand */ 49*b0104773SPascal Brand 50*b0104773SPascal Brand struct user_ta_head { 51*b0104773SPascal Brand TEE_UUID uuid; 52*b0104773SPascal Brand uint32_t nbr_func; 53*b0104773SPascal Brand uint32_t ro_size; 54*b0104773SPascal Brand uint32_t rw_size; 55*b0104773SPascal Brand uint32_t zi_size; 56*b0104773SPascal Brand uint32_t got_size; 57*b0104773SPascal Brand uint32_t hash_type; 58*b0104773SPascal Brand }; 59*b0104773SPascal Brand 60*b0104773SPascal Brand #define USER_TA_HEAD_FLAG_USER_MODE 0x80000000UL 61*b0104773SPascal Brand #define USER_TA_HEAD_FLAG_DDR_EXEC 0x40000000UL 62*b0104773SPascal Brand 63*b0104773SPascal Brand struct user_ta_func_head { 64*b0104773SPascal Brand uint32_t cmd_id; 65*b0104773SPascal Brand uint32_t start; /* offset to start func */ 66*b0104773SPascal Brand }; 67*b0104773SPascal Brand 68*b0104773SPascal Brand struct user_ta_sub_head { 69*b0104773SPascal Brand uint32_t flags; 70*b0104773SPascal Brand uint32_t spare; 71*b0104773SPascal Brand uint32_t heap_size; 72*b0104773SPascal Brand uint32_t stack_size; 73*b0104773SPascal Brand }; 74*b0104773SPascal Brand 75*b0104773SPascal Brand #define TA_FLAG_USER_MODE (1 << 0) 76*b0104773SPascal Brand #define TA_FLAG_EXEC_DDR (1 << 1) 77*b0104773SPascal Brand #define TA_FLAG_SINGLE_INSTANCE (1 << 2) 78*b0104773SPascal Brand #define TA_FLAG_MULTI_SESSION (1 << 3) 79*b0104773SPascal Brand #define TA_FLAG_INSTANCE_KEEP_ALIVE (1 << 4) 80*b0104773SPascal Brand /* 81*b0104773SPascal Brand * TEE Core will allow memrefs in some firewalled memory if this flag is 82*b0104773SPascal Brand * set for a User TA. 83*b0104773SPascal Brand */ 84*b0104773SPascal Brand #define TA_FLAG_UNSAFE_NW_PARAMS (1 << 5) 85*b0104773SPascal Brand 86*b0104773SPascal Brand enum user_ta_prop_type { 87*b0104773SPascal Brand USER_TA_PROP_TYPE_BOOL, /* bool */ 88*b0104773SPascal Brand USER_TA_PROP_TYPE_U32, /* uint32_t */ 89*b0104773SPascal Brand USER_TA_PROP_TYPE_UUID, /* TEE_UUID */ 90*b0104773SPascal Brand USER_TA_PROP_TYPE_IDENTITY, /* TEE_Identity */ 91*b0104773SPascal Brand USER_TA_PROP_TYPE_STRING, /* zero terminated string of char */ 92*b0104773SPascal Brand USER_TA_PROP_TYPE_BINARY_BLOCK, /* zero terminated base64 coded string */ 93*b0104773SPascal Brand }; 94*b0104773SPascal Brand 95*b0104773SPascal Brand enum user_ta_core_service_id { 96*b0104773SPascal Brand USER_TA_CORE_ENTRY_MATH_INIT = 0x00000010, 97*b0104773SPascal Brand USER_TA_CORE_ENTRY_GARBAGE = 0x00000011, 98*b0104773SPascal Brand USER_TA_CORE_ENTRY_CLOSESESSION = 0x00000012, 99*b0104773SPascal Brand }; 100*b0104773SPascal Brand 101*b0104773SPascal Brand struct user_ta_property { 102*b0104773SPascal Brand const char *name; 103*b0104773SPascal Brand enum user_ta_prop_type type; 104*b0104773SPascal Brand const void *value; 105*b0104773SPascal Brand }; 106*b0104773SPascal Brand 107*b0104773SPascal Brand extern const struct user_ta_property ta_props[]; 108*b0104773SPascal Brand extern const size_t ta_num_props; 109*b0104773SPascal Brand 110*b0104773SPascal Brand /* Needed by TEE_CheckMemoryAccessRights() */ 111*b0104773SPascal Brand extern uint32_t ta_param_types; 112*b0104773SPascal Brand extern TEE_Param ta_params[4]; 113*b0104773SPascal Brand 114*b0104773SPascal Brand /* Trusted Application Function header */ 115*b0104773SPascal Brand typedef struct ta_func_head { 116*b0104773SPascal Brand uint32_t cmd_id; /* Trusted Application Function ID */ 117*b0104773SPascal Brand uint32_t start; /* offset to start func */ 118*b0104773SPascal Brand } ta_func_head_t; 119*b0104773SPascal Brand 120*b0104773SPascal Brand typedef struct { 121*b0104773SPascal Brand /* Same Prefix as ta_head_t */ 122*b0104773SPascal Brand TEE_UUID uuid; 123*b0104773SPascal Brand const char *name; 124*b0104773SPascal Brand uint32_t flags; 125*b0104773SPascal Brand 126*b0104773SPascal Brand /* properties */ 127*b0104773SPascal Brand uint32_t prop_datasize; 128*b0104773SPascal Brand uint32_t prop_stacksize; 129*b0104773SPascal Brand uint32_t prop_tracelevel; 130*b0104773SPascal Brand 131*b0104773SPascal Brand const ta_func_head_t *funcs; 132*b0104773SPascal Brand uint32_t nbr_func; 133*b0104773SPascal Brand TEE_Result(*create_entry_point) (void); 134*b0104773SPascal Brand void (*destroy_entry_point) (void); 135*b0104773SPascal Brand TEE_Result(*open_session_entry_point) (uint32_t nParamTypes, 136*b0104773SPascal Brand TEE_Param pParams[4], 137*b0104773SPascal Brand void **ppSessionContext); 138*b0104773SPascal Brand void (*close_session_entry_point) (void *pSessionContext); 139*b0104773SPascal Brand TEE_Result(*invoke_command_entry_point) (void *pSessionContext, 140*b0104773SPascal Brand uint32_t nCommandID, 141*b0104773SPascal Brand uint32_t nParamTypes, 142*b0104773SPascal Brand TEE_Param pParams[4]); 143*b0104773SPascal Brand TEE_Result(*core_entries) (uint32_t nServiceId, uint32_t nParamTypes, 144*b0104773SPascal Brand TEE_Param pParam[4]); 145*b0104773SPascal Brand } ta_static_head_t; 146*b0104773SPascal Brand 147*b0104773SPascal Brand int tahead_get_trace_level(void); 148*b0104773SPascal Brand 149*b0104773SPascal Brand #endif /* USER_TA_HEADER_H */ 150