diff options
author | Martin Hovang <martin.xm.hovang@stericsson.com> | 2011-05-09 11:57:00 +0200 |
---|---|---|
committer | Henrik Aberg <henrik.aberg@stericsson.com> | 2011-05-18 09:40:15 +0200 |
commit | 0cbbb90e951ddf96edee57d321a9309849d0fe97 (patch) | |
tree | a9972a0d6ae869bf5c410406dc523480c1f0d40c /include | |
parent | 95769f26527700c1eb1564018db575e7db461d2c (diff) |
TEE: Added TEE kernel interface
ST-Ericsson ID: 337171
ST Ericsson FOSS-OUT ID: Trivial
ST Ericsson Linux next: Not tested
Change-Id: I4c87bd550547a1fd90f1fef8c3c553246940b31e
Signed-off-by: Martin Hovang <martin.xm.hovang@stericsson.com>
Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/22666
Reviewed-by: QATEST
Reviewed-by: Joakim BECH <joakim.xx.bech@stericsson.com>
Reviewed-by: Jonas ABERG <jonas.aberg@stericsson.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/tee.h | 135 |
1 files changed, 134 insertions, 1 deletions
diff --git a/include/linux/tee.h b/include/linux/tee.h index 0cdec2d254a..4928e4dca1f 100644 --- a/include/linux/tee.h +++ b/include/linux/tee.h @@ -3,7 +3,7 @@ * * Copyright (C) ST-Ericsson SA 2010 * Author: Shujuan Chen <shujuan.chen@stericsson.com> - * Author: Martin Hovang <martin.xm.hovang@stericsson.com + * Author: Martin Hovang <martin.xm.hovang@stericsson.com> * Author: Joakim Bech <joakim.xx.bech@stericsson.com> * License terms: GNU General Public License (GPL) version 2 */ @@ -45,6 +45,37 @@ #define TEEC_CONFIG_PAYLOAD_REF_COUNT 4 +/* + * Flag constants indicating which of the memory references in an open session + * or invoke command operation payload (TEEC_Operation) that are used. + */ +#define TEEC_MEMREF_0_USED 0x00000001 +#define TEEC_MEMREF_1_USED 0x00000002 +#define TEEC_MEMREF_2_USED 0x00000004 +#define TEEC_MEMREF_3_USED 0x00000008 + +/* + * Flag constants indicating the data transfer direction of memory in + * TEEC_SharedMemory and TEEC_MemoryReference. TEEC_MEM_INPUT signifies data + * transfer direction from the client application to the TEE. TEEC_MEM_OUTPUT + * signifies data transfer direction from the TEE to the client application. + */ +#define TEEC_MEM_INPUT 0x00000001 +#define TEEC_MEM_OUTPUT 0x00000002 + +/* + * Session login methods, for use in TEEC_OpenSession() as parameter + * connectionMethod. Type is t_uint32. + * + * TEEC_LOGIN_PUBLIC No login data is provided. + */ +#define TEEC_LOGIN_PUBLIC 0x0 + +/* + * Exposed functions (command_id) in the static TA + */ +#define TEE_STA_SET_L2CC_PREFETCH_CTRL_REGISTER 11 + /** * struct tee_uuid - Structure that represent an uuid. * @timeLow: The low field of the time stamp. @@ -85,6 +116,8 @@ struct tee_operation { uint32_t flags; }; +struct tee_context {}; + /** * struct tee_session - The session of an open tee device. * @state: The current state in the linux kernel. @@ -140,4 +173,104 @@ struct tee_read { */ int call_sec_world(struct tee_session *ts, int sec_cmd); + +/** + * teec_initialize_context() - Initializes a context holding connection + * information on the specific TEE. + * @param name: A zero-terminated string identifying the TEE to connect to. + * If name is set to NULL, the default TEE is connected to. + * NULL is the only supported value in this version of the + * API implementation. + * @param context: The context structure which is to be initialized. + * + * Initializes a context holding connection information between the calling + * client application and the TEE designated by the name string. + */ +int teec_initialize_context(const char *name, struct tee_context *context); + +/** + * teec_finalize_context() - Destroys a context holding connection information + * on the specific TEE. + * @param context: The context to be destroyed. + * + * This function destroys an initialized TEE context, closing the connection + * between the client application and the TEE. This function must only be + * called when all sessions related to this TEE context have been closed and + * all shared memory blocks have been released. + */ +int teec_finalize_context(struct tee_context *context); + +/** + * teec_open_session() - Opens a new session with the specified trusted + * application. + * @param context: The initialized TEE context structure in which scope to + * open the session. + * @param session: The session to initialize. + * @param destination: A structure identifying the trusted application with + * which to open a session. If this is set to NULL the + * operation TEEC_MEMREF_0 is expected to contain the blob + * which holds the Trusted Application. + * @param connection_method: The connection method to use. + * @param connection_data: Any data necessary to connect with the chosen + * connection method. Not supported should be set to + * NULL. + * @param operation: An operation structure to use in the session. May be + * set to NULL to signify no operation structure needed. + * If destination is set to NULL, TEEC_MEMREF_0 is + * expected to hold the TA binary as described above. + * @param error_origin: A parameter which will hold the error origin if this + * function returns any value other than TEEC_SUCCESS. + * + * Opens a new session with the specified trusted application. Only + * connectionMethod == TEEC_LOGIN_PUBLIC is supported. connectionData and + * operation shall be set to NULL. + */ +int teec_open_session(struct tee_context *context, struct tee_session *session, + const struct tee_uuid *destination, + unsigned int connection_method, + void *connection_data, struct tee_operation *operation, + unsigned int *error_origin); + +/** + * teec_close_session() - Closes the session which has been opened with the + * specific trusted application. + * @param session: The opened session to close. + * + * Closes the session which has been opened with the specific trusted + * application. + */ +int teec_close_session(struct tee_session *session); + +/** + * teec_invoke_command() - Executes a command in the specified trusted + * application. + * @param destination: A structure identifying the trusted application. + * @param command_id: Identifier of the command in the trusted application to + * invoke. + * @param operation: An operation structure to use in the invoke command. May + * be set to NULL to signify no operation structure needed. + * @param error_origin: A parameter which will hold the error origin if this + * function returns any value other than TEEC_SUCCESS. + * + * Executes a command in the specified trusted application. + */ +int teec_invoke_command(struct tee_session *session, unsigned int command_id, + struct tee_operation *operation, + unsigned int *error_origin); + +/** + * teec_allocate_shared_memory() - Allocate shared memory for TEE. + * @param context: The initialized TEE context structure in which scope to + * open the session. + * @param shared_memory: Pointer to the allocated shared memory. + */ +int teec_allocate_shared_memory(struct tee_context *context, + struct tee_sharedmemory *shared_memory); + +/** + * teec_release_shared_memory() - Free the shared memory. + * @param shared_memory: Pointer to the shared memory to be freed. + */ +void teec_release_shared_memory(struct tee_sharedmemory *shared_memory); + #endif |