Rev 4338 | Rev 4344 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 4338 | Rev 4343 | ||
|---|---|---|---|
| Line 48... | Line 48... | ||
| 48 | #include <unistd.h> |
48 | #include <unistd.h> |
| 49 | #include <bool.h> |
49 | #include <bool.h> |
| 50 | #include <fcntl.h> |
50 | #include <fcntl.h> |
| 51 | #include <sys/types.h> |
51 | #include <sys/types.h> |
| 52 | #include <ipc/ipc.h> |
52 | #include <ipc/ipc.h> |
| - | 53 | #include <ipc/services.h> |
|
| 53 | #include <ipc/loader.h> |
54 | #include <ipc/loader.h> |
| 54 | #include <loader/pcb.h> |
55 | #include <loader/pcb.h> |
| 55 | #include <errno.h> |
56 | #include <errno.h> |
| 56 | #include <async.h> |
57 | #include <async.h> |
| 57 | #include <as.h> |
58 | #include <as.h> |
| Line 79... | Line 80... | ||
| 79 | static elf_info_t prog_info; |
80 | static elf_info_t prog_info; |
| 80 | static elf_info_t interp_info; |
81 | static elf_info_t interp_info; |
| 81 | 82 | ||
| 82 | static bool is_dyn_linked; |
83 | static bool is_dyn_linked; |
| 83 | 84 | ||
| - | 85 | /** Used to limit number of connections to one. */ |
|
| - | 86 | static bool connected; |
|
| 84 | 87 | ||
| 85 | static void loader_get_taskid(ipc_callid_t rid, ipc_call_t *request) |
88 | static void loader_get_taskid(ipc_callid_t rid, ipc_call_t *request) |
| 86 | { |
89 | { |
| 87 | ipc_callid_t callid; |
90 | ipc_callid_t callid; |
| 88 | task_id_t task_id; |
91 | task_id_t task_id; |
| Line 303... | Line 306... | ||
| 303 | { |
306 | { |
| 304 | ipc_callid_t callid; |
307 | ipc_callid_t callid; |
| 305 | ipc_call_t call; |
308 | ipc_call_t call; |
| 306 | int retval; |
309 | int retval; |
| 307 | 310 | ||
| - | 311 | /* Already have a connection? */ |
|
| - | 312 | if (connected) { |
|
| - | 313 | ipc_answer_0(iid, ELIMIT); |
|
| - | 314 | return; |
|
| - | 315 | } |
|
| - | 316 | ||
| - | 317 | connected = true; |
|
| - | 318 | ||
| - | 319 | /* Accept the connection */ |
|
| - | 320 | ipc_answer_0(iid, EOK); |
|
| - | 321 | ||
| 308 | /* Ignore parameters, the connection is already open */ |
322 | /* Ignore parameters, the connection is already open */ |
| 309 | (void)iid; (void)icall; |
323 | (void)iid; (void)icall; |
| 310 | 324 | ||
| 311 | while (1) { |
325 | while (1) { |
| 312 | callid = async_get_call(&call); |
326 | callid = async_get_call(&call); |
| Line 344... | Line 358... | ||
| 344 | 358 | ||
| 345 | /** Program loader main function. |
359 | /** Program loader main function. |
| 346 | */ |
360 | */ |
| 347 | int main(int argc, char *argv[]) |
361 | int main(int argc, char *argv[]) |
| 348 | { |
362 | { |
| 349 | ipc_callid_t callid; |
- | |
| 350 | ipc_call_t call; |
- | |
| 351 | ipcarg_t phone_hash; |
363 | ipcarg_t phonead; |
| 352 | - | ||
| 353 | /* The first call only communicates the incoming phone hash */ |
- | |
| 354 | callid = ipc_wait_for_call(&call); |
- | |
| 355 | 364 | ||
| 356 | if (IPC_GET_METHOD(call) != LOADER_HELLO) { |
- | |
| 357 | if (IPC_GET_METHOD(call) != IPC_M_PHONE_HUNGUP) |
- | |
| 358 | ipc_answer_0(callid, EINVAL); |
- | |
| 359 | return 1; |
365 | connected = false; |
| 360 | } |
366 | |
| 361 | - | ||
| 362 | ipc_answer_0(callid, EOK); |
367 | /* Set a handler of incomming connections. */ |
| 363 | phone_hash = call.in_phone_hash; |
368 | async_set_client_connection(loader_connection); |
| 364 | 369 | ||
| 365 | /* |
- | |
| 366 | * Up until now async must not be used as it couldn't |
370 | /* Register at naming service. */ |
| 367 | * handle incoming requests. (Which means e.g. printf() |
371 | if (ipc_connect_to_me(PHONE_NS, SERVICE_LOAD, 0, 0, &phonead) != 0) |
| 368 | * cannot be used) |
372 | return -1; |
| 369 | */ |
373 | |
| 370 | async_new_connection(phone_hash, 0, NULL, loader_connection); |
- | |
| 371 | async_manager(); |
374 | async_manager(); |
| 372 | 375 | ||
| 373 | /* not reached */ |
376 | /* Never reached */ |
| 374 | return 0; |
377 | return 0; |
| 375 | } |
378 | } |
| 376 | 379 | ||
| 377 | /** @} |
380 | /** @} |
| 378 | */ |
381 | */ |