Home | History | Annotate | Download | only in include
      1 /**
      2  * Copyright(c) 2011 Trusted Logic.   All rights reserved.
      3  *
      4  * Redistribution and use in source and binary forms, with or without
      5  * modification, are permitted provided that the following conditions
      6  * are met:
      7  *
      8  *  * Redistributions of source code must retain the above copyright
      9  *    notice, this list of conditions and the following disclaimer.
     10  *  * Redistributions in binary form must reproduce the above copyright
     11  *    notice, this list of conditions and the following disclaimer in
     12  *    the documentation and/or other materials provided with the
     13  *    distribution.
     14  *  * Neither the name Trusted Logic nor the names of its
     15  *    contributors may be used to endorse or promote products derived
     16  *    from this software without specific prior written permission.
     17  *
     18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     29  */
     30 
     31 /*
     32  * This header file corresponds to V1.0 of the GlobalPlatform
     33  * TEE Client API Specification
     34  */
     35 #ifndef   __TEE_CLIENT_API_H__
     36 #define   __TEE_CLIENT_API_H__
     37 
     38 #include "s_type.h"
     39 #include "s_error.h"
     40 
     41 #ifndef TEEC_EXPORT
     42 #define TEEC_EXPORT
     43 #endif
     44 
     45 /* The header tee_client_api_imp.h must define implementation-dependent
     46    types, constants and macros.
     47 
     48    The implementation-dependent types are:
     49      - TEEC_Context_IMP
     50      - TEEC_Session_IMP
     51      - TEEC_SharedMemory_IMP
     52      - TEEC_Operation_IMP
     53 
     54    The implementation-dependent constants are:
     55      - TEEC_CONFIG_SHAREDMEM_MAX_SIZE
     56    The implementation-dependent macros are:
     57      - TEEC_PARAM_TYPES
     58 */
     59 #include "tee_client_api_imp.h"
     60 
     61 /* Type definitions */
     62 typedef struct TEEC_Context
     63 {
     64    TEEC_Context_IMP imp;
     65 } TEEC_Context;
     66 
     67 typedef struct TEEC_Session
     68 {
     69    TEEC_Session_IMP imp;
     70 } TEEC_Session;
     71 
     72 typedef struct TEEC_SharedMemory
     73 {
     74     void*    buffer;
     75     size_t   size;
     76     uint32_t flags;
     77     TEEC_SharedMemory_IMP imp;
     78 } TEEC_SharedMemory;
     79 
     80 typedef struct
     81 {
     82     void*     buffer;
     83     size_t    size;
     84 } TEEC_TempMemoryReference;
     85 
     86 typedef struct
     87 {
     88     TEEC_SharedMemory * parent;
     89     size_t    size;
     90     size_t    offset;
     91 } TEEC_RegisteredMemoryReference;
     92 
     93 typedef struct
     94 {
     95     uint32_t   a;
     96     uint32_t   b;
     97 } TEEC_Value;
     98 
     99 typedef union
    100 {
    101    TEEC_TempMemoryReference        tmpref;
    102    TEEC_RegisteredMemoryReference  memref;
    103    TEEC_Value                      value;
    104 } TEEC_Parameter;
    105 
    106 typedef struct TEEC_Operation
    107 {
    108     volatile uint32_t    started;
    109     uint32_t             paramTypes;
    110     TEEC_Parameter       params[4];
    111 
    112     TEEC_Operation_IMP   imp;
    113 } TEEC_Operation;
    114 
    115 
    116 #define TEEC_ORIGIN_API                      0x00000001
    117 #define TEEC_ORIGIN_COMMS                    0x00000002
    118 #define TEEC_ORIGIN_TEE                      0x00000003
    119 #define TEEC_ORIGIN_TRUSTED_APP              0x00000004
    120 
    121 #define TEEC_MEM_INPUT                       0x00000001
    122 #define TEEC_MEM_OUTPUT                      0x00000002
    123 
    124 #define TEEC_NONE                     0x0
    125 #define TEEC_VALUE_INPUT              0x1
    126 #define TEEC_VALUE_OUTPUT             0x2
    127 #define TEEC_VALUE_INOUT              0x3
    128 #define TEEC_MEMREF_TEMP_INPUT        0x5
    129 #define TEEC_MEMREF_TEMP_OUTPUT       0x6
    130 #define TEEC_MEMREF_TEMP_INOUT        0x7
    131 #define TEEC_MEMREF_WHOLE             0xC
    132 #define TEEC_MEMREF_PARTIAL_INPUT     0xD
    133 #define TEEC_MEMREF_PARTIAL_OUTPUT    0xE
    134 #define TEEC_MEMREF_PARTIAL_INOUT     0xF
    135 
    136 #define TEEC_LOGIN_PUBLIC                    0x00000000
    137 #define TEEC_LOGIN_USER                      0x00000001
    138 #define TEEC_LOGIN_GROUP                     0x00000002
    139 #define TEEC_LOGIN_APPLICATION               0x00000004
    140 #define TEEC_LOGIN_USER_APPLICATION          0x00000005
    141 #define TEEC_LOGIN_GROUP_APPLICATION         0x00000006
    142 
    143 TEEC_Result TEEC_EXPORT TEEC_InitializeContext(
    144     const char*   name,
    145     TEEC_Context* context);
    146 
    147 void TEEC_EXPORT TEEC_FinalizeContext(
    148     TEEC_Context* context);
    149 
    150 TEEC_Result TEEC_EXPORT TEEC_RegisterSharedMemory(
    151     TEEC_Context*      context,
    152     TEEC_SharedMemory* sharedMem);
    153 
    154 TEEC_Result TEEC_EXPORT TEEC_AllocateSharedMemory(
    155     TEEC_Context*      context,
    156     TEEC_SharedMemory* sharedMem);
    157 
    158 void TEEC_EXPORT TEEC_ReleaseSharedMemory (
    159     TEEC_SharedMemory* sharedMem);
    160 
    161 TEEC_Result TEEC_EXPORT TEEC_OpenSession (
    162     TEEC_Context*    context,
    163     TEEC_Session*    session,
    164     const TEEC_UUID* destination,
    165     uint32_t         connectionMethod,
    166     void*            connectionData,
    167     TEEC_Operation*  operation,
    168     uint32_t*        errorOrigin);
    169 
    170 void TEEC_EXPORT TEEC_CloseSession (
    171     TEEC_Session* session);
    172 
    173 TEEC_Result TEEC_EXPORT TEEC_InvokeCommand(
    174     TEEC_Session*     session,
    175     uint32_t          commandID,
    176     TEEC_Operation*   operation,
    177     uint32_t*         errorOrigin);
    178 
    179 void TEEC_EXPORT TEEC_RequestCancellation(
    180     TEEC_Operation* operation);
    181 
    182 #include "tee_client_api_ex.h"
    183 
    184 #endif /* __TEE_CLIENT_API_H__ */
    185