1 /* SPDX-License-Identifier: BSD-2-Clause */ 2 /* 3 * Copyright (c) 2014, STMicroelectronics International N.V. 4 */ 5 6 #ifndef __TEE_TEE_POBJ_H 7 #define __TEE_TEE_POBJ_H 8 9 #include <stdint.h> 10 #include <sys/queue.h> 11 #include <tee_api_types.h> 12 #include <tee/tee_fs.h> 13 14 struct tee_pobj { 15 TAILQ_ENTRY(tee_pobj) link; 16 uint32_t refcnt; 17 TEE_UUID uuid; 18 void *obj_id; 19 uint32_t obj_id_len; 20 uint32_t flags; 21 uint32_t obj_info_usage; 22 bool temporary; /* can be changed while creating == true */ 23 bool creating; /* can only be changed with mutex held */ 24 /* Filesystem handling this object */ 25 const struct tee_file_operations *fops; 26 }; 27 28 enum tee_pobj_usage { 29 TEE_POBJ_USAGE_OPEN, 30 TEE_POBJ_USAGE_RENAME, 31 TEE_POBJ_USAGE_CREATE, 32 TEE_POBJ_USAGE_ENUM, 33 }; 34 35 TEE_Result tee_pobj_get(TEE_UUID *uuid, void *obj_id, uint32_t obj_id_len, 36 uint32_t flags, enum tee_pobj_usage usage, 37 const struct tee_file_operations *fops, 38 struct tee_pobj **obj); 39 40 void tee_pobj_create_final(struct tee_pobj *obj); 41 42 TEE_Result tee_pobj_release(struct tee_pobj *obj); 43 44 TEE_Result tee_pobj_rename(struct tee_pobj *obj, void *obj_id, 45 uint32_t obj_id_len); 46 47 /* 48 * Locks and unlocks a mutex intended to protect the obj_info_usage field 49 * in struct tee_pobj. 50 */ 51 void tee_pobj_lock_usage(struct tee_pobj *obj); 52 void tee_pobj_unlock_usage(struct tee_pobj *obj); 53 54 #endif 55