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