• 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 #ifndef SRVMGR_H
13 #define SRVMGR_H
14 
15 #ifdef CHCORE_OH_TEE
16 #include <spawn_ext.h>
17 #endif /* CHCORE_OH_TEE */
18 #include <chcore/ipc.h>
19 #include <chcore-internal/procmgr_defs.h>
20 
21 struct new_process_args {
22     int envp_argc;
23     char **envp_argv;
24     unsigned long stack_size;
25 #ifdef CHCORE_OH_TEE
26     spawn_uuid_t puuid;
27     unsigned long heap_size;
28 #endif /* CHCORE_OH_TEE */
29 };
30 
31 /* fsm_server_cap in current process; can be copied to others */
32 extern cap_t fsm_server_cap;
33 /* lwip_server_cap in current process; can be copied to others */
34 extern cap_t lwip_server_cap;
35 /* in srvmgr.c */
36 extern cap_t __procmgr_server_cap;
37 
38 extern char __binary_fsm_elf_start;
39 extern char __binary_fsm_elf_size;
40 
41 extern char __binary_tmpfs_elf_start;
42 extern char __binary_tmpfs_elf_size;
43 
44 struct proc_node *procmgr_launch_process(int input_argc, char **input_argv,
45                                          char *name, bool if_has_parent,
46                                          badge_t parent_badge,
47                                          struct new_process_args *np_args,
48                                          int proc_type);
49 struct proc_node *procmgr_launch_basic_server(int input_argc, char **input_argv,
50                                               char *name, bool if_has_parent,
51                                               badge_t parent_badge);
52 
53 /*
54  * There three kinds of servers in ChCore for now.
55  *  1. servers booted before procmgr like tmpfs, fsm and lwip
56  *  2. servers which will be booted once procmgr is up like usb_devmgr
57  *  3. servers which will be booted lazily like shmmgr, hdmi, sd4, etc.
58  *
59  * boot_secondary_servers() is in charge of booting the second kind of servers.
60  */
61 void set_tmpfs_cap(cap_t cap);
62 void boot_secondary_servers(void);
63 
64 /* Initialize sys_servers and sys_server_locks */
65 void init_srvmgr(void);
66 void handle_get_server_cap(ipc_msg_t *ipc_msg, struct proc_request *pr);
67 
68 void start_daemon_service(void);
69 
70 #endif /* SRVMGR_H */
71