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