Changeset 4470e26 in mainline for uspace/srv/loader/main.c
- Timestamp:
- 2008-09-24T10:57:21Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0993087
- Parents:
- 45454e9b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/loader/main.c
r45454e9b r4470e26 47 47 #include <stdlib.h> 48 48 #include <unistd.h> 49 #include <bool.h> 49 50 #include <fcntl.h> 50 51 #include <sys/types.h> … … 78 79 static char *arg_buf = NULL; 79 80 80 static int loader_get_taskid(ipc_callid_t rid, ipc_call_t *request) 81 static elf_info_t prog_info; 82 static elf_info_t interp_info; 83 84 static bool is_dyn_linked; 85 86 87 static void loader_get_taskid(ipc_callid_t rid, ipc_call_t *request) 81 88 { 82 89 ipc_callid_t callid; … … 213 220 } 214 221 215 216 /** Load and run the previously selected program. 222 /** Load the previously selected program. 217 223 * 218 224 * @param rid … … 220 226 * @return 0 on success, !0 on error. 221 227 */ 222 static int loader_ run(ipc_callid_t rid, ipc_call_t *request)228 static int loader_load(ipc_callid_t rid, ipc_call_t *request) 223 229 { 224 230 int rc; 225 226 elf_info_t prog_info;227 elf_info_t interp_info;228 231 229 232 // printf("Load program '%s'\n", pathname); … … 246 249 // printf("Run statically linked program\n"); 247 250 // printf("entry point: 0x%llx\n", prog_info.entry); 251 is_dyn_linked = false; 248 252 ipc_answer_0(rid, EOK); 249 close_console();250 elf_run(&prog_info, &pcb);251 253 return 0; 252 254 } … … 266 268 pcb.rtld_bias = RTLD_BIAS; 267 269 268 printf("run dynamic linker\n"); 269 printf("entry point: 0x%llx\n", interp_info.entry); 270 close_console(); 271 270 is_dyn_linked = true; 272 271 ipc_answer_0(rid, EOK); 273 elf_run(&interp_info, &pcb); 272 273 return 0; 274 } 275 276 277 /** Run the previously loaded program. 278 * 279 * @param rid 280 * @param request 281 * @return 0 on success, !0 on error. 282 */ 283 static void loader_run(ipc_callid_t rid, ipc_call_t *request) 284 { 285 if (is_dyn_linked == true) { 286 /* Dynamically linked program */ 287 printf("run dynamic linker\n"); 288 printf("entry point: 0x%llx\n", interp_info.entry); 289 close_console(); 290 291 ipc_answer_0(rid, EOK); 292 elf_run(&interp_info, &pcb); 293 294 } else { 295 /* Statically linked program */ 296 close_console(); 297 ipc_answer_0(rid, EOK); 298 elf_run(&prog_info, &pcb); 299 } 274 300 275 301 /* Not reached */ 276 return 0;277 302 } 278 303 … … 293 318 while (1) { 294 319 callid = async_get_call(&call); 295 // printf("received call from phone %d, method=%d\n", 296 // call.in_phone_hash, IPC_GET_METHOD(call)); 320 297 321 switch (IPC_GET_METHOD(call)) { 298 322 case LOADER_GET_TASKID: … … 304 328 case LOADER_SET_ARGS: 305 329 loader_set_args(callid, &call); 330 continue; 331 case LOADER_LOAD: 332 loader_load(callid, &call); 333 continue; 306 334 case LOADER_RUN: 307 335 loader_run(callid, &call); 308 exit(0); 309 continue; 336 /* Not reached */ 310 337 default: 311 338 retval = ENOENT;
Note:
See TracChangeset
for help on using the changeset viewer.