Changes in kernel/generic/src/ipc/sysipc.c [ae66564:48bcf49] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/ipc/sysipc.c
rae66564 r48bcf49 34 34 35 35 #include <arch.h> 36 #include <assert.h> 36 37 #include <errno.h> 37 #include <mem str.h>38 #include <mem.h> 38 39 #include <ipc/ipc.h> 39 40 #include <abi/ipc/methods.h> … … 48 49 #include <arch/interrupt.h> 49 50 #include <syscall/copy.h> 50 #include <security/ cap.h>51 #include <security/perm.h> 51 52 #include <console/console.h> 52 53 #include <print.h> … … 84 85 { 85 86 switch (imethod) { 86 case IPC_M_CONNECTION_CLONE:87 case IPC_M_CLONE_ESTABLISH:88 87 case IPC_M_PHONE_HUNGUP: 89 88 /* This message is meant only for the original recipient. */ … … 134 133 { 135 134 switch (IPC_GET_IMETHOD(call->data)) { 136 case IPC_M_CONNECTION_CLONE:137 case IPC_M_CLONE_ESTABLISH:138 135 case IPC_M_CONNECT_TO_ME: 139 136 case IPC_M_CONNECT_ME_TO: … … 174 171 return rc; 175 172 } else { 176 ASSERT(answer->active);173 assert(answer->active); 177 174 178 175 /* … … 263 260 /** Make a call over IPC and wait for reply. 264 261 * 265 * @param phoneid Phonehandle for the call.266 * @param data[inout] Structure with request/reply data.267 * @param priv Value to be stored in call->priv.262 * @param handle Phone capability handle for the call. 263 * @param data[inout] Structure with request/reply data. 264 * @param priv Value to be stored in call->priv. 268 265 * 269 266 * @return EOK on success. … … 271 268 * 272 269 */ 273 int ipc_req_internal( int phoneid, ipc_data_t *data, sysarg_t priv)274 { 275 phone_t *phone;276 if ( phone_get(phoneid, &phone) != EOK)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) 277 274 return ENOENT; 278 275 … … 281 278 memcpy(call->data.args, data->args, sizeof(data->args)); 282 279 283 int rc = request_preprocess(call, phone);280 int rc = request_preprocess(call, kobj->phone); 284 281 if (!rc) { 285 282 #ifdef CONFIG_UDEBUG … … 288 285 289 286 ipc_call_hold(call); 290 rc = ipc_call_sync( phone, call);287 rc = ipc_call_sync(kobj->phone, call); 291 288 spinlock_lock(&call->forget_lock); 292 289 bool forgotten = call->forget; … … 313 310 * We are no longer expected to free it. 314 311 */ 315 ASSERT(rc == EINTR);312 assert(rc == EINTR); 316 313 } 317 return rc; 314 kobject_put(kobj); 315 return rc; 318 316 } 319 317 … … 324 322 memcpy(data->args, call->data.args, sizeof(data->args)); 325 323 ipc_call_free(call); 324 kobject_put(kobj); 326 325 327 326 return EOK; … … 349 348 * the generic function sys_ipc_call_async_slow(). 350 349 * 351 * @param phoneid Phonehandle for the call.352 * @param imethod Interface and method of the call.353 * @param arg1 Service-defined payload argument.354 * @param arg2 Service-defined payload argument.355 * @param arg3 Service-defined payload argument.356 * @param arg4 Service-defined payload argument.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. 357 356 * 358 357 * @return Call hash on success. … … 362 361 * 363 362 */ 364 sysarg_t sys_ipc_call_async_fast(sysarg_t phoneid, sysarg_t imethod,363 sysarg_t sys_ipc_call_async_fast(sysarg_t handle, sysarg_t imethod, 365 364 sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, sysarg_t arg4) 366 365 { 367 phone_t *phone;368 if ( phone_get(phoneid, &phone) != EOK)366 kobject_t *kobj = kobject_get(TASK, handle, KOBJECT_TYPE_PHONE); 367 if (!kobj) 369 368 return IPC_CALLRET_FATAL; 370 369 371 if (check_call_limit(phone)) 370 if (check_call_limit(kobj->phone)) { 371 kobject_put(kobj); 372 372 return IPC_CALLRET_TEMPORARY; 373 } 373 374 374 375 call_t *call = ipc_call_alloc(0); … … 385 386 IPC_SET_ARG5(call->data, 0); 386 387 387 int res = request_preprocess(call, phone);388 int res = request_preprocess(call, kobj->phone); 388 389 389 390 if (!res) 390 ipc_call( phone, call);391 ipc_call(kobj->phone, call); 391 392 else 392 ipc_backsend_err(phone, call, res); 393 393 ipc_backsend_err(kobj->phone, call, res); 394 395 kobject_put(kobj); 394 396 return (sysarg_t) call; 395 397 } … … 397 399 /** Make an asynchronous IPC call allowing to transmit the entire payload. 398 400 * 399 * @param phoneid Phone handlefor the call.401 * @param handle Phone capability for the call. 400 402 * @param data Userspace address of call data with the request. 401 403 * … … 403 405 * 404 406 */ 405 sysarg_t sys_ipc_call_async_slow(sysarg_t phoneid, ipc_data_t *data)406 { 407 phone_t *phone;408 if ( phone_get(phoneid, &phone) != EOK)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) 409 411 return IPC_CALLRET_FATAL; 410 412 411 if (check_call_limit(phone)) 413 if (check_call_limit(kobj->phone)) { 414 kobject_put(kobj); 412 415 return IPC_CALLRET_TEMPORARY; 416 } 413 417 414 418 call_t *call = ipc_call_alloc(0); … … 417 421 if (rc != 0) { 418 422 ipc_call_free(call); 423 kobject_put(kobj); 419 424 return (sysarg_t) rc; 420 425 } 421 426 422 int res = request_preprocess(call, phone);427 int res = request_preprocess(call, kobj->phone); 423 428 424 429 if (!res) 425 ipc_call( phone, call);430 ipc_call(kobj->phone, call); 426 431 else 427 ipc_backsend_err(phone, call, res); 428 432 ipc_backsend_err(kobj->phone, call, res); 433 434 kobject_put(kobj); 429 435 return (sysarg_t) call; 430 436 } … … 434 440 * Common code for both the fast and the slow version. 435 441 * 436 * @param callid Hash of the call to forward.437 * @param phoneid Phone handleto use for forwarding.438 * @param imethod New interface and method to use for the forwarded call.439 * @param arg1 New value of the first argument for the forwarded call.440 * @param arg2 New value of the second argument for the forwarded call.441 * @param arg3 New value of the third argument for the forwarded call.442 * @param arg4 New value of the fourth argument for the forwarded call.443 * @param arg5 New value of the fifth argument for the forwarded call.444 * @param mode Flags that specify mode of the forward operation.445 * @param slow If true, arg3, arg4 and arg5 are considered. Otherwise446 * the function considers only the fast version arguments:447 * i.e. arg1 and arg2.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. 448 454 * 449 455 * @return 0 on succes, otherwise an error code. … … 452 458 * 453 459 */ 454 static sysarg_t sys_ipc_forward_common(sysarg_t callid, sysarg_t phoneid,460 static sysarg_t sys_ipc_forward_common(sysarg_t callid, sysarg_t handle, 455 461 sysarg_t imethod, sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, 456 462 sysarg_t arg4, sysarg_t arg5, unsigned int mode, bool slow) … … 467 473 bool after_forward = false; 468 474 int rc; 469 phone_t *phone; 470 471 if ( phone_get(phoneid, &phone) != EOK) {475 476 kobject_t *kobj = kobject_get(TASK, handle, KOBJECT_TYPE_PHONE); 477 if (!kobj) { 472 478 rc = ENOENT; 473 479 goto error; … … 515 521 } 516 522 517 rc = ipc_forward(call, phone, &TASK->answerbox, mode);523 rc = ipc_forward(call, kobj->phone, &TASK->answerbox, mode); 518 524 if (rc != EOK) { 519 525 after_forward = true; … … 521 527 } 522 528 529 kobject_put(kobj); 523 530 return EOK; 524 531 … … 531 538 ipc_answer(&TASK->answerbox, call); 532 539 540 if (kobj) 541 kobject_put(kobj); 533 542 return rc; 534 543 } … … 543 552 * arguments are not set and these values are ignored. 544 553 * 545 * @param callid Hash of the call to forward.546 * @param phoneidPhone handle to use for forwarding.547 * @param imethod New interface and method to use for the forwarded call.548 * @param arg1 New value of the first argument for the forwarded call.549 * @param arg2 New value of the second argument for the forwarded call.550 * @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. 551 560 * 552 561 * @return 0 on succes, otherwise an error code. 553 562 * 554 563 */ 555 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, 556 565 sysarg_t imethod, sysarg_t arg1, sysarg_t arg2, unsigned int mode) 557 566 { 558 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, 559 568 0, mode, false); 560 569 } … … 570 579 * 571 580 * @param callid Hash of the call to forward. 572 * @param phoneidPhone handle to use for forwarding.581 * @param handle Phone handle to use for forwarding. 573 582 * @param data Userspace address of the new IPC data. 574 583 * @param mode Flags that specify mode of the forward operation. … … 577 586 * 578 587 */ 579 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, 580 589 ipc_data_t *data, unsigned int mode) 581 590 { … … 586 595 return (sysarg_t) rc; 587 596 588 return sys_ipc_forward_common(callid, phoneid,597 return sys_ipc_forward_common(callid, handle, 589 598 IPC_GET_IMETHOD(newdata), IPC_GET_ARG1(newdata), 590 599 IPC_GET_ARG2(newdata), IPC_GET_ARG3(newdata), … … 684 693 /** Hang up a phone. 685 694 * 686 * @param Phonehandle of the phone to be hung up.695 * @param handle Phone capability handle of the phone to be hung up. 687 696 * 688 697 * @return 0 on success or an error code. 689 698 * 690 699 */ 691 sysarg_t sys_ipc_hangup(sysarg_t phoneid) 692 { 693 phone_t *phone; 694 695 if (phone_get(phoneid, &phone) != EOK) 700 sysarg_t sys_ipc_hangup(sysarg_t handle) 701 { 702 kobject_t *kobj = kobject_get(TASK, handle, KOBJECT_TYPE_PHONE); 703 if (!kobj) 696 704 return ENOENT; 697 705 698 if (ipc_phone_hangup(phone)) 706 if (ipc_phone_hangup(kobj->phone)) { 707 kobject_put(kobj); 699 708 return -1; 700 709 } 710 711 kobject_put(kobj); 701 712 return 0; 702 713 } … … 801 812 * 802 813 * @param inr IRQ number. 803 * @param devno Device number.804 814 * @param imethod Interface and method to be associated with the notification. 805 815 * @param ucode Uspace pointer to the top-half pseudocode. 806 816 * 807 * @return EPERM or a return code returned by ipc_irq_subscribe(). 808 * 809 */ 810 sysarg_t sys_ipc_irq_subscribe(inr_t inr, devno_t devno, sysarg_t imethod, 811 irq_code_t *ucode) 812 { 813 if (!(cap_get(TASK) & CAP_IRQ_REG)) 817 * @return IRQ kernel object capability 818 * @return EPERM 819 * @return Error code returned by ipc_irq_subscribe(). 820 * 821 */ 822 sysarg_t sys_ipc_irq_subscribe(inr_t inr, sysarg_t imethod, irq_code_t *ucode) 823 { 824 if (!(perm_get(TASK) & PERM_IRQ_REG)) 814 825 return EPERM; 815 826 816 return ipc_irq_subscribe(&TASK->answerbox, inr, devno,imethod, ucode);827 return ipc_irq_subscribe(&TASK->answerbox, inr, imethod, ucode); 817 828 } 818 829 … … 825 836 * 826 837 */ 827 sysarg_t sys_ipc_irq_unsubscribe( inr_t inr, devno_t devno)828 { 829 if (!( cap_get(TASK) & CAP_IRQ_REG))838 sysarg_t sys_ipc_irq_unsubscribe(sysarg_t cap) 839 { 840 if (!(perm_get(TASK) & PERM_IRQ_REG)) 830 841 return EPERM; 831 842 832 ipc_irq_unsubscribe(&TASK->answerbox, inr, devno);843 ipc_irq_unsubscribe(&TASK->answerbox, cap); 833 844 834 845 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.