Rev 3169 | Rev 3171 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3169 | Rev 3170 | ||
---|---|---|---|
Line 55... | Line 55... | ||
55 | #include <async.h> |
55 | #include <async.h> |
56 | #include <as.h> |
56 | #include <as.h> |
57 | 57 | ||
58 | #include <elf.h> |
58 | #include <elf.h> |
59 | #include <elf_load.h> |
59 | #include <elf_load.h> |
60 | #include <arch/pcb.h> |
- | |
61 | 60 | ||
62 | /** |
61 | /** |
63 | * Bias used for loading the dynamic linker. This will be soon replaced |
62 | * Bias used for loading the dynamic linker. This will be soon replaced |
64 | * by automatic placement. |
63 | * by automatic placement. |
65 | */ |
64 | */ |
66 | #define RTLD_BIAS 0x80000 |
65 | #define RTLD_BIAS 0x80000 |
67 | 66 | ||
68 | /** Pathname of the file that will be loaded */ |
67 | /** Pathname of the file that will be loaded */ |
69 | static char *pathname = NULL; |
68 | static char *pathname = NULL; |
70 | 69 | ||
- | 70 | /** The Program control block */ |
|
- | 71 | static pcb_t pcb; |
|
- | 72 | ||
71 | /** Receive a call setting pathname of the program to execute. |
73 | /** Receive a call setting pathname of the program to execute. |
72 | * |
74 | * |
73 | * @param rid |
75 | * @param rid |
74 | * @param request |
76 | * @param request |
75 | */ |
77 | */ |
Line 111... | Line 113... | ||
111 | * @return 0 on success, !0 on error. |
113 | * @return 0 on success, !0 on error. |
112 | */ |
114 | */ |
113 | static int iloader_run(ipc_callid_t rid, ipc_call_t *request) |
115 | static int iloader_run(ipc_callid_t rid, ipc_call_t *request) |
114 | { |
116 | { |
115 | int rc; |
117 | int rc; |
116 | pcb_t *pcb; |
- | |
117 | 118 | ||
118 | elf_info_t prog_info; |
119 | elf_info_t prog_info; |
119 | elf_info_t interp_info; |
120 | elf_info_t interp_info; |
120 | 121 | ||
121 | // printf("Load program '%s'\n", pathname); |
122 | // printf("Load program '%s'\n", pathname); |
Line 126... | Line 127... | ||
126 | ipc_answer_0(rid, EINVAL); |
127 | ipc_answer_0(rid, EINVAL); |
127 | return 1; |
128 | return 1; |
128 | } |
129 | } |
129 | 130 | ||
130 | // printf("Create PCB\n"); |
131 | // printf("Create PCB\n"); |
131 | if (elf_create_pcb(&prog_info) < 0) { |
132 | elf_create_pcb(&prog_info, &pcb); |
132 | ipc_answer_0(rid, ENOMEM); |
- | |
133 | return 1; |
- | |
134 | } |
- | |
135 | 133 | ||
136 | if (prog_info.interp == NULL) { |
134 | if (prog_info.interp == NULL) { |
137 | /* Statically linked program */ |
135 | /* Statically linked program */ |
138 | // printf("Run statically linked program\n"); |
136 | // printf("Run statically linked program\n"); |
139 | // printf("entry point: 0x%llx\n", prog_info.entry); |
137 | // printf("entry point: 0x%llx\n", prog_info.entry); |
140 | ipc_answer_0(rid, EOK); |
138 | ipc_answer_0(rid, EOK); |
141 | close_console(); |
139 | close_console(); |
142 | elf_run(&prog_info, __pcb_get()); |
140 | elf_run(&prog_info, &pcb); |
143 | return 0; |
141 | return 0; |
144 | } |
142 | } |
145 | 143 | ||
146 | printf("Load dynamic linker '%s'\n", prog_info.interp); |
144 | printf("Load dynamic linker '%s'\n", prog_info.interp); |
147 | rc = elf_load_file("/rtld.so", RTLD_BIAS, &interp_info); |
145 | rc = elf_load_file("/rtld.so", RTLD_BIAS, &interp_info); |
Line 152... | Line 150... | ||
152 | } |
150 | } |
153 | 151 | ||
154 | /* |
152 | /* |
155 | * Provide dynamic linker with some useful data |
153 | * Provide dynamic linker with some useful data |
156 | */ |
154 | */ |
157 | pcb = (pcb_t *)PCB_ADDRESS; |
- | |
158 | pcb->rtld_dynamic = interp_info.dynamic; |
155 | pcb.rtld_dynamic = interp_info.dynamic; |
159 | pcb->rtld_bias = RTLD_BIAS; |
156 | pcb.rtld_bias = RTLD_BIAS; |
160 | 157 | ||
161 | printf("run dynamic linker\n"); |
158 | printf("run dynamic linker\n"); |
162 | printf("entry point: 0x%llx\n", interp_info.entry); |
159 | printf("entry point: 0x%llx\n", interp_info.entry); |
163 | close_console(); |
160 | close_console(); |
164 | 161 | ||
165 | ipc_answer_0(rid, EOK); |
162 | ipc_answer_0(rid, EOK); |
166 | elf_run(&interp_info, __pcb_get()); |
163 | elf_run(&interp_info, &pcb); |
167 | 164 | ||
168 | /* Not reached(?) */ |
165 | /* Not reached */ |
169 | return 0; |
166 | return 0; |
170 | } |
167 | } |
171 | 168 | ||
172 | /** Handle loader connection. |
169 | /** Handle loader connection. |
173 | * |
170 | * |
Line 225... | Line 222... | ||
225 | 222 | ||
226 | ipc_answer_0(callid, EOK); |
223 | ipc_answer_0(callid, EOK); |
227 | phone_hash = call.in_phone_hash; |
224 | phone_hash = call.in_phone_hash; |
228 | 225 | ||
229 | /* |
226 | /* |
230 | * FIXME: up until now no async calls can be used!!! |
227 | * Up until now async must not be used as it couldn't |
231 | * (Which means e.g. printf() cannot be used) |
228 | * handle incoming requests. (Which means e.g. printf() |
- | 229 | * cannot be used) |
|
232 | */ |
230 | */ |
233 | async_new_connection(phone_hash, 0, NULL, loader_connection); |
231 | async_new_connection(phone_hash, 0, NULL, loader_connection); |
234 | async_manager(); |
232 | async_manager(); |
235 | 233 | ||
236 | /* not reached */ |
234 | /* not reached */ |