1 /** @file 2 OP-TEE specific header file. 3 4 Copyright (c) 2018, Linaro Ltd. All rights reserved.<BR> 5 6 SPDX-License-Identifier: BSD-2-Clause-Patent 7 8 **/ 9 10 #ifndef _OPTEE_H_ 11 #define _OPTEE_H_ 12 13 /* 14 * The 'Trusted OS Call UID' is supposed to return the following UUID for 15 * OP-TEE OS. This is a 128-bit value. 16 */ 17 #define OPTEE_OS_UID0 0x384fb3e0 18 #define OPTEE_OS_UID1 0xe7f811e3 19 #define OPTEE_OS_UID2 0xaf630002 20 #define OPTEE_OS_UID3 0xa5d5c51b 21 22 #define OPTEE_MESSAGE_ATTRIBUTE_TYPE_NONE 0x0 23 #define OPTEE_MESSAGE_ATTRIBUTE_TYPE_VALUE_INPUT 0x1 24 #define OPTEE_MESSAGE_ATTRIBUTE_TYPE_VALUE_OUTPUT 0x2 25 #define OPTEE_MESSAGE_ATTRIBUTE_TYPE_VALUE_INOUT 0x3 26 #define OPTEE_MESSAGE_ATTRIBUTE_TYPE_MEMORY_INPUT 0x9 27 #define OPTEE_MESSAGE_ATTRIBUTE_TYPE_MEMORY_OUTPUT 0xa 28 #define OPTEE_MESSAGE_ATTRIBUTE_TYPE_MEMORY_INOUT 0xb 29 30 #define OPTEE_MESSAGE_ATTRIBUTE_TYPE_MASK 0xff 31 32 #define OPTEE_SUCCESS 0x00000000 33 #define OPTEE_ORIGIN_COMMUNICATION 0x00000002 34 #define OPTEE_ERROR_COMMUNICATION 0xFFFF000E 35 36 typedef struct { 37 UINT64 BufferAddress; 38 UINT64 Size; 39 UINT64 SharedMemoryReference; 40 } OPTEE_MESSAGE_PARAM_MEMORY; 41 42 typedef struct { 43 UINT64 A; 44 UINT64 B; 45 UINT64 C; 46 } OPTEE_MESSAGE_PARAM_VALUE; 47 48 typedef struct { 49 UINT64 Attribute; 50 union { 51 OPTEE_MESSAGE_PARAM_MEMORY Memory; 52 OPTEE_MESSAGE_PARAM_VALUE Value; 53 } Union; 54 } OPTEE_MESSAGE_PARAM; 55 56 #define OPTEE_MAX_CALL_PARAMS 4 57 58 typedef struct { 59 UINT32 Command; 60 UINT32 Function; 61 UINT32 Session; 62 UINT32 CancelId; 63 UINT32 Pad; 64 UINT32 Return; 65 UINT32 ReturnOrigin; 66 UINT32 NumParams; 67 68 // NumParams tells the actual number of element in Params 69 OPTEE_MESSAGE_PARAM Params[OPTEE_MAX_CALL_PARAMS]; 70 } OPTEE_MESSAGE_ARG; 71 72 typedef struct { 73 EFI_GUID Uuid; // [in] GUID/UUID of the Trusted Application 74 UINT32 Session; // [out] Session id 75 UINT32 Return; // [out] Return value 76 UINT32 ReturnOrigin; // [out] Origin of the return value 77 } OPTEE_OPEN_SESSION_ARG; 78 79 typedef struct { 80 UINT32 Function; // [in] Trusted Application function, specific to the TA 81 UINT32 Session; // [in] Session id 82 UINT32 Return; // [out] Return value 83 UINT32 ReturnOrigin; // [out] Origin of the return value 84 OPTEE_MESSAGE_PARAM Params[OPTEE_MAX_CALL_PARAMS]; // Params for function to be invoked 85 } OPTEE_INVOKE_FUNCTION_ARG; 86 87 BOOLEAN 88 EFIAPI 89 IsOpteePresent ( 90 VOID 91 ); 92 93 EFI_STATUS 94 EFIAPI 95 OpteeInit ( 96 VOID 97 ); 98 99 EFI_STATUS 100 EFIAPI 101 OpteeOpenSession ( 102 IN OUT OPTEE_OPEN_SESSION_ARG *OpenSessionArg 103 ); 104 105 EFI_STATUS 106 EFIAPI 107 OpteeCloseSession ( 108 IN UINT32 Session 109 ); 110 111 EFI_STATUS 112 EFIAPI 113 OpteeInvokeFunction ( 114 IN OUT OPTEE_INVOKE_FUNCTION_ARG *InvokeFunctionArg 115 ); 116 117 #endif 118