1 /* SPDX-License-Identifier: MIT */
4 * Copyright 2019 Advanced Micro Devices, Inc.
8 * This file has definitions related to Host and AMD-TEE Trusted OS interface.
9 * These definitions must match the definitions on the TEE side.
15 #include <linux/types.h>
17 /*****************************************************************************
19 ******************************************************************************/
20 #define TEE_MAX_PARAMS 4
23 * struct memref - memory reference structure
24 * @buf_id: buffer ID of the buffer mapped by TEE_CMD_ID_MAP_SHARED_MEM
25 * @offset: offset in bytes from beginning of the buffer
26 * @size: data size in bytes
40 * Parameters passed to open_session or invoke_command
47 struct tee_operation
{
49 union tee_op_param params
[TEE_MAX_PARAMS
];
52 /* Must be same as in GP TEE specification */
53 #define TEE_OP_PARAM_TYPE_NONE 0
54 #define TEE_OP_PARAM_TYPE_VALUE_INPUT 1
55 #define TEE_OP_PARAM_TYPE_VALUE_OUTPUT 2
56 #define TEE_OP_PARAM_TYPE_VALUE_INOUT 3
57 #define TEE_OP_PARAM_TYPE_INVALID 4
58 #define TEE_OP_PARAM_TYPE_MEMREF_INPUT 5
59 #define TEE_OP_PARAM_TYPE_MEMREF_OUTPUT 6
60 #define TEE_OP_PARAM_TYPE_MEMREF_INOUT 7
62 #define TEE_PARAM_TYPE_GET(t, i) (((t) >> ((i) * 4)) & 0xF)
63 #define TEE_PARAM_TYPES(t0, t1, t2, t3) \
64 ((t0) | ((t1) << 4) | ((t2) << 8) | ((t3) << 12))
66 /*****************************************************************************
68 *****************************************************************************/
71 * The shared memory between rich world and secure world may be physically
72 * non-contiguous. Below structures are meant to describe a shared memory region
73 * via scatter/gather (sg) list
77 * struct tee_sg_desc - sg descriptor for a physically contiguous buffer
78 * @low_addr: [in] bits[31:0] of buffer's physical address. Must be 4KB aligned
79 * @hi_addr: [in] bits[63:32] of the buffer's physical address
80 * @size: [in] size in bytes (must be multiple of 4KB)
89 * struct tee_sg_list - structure describing a scatter/gather list
90 * @count: [in] number of sg descriptors
91 * @size: [in] total size of all buffers in the list. Must be multiple of 4KB
92 * @buf: [in] list of sg buffer descriptors
94 #define TEE_MAX_SG_DESC 64
98 struct tee_sg_desc buf
[TEE_MAX_SG_DESC
];
102 * struct tee_cmd_map_shared_mem - command to map shared memory
103 * @buf_id: [out] return buffer ID value
104 * @sg_list: [in] list describing memory to be mapped
106 struct tee_cmd_map_shared_mem
{
108 struct tee_sg_list sg_list
;
112 * struct tee_cmd_unmap_shared_mem - command to unmap shared memory
113 * @buf_id: [in] buffer ID of memory to be unmapped
115 struct tee_cmd_unmap_shared_mem
{
120 * struct tee_cmd_load_ta - load Trusted Application (TA) binary into TEE
121 * @low_addr: [in] bits [31:0] of the physical address of the TA binary
122 * @hi_addr: [in] bits [63:32] of the physical address of the TA binary
123 * @size: [in] size of TA binary in bytes
124 * @ta_handle: [out] return handle of the loaded TA
126 struct tee_cmd_load_ta
{
134 * struct tee_cmd_unload_ta - command to unload TA binary from TEE environment
135 * @ta_handle: [in] handle of the loaded TA to be unloaded
137 struct tee_cmd_unload_ta
{
142 * struct tee_cmd_open_session - command to call TA_OpenSessionEntryPoint in TA
143 * @ta_handle: [in] handle of the loaded TA
144 * @session_info: [out] pointer to TA allocated session data
145 * @op: [in/out] operation parameters
146 * @return_origin: [out] origin of return code after TEE processing
148 struct tee_cmd_open_session
{
151 struct tee_operation op
;
156 * struct tee_cmd_close_session - command to call TA_CloseSessionEntryPoint()
158 * @ta_handle: [in] handle of the loaded TA
159 * @session_info: [in] pointer to TA allocated session data
161 struct tee_cmd_close_session
{
167 * struct tee_cmd_invoke_cmd - command to call TA_InvokeCommandEntryPoint() in
169 * @ta_handle: [in] handle of the loaded TA
170 * @cmd_id: [in] TA command ID
171 * @session_info: [in] pointer to TA allocated session data
172 * @op: [in/out] operation parameters
173 * @return_origin: [out] origin of return code after TEE processing
175 struct tee_cmd_invoke_cmd
{
179 struct tee_operation op
;
183 #endif /*AMDTEE_IF_H*/