39#ifndef ZEPHYR_INCLUDE_DRIVERS_TEE_H_
40#define ZEPHYR_INCLUDE_DRIVERS_TEE_H_
74#define TEE_UUID_LEN 16
76#define TEE_GEN_CAP_GP BIT(0)
77#define TEE_GEN_CAP_PRIVILEGED BIT(1)
78#define TEE_GEN_CAP_REG_MEM BIT(2)
79#define TEE_GEN_CAP_MEMREF_NULL BIT(3)
81#define TEE_SHM_REGISTER BIT(0)
82#define TEE_SHM_ALLOC BIT(1)
84#define TEE_PARAM_ATTR_TYPE_NONE 0
85#define TEE_PARAM_ATTR_TYPE_VALUE_INPUT 1
86#define TEE_PARAM_ATTR_TYPE_VALUE_OUTPUT 2
87#define TEE_PARAM_ATTR_TYPE_VALUE_INOUT 3
88#define TEE_PARAM_ATTR_TYPE_MEMREF_INPUT 5
89#define TEE_PARAM_ATTR_TYPE_MEMREF_OUTPUT 6
90#define TEE_PARAM_ATTR_TYPE_MEMREF_INOUT 7
91#define TEE_PARAM_ATTR_TYPE_MASK 0xff
92#define TEE_PARAM_ATTR_META 0x100
93#define TEE_PARAM_ATTR_MASK (TEE_PARAM_ATTR_TYPE_MASK | TEE_PARAM_ATTR_META)
108#define TEEC_ORIGIN_API 0x00000001
109#define TEEC_ORIGIN_COMMS 0x00000002
110#define TEEC_ORIGIN_TEE 0x00000003
111#define TEEC_ORIGIN_TRUSTED_APP 0x00000004
145#define TEEC_SUCCESS 0x00000000
146#define TEEC_ERROR_STORAGE_NOT_AVAILABLE 0xF0100003
147#define TEEC_ERROR_GENERIC 0xFFFF0000
148#define TEEC_ERROR_ACCESS_DENIED 0xFFFF0001
149#define TEEC_ERROR_CANCEL 0xFFFF0002
150#define TEEC_ERROR_ACCESS_CONFLICT 0xFFFF0003
151#define TEEC_ERROR_EXCESS_DATA 0xFFFF0004
152#define TEEC_ERROR_BAD_FORMAT 0xFFFF0005
153#define TEEC_ERROR_BAD_PARAMETERS 0xFFFF0006
154#define TEEC_ERROR_BAD_STATE 0xFFFF0007
155#define TEEC_ERROR_ITEM_NOT_FOUND 0xFFFF0008
156#define TEEC_ERROR_NOT_IMPLEMENTED 0xFFFF0009
157#define TEEC_ERROR_NOT_SUPPORTED 0xFFFF000A
158#define TEEC_ERROR_NO_DATA 0xFFFF000B
159#define TEEC_ERROR_OUT_OF_MEMORY 0xFFFF000C
160#define TEEC_ERROR_BUSY 0xFFFF000D
161#define TEEC_ERROR_COMMUNICATION 0xFFFF000E
162#define TEEC_ERROR_SECURITY 0xFFFF000F
163#define TEEC_ERROR_SHORT_BUFFER 0xFFFF0010
164#define TEEC_ERROR_EXTERNAL_CANCEL 0xFFFF0011
165#define TEEC_ERROR_TARGET_DEAD 0xFFFF3024
166#define TEEC_ERROR_STORAGE_NO_SPACE 0xFFFF3041
184#define TEEC_LOGIN_PUBLIC 0x00000000
185#define TEEC_LOGIN_USER 0x00000001
186#define TEEC_LOGIN_GROUP 0x00000002
187#define TEEC_LOGIN_APPLICATION 0x00000004
188#define TEEC_LOGIN_USER_APPLICATION 0x00000005
189#define TEEC_LOGIN_GROUP_APPLICATION 0x00000006
274 unsigned int num_param,
struct tee_param *param,
299 unsigned int num_param,
struct tee_param *param);
387 unsigned int num_param,
struct tee_param *param,
390static inline int z_impl_tee_open_session(
const struct device *dev,
392 unsigned int num_param,
struct tee_param *param,
401 return api->
open_session(dev, arg, num_param, param, session_id);
418static inline int z_impl_tee_close_session(
const struct device *dev,
uint32_t session_id)
444static inline int z_impl_tee_cancel(
const struct device *dev,
uint32_t session_id,
453 return api->
cancel(dev, session_id, cancel_id);
471 unsigned int num_param,
struct tee_param *param);
474 unsigned int num_param,
struct tee_param *param)
482 return api->
invoke_func(dev, arg, num_param, param);
532static inline int z_impl_tee_shm_register(
const struct device *dev,
void *addr,
size_t size,
553static inline int z_impl_tee_shm_unregister(
const struct device *dev,
struct tee_shm *shm)
575static inline int z_impl_tee_shm_alloc(
const struct device *dev,
size_t size,
uint32_t flags,
595static inline int z_impl_tee_shm_free(
const struct device *dev,
struct tee_shm *shm)
615static inline int z_impl_tee_suppl_recv(
const struct device *dev,
uint32_t *func,
616 unsigned int *num_params,
struct tee_param *param)
624 return api->
suppl_recv(dev, func, num_params, param);
643static inline int z_impl_tee_suppl_send(
const struct device *dev,
unsigned int ret,
644 unsigned int num_params,
struct tee_param *param)
652 return api->
suppl_send(dev, ret, num_params, param);
663#include <zephyr/syscalls/tee.h>
#define DEVICE_API_GET(_class, _dev)
Expands to the pointer of a device's API for a given class.
Definition device.h:1449
#define ENOSYS
Function not implemented.
Definition errno.h:83
int tee_shm_register(const struct device *dev, void *addr, size_t size, uint32_t flags, struct tee_shm **shm)
Register shared memory for Trusted Environment.
int tee_suppl_recv(const struct device *dev, uint32_t *func, unsigned int *num_params, struct tee_param *param)
Receive a request for TEE Supplicant.
int(* tee_shm_unregister_t)(const struct device *dev, struct tee_shm *shm)
Callback API to unregister shared memory.
Definition tee.h:314
#define TEE_SHM_REGISTER
Definition tee.h:81
int tee_shm_free(const struct device *dev, struct tee_shm *shm)
Free shared memory region for Trusted Environment.
int tee_cancel(const struct device *dev, uint32_t session_id, uint32_t cancel_id)
Cancel session or invoke function for Trusted Environment.
int(* tee_suppl_send_t)(const struct device *dev, unsigned int ret, unsigned int num_params, struct tee_param *param)
Callback API to send a request for TEE supplicant.
Definition tee.h:331
int tee_shm_alloc(const struct device *dev, size_t size, uint32_t flags, struct tee_shm **shm)
Allocate shared memory region for Trusted Environment.
#define TEE_UUID_LEN
Definition tee.h:74
#define TEE_SHM_ALLOC
Definition tee.h:82
int tee_suppl_send(const struct device *dev, unsigned int ret, unsigned int num_params, struct tee_param *param)
Send a request for TEE Supplicant function.
int(* tee_shm_register_t)(const struct device *dev, struct tee_shm *shm)
Callback API to register shared memory.
Definition tee.h:306
int(* tee_suppl_recv_t)(const struct device *dev, uint32_t *func, unsigned int *num_params, struct tee_param *param)
Callback API to receive a request for TEE supplicant.
Definition tee.h:322
int(* tee_invoke_func_t)(const struct device *dev, struct tee_invoke_func_arg *arg, unsigned int num_param, struct tee_param *param)
Callback API to invoke function to TA.
Definition tee.h:298
int(* tee_close_session_t)(const struct device *dev, uint32_t session_id)
Callback API to close session to TA.
Definition tee.h:282
int(* tee_get_version_t)(const struct device *dev, struct tee_version_info *info)
Callback API to get current tee version.
Definition tee.h:265
int tee_close_session(const struct device *dev, uint32_t session_id)
Close session for Trusted Environment.
int(* tee_cancel_t)(const struct device *dev, uint32_t session_id, uint32_t cancel_id)
Callback API to cancel open session of invoke function to TA.
Definition tee.h:290
int tee_open_session(const struct device *dev, struct tee_open_session_arg *arg, unsigned int num_param, struct tee_param *param, uint32_t *session_id)
Open session for Trusted Environment.
int tee_get_version(const struct device *dev, struct tee_version_info *info)
Get the current TEE version info.
int tee_shm_unregister(const struct device *dev, struct tee_shm *shm)
Unregister shared memory for Trusted Environment.
int tee_add_shm(const struct device *dev, void *addr, size_t align, size_t size, uint32_t flags, struct tee_shm **shmp)
Helper function to allocate and register shared memory.
int tee_invoke_func(const struct device *dev, struct tee_invoke_func_arg *arg, unsigned int num_param, struct tee_param *param)
Invoke function for Trusted Environment Application.
int tee_rm_shm(const struct device *dev, struct tee_shm *shm)
Helper function to remove and unregister shared memory.
int(* tee_open_session_t)(const struct device *dev, struct tee_open_session_arg *arg, unsigned int num_param, struct tee_param *param, uint32_t *session_id)
Callback API to open session to Trusted Application.
Definition tee.h:273
#define NULL
Definition iar_missing_defs.h:20
flags
Definition parser.h:97
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT64_TYPE__ uint64_t
Definition stdint.h:91
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
Runtime device structure (in ROM) per driver instance.
Definition device.h:513
tee_cancel_t cancel
Definition tee.h:338
tee_shm_register_t shm_register
Definition tee.h:340
tee_suppl_recv_t suppl_recv
Definition tee.h:342
tee_close_session_t close_session
Definition tee.h:337
tee_invoke_func_t invoke_func
Definition tee.h:339
tee_suppl_send_t suppl_send
Definition tee.h:343
tee_shm_unregister_t shm_unregister
Definition tee.h:341
tee_get_version_t get_version
Definition tee.h:335
tee_open_session_t open_session
Definition tee.h:336
Invokes a function in a Trusted Application.
Definition tee.h:241
uint32_t func
[in] Trusted Application function, specific to the TA
Definition tee.h:242
uint32_t cancel_id
[in] cancellation id, a unique value to identify this request
Definition tee.h:244
uint32_t ret_origin
[out] origin of the return value
Definition tee.h:246
uint32_t session
[in] session id
Definition tee.h:243
uint32_t ret
[out] return value
Definition tee.h:245
Open session argument
Definition tee.h:207
uint32_t clnt_login
login class of client, TEE_IOCTL_LOGIN_* above
Definition tee.h:210
uint32_t ret
[out] return value
Definition tee.h:213
uint32_t session
[out] session id
Definition tee.h:212
uint32_t ret_origin
[out] origin of the return value
Definition tee.h:214
uint8_t uuid[16]
[in] UUID of the Trusted Application
Definition tee.h:208
uint32_t cancel_id
[in] cancellation id, a unique value to identify this request
Definition tee.h:211
uint8_t clnt_uuid[16]
[in] UUID of client
Definition tee.h:209
Tee parameter.
Definition tee.h:231
uint64_t b
if a memref, size of the buffer, else a value parameter
Definition tee.h:234
uint64_t c
if a memref, shared memory identifier, else a value parameter
Definition tee.h:235
uint64_t attr
attributes
Definition tee.h:232
uint64_t a
if a memref, offset into the shared memory object, else a value
Definition tee.h:233
Tee shared memory structure.
Definition tee.h:252
uint64_t size
[out] shared buffer size
Definition tee.h:255
void * addr
[out] shared buffer pointer
Definition tee.h:254
const struct device * dev
[out] pointer to the device driver structure
Definition tee.h:253
uint32_t flags
[out] shared buffer flags
Definition tee.h:256
TEE version.
Definition tee.h:198
uint32_t gen_caps
Generic capabilities, defined by TEE_GEN_CAPS_* above.
Definition tee.h:201
uint32_t impl_caps
[out] implementation specific capabilities
Definition tee.h:200
uint32_t impl_id
[out] TEE implementation id
Definition tee.h:199