Changeset a35b458 in mainline for uspace/srv/loader/main.c
- Timestamp:
- 2018-03-02T20:10:49Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/loader/main.c
r3061bc1 ra35b458 95 95 task_id_t task_id; 96 96 size_t len; 97 97 98 98 task_id = task_get_id(); 99 99 100 100 if (!async_data_read_receive(&callid, &len)) { 101 101 async_answer_0(callid, EINVAL); … … 103 103 return; 104 104 } 105 105 106 106 if (len > sizeof(task_id)) 107 107 len = sizeof(task_id); 108 108 109 109 async_data_read_finalize(callid, &task_id, len); 110 110 async_answer_0(rid, EOK); … … 120 120 char *buf; 121 121 errno_t rc = async_data_write_accept((void **) &buf, true, 0, 0, 0, NULL); 122 122 123 123 if (rc == EOK) { 124 124 if (cwd != NULL) 125 125 free(cwd); 126 126 127 127 cwd = buf; 128 128 } 129 129 130 130 async_answer_0(rid, rc); 131 131 } … … 158 158 return; 159 159 } 160 160 161 161 progname = name; 162 162 program_fd = file; … … 174 174 size_t buf_size; 175 175 errno_t rc = async_data_write_accept((void **) &buf, true, 0, 0, 0, &buf_size); 176 176 177 177 if (rc == EOK) { 178 178 /* … … 181 181 char *cur = buf; 182 182 int count = 0; 183 183 184 184 while (cur < buf + buf_size) { 185 185 size_t arg_size = str_size(cur); … … 187 187 count++; 188 188 } 189 189 190 190 /* 191 191 * Allocate new argv … … 197 197 return; 198 198 } 199 199 200 200 /* 201 201 * Fill the new argv with argument pointers … … 205 205 while (cur < buf + buf_size) { 206 206 _argv[count] = cur; 207 207 208 208 size_t arg_size = str_size(cur); 209 209 cur += arg_size + 1; … … 211 211 } 212 212 _argv[count] = NULL; 213 213 214 214 /* 215 215 * Copy temporary data to global variables … … 217 217 if (arg_buf != NULL) 218 218 free(arg_buf); 219 219 220 220 if (argv != NULL) 221 221 free(argv); 222 222 223 223 argc = count; 224 224 arg_buf = buf; 225 225 argv = _argv; 226 226 } 227 227 228 228 async_answer_0(rid, rc); 229 229 } … … 289 289 return 1; 290 290 } 291 291 292 292 elf_set_pcb(&prog_info, &pcb); 293 293 294 294 pcb.cwd = cwd; 295 295 296 296 pcb.argc = argc; 297 297 pcb.argv = argv; 298 298 299 299 pcb.inbox = inbox; 300 300 pcb.inbox_entries = inbox_entries; 301 301 302 302 async_answer_0(rid, EOK); 303 303 return 0; … … 317 317 /* Set the task name. */ 318 318 task_set_name(progname); 319 319 320 320 /* Run program */ 321 321 DPRINTF("Reply OK\n"); … … 323 323 DPRINTF("Jump to entry point at %p\n", pcb.entry); 324 324 entry_point_jmp(prog_info.finfo.entry, &pcb); 325 325 326 326 /* Not reached */ 327 327 } … … 339 339 return; 340 340 } 341 341 342 342 connected = true; 343 343 344 344 /* Accept the connection */ 345 345 async_answer_0(iid, EOK); 346 346 347 347 /* Ignore parameters, the connection is already open */ 348 348 (void) icall; 349 349 350 350 while (true) { 351 351 errno_t retval; 352 352 ipc_call_t call; 353 353 ipc_callid_t callid = async_get_call(&call); 354 354 355 355 if (!IPC_GET_IMETHOD(call)) 356 356 exit(0); 357 357 358 358 switch (IPC_GET_IMETHOD(call)) { 359 359 case LOADER_GET_TASKID: … … 382 382 break; 383 383 } 384 384 385 385 async_answer_0(callid, retval); 386 386 } … … 392 392 { 393 393 async_set_fallback_port_handler(ldr_connection, NULL); 394 394 395 395 /* Introduce this task to the NS (give it our task ID). */ 396 396 task_id_t id = task_get_id(); … … 398 398 if (rc != EOK) 399 399 return rc; 400 400 401 401 /* Create port */ 402 402 port_id_t port; … … 404 404 if (rc != EOK) 405 405 return rc; 406 406 407 407 /* Register at naming service. */ 408 408 rc = service_register(SERVICE_LOADER); 409 409 if (rc != EOK) 410 410 return rc; 411 411 412 412 async_manager(); 413 413 414 414 /* Never reached */ 415 415 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.