Blame view

drivers/tee/tee_private.h 1.76 KB
9c92ab619   Thomas Gleixner   treewide: Replace...
1
  /* SPDX-License-Identifier: GPL-2.0-only */
967c9cca2   Jens Wiklander   tee: generic TEE ...
2
3
  /*
   * Copyright (c) 2015-2016, Linaro Limited
967c9cca2   Jens Wiklander   tee: generic TEE ...
4
5
6
7
8
9
10
11
12
13
   */
  #ifndef TEE_PRIVATE_H
  #define TEE_PRIVATE_H
  
  #include <linux/cdev.h>
  #include <linux/completion.h>
  #include <linux/device.h>
  #include <linux/kref.h>
  #include <linux/mutex.h>
  #include <linux/types.h>
967c9cca2   Jens Wiklander   tee: generic TEE ...
14
15
16
17
18
  /**
   * struct tee_shm_pool - shared memory pool
   * @private_mgr:	pool manager for shared memory only between kernel
   *			and secure world
   * @dma_buf_mgr:	pool manager for shared memory exported to user space
967c9cca2   Jens Wiklander   tee: generic TEE ...
19
20
   */
  struct tee_shm_pool {
e2aca5d89   Jens Wiklander   tee: flexible sha...
21
22
  	struct tee_shm_pool_mgr *private_mgr;
  	struct tee_shm_pool_mgr *dma_buf_mgr;
967c9cca2   Jens Wiklander   tee: generic TEE ...
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
  };
  
  #define TEE_DEVICE_FLAG_REGISTERED	0x1
  #define TEE_MAX_DEV_NAME_LEN		32
  
  /**
   * struct tee_device - TEE Device representation
   * @name:	name of device
   * @desc:	description of device
   * @id:		unique id of device
   * @flags:	represented by TEE_DEVICE_FLAG_REGISTERED above
   * @dev:	embedded basic device structure
   * @cdev:	embedded cdev
   * @num_users:	number of active users of this device
   * @c_no_user:	completion used when unregistering the device
   * @mutex:	mutex protecting @num_users and @idr
   * @idr:	register of shared memory object allocated on this device
   * @pool:	shared memory pool
   */
  struct tee_device {
  	char name[TEE_MAX_DEV_NAME_LEN];
  	const struct tee_desc *desc;
  	int id;
  	unsigned int flags;
  
  	struct device dev;
  	struct cdev cdev;
  
  	size_t num_users;
  	struct completion c_no_users;
  	struct mutex mutex;	/* protects num_users and idr */
  
  	struct idr idr;
  	struct tee_shm_pool *pool;
  };
  
  int tee_shm_init(void);
  
  int tee_shm_get_fd(struct tee_shm *shm);
  
  bool tee_device_get(struct tee_device *teedev);
  void tee_device_put(struct tee_device *teedev);
217e0250c   Volodymyr Babchuk   tee: use referenc...
65
66
  void teedev_ctx_get(struct tee_context *ctx);
  void teedev_ctx_put(struct tee_context *ctx);
967c9cca2   Jens Wiklander   tee: generic TEE ...
67
  #endif /*TEE_PRIVATE_H*/