• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include <chcore/ipc.h>
13 #include <chcore/syscall.h>
14 #include <chcore-internal/chanmgr_defs.h>
15 #include <errno.h>
16 #include <chanmgr.h>
17 
chanmgr_dispatch(ipc_msg_t * ipc_msg,badge_t client_badge,int pid,int tid)18 void chanmgr_dispatch(ipc_msg_t *ipc_msg, badge_t client_badge, int pid,
19                       int tid)
20 {
21     struct chan_request *req;
22 
23     req = (struct chan_request *)ipc_get_msg_data(ipc_msg);
24 
25     switch (req->req) {
26     case CHAN_REQ_CREATE_CHANNEL:
27         chanmgr_handle_create_channel(ipc_msg, client_badge, pid, tid);
28         break;
29     case CHAN_REQ_REMOVE_CHANNEL:
30         chanmgr_handle_remove_channel(ipc_msg, client_badge, pid, tid);
31         break;
32     case CHAN_REQ_REGISTER_TAMGR:
33         chanmgr_handle_register_tamgr(ipc_msg, client_badge, pid, tid);
34         break;
35     case CHAN_REQ_HUNT_BY_NAME:
36         chanmgr_handle_hunt_by_name(ipc_msg, pid, tid);
37         break;
38     case CHAN_REQ_GET_CH_FROM_PATH:
39         chanmgr_handle_get_ch_from_path(ipc_msg, pid, tid);
40         break;
41     case CHAN_REQ_GET_CH_FROM_TASKID:
42         chanmgr_handle_get_ch_from_taskid(ipc_msg, pid, tid);
43         break;
44     default:
45         ipc_return(ipc_msg, -EBADRQC);
46         break;
47     }
48 }
49 
main(void)50 int main(void)
51 {
52     int ret;
53 
54     chanmgr_init();
55 
56     ret = ipc_register_server_with_destructor(
57         chanmgr_dispatch, DEFAULT_CLIENT_REGISTER_HANDLER, chanmgr_destructor);
58     printf("[chanmgr] register server value = %d\n", ret);
59 
60     usys_exit(0);
61 }
62