1 /* 2 * Copyright (C) 2022 Huawei Technologies Co., Ltd. 3 * Licensed under the Mulan PSL v2. 4 * You can use this software according to the terms and conditions of the Mulan PSL v2. 5 * You may obtain a copy of Mulan PSL v2 at: 6 * http://license.coscl.org.cn/MulanPSL2 7 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR 8 * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR 9 * PURPOSE. 10 * See the Mulan PSL v2 for more details. 11 */ 12 #ifndef DRVMGR_SRC_DRV_FD_OPS_H 13 #define DRVMGR_SRC_DRV_FD_OPS_H 14 15 #include <stdint.h> 16 #include <pthread.h> 17 #include "drv_dispatch.h" 18 #include "drvcall_dyn_conf_mgr.h" 19 20 #define TASK_FD_COUNT_MAX 32U 21 22 int32_t drv_mutex_lock(pthread_mutex_t *mtx); 23 int32_t drv_mutex_init(pthread_mutex_t *mtx); 24 struct fd_node *alloc_and_init_fd_node(void); 25 int32_t add_fd_to_drvcall_node(struct fd_node *data, struct task_node *node); 26 int32_t get_fd_count(struct task_node *node); 27 void put_fd_count(struct task_node *node); 28 struct fd_node *close_get_fd_node_with_lock(struct task_node *node, int64_t fd); 29 int32_t del_fd_to_drvcall_node(struct fd_node **fnode, struct task_node *node); 30 31 #ifdef TEE_SUPPORT_DYN_CONF_DEBUG 32 void dump_drvcall_fd(struct task_node *node); 33 #endif 34 35 uint32_t exception_close_handle(struct task_node *node); 36 #endif 37