tee_private.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2015-2016, Linaro Limited
  4. */
  5. #ifndef TEE_PRIVATE_H
  6. #define TEE_PRIVATE_H
  7. #include <linux/cdev.h>
  8. #include <linux/completion.h>
  9. #include <linux/device.h>
  10. #include <linux/kref.h>
  11. #include <linux/mutex.h>
  12. #include <linux/types.h>
  13. #define TEE_DEVICE_FLAG_REGISTERED 0x1
  14. #define TEE_MAX_DEV_NAME_LEN 32
  15. /**
  16. * struct tee_device - TEE Device representation
  17. * @name: name of device
  18. * @desc: description of device
  19. * @id: unique id of device
  20. * @flags: represented by TEE_DEVICE_FLAG_REGISTERED above
  21. * @dev: embedded basic device structure
  22. * @cdev: embedded cdev
  23. * @num_users: number of active users of this device
  24. * @c_no_user: completion used when unregistering the device
  25. * @mutex: mutex protecting @num_users and @idr
  26. * @idr: register of user space shared memory objects allocated or
  27. * registered on this device
  28. * @pool: shared memory pool
  29. */
  30. struct tee_device {
  31. char name[TEE_MAX_DEV_NAME_LEN];
  32. const struct tee_desc *desc;
  33. int id;
  34. unsigned int flags;
  35. struct device dev;
  36. struct cdev cdev;
  37. size_t num_users;
  38. struct completion c_no_users;
  39. struct mutex mutex; /* protects num_users and idr */
  40. struct idr idr;
  41. struct tee_shm_pool *pool;
  42. };
  43. int tee_shm_init(void);
  44. int tee_shm_get_fd(struct tee_shm *shm);
  45. bool tee_device_get(struct tee_device *teedev);
  46. void tee_device_put(struct tee_device *teedev);
  47. void teedev_ctx_get(struct tee_context *ctx);
  48. void teedev_ctx_put(struct tee_context *ctx);
  49. struct tee_shm *tee_shm_alloc_user_buf(struct tee_context *ctx, size_t size);
  50. struct tee_shm *tee_shm_register_user_buf(struct tee_context *ctx,
  51. unsigned long addr, size_t length);
  52. #endif /*TEE_PRIVATE_H*/