Merge branch 'master' into prog-loader
[lunaix-os.git] / lunaix-os / includes / lunaix / ld.h
1 #ifndef __LUNAIX_LOADER_H
2 #define __LUNAIX_LOADER_H
3
4 #include <lunaix/elf.h>
5 #include <lunaix/process.h>
6 #include <lunaix/types.h>
7
8 #define LD_STAT_FKUP 0x1U
9
10 #define MAX_VAR_PAGES 8
11 #define DEFAULT_HEAP_PAGES 16
12
13 struct ld_info
14 {
15     struct elf32_ehdr ehdr_out;
16     ptr_t base;
17     ptr_t end;
18     ptr_t mem_sz;
19
20     ptr_t stack_top;
21     ptr_t entry;
22 };
23
24 struct ld_param
25 {
26     struct proc_info* proc;
27     ptr_t vms_mnt;
28
29     struct ld_info info;
30     int status;
31 };
32
33 struct usr_exec_param
34 {
35     int argc;
36     char** argv;
37     int envc;
38     char** envp;
39     struct ld_info info;
40 } PACKED;
41
42 #ifndef __USR_WRAPPER__
43 int
44 elf_load(struct ld_param* ldparam, struct v_file* elfile);
45
46 int
47 exec_load_byname(struct ld_param* param,
48                  const char* filename,
49                  const char** argv,
50                  const char** envp);
51
52 int
53 exec_load(struct ld_param* param,
54           struct v_file* executable,
55           const char** argv,
56           const char** envp);
57
58 void
59 ld_create_param(struct ld_param* param, struct proc_info* proc, ptr_t vms);
60 #endif
61
62 #endif /* __LUNAIX_LOADER_H */