rewrite the device subsystem interfaces (#48)
[lunaix-os.git] / lunaix-os / includes / lunaix / exec.h
1 #ifndef __LUNAIX_EXEC_H
2 #define __LUNAIX_EXEC_H
3
4 #include <lunaix/fs.h>
5 #include <lunaix/process.h>
6 #include <lunaix/types.h>
7
8 #define MAX_PARAM_LEN    1024
9 #define MAX_PARAM_SIZE   4096
10
11 #define MAX_VAR_PAGES 8
12 #define DEFAULT_HEAP_PAGES 16
13
14 struct load_context
15 {
16     struct exec_host* container;
17     ptr_t base;
18     ptr_t end;
19     ptr_t mem_sz;
20
21     ptr_t entry;
22 };
23
24 struct exec_arrptr
25 {
26     unsigned int len;
27     unsigned int size;
28     ptr_t raw;
29     ptr_t copied;
30 };
31
32
33 struct exec_host
34 {
35     struct proc_info* proc;
36     ptr_t vms_mnt;
37
38     struct load_context exe;
39
40     struct exec_arrptr argv;
41     struct exec_arrptr envp;
42
43     ptr_t stack_top;
44
45     int status;
46 };
47
48 struct uexec_param
49 {
50     int argc;
51     char** argv;
52     int envc;
53     char** envp;
54 } compact;
55
56 int
57 exec_arch_prepare_entry(struct thread* thread, struct exec_host* container);
58
59 int
60 exec_load_byname(struct exec_host* container, const char* filename);
61
62 int
63 exec_load(struct exec_host* container, struct v_file* executable);
64
65 int
66 exec_kexecve(const char* filename, const char* argv[], const char* envp[]);
67
68 void
69 exec_init_container(struct exec_host* param,
70                     struct thread* thread,
71                     ptr_t vms,
72                     const char** argv,
73                     const char** envp);
74
75 #endif /* __LUNAIX_LOADER_H */