Changeset 48bcf49 in mainline for kernel/generic/src/ipc/sysipc.c
- Timestamp:
- 2017-09-28T22:08:15Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6636fb19
- Parents:
- dd20cbb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/ipc/sysipc.c
rdd20cbb r48bcf49 260 260 /** Make a call over IPC and wait for reply. 261 261 * 262 * @param phone_cap Phone capabilityfor the call.262 * @param handle Phone capability handle for the call. 263 263 * @param data[inout] Structure with request/reply data. 264 264 * @param priv Value to be stored in call->priv. … … 268 268 * 269 269 */ 270 int ipc_req_internal( int phone_cap, ipc_data_t *data, sysarg_t priv)271 { 272 phone_t *phone = phone_get_current(phone_cap);273 if (! phone)270 int ipc_req_internal(cap_handle_t handle, ipc_data_t *data, sysarg_t priv) 271 { 272 kobject_t *kobj = kobject_get(TASK, handle, KOBJECT_TYPE_PHONE); 273 if (!kobj->phone) 274 274 return ENOENT; 275 275 … … 278 278 memcpy(call->data.args, data->args, sizeof(data->args)); 279 279 280 int rc = request_preprocess(call, phone);280 int rc = request_preprocess(call, kobj->phone); 281 281 if (!rc) { 282 282 #ifdef CONFIG_UDEBUG … … 285 285 286 286 ipc_call_hold(call); 287 rc = ipc_call_sync( phone, call);287 rc = ipc_call_sync(kobj->phone, call); 288 288 spinlock_lock(&call->forget_lock); 289 289 bool forgotten = call->forget; … … 312 312 assert(rc == EINTR); 313 313 } 314 return rc; 314 kobject_put(kobj); 315 return rc; 315 316 } 316 317 … … 321 322 memcpy(data->args, call->data.args, sizeof(data->args)); 322 323 ipc_call_free(call); 324 kobject_put(kobj); 323 325 324 326 return EOK; … … 346 348 * the generic function sys_ipc_call_async_slow(). 347 349 * 348 * @param phone_cap Phone capabilityfor the call.349 * @param imethod 350 * @param arg1 351 * @param arg2 352 * @param arg3 353 * @param arg4 350 * @param handle Phone capability handle for the call. 351 * @param imethod Interface and method of the call. 352 * @param arg1 Service-defined payload argument. 353 * @param arg2 Service-defined payload argument. 354 * @param arg3 Service-defined payload argument. 355 * @param arg4 Service-defined payload argument. 354 356 * 355 357 * @return Call hash on success. … … 359 361 * 360 362 */ 361 sysarg_t sys_ipc_call_async_fast(sysarg_t phone_cap, sysarg_t imethod,363 sysarg_t sys_ipc_call_async_fast(sysarg_t handle, sysarg_t imethod, 362 364 sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, sysarg_t arg4) 363 365 { 364 phone_t *phone = phone_get_current(phone_cap);365 if (! phone)366 kobject_t *kobj = kobject_get(TASK, handle, KOBJECT_TYPE_PHONE); 367 if (!kobj) 366 368 return IPC_CALLRET_FATAL; 367 369 368 if (check_call_limit(phone)) 370 if (check_call_limit(kobj->phone)) { 371 kobject_put(kobj); 369 372 return IPC_CALLRET_TEMPORARY; 373 } 370 374 371 375 call_t *call = ipc_call_alloc(0); … … 382 386 IPC_SET_ARG5(call->data, 0); 383 387 384 int res = request_preprocess(call, phone);388 int res = request_preprocess(call, kobj->phone); 385 389 386 390 if (!res) 387 ipc_call( phone, call);391 ipc_call(kobj->phone, call); 388 392 else 389 ipc_backsend_err(phone, call, res); 390 393 ipc_backsend_err(kobj->phone, call, res); 394 395 kobject_put(kobj); 391 396 return (sysarg_t) call; 392 397 } … … 394 399 /** Make an asynchronous IPC call allowing to transmit the entire payload. 395 400 * 396 * @param phone_capPhone capability for the call.397 * @param data 401 * @param handle Phone capability for the call. 402 * @param data Userspace address of call data with the request. 398 403 * 399 404 * @return See sys_ipc_call_async_fast(). 400 405 * 401 406 */ 402 sysarg_t sys_ipc_call_async_slow(sysarg_t phone_cap, ipc_data_t *data)403 { 404 phone_t *phone = phone_get_current(phone_cap);405 if (! phone)407 sysarg_t sys_ipc_call_async_slow(sysarg_t handle, ipc_data_t *data) 408 { 409 kobject_t *kobj = kobject_get(TASK, handle, KOBJECT_TYPE_PHONE); 410 if (!kobj) 406 411 return IPC_CALLRET_FATAL; 407 412 408 if (check_call_limit(phone)) 413 if (check_call_limit(kobj->phone)) { 414 kobject_put(kobj); 409 415 return IPC_CALLRET_TEMPORARY; 416 } 410 417 411 418 call_t *call = ipc_call_alloc(0); … … 414 421 if (rc != 0) { 415 422 ipc_call_free(call); 423 kobject_put(kobj); 416 424 return (sysarg_t) rc; 417 425 } 418 426 419 int res = request_preprocess(call, phone);427 int res = request_preprocess(call, kobj->phone); 420 428 421 429 if (!res) 422 ipc_call( phone, call);430 ipc_call(kobj->phone, call); 423 431 else 424 ipc_backsend_err(phone, call, res); 425 432 ipc_backsend_err(kobj->phone, call, res); 433 434 kobject_put(kobj); 426 435 return (sysarg_t) call; 427 436 } … … 431 440 * Common code for both the fast and the slow version. 432 441 * 433 * @param callid 434 * @param phone_capPhone capability to use for forwarding.435 * @param imethod 436 * @param arg1 437 * @param arg2 438 * @param arg3 439 * @param arg4 440 * @param arg5 441 * @param mode 442 * @param slow 443 * 444 * 442 * @param callid Hash of the call to forward. 443 * @param handle Phone capability to use for forwarding. 444 * @param imethod New interface and method to use for the forwarded call. 445 * @param arg1 New value of the first argument for the forwarded call. 446 * @param arg2 New value of the second argument for the forwarded call. 447 * @param arg3 New value of the third argument for the forwarded call. 448 * @param arg4 New value of the fourth argument for the forwarded call. 449 * @param arg5 New value of the fifth argument for the forwarded call. 450 * @param mode Flags that specify mode of the forward operation. 451 * @param slow If true, arg3, arg4 and arg5 are considered. Otherwise 452 * the function considers only the fast version arguments: 453 * i.e. arg1 and arg2. 445 454 * 446 455 * @return 0 on succes, otherwise an error code. … … 449 458 * 450 459 */ 451 static sysarg_t sys_ipc_forward_common(sysarg_t callid, sysarg_t phone_cap,460 static sysarg_t sys_ipc_forward_common(sysarg_t callid, sysarg_t handle, 452 461 sysarg_t imethod, sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, 453 462 sysarg_t arg4, sysarg_t arg5, unsigned int mode, bool slow) … … 465 474 int rc; 466 475 467 phone_t *phone = phone_get_current(phone_cap);468 if (! phone) {476 kobject_t *kobj = kobject_get(TASK, handle, KOBJECT_TYPE_PHONE); 477 if (!kobj) { 469 478 rc = ENOENT; 470 479 goto error; … … 512 521 } 513 522 514 rc = ipc_forward(call, phone, &TASK->answerbox, mode);523 rc = ipc_forward(call, kobj->phone, &TASK->answerbox, mode); 515 524 if (rc != EOK) { 516 525 after_forward = true; … … 518 527 } 519 528 529 kobject_put(kobj); 520 530 return EOK; 521 531 … … 528 538 ipc_answer(&TASK->answerbox, call); 529 539 540 if (kobj) 541 kobject_put(kobj); 530 542 return rc; 531 543 } … … 540 552 * arguments are not set and these values are ignored. 541 553 * 542 * @param callid Hash of the call to forward.543 * @param phoneidPhone handle to use for forwarding.544 * @param imethod New interface and method to use for the forwarded call.545 * @param arg1 New value of the first argument for the forwarded call.546 * @param arg2 New value of the second argument for the forwarded call.547 * @param mode Flags that specify mode of the forward operation.554 * @param callid Hash of the call to forward. 555 * @param handle Phone handle to use for forwarding. 556 * @param imethod New interface and method to use for the forwarded call. 557 * @param arg1 New value of the first argument for the forwarded call. 558 * @param arg2 New value of the second argument for the forwarded call. 559 * @param mode Flags that specify mode of the forward operation. 548 560 * 549 561 * @return 0 on succes, otherwise an error code. 550 562 * 551 563 */ 552 sysarg_t sys_ipc_forward_fast(sysarg_t callid, sysarg_t phoneid,564 sysarg_t sys_ipc_forward_fast(sysarg_t callid, sysarg_t handle, 553 565 sysarg_t imethod, sysarg_t arg1, sysarg_t arg2, unsigned int mode) 554 566 { 555 return sys_ipc_forward_common(callid, phoneid, imethod, arg1, arg2, 0, 0,567 return sys_ipc_forward_common(callid, handle, imethod, arg1, arg2, 0, 0, 556 568 0, mode, false); 557 569 } … … 567 579 * 568 580 * @param callid Hash of the call to forward. 569 * @param phoneidPhone handle to use for forwarding.581 * @param handle Phone handle to use for forwarding. 570 582 * @param data Userspace address of the new IPC data. 571 583 * @param mode Flags that specify mode of the forward operation. … … 574 586 * 575 587 */ 576 sysarg_t sys_ipc_forward_slow(sysarg_t callid, sysarg_t phoneid,588 sysarg_t sys_ipc_forward_slow(sysarg_t callid, sysarg_t handle, 577 589 ipc_data_t *data, unsigned int mode) 578 590 { … … 583 595 return (sysarg_t) rc; 584 596 585 return sys_ipc_forward_common(callid, phoneid,597 return sys_ipc_forward_common(callid, handle, 586 598 IPC_GET_IMETHOD(newdata), IPC_GET_ARG1(newdata), 587 599 IPC_GET_ARG2(newdata), IPC_GET_ARG3(newdata), … … 681 693 /** Hang up a phone. 682 694 * 683 * @param phone_cap Phone capabilityof the phone to be hung up.695 * @param handle Phone capability handle of the phone to be hung up. 684 696 * 685 697 * @return 0 on success or an error code. 686 698 * 687 699 */ 688 sysarg_t sys_ipc_hangup(sysarg_t phone_cap)689 { 690 phone_t *phone = phone_get_current(phone_cap);691 if (! phone)700 sysarg_t sys_ipc_hangup(sysarg_t handle) 701 { 702 kobject_t *kobj = kobject_get(TASK, handle, KOBJECT_TYPE_PHONE); 703 if (!kobj) 692 704 return ENOENT; 693 705 694 if (ipc_phone_hangup(phone)) 706 if (ipc_phone_hangup(kobj->phone)) { 707 kobject_put(kobj); 695 708 return -1; 696 709 } 710 711 kobject_put(kobj); 697 712 return 0; 698 713 }
Note:
See TracChangeset
for help on using the changeset viewer.