Changes in uspace/srv/loader/main.c [8c3bc75:228e490] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/loader/main.c
r8c3bc75 r228e490 50 50 #include <fcntl.h> 51 51 #include <sys/types.h> 52 #include <ipc/ipc.h> 52 53 #include <ipc/services.h> 53 54 #include <ipc/loader.h> … … 94 95 95 96 /** Used to limit number of connections to one. */ 96 static bool connected = false;97 static bool connected; 97 98 98 99 static void ldr_get_taskid(ipc_callid_t rid, ipc_call_t *request) … … 105 106 106 107 if (!async_data_read_receive(&callid, &len)) { 107 async_answer_0(callid, EINVAL);108 async_answer_0(rid, EINVAL);108 ipc_answer_0(callid, EINVAL); 109 ipc_answer_0(rid, EINVAL); 109 110 return; 110 111 } … … 114 115 115 116 async_data_read_finalize(callid, &task_id, len); 116 async_answer_0(rid, EOK);117 ipc_answer_0(rid, EOK); 117 118 } 118 119 … … 134 135 } 135 136 136 async_answer_0(rid, rc);137 ipc_answer_0(rid, rc); 137 138 } 138 139 … … 154 155 } 155 156 156 async_answer_0(rid, rc);157 ipc_answer_0(rid, rc); 157 158 } 158 159 … … 187 188 if (_argv == NULL) { 188 189 free(buf); 189 async_answer_0(rid, ENOMEM);190 ipc_answer_0(rid, ENOMEM); 190 191 return; 191 192 } … … 219 220 } 220 221 221 async_answer_0(rid, rc);222 ipc_answer_0(rid, rc); 222 223 } 223 224 … … 243 244 if (_filv == NULL) { 244 245 free(buf); 245 async_answer_0(rid, ENOMEM);246 ipc_answer_0(rid, ENOMEM); 246 247 return; 247 248 } … … 270 271 } 271 272 272 async_answer_0(rid, EOK);273 ipc_answer_0(rid, EOK); 273 274 } 274 275 … … 286 287 if (rc != EE_OK) { 287 288 DPRINTF("Failed to load executable '%s'.\n", pathname); 288 async_answer_0(rid, EINVAL);289 ipc_answer_0(rid, EINVAL); 289 290 return 1; 290 291 } … … 303 304 /* Statically linked program */ 304 305 is_dyn_linked = false; 305 async_answer_0(rid, EOK);306 ipc_answer_0(rid, EOK); 306 307 return 0; 307 308 } … … 311 312 DPRINTF("Failed to load interpreter '%s.'\n", 312 313 prog_info.interp); 313 async_answer_0(rid, EINVAL);314 ipc_answer_0(rid, EINVAL); 314 315 return 1; 315 316 } 316 317 317 318 is_dyn_linked = true; 318 async_answer_0(rid, EOK);319 ipc_answer_0(rid, EOK); 319 320 320 321 return 0; … … 342 343 DPRINTF("Entry point: %p\n", interp_info.entry); 343 344 344 async_answer_0(rid, EOK);345 ipc_answer_0(rid, EOK); 345 346 elf_run(&interp_info, &pcb); 346 347 } else { 347 348 /* Statically linked program */ 348 async_answer_0(rid, EOK);349 ipc_answer_0(rid, EOK); 349 350 elf_run(&prog_info, &pcb); 350 351 } … … 366 367 /* Already have a connection? */ 367 368 if (connected) { 368 async_answer_0(iid, ELIMIT);369 ipc_answer_0(iid, ELIMIT); 369 370 return; 370 371 } … … 373 374 374 375 /* Accept the connection */ 375 async_answer_0(iid, EOK);376 ipc_answer_0(iid, EOK); 376 377 377 378 /* Ignore parameters, the connection is already open */ … … 407 408 /* Not reached */ 408 409 default: 409 retval = E INVAL;410 retval = ENOENT; 410 411 break; 411 412 } 412 413 if (IPC_GET_IMETHOD(call) != IPC_M_PHONE_HUNGUP) 414 async_answer_0(callid, retval); 413 if (IPC_GET_IMETHOD(call) != IPC_M_PHONE_HUNGUP) { 414 DPRINTF("Responding EINVAL to method %d.\n", 415 IPC_GET_IMETHOD(call)); 416 ipc_answer_0(callid, EINVAL); 417 } 415 418 } 416 419 } … … 420 423 int main(int argc, char *argv[]) 421 424 { 425 sysarg_t phonead; 426 task_id_t id; 427 int rc; 428 429 connected = false; 430 431 /* Introduce this task to the NS (give it our task ID). */ 432 id = task_get_id(); 433 rc = async_req_2_0(PHONE_NS, NS_ID_INTRO, LOWER32(id), UPPER32(id)); 434 if (rc != EOK) 435 return -1; 436 422 437 /* Set a handler of incomming connections. */ 423 438 async_set_client_connection(ldr_connection); 424 439 425 /* Introduce this task to the NS (give it our task ID). */426 task_id_t id = task_get_id();427 int rc = async_req_2_0(PHONE_NS, NS_ID_INTRO, LOWER32(id), UPPER32(id));428 if (rc != EOK)429 return -1;430 431 440 /* Register at naming service. */ 432 if ( service_register(SERVICE_LOAD) != EOK)441 if (ipc_connect_to_me(PHONE_NS, SERVICE_LOAD, 0, 0, &phonead) != 0) 433 442 return -2; 434 443 435 444 async_manager(); 436 445
Note:
See TracChangeset
for help on using the changeset viewer.