![]() |
|
|||
0001 /* SPDX-License-Identifier: MIT */ 0002 0003 /* 0004 * Copyright 2019 Advanced Micro Devices, Inc. 0005 */ 0006 0007 /* 0008 * This file has definitions related to Host and AMD-TEE Trusted OS interface. 0009 * These definitions must match the definitions on the TEE side. 0010 */ 0011 0012 #ifndef AMDTEE_IF_H 0013 #define AMDTEE_IF_H 0014 0015 #include <linux/types.h> 0016 0017 /***************************************************************************** 0018 ** TEE Param 0019 ******************************************************************************/ 0020 #define TEE_MAX_PARAMS 4 0021 0022 /** 0023 * struct memref - memory reference structure 0024 * @buf_id: buffer ID of the buffer mapped by TEE_CMD_ID_MAP_SHARED_MEM 0025 * @offset: offset in bytes from beginning of the buffer 0026 * @size: data size in bytes 0027 */ 0028 struct memref { 0029 u32 buf_id; 0030 u32 offset; 0031 u32 size; 0032 }; 0033 0034 struct value { 0035 u32 a; 0036 u32 b; 0037 }; 0038 0039 /* 0040 * Parameters passed to open_session or invoke_command 0041 */ 0042 union tee_op_param { 0043 struct memref mref; 0044 struct value val; 0045 }; 0046 0047 struct tee_operation { 0048 u32 param_types; 0049 union tee_op_param params[TEE_MAX_PARAMS]; 0050 }; 0051 0052 /* Must be same as in GP TEE specification */ 0053 #define TEE_OP_PARAM_TYPE_NONE 0 0054 #define TEE_OP_PARAM_TYPE_VALUE_INPUT 1 0055 #define TEE_OP_PARAM_TYPE_VALUE_OUTPUT 2 0056 #define TEE_OP_PARAM_TYPE_VALUE_INOUT 3 0057 #define TEE_OP_PARAM_TYPE_INVALID 4 0058 #define TEE_OP_PARAM_TYPE_MEMREF_INPUT 5 0059 #define TEE_OP_PARAM_TYPE_MEMREF_OUTPUT 6 0060 #define TEE_OP_PARAM_TYPE_MEMREF_INOUT 7 0061 0062 #define TEE_PARAM_TYPE_GET(t, i) (((t) >> ((i) * 4)) & 0xF) 0063 #define TEE_PARAM_TYPES(t0, t1, t2, t3) \ 0064 ((t0) | ((t1) << 4) | ((t2) << 8) | ((t3) << 12)) 0065 0066 /***************************************************************************** 0067 ** TEE Commands 0068 *****************************************************************************/ 0069 0070 /* 0071 * The shared memory between rich world and secure world may be physically 0072 * non-contiguous. Below structures are meant to describe a shared memory region 0073 * via scatter/gather (sg) list 0074 */ 0075 0076 /** 0077 * struct tee_sg_desc - sg descriptor for a physically contiguous buffer 0078 * @low_addr: [in] bits[31:0] of buffer's physical address. Must be 4KB aligned 0079 * @hi_addr: [in] bits[63:32] of the buffer's physical address 0080 * @size: [in] size in bytes (must be multiple of 4KB) 0081 */ 0082 struct tee_sg_desc { 0083 u32 low_addr; 0084 u32 hi_addr; 0085 u32 size; 0086 }; 0087 0088 /** 0089 * struct tee_sg_list - structure describing a scatter/gather list 0090 * @count: [in] number of sg descriptors 0091 * @size: [in] total size of all buffers in the list. Must be multiple of 4KB 0092 * @buf: [in] list of sg buffer descriptors 0093 */ 0094 #define TEE_MAX_SG_DESC 64 0095 struct tee_sg_list { 0096 u32 count; 0097 u32 size; 0098 struct tee_sg_desc buf[TEE_MAX_SG_DESC]; 0099 }; 0100 0101 /** 0102 * struct tee_cmd_map_shared_mem - command to map shared memory 0103 * @buf_id: [out] return buffer ID value 0104 * @sg_list: [in] list describing memory to be mapped 0105 */ 0106 struct tee_cmd_map_shared_mem { 0107 u32 buf_id; 0108 struct tee_sg_list sg_list; 0109 }; 0110 0111 /** 0112 * struct tee_cmd_unmap_shared_mem - command to unmap shared memory 0113 * @buf_id: [in] buffer ID of memory to be unmapped 0114 */ 0115 struct tee_cmd_unmap_shared_mem { 0116 u32 buf_id; 0117 }; 0118 0119 /** 0120 * struct tee_cmd_load_ta - load Trusted Application (TA) binary into TEE 0121 * @low_addr: [in] bits [31:0] of the physical address of the TA binary 0122 * @hi_addr: [in] bits [63:32] of the physical address of the TA binary 0123 * @size: [in] size of TA binary in bytes 0124 * @ta_handle: [out] return handle of the loaded TA 0125 */ 0126 struct tee_cmd_load_ta { 0127 u32 low_addr; 0128 u32 hi_addr; 0129 u32 size; 0130 u32 ta_handle; 0131 }; 0132 0133 /** 0134 * struct tee_cmd_unload_ta - command to unload TA binary from TEE environment 0135 * @ta_handle: [in] handle of the loaded TA to be unloaded 0136 */ 0137 struct tee_cmd_unload_ta { 0138 u32 ta_handle; 0139 }; 0140 0141 /** 0142 * struct tee_cmd_open_session - command to call TA_OpenSessionEntryPoint in TA 0143 * @ta_handle: [in] handle of the loaded TA 0144 * @session_info: [out] pointer to TA allocated session data 0145 * @op: [in/out] operation parameters 0146 * @return_origin: [out] origin of return code after TEE processing 0147 */ 0148 struct tee_cmd_open_session { 0149 u32 ta_handle; 0150 u32 session_info; 0151 struct tee_operation op; 0152 u32 return_origin; 0153 }; 0154 0155 /** 0156 * struct tee_cmd_close_session - command to call TA_CloseSessionEntryPoint() 0157 * in TA 0158 * @ta_handle: [in] handle of the loaded TA 0159 * @session_info: [in] pointer to TA allocated session data 0160 */ 0161 struct tee_cmd_close_session { 0162 u32 ta_handle; 0163 u32 session_info; 0164 }; 0165 0166 /** 0167 * struct tee_cmd_invoke_cmd - command to call TA_InvokeCommandEntryPoint() in 0168 * TA 0169 * @ta_handle: [in] handle of the loaded TA 0170 * @cmd_id: [in] TA command ID 0171 * @session_info: [in] pointer to TA allocated session data 0172 * @op: [in/out] operation parameters 0173 * @return_origin: [out] origin of return code after TEE processing 0174 */ 0175 struct tee_cmd_invoke_cmd { 0176 u32 ta_handle; 0177 u32 cmd_id; 0178 u32 session_info; 0179 struct tee_operation op; 0180 u32 return_origin; 0181 }; 0182 0183 #endif /*AMDTEE_IF_H*/
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |