123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308 |
- #ifndef __TEE_DRV_H
- #define __TEE_DRV_H
- #include <linux/types.h>
- #include <linux/idr.h>
- #include <linux/list.h>
- #include <linux/tee.h>
- #define TEE_SHM_MAPPED BIT(0)
- #define TEE_SHM_DMA_BUF BIT(1)
- #define TEE_SHM_EXT_DMA_BUF BIT(2)
- struct tee_device;
- struct tee_shm;
- struct tee_shm_pool;
- struct tee_context {
- struct tee_device *teedev;
- struct list_head list_shm;
- void *data;
- };
- struct tee_param_memref {
- size_t shm_offs;
- size_t size;
- struct tee_shm *shm;
- };
- struct tee_param_value {
- u64 a;
- u64 b;
- u64 c;
- };
- struct tee_param {
- u64 attr;
- union {
- struct tee_param_memref memref;
- struct tee_param_value value;
- } u;
- };
- struct tee_driver_ops {
- void (*get_version)(struct tee_device *teedev,
- struct tee_ioctl_version_data *vers);
- int (*open)(struct tee_context *ctx);
- void (*release)(struct tee_context *ctx);
- int (*open_session)(struct tee_context *ctx,
- struct tee_ioctl_open_session_arg *arg,
- struct tee_param *param);
- int (*close_session)(struct tee_context *ctx, u32 session);
- int (*invoke_func)(struct tee_context *ctx,
- struct tee_ioctl_invoke_arg *arg,
- struct tee_param *param);
- int (*cancel_req)(struct tee_context *ctx, u32 cancel_id, u32 session);
- int (*supp_recv)(struct tee_context *ctx, u32 *func, u32 *num_params,
- struct tee_param *param);
- int (*supp_send)(struct tee_context *ctx, u32 ret, u32 num_params,
- struct tee_param *param);
- };
- #define TEE_DESC_PRIVILEGED 0x1
- struct tee_desc {
- const char *name;
- const struct tee_driver_ops *ops;
- struct module *owner;
- u32 flags;
- };
- struct tee_device *tee_device_alloc(const struct tee_desc *teedesc,
- struct device *dev,
- struct tee_shm_pool *pool,
- void *driver_data);
- int tee_device_register(struct tee_device *teedev);
- void tee_device_unregister(struct tee_device *teedev);
- struct tee_shm_pool_mem_info {
- unsigned long vaddr;
- phys_addr_t paddr;
- size_t size;
- };
- struct tee_shm_pool *
- tee_shm_pool_alloc_res_mem(struct tee_shm_pool_mem_info *priv_info,
- struct tee_shm_pool_mem_info *dmabuf_info);
- void tee_shm_pool_free(struct tee_shm_pool *pool);
- void *tee_get_drvdata(struct tee_device *teedev);
- struct tee_shm *tee_shm_alloc(struct tee_context *ctx, size_t size, u32 flags);
- struct tee_shm *tee_shm_register_fd(struct tee_context *ctx, int fd);
- void tee_shm_free(struct tee_shm *shm);
- void tee_shm_put(struct tee_shm *shm);
- int tee_shm_va2pa(struct tee_shm *shm, void *va, phys_addr_t *pa);
- int tee_shm_pa2va(struct tee_shm *shm, phys_addr_t pa, void **va);
- void *tee_shm_get_va(struct tee_shm *shm, size_t offs);
- int tee_shm_get_pa(struct tee_shm *shm, size_t offs, phys_addr_t *pa);
- int tee_shm_get_id(struct tee_shm *shm);
- struct tee_shm *tee_shm_get_from_id(struct tee_context *ctx, int id);
- struct tee_context *tee_client_open_context(struct tee_context *start,
- int (*match)(struct tee_ioctl_version_data *,
- const void *),
- const void *data, struct tee_ioctl_version_data *vers);
- void tee_client_close_context(struct tee_context *ctx);
- void tee_client_get_version(struct tee_context *ctx,
- struct tee_ioctl_version_data *vers);
- int tee_client_open_session(struct tee_context *ctx,
- struct tee_ioctl_open_session_arg *arg,
- struct tee_param *param);
- int tee_client_close_session(struct tee_context *ctx, u32 session);
- int tee_client_invoke_func(struct tee_context *ctx,
- struct tee_ioctl_invoke_arg *arg,
- struct tee_param *param);
- #endif
|