1 /*
2  * Copyright (c) 2014, STMicroelectronics International N.V.
3  * All rights reserved.
4  * Copyright (c) 2015, Linaro Limited
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright notice,
11  * this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright notice,
14  * this list of conditions and the following disclaimer in the documentation
15  * and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 #ifndef TEE_CLIENT_API_H
30 #define TEE_CLIENT_API_H
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 #include <stdint.h>
37 #include <stddef.h>
38 #include <stdbool.h>
39 #include <limits.h>
40 
41 /*
42  * Defines the number of available memory references in an open session or
43  * invoke command operation payload.
44  */
45 #define TEEC_CONFIG_PAYLOAD_REF_COUNT 4
46 
47 /**
48  * Defines the maximum size of a single shared memory block, in bytes, of both
49  * API allocated and API registered memory. There is no good value to put here
50  * (limits depend on specific config used), so this define does not provide any
51  * restriction in this implementation.
52  */
53 #define TEEC_CONFIG_SHAREDMEM_MAX_SIZE ULONG_MAX
54 
55 /**
56  * Flag constants indicating the type of parameters encoded inside the
57  * operation payload (TEEC_Operation), Type is uint32_t.
58  *
59  * TEEC_NONE                   The Parameter is not used
60  *
61  * TEEC_VALUE_INPUT            The Parameter is a TEEC_Value tagged as input.
62  *
63  * TEEC_VALUE_OUTPUT           The Parameter is a TEEC_Value tagged as output.
64  *
65  * TEEC_VALUE_INOUT            The Parameter is a TEEC_Value tagged as both as
66  *                             input and output, i.e., for which both the
67  *                             behaviors of TEEC_VALUE_INPUT and
68  *                             TEEC_VALUE_OUTPUT apply.
69  *
70  * TEEC_MEMREF_TEMP_INPUT      The Parameter is a TEEC_TempMemoryReference
71  *                             describing a region of memory which needs to be
72  *                             temporarily registered for the duration of the
73  *                             Operation and is tagged as input.
74  *
75  * TEEC_MEMREF_TEMP_OUTPUT     Same as TEEC_MEMREF_TEMP_INPUT, but the Memory
76  *                             Reference is tagged as output. The
77  *                             Implementation may update the size field to
78  *                             reflect the required output size in some use
79  *                             cases.
80  *
81  * TEEC_MEMREF_TEMP_INOUT      A Temporary Memory Reference tagged as both
82  *                             input and output, i.e., for which both the
83  *                             behaviors of TEEC_MEMREF_TEMP_INPUT and
84  *                             TEEC_MEMREF_TEMP_OUTPUT apply.
85  *
86  * TEEC_MEMREF_WHOLE           The Parameter is a Registered Memory Reference
87  *                             that refers to the entirety of its parent Shared
88  *                             Memory block. The parameter structure is a
89  *                             TEEC_RegisteredMemoryReference. In this
90  *                             structure, the Implementation MUST read only the
91  *                             parent field and MAY update the size field when
92  *                             the operation completes.
93  *
94  * TEEC_MEMREF_PARTIAL_INPUT   A Registered Memory Reference structure that
95  *                             refers to a partial region of its parent Shared
96  *                             Memory block and is tagged as input.
97  *
98  * TEEC_MEMREF_PARTIAL_OUTPUT  Registered Memory Reference structure that
99  *                             refers to a partial region of its parent Shared
100  *                             Memory block and is tagged as output.
101  *
102  * TEEC_MEMREF_PARTIAL_INOUT   The Registered Memory Reference structure that
103  *                             refers to a partial region of its parent Shared
104  *                             Memory block and is tagged as both input and
105  *                             output, i.e., for which both the behaviors of
106  *                             TEEC_MEMREF_PARTIAL_INPUT and
107  *                             TEEC_MEMREF_PARTIAL_OUTPUT apply.
108  */
109 #define TEEC_NONE                   0x00000000
110 #define TEEC_VALUE_INPUT            0x00000001
111 #define TEEC_VALUE_OUTPUT           0x00000002
112 #define TEEC_VALUE_INOUT            0x00000003
113 #define TEEC_MEMREF_TEMP_INPUT      0x00000005
114 #define TEEC_MEMREF_TEMP_OUTPUT     0x00000006
115 #define TEEC_MEMREF_TEMP_INOUT      0x00000007
116 #define TEEC_MEMREF_WHOLE           0x0000000C
117 #define TEEC_MEMREF_PARTIAL_INPUT   0x0000000D
118 #define TEEC_MEMREF_PARTIAL_OUTPUT  0x0000000E
119 #define TEEC_MEMREF_PARTIAL_INOUT   0x0000000F
120 
121 /**
122  * Flag constants indicating the data transfer direction of memory in
123  * TEEC_Parameter. TEEC_MEM_INPUT signifies data transfer direction from the
124  * client application to the TEE. TEEC_MEM_OUTPUT signifies data transfer
125  * direction from the TEE to the client application. Type is uint32_t.
126  *
127  * TEEC_MEM_INPUT   The Shared Memory can carry data from the client
128  *                  application to the Trusted Application.
129  * TEEC_MEM_OUTPUT  The Shared Memory can carry data from the Trusted
130  *                  Application to the client application.
131  */
132 #define TEEC_MEM_INPUT   0x00000001
133 #define TEEC_MEM_OUTPUT  0x00000002
134 
135 /**
136  * Return values. Type is TEEC_Result
137  *
138  * TEEC_SUCCESS                 The operation was successful.
139  * TEEC_ERROR_GENERIC           Non-specific cause.
140  * TEEC_ERROR_ACCESS_DENIED     Access privileges are not sufficient.
141  * TEEC_ERROR_CANCEL            The operation was canceled.
142  * TEEC_ERROR_ACCESS_CONFLICT   Concurrent accesses caused conflict.
143  * TEEC_ERROR_EXCESS_DATA       Too much data for the requested operation was
144  *                              passed.
145  * TEEC_ERROR_BAD_FORMAT        Input data was of invalid format.
146  * TEEC_ERROR_BAD_PARAMETERS    Input parameters were invalid.
147  * TEEC_ERROR_BAD_STATE         Operation is not valid in the current state.
148  * TEEC_ERROR_ITEM_NOT_FOUND    The requested data item is not found.
149  * TEEC_ERROR_NOT_IMPLEMENTED   The requested operation should exist but is not
150  *                              yet implemented.
151  * TEEC_ERROR_NOT_SUPPORTED     The requested operation is valid but is not
152  *                              supported in this implementation.
153  * TEEC_ERROR_NO_DATA           Expected data was missing.
154  * TEEC_ERROR_OUT_OF_MEMORY     System ran out of resources.
155  * TEEC_ERROR_BUSY              The system is busy working on something else.
156  * TEEC_ERROR_COMMUNICATION     Communication with a remote party failed.
157  * TEEC_ERROR_SECURITY          A security fault was detected.
158  * TEEC_ERROR_SHORT_BUFFER      The supplied buffer is too short for the
159  *                              generated output.
160  * TEE_ERROR_EXTERNAL_CANCEL    Defined by the Trusted User Interface
161  *                              specification: An external event has caused a
162  *                              User Interface operation to be aborted.
163  * TEEC_ERROR_EXTERNAL_CANCEL   Deprecated: not specified in client API, use
164  *                              TEE_ERROR_EXTERNAL_CANCEL intead.
165  * TEE_ERROR_OVERFLOW           Internal TEE error – documented for completeness
166  * TEE_ERROR_TARGET_DEAD        The Trusted Application has terminated.
167  * TEEC_ERROR_TARGET_DEAD       The Trusted Application has terminated.
168  * TEE_ERROR_STORAGE_NO_SPACE   Internal TEE error – documented for completeness
169  * TEEC_ERROR_STORAGE_NO_SPACE  Deprecated: not specified in client API, use
170  *                              TEE_ERROR_STORAGE_NO_SPACE instead.
171  * TEE_ERROR_MAC_INVALID        Internal TEE error – documented for completeness
172  * TEE_ERROR_SIGNATURE_INVALID  Internal TEE error – documented for completeness
173  * TEE_ERROR_TIME_NOT_SET       Internal TEE error – documented for completeness
174  * TEE_ERROR_TIME_NEEDS_RESET   Internal TEE error – documented for completeness
175  */
176 
177 /**
178  *  Standard defined error codes.
179  */
180 #define TEEC_SUCCESS                       0x00000000
181 #define TEEC_ERROR_STORAGE_NOT_AVAILABLE   0xF0100003
182 #define TEEC_ERROR_GENERIC                 0xFFFF0000
183 #define TEEC_ERROR_ACCESS_DENIED           0xFFFF0001
184 #define TEEC_ERROR_CANCEL                  0xFFFF0002
185 #define TEEC_ERROR_ACCESS_CONFLICT         0xFFFF0003
186 #define TEEC_ERROR_EXCESS_DATA             0xFFFF0004
187 #define TEEC_ERROR_BAD_FORMAT              0xFFFF0005
188 #define TEEC_ERROR_BAD_PARAMETERS          0xFFFF0006
189 #define TEEC_ERROR_BAD_STATE               0xFFFF0007
190 #define TEEC_ERROR_ITEM_NOT_FOUND          0xFFFF0008
191 #define TEEC_ERROR_NOT_IMPLEMENTED         0xFFFF0009
192 #define TEEC_ERROR_NOT_SUPPORTED           0xFFFF000A
193 #define TEEC_ERROR_NO_DATA                 0xFFFF000B
194 #define TEEC_ERROR_OUT_OF_MEMORY           0xFFFF000C
195 #define TEEC_ERROR_BUSY                    0xFFFF000D
196 #define TEEC_ERROR_COMMUNICATION           0xFFFF000E
197 #define TEEC_ERROR_SECURITY                0xFFFF000F
198 #define TEEC_ERROR_SHORT_BUFFER            0xFFFF0010
199 #define TEE_ERROR_EXTERNAL_CANCEL          0xFFFF0011
200 #define TEEC_ERROR_EXTERNAL_CANCEL         0xFFFF0011
201 #define TEE_ERROR_OVERFLOW                 0xFFFF300F
202 #define TEE_ERROR_TARGET_DEAD              0xFFFF3024
203 #define TEEC_ERROR_TARGET_DEAD             0xFFFF3024
204 #define TEE_ERROR_STORAGE_NO_SPACE         0xFFFF3041
205 #define TEEC_ERROR_STORAGE_NO_SPACE        0xFFFF3041
206 #define TEE_ERROR_MAC_INVALID              0xFFFF3071
207 #define TEE_ERROR_SIGNATURE_INVALID        0xFFFF3072
208 #define TEE_ERROR_TIME_NOT_SET             0xFFFF5000
209 #define TEE_ERROR_TIME_NEEDS_RESET         0xFFFF5001
210 
211 /**
212  * Function error origins, of type TEEC_ErrorOrigin. These indicate where in
213  * the software stack a particular return value originates from.
214  *
215  * TEEC_ORIGIN_API          The error originated within the TEE Client API
216  *                          implementation.
217  * TEEC_ORIGIN_COMMS        The error originated within the underlying
218  *                          communications stack linking the rich OS with
219  *                          the TEE.
220  * TEEC_ORIGIN_TEE          The error originated within the common TEE code.
221  * TEEC_ORIGIN_TRUSTED_APP  The error originated within the Trusted Application
222  *                          code.
223  */
224 #define TEEC_ORIGIN_API          0x00000001
225 #define TEEC_ORIGIN_COMMS        0x00000002
226 #define TEEC_ORIGIN_TEE          0x00000003
227 #define TEEC_ORIGIN_TRUSTED_APP  0x00000004
228 
229 /**
230  * Session login methods, for use in TEEC_OpenSession() as parameter
231  * connectionMethod. Type is uint32_t.
232  *
233  * TEEC_LOGIN_PUBLIC    	 No login data is provided.
234  * TEEC_LOGIN_USER         	Login data about the user running the Client
235  *                         	Application process is provided.
236  * TEEC_LOGIN_GROUP        	Login data about the group running the Client
237  *                         	Application process is provided.
238  * TEEC_LOGIN_APPLICATION  	Login data about the running Client Application
239  *                         	itself is provided.
240  * TEEC_LOGIN_USER_APPLICATION  Login data about the user and the running
241  *                          	Client Application itself is provided.
242  * TEEC_LOGIN_GROUP_APPLICATION Login data about the group and the running
243  *                          	Client Application itself is provided.
244  */
245 #define TEEC_LOGIN_PUBLIC       0x00000000
246 #define TEEC_LOGIN_USER         0x00000001
247 #define TEEC_LOGIN_GROUP        0x00000002
248 #define TEEC_LOGIN_APPLICATION  0x00000004
249 #define TEEC_LOGIN_USER_APPLICATION  0x00000005
250 #define TEEC_LOGIN_GROUP_APPLICATION  0x00000006
251 
252 /**
253  * Encode the paramTypes according to the supplied types.
254  *
255  * @param p0 The first param type.
256  * @param p1 The second param type.
257  * @param p2 The third param type.
258  * @param p3 The fourth param type.
259  */
260 #define TEEC_PARAM_TYPES(p0, p1, p2, p3) \
261 	((p0) | ((p1) << 4) | ((p2) << 8) | ((p3) << 12))
262 
263 /**
264  * Get the i_th param type from the paramType.
265  *
266  * @param p The paramType.
267  * @param i The i-th parameter to get the type for.
268  */
269 #define TEEC_PARAM_TYPE_GET(p, i) (((p) >> (i * 4)) & 0xF)
270 
271 typedef uint32_t TEEC_Result;
272 
273 /**
274  * struct TEEC_Context - Represents a connection between a client application
275  * and a TEE.
276  */
277 typedef struct {
278 	/* Implementation defined */
279 	struct {
280 		int fd;
281 		bool reg_mem;
282 		bool memref_null;
283 	} imp;
284 } TEEC_Context;
285 
286 /**
287  * This type contains a Universally Unique Resource Identifier (UUID) type as
288  * defined in RFC4122. These UUID values are used to identify Trusted
289  * Applications.
290  */
291 typedef struct {
292 	uint32_t timeLow;
293 	uint16_t timeMid;
294 	uint16_t timeHiAndVersion;
295 	uint8_t clockSeqAndNode[8];
296 } TEEC_UUID;
297 
298 /**
299  * struct TEEC_SharedMemory - Memory to transfer data between a client
300  * application and trusted code.
301  *
302  * @param buffer      The memory buffer which is to be, or has been, shared
303  *                    with the TEE.
304  * @param size        The size, in bytes, of the memory buffer.
305  * @param flags       Bit-vector which holds properties of buffer.
306  *                    The bit-vector can contain either or both of the
307  *                    TEEC_MEM_INPUT and TEEC_MEM_OUTPUT flags.
308  *
309  * A shared memory block is a region of memory allocated in the context of the
310  * client application memory space that can be used to transfer data between
311  * that client application and a trusted application. The user of this struct
312  * is responsible to populate the buffer pointer.
313  */
314 typedef struct {
315 	void *buffer;
316 	size_t size;
317 	uint32_t flags;
318 	/*
319 	 * Implementation defined
320 	 */
321 	struct {
322 		int id;
323 		size_t alloced_size;
324 		void *shadow_buffer;
325 		int registered_fd;
326 		uint32_t flags;
327 	} imp;
328 } TEEC_SharedMemory;
329 
330 /**
331  * struct TEEC_TempMemoryReference - Temporary memory to transfer data between
332  * a client application and trusted code, only used for the duration of the
333  * operation.
334  *
335  * @param buffer  The memory buffer which is to be, or has been shared with
336  *                the TEE.
337  * @param size    The size, in bytes, of the memory buffer.
338  *
339  * A memory buffer that is registered temporarily for the duration of the
340  * operation to be called.
341  */
342 typedef struct {
343 	void *buffer;
344 	size_t size;
345 } TEEC_TempMemoryReference;
346 
347 /**
348  * struct TEEC_RegisteredMemoryReference - use a pre-registered or
349  * pre-allocated shared memory block of memory to transfer data between
350  * a client application and trusted code.
351  *
352  * @param parent  Points to a shared memory structure. The memory reference
353  *                may utilize the whole shared memory or only a part of it.
354  *                Must not be NULL
355  *
356  * @param size    The size, in bytes, of the memory buffer.
357  *
358  * @param offset  The offset, in bytes, of the referenced memory region from
359  *                the start of the shared memory block.
360  *
361  */
362 typedef struct {
363 	TEEC_SharedMemory *parent;
364 	size_t size;
365 	size_t offset;
366 } TEEC_RegisteredMemoryReference;
367 
368 /**
369  * struct TEEC_Value - Small raw data container
370  *
371  * Instead of allocating a shared memory buffer this structure can be used
372  * to pass small raw data between a client application and trusted code.
373  *
374  * @param a  The first integer value.
375  *
376  * @param b  The second value.
377  */
378 typedef struct {
379 	uint32_t a;
380 	uint32_t b;
381 } TEEC_Value;
382 
383 /**
384  * union TEEC_Parameter - Memory container to be used when passing data between
385  *                        client application and trusted code.
386  *
387  * Either the client uses a shared memory reference, parts of it or a small raw
388  * data container.
389  *
390  * @param tmpref  A temporary memory reference only valid for the duration
391  *                of the operation.
392  *
393  * @param memref  The entire shared memory or parts of it.
394  *
395  * @param value   The small raw data container to use
396  */
397 typedef union {
398 	TEEC_TempMemoryReference tmpref;
399 	TEEC_RegisteredMemoryReference memref;
400 	TEEC_Value value;
401 } TEEC_Parameter;
402 
403 /**
404  * struct TEEC_Session - Represents a connection between a client application
405  * and a trusted application.
406  */
407 typedef struct {
408 	/* Implementation defined */
409 	struct {
410 		TEEC_Context *ctx;
411 		uint32_t session_id;
412 	} imp;
413 } TEEC_Session;
414 
415 /**
416  * struct TEEC_Operation - Holds information and memory references used in
417  * TEEC_InvokeCommand().
418  *
419  * @param   started     Client must initialize to zero if it needs to cancel
420  *                      an operation about to be performed.
421  * @param   paramTypes  Type of data passed. Use TEEC_PARAM_TYPES macro to
422  *                      create the correct flags.
423  *                      0 means TEEC_NONE is passed for all params.
424  * @param   params      Array of parameters of type TEEC_Parameter.
425  * @param   imp         Implementation defined parameter. Here it is a struct
426  *                      containing one parameter: session. session is an
427  *                      internal pointer to the last session used by
428  *                      TEEC_InvokeCommand with this operation.
429  *
430  */
431 typedef struct {
432 	uint32_t started;
433 	uint32_t paramTypes;
434 	TEEC_Parameter params[TEEC_CONFIG_PAYLOAD_REF_COUNT];
435 	/* Implementation defined */
436 	struct {
437 		TEEC_Session *session;
438 	} imp;
439 } TEEC_Operation;
440 
441 /**
442  * TEEC_InitializeContext() - Initializes a context holding connection
443  * information on the specific TEE, designated by the name string.
444 
445  * @param name    A zero-terminated string identifying the TEE to connect to.
446  *                If name is set to NULL, the default TEE is connected to. NULL
447  *                is the only supported value in this version of the API
448  *                implementation.
449  *
450  * @param context The context structure which is to be initialized.
451  *
452  * @return TEEC_SUCCESS  The initialization was successful.
453  * @return TEEC_Result   Something failed.
454  */
455 TEEC_Result TEEC_InitializeContext(const char *name, TEEC_Context *context);
456 
457 /**
458  * TEEC_FinalizeContext() - Destroys a context holding connection information
459  * on the specific TEE.
460  *
461  * This function destroys an initialized TEE context, closing the connection
462  * between the client application and the TEE. This function must only be
463  * called when all sessions related to this TEE context have been closed and
464  * all shared memory blocks have been released.
465  *
466  * @param context       The context to be destroyed.
467  */
468 void TEEC_FinalizeContext(TEEC_Context *context);
469 
470 /**
471  * TEEC_OpenSession() - Opens a new session with the specified trusted
472  *                      application.
473  *
474  * @param context            The initialized TEE context structure in which
475  *                           scope to open the session.
476  * @param session            The session to initialize.
477  * @param destination        A structure identifying the trusted application
478  *                           with which to open a session.
479  *
480  * @param connectionMethod   The connection method to use.
481  * @param connectionData     Any data necessary to connect with the chosen
482  *                           connection method. Not supported, should be set to
483  *                           NULL.
484  * @param operation          An operation structure to use in the session. May
485  *                           be set to NULL to signify no operation structure
486  *                           needed.
487  *
488  * @param returnOrigin       A parameter which will hold the error origin if
489  *                           this function returns any value other than
490  *                           TEEC_SUCCESS.
491  *
492  * @return TEEC_SUCCESS      OpenSession successfully opened a new session.
493  * @return TEEC_Result       Something failed.
494  *
495  */
496 TEEC_Result TEEC_OpenSession(TEEC_Context *context,
497 			     TEEC_Session *session,
498 			     const TEEC_UUID *destination,
499 			     uint32_t connectionMethod,
500 			     const void *connectionData,
501 			     TEEC_Operation *operation,
502 			     uint32_t *returnOrigin);
503 
504 /**
505  * TEEC_CloseSession() - Closes the session which has been opened with the
506  * specific trusted application.
507  *
508  * @param session The opened session to close.
509  */
510 void TEEC_CloseSession(TEEC_Session *session);
511 
512 /**
513  * TEEC_InvokeCommand() - Executes a command in the specified trusted
514  * application.
515  *
516  * @param session        A handle to an open connection to the trusted
517  *                       application.
518  * @param commandID      Identifier of the command in the trusted application
519  *                       to invoke.
520  * @param operation      An operation structure to use in the invoke command.
521  *                       May be set to NULL to signify no operation structure
522  *                       needed.
523  * @param returnOrigin   A parameter which will hold the error origin if this
524  *                       function returns any value other than TEEC_SUCCESS.
525  *
526  * @return TEEC_SUCCESS  OpenSession successfully opened a new session.
527  * @return TEEC_Result   Something failed.
528  */
529 TEEC_Result TEEC_InvokeCommand(TEEC_Session *session,
530 			       uint32_t commandID,
531 			       TEEC_Operation *operation,
532 			       uint32_t *returnOrigin);
533 
534 /**
535  * TEEC_RegisterSharedMemory() - Register a block of existing memory as a
536  * shared block within the scope of the specified context.
537  *
538  * @param context    The initialized TEE context structure in which scope to
539  *                   open the session.
540  * @param sharedMem  pointer to the shared memory structure to register.
541  *
542  * @return TEEC_SUCCESS              The registration was successful.
543  * @return TEEC_ERROR_OUT_OF_MEMORY  Memory exhaustion.
544  * @return TEEC_Result               Something failed.
545  */
546 TEEC_Result TEEC_RegisterSharedMemory(TEEC_Context *context,
547 				      TEEC_SharedMemory *sharedMem);
548 
549 /**
550  * TEEC_AllocateSharedMemory() - Allocate shared memory for TEE.
551  *
552  * @param context     The initialized TEE context structure in which scope to
553  *                    open the session.
554  * @param sharedMem   Pointer to the allocated shared memory.
555  *
556  * @return TEEC_SUCCESS              The registration was successful.
557  * @return TEEC_ERROR_OUT_OF_MEMORY  Memory exhaustion.
558  * @return TEEC_Result               Something failed.
559  */
560 TEEC_Result TEEC_AllocateSharedMemory(TEEC_Context *context,
561 				      TEEC_SharedMemory *sharedMem);
562 
563 /**
564  * TEEC_ReleaseSharedMemory() - Free or deregister the shared memory.
565  *
566  * @param sharedMem  Pointer to the shared memory to be freed.
567  */
568 void TEEC_ReleaseSharedMemory(TEEC_SharedMemory *sharedMemory);
569 
570 /**
571  * TEEC_RequestCancellation() - Request the cancellation of a pending open
572  *                              session or command invocation.
573  *
574  * @param operation Pointer to an operation previously passed to open session
575  *                  or invoke.
576  */
577 void TEEC_RequestCancellation(TEEC_Operation *operation);
578 
579 #ifdef __cplusplus
580 }
581 #endif
582 
583 #endif
584