1 /* 2 * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) 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 CHANMGR_H 13 #define CHANMGR_H 14 15 #include <chcore/ipc.h> 16 #include <chcore-internal/chanmgr_defs.h> 17 #include <pthread.h> 18 #include <chcore/container/hashtable.h> 19 20 #define GTASK_PID (4) 21 #define GTASK_TID (0xa) 22 #define GTASK_TASKID (pid_to_taskid(GTASK_TID, GTASK_PID)) 23 24 struct chanmgr { 25 struct htable name2chan; 26 struct htable cid2chan; 27 struct htable badge2chan; 28 struct htable name2taskid; 29 struct htable badge2tamgr; 30 pthread_mutex_t lock; 31 }; 32 33 int chanmgr_init(void); 34 void chanmgr_deinit(void); 35 36 /* 37 * chanmgr ipc interfaces for channel registering, indexing, deregistering 38 */ 39 void chanmgr_handle_create_channel(ipc_msg_t *ipc_msg, badge_t badge, int pid, 40 int tid); 41 void chanmgr_handle_remove_channel(ipc_msg_t *ipc_msg, badge_t badge, int pid, 42 int tid); 43 void chanmgr_handle_register_tamgr(ipc_msg_t *ipc_msg, badge_t badge, int pid, 44 int tid); 45 void chanmgr_handle_hunt_by_name(ipc_msg_t *ipc_msg, int pid, int tid); 46 void chanmgr_handle_get_ch_from_path(ipc_msg_t *ipc_msg, int pid, int tid); 47 void chanmgr_handle_get_ch_from_taskid(ipc_msg_t *ipc_msg, int pid, int tid); 48 49 /* 50 * Destructor called when client cap_group exiting. Destructor will free 51 * corresponding channel records. 52 */ 53 void chanmgr_destructor(badge_t client_badge); 54 55 #endif /* CHANMGR_H */