Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright (c) 2015-2016, Linaro Limited
0004  */
0005 #ifndef TEE_PRIVATE_H
0006 #define TEE_PRIVATE_H
0007 
0008 #include <linux/cdev.h>
0009 #include <linux/completion.h>
0010 #include <linux/device.h>
0011 #include <linux/kref.h>
0012 #include <linux/mutex.h>
0013 #include <linux/types.h>
0014 
0015 #define TEE_DEVICE_FLAG_REGISTERED  0x1
0016 #define TEE_MAX_DEV_NAME_LEN        32
0017 
0018 /**
0019  * struct tee_device - TEE Device representation
0020  * @name:   name of device
0021  * @desc:   description of device
0022  * @id:     unique id of device
0023  * @flags:  represented by TEE_DEVICE_FLAG_REGISTERED above
0024  * @dev:    embedded basic device structure
0025  * @cdev:   embedded cdev
0026  * @num_users:  number of active users of this device
0027  * @c_no_user:  completion used when unregistering the device
0028  * @mutex:  mutex protecting @num_users and @idr
0029  * @idr:    register of user space shared memory objects allocated or
0030  *      registered on this device
0031  * @pool:   shared memory pool
0032  */
0033 struct tee_device {
0034     char name[TEE_MAX_DEV_NAME_LEN];
0035     const struct tee_desc *desc;
0036     int id;
0037     unsigned int flags;
0038 
0039     struct device dev;
0040     struct cdev cdev;
0041 
0042     size_t num_users;
0043     struct completion c_no_users;
0044     struct mutex mutex; /* protects num_users and idr */
0045 
0046     struct idr idr;
0047     struct tee_shm_pool *pool;
0048 };
0049 
0050 int tee_shm_init(void);
0051 
0052 int tee_shm_get_fd(struct tee_shm *shm);
0053 
0054 bool tee_device_get(struct tee_device *teedev);
0055 void tee_device_put(struct tee_device *teedev);
0056 
0057 void teedev_ctx_get(struct tee_context *ctx);
0058 void teedev_ctx_put(struct tee_context *ctx);
0059 
0060 struct tee_shm *tee_shm_alloc_user_buf(struct tee_context *ctx, size_t size);
0061 struct tee_shm *tee_shm_register_user_buf(struct tee_context *ctx,
0062                       unsigned long addr, size_t length);
0063 
0064 #endif /*TEE_PRIVATE_H*/