xref: /optee_os/core/include/tee/tee_obj.h (revision a1d5c81f8834a9d2c6f4372cce2e59e70e709121)
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3  * Copyright (c) 2014, STMicroelectronics International N.V.
4  */
5 
6 #ifndef TEE_OBJ_H
7 #define TEE_OBJ_H
8 
9 #include <tee_api_types.h>
10 #include <kernel/tee_ta_manager.h>
11 #include <sys/queue.h>
12 
13 #define TEE_USAGE_DEFAULT   0xffffffff
14 
15 struct tee_obj {
16 	TAILQ_ENTRY(tee_obj) link;
17 	TEE_ObjectInfo info;
18 	bool busy;		/* true if used by an operation */
19 	uint32_t have_attrs;	/* bitfield identifying set properties */
20 	void *attr;
21 	size_t ds_pos;
22 	struct tee_pobj *pobj;	/* ptr to persistant object */
23 	struct tee_file_handle *fh;
24 };
25 
26 void tee_obj_add(struct user_ta_ctx *utc, struct tee_obj *o);
27 
28 TEE_Result tee_obj_get(struct user_ta_ctx *utc, uint32_t obj_id,
29 		       struct tee_obj **obj);
30 
31 void tee_obj_close(struct user_ta_ctx *utc, struct tee_obj *o);
32 
33 void tee_obj_close_all(struct user_ta_ctx *utc);
34 
35 TEE_Result tee_obj_verify(struct tee_ta_session *sess, struct tee_obj *o);
36 
37 struct tee_obj *tee_obj_alloc(void);
38 void tee_obj_free(struct tee_obj *o);
39 
40 #endif
41