Rev 3004 | Rev 3148 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3004 | Rev 3101 | ||
---|---|---|---|
Line 30... | Line 30... | ||
30 | * @brief Loads and runs programs from VFS. |
30 | * @brief Loads and runs programs from VFS. |
31 | * @{ |
31 | * @{ |
32 | */ |
32 | */ |
33 | /** |
33 | /** |
34 | * @file |
34 | * @file |
- | 35 | * @brief Loads and runs programs from VFS. |
|
- | 36 | * |
|
- | 37 | * The program loader is a special init binary. Its image is used |
|
- | 38 | * to create a new task upon a @c task_spawn syscall. The syscall |
|
- | 39 | * returns the id of a phone connected to the newly created task. |
|
- | 40 | * |
|
- | 41 | * The caller uses this phone to send the pathname and various other |
|
- | 42 | * information to the loader. This is normally done by the C library |
|
- | 43 | * and completely hidden from applications. |
|
35 | */ |
44 | */ |
36 | 45 | ||
37 | #include <stdio.h> |
46 | #include <stdio.h> |
38 | #include <stdlib.h> |
47 | #include <stdlib.h> |
39 | #include <unistd.h> |
48 | #include <unistd.h> |
Line 45... | Line 54... | ||
45 | 54 | ||
46 | #include <elf.h> |
55 | #include <elf.h> |
47 | #include <elf_load.h> |
56 | #include <elf_load.h> |
48 | #include <pcb.h> |
57 | #include <pcb.h> |
49 | 58 | ||
- | 59 | /** |
|
- | 60 | * Bias used for loading the dynamic linker. This will be soon replaced |
|
- | 61 | * by automatic placement. |
|
- | 62 | */ |
|
50 | #define RTLD_BIAS 0x80000 |
63 | #define RTLD_BIAS 0x80000 |
51 | 64 | ||
- | 65 | /** Pathname of the file that will be loaded */ |
|
52 | static char *pathname = NULL; |
66 | static char *pathname = NULL; |
53 | 67 | ||
- | 68 | /** Receive a call setting pathname of the program to execute. |
|
- | 69 | * |
|
- | 70 | * @param rid |
|
- | 71 | * @param request |
|
- | 72 | */ |
|
54 | void iloader_set_pathname(ipc_callid_t rid, ipc_call_t *request) |
73 | void iloader_set_pathname(ipc_callid_t rid, ipc_call_t *request) |
55 | { |
74 | { |
56 | // ipc_callid_t callid; |
75 | // ipc_callid_t callid; |
57 | size_t len; |
76 | size_t len; |
58 | char *name_buf; |
77 | char *name_buf; |
Line 84... | Line 103... | ||
84 | } |
103 | } |
85 | 104 | ||
86 | pathname = name_buf; |
105 | pathname = name_buf; |
87 | } |
106 | } |
88 | 107 | ||
- | 108 | /** Load and run the previously selected program. |
|
- | 109 | * |
|
- | 110 | * @param rid |
|
- | 111 | * @param request |
|
- | 112 | * @return 0 on success, !0 on error. |
|
- | 113 | */ |
|
89 | int iloader_run(ipc_callid_t rid, ipc_call_t *request) |
114 | int iloader_run(ipc_callid_t rid, ipc_call_t *request) |
90 | { |
115 | { |
91 | int rc; |
116 | int rc; |
92 | pcb_t *pcb; |
117 | pcb_t *pcb; |
93 | 118 | ||
Line 130... | Line 155... | ||
130 | elf_run(&interp_info); |
155 | elf_run(&interp_info); |
131 | 156 | ||
132 | return 0; |
157 | return 0; |
133 | } |
158 | } |
134 | 159 | ||
- | 160 | /** Program loader main function. |
|
- | 161 | * |
|
- | 162 | * Receive and carry out commands (of which the last one should be |
|
- | 163 | * to execute the loaded program). |
|
- | 164 | */ |
|
135 | int main(int argc, char *argv[]) |
165 | int main(int argc, char *argv[]) |
136 | { |
166 | { |
137 | ipc_callid_t callid; |
167 | ipc_callid_t callid; |
138 | ipc_call_t call; |
168 | ipc_call_t call; |
139 | int retval; |
169 | int retval; |