Rev 3397 | Rev 3665 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3397 | Rev 3492 | ||
---|---|---|---|
Line 40... | Line 40... | ||
40 | #include <debug.h> |
40 | #include <debug.h> |
41 | #include <ipc/ipc.h> |
41 | #include <ipc/ipc.h> |
42 | #include <ipc/sysipc.h> |
42 | #include <ipc/sysipc.h> |
43 | #include <ipc/irq.h> |
43 | #include <ipc/irq.h> |
44 | #include <ipc/ipcrsc.h> |
44 | #include <ipc/ipcrsc.h> |
- | 45 | #include <ipc/kbox.h> |
|
- | 46 | #include <udebug/udebug_ipc.h> |
|
45 | #include <arch/interrupt.h> |
47 | #include <arch/interrupt.h> |
46 | #include <print.h> |
- | |
47 | #include <syscall/copy.h> |
48 | #include <syscall/copy.h> |
48 | #include <security/cap.h> |
49 | #include <security/cap.h> |
49 | #include <mm/as.h> |
50 | #include <mm/as.h> |
50 | #include <print.h> |
51 | #include <print.h> |
51 | 52 | ||
Line 293... | Line 294... | ||
293 | } |
294 | } |
294 | 295 | ||
295 | /** Called before the request is sent. |
296 | /** Called before the request is sent. |
296 | * |
297 | * |
297 | * @param call Call structure with the request. |
298 | * @param call Call structure with the request. |
- | 299 | * @param phone Phone that the call will be sent through. |
|
298 | * |
300 | * |
299 | * @return Return 0 on success, ELIMIT or EPERM on error. |
301 | * @return Return 0 on success, ELIMIT or EPERM on error. |
300 | */ |
302 | */ |
301 | static int request_preprocess(call_t *call) |
303 | static int request_preprocess(call_t *call, phone_t *phone) |
302 | { |
304 | { |
303 | int newphid; |
305 | int newphid; |
304 | size_t size; |
306 | size_t size; |
305 | uintptr_t src; |
307 | uintptr_t src; |
306 | int rc; |
308 | int rc; |
Line 338... | Line 340... | ||
338 | if (rc != 0) { |
340 | if (rc != 0) { |
339 | free(call->buffer); |
341 | free(call->buffer); |
340 | return rc; |
342 | return rc; |
341 | } |
343 | } |
342 | break; |
344 | break; |
- | 345 | #ifdef CONFIG_UDEBUG |
|
- | 346 | case IPC_M_DEBUG_ALL: |
|
- | 347 | return udebug_request_preprocess(call, phone); |
|
- | 348 | #endif |
|
343 | default: |
349 | default: |
344 | break; |
350 | break; |
345 | } |
351 | } |
346 | return 0; |
352 | return 0; |
347 | } |
353 | } |
Line 367... | Line 373... | ||
367 | IPC_SET_ARG5(call->data, call->priv); |
373 | IPC_SET_ARG5(call->data, call->priv); |
368 | } |
374 | } |
369 | 375 | ||
370 | if (call->buffer) { |
376 | if (call->buffer) { |
371 | /* This must be an affirmative answer to IPC_M_DATA_READ. */ |
377 | /* This must be an affirmative answer to IPC_M_DATA_READ. */ |
- | 378 | /* or IPC_M_DEBUG_ALL/UDEBUG_M_MEM_READ... */ |
|
372 | uintptr_t dst = IPC_GET_ARG1(call->data); |
379 | uintptr_t dst = IPC_GET_ARG1(call->data); |
373 | size_t size = IPC_GET_ARG2(call->data); |
380 | size_t size = IPC_GET_ARG2(call->data); |
374 | int rc = copy_to_uspace((void *) dst, call->buffer, size); |
381 | int rc = copy_to_uspace((void *) dst, call->buffer, size); |
375 | if (rc) |
382 | if (rc) |
376 | IPC_SET_RETVAL(call->data, rc); |
383 | IPC_SET_RETVAL(call->data, rc); |
Line 397... | Line 404... | ||
397 | IPC_SET_RETVAL(call->data, ELIMIT); |
404 | IPC_SET_RETVAL(call->data, ELIMIT); |
398 | ipc_answer(box, call); |
405 | ipc_answer(box, call); |
399 | return -1; |
406 | return -1; |
400 | } |
407 | } |
401 | IPC_SET_ARG5(call->data, phoneid); |
408 | IPC_SET_ARG5(call->data, phoneid); |
402 | } |
409 | } |
- | 410 | switch (IPC_GET_METHOD(call->data)) { |
|
- | 411 | case IPC_M_DEBUG_ALL: |
|
- | 412 | return -1; |
|
- | 413 | default: |
|
- | 414 | break; |
|
- | 415 | } |
|
403 | return 0; |
416 | return 0; |
404 | } |
417 | } |
405 | 418 | ||
406 | /** Make a fast call over IPC, wait for reply and return to user. |
419 | /** Make a fast call over IPC, wait for reply and return to user. |
407 | * |
420 | * |
Line 439... | Line 452... | ||
439 | * the limits of the fast version. |
452 | * the limits of the fast version. |
440 | */ |
453 | */ |
441 | IPC_SET_ARG4(call.data, 0); |
454 | IPC_SET_ARG4(call.data, 0); |
442 | IPC_SET_ARG5(call.data, 0); |
455 | IPC_SET_ARG5(call.data, 0); |
443 | 456 | ||
444 | if (!(res = request_preprocess(&call))) { |
457 | if (!(res = request_preprocess(&call, phone))) { |
445 | rc = ipc_call_sync(phone, &call); |
458 | rc = ipc_call_sync(phone, &call); |
446 | if (rc != EOK) |
459 | if (rc != EOK) |
447 | return rc; |
460 | return rc; |
448 | process_answer(&call); |
461 | process_answer(&call); |
449 | } else { |
462 | } else { |
Line 479... | Line 492... | ||
479 | if (rc != 0) |
492 | if (rc != 0) |
480 | return (unative_t) rc; |
493 | return (unative_t) rc; |
481 | 494 | ||
482 | GET_CHECK_PHONE(phone, phoneid, return ENOENT); |
495 | GET_CHECK_PHONE(phone, phoneid, return ENOENT); |
483 | 496 | ||
484 | if (!(res = request_preprocess(&call))) { |
497 | if (!(res = request_preprocess(&call, phone))) { |
485 | rc = ipc_call_sync(phone, &call); |
498 | rc = ipc_call_sync(phone, &call); |
486 | if (rc != EOK) |
499 | if (rc != EOK) |
487 | return rc; |
500 | return rc; |
488 | process_answer(&call); |
501 | process_answer(&call); |
489 | } else |
502 | } else |
Line 548... | Line 561... | ||
548 | * To achieve deterministic behavior, zero out arguments that are beyond |
561 | * To achieve deterministic behavior, zero out arguments that are beyond |
549 | * the limits of the fast version. |
562 | * the limits of the fast version. |
550 | */ |
563 | */ |
551 | IPC_SET_ARG5(call->data, 0); |
564 | IPC_SET_ARG5(call->data, 0); |
552 | 565 | ||
553 | if (!(res = request_preprocess(call))) |
566 | if (!(res = request_preprocess(call, phone))) |
554 | ipc_call(phone, call); |
567 | ipc_call(phone, call); |
555 | else |
568 | else |
556 | ipc_backsend_err(phone, call, res); |
569 | ipc_backsend_err(phone, call, res); |
557 | 570 | ||
558 | return (unative_t) call; |
571 | return (unative_t) call; |
Line 582... | Line 595... | ||
582 | sizeof(call->data.args)); |
595 | sizeof(call->data.args)); |
583 | if (rc != 0) { |
596 | if (rc != 0) { |
584 | ipc_call_free(call); |
597 | ipc_call_free(call); |
585 | return (unative_t) rc; |
598 | return (unative_t) rc; |
586 | } |
599 | } |
587 | if (!(res = request_preprocess(call))) |
600 | if (!(res = request_preprocess(call, phone))) |
588 | ipc_call(phone, call); |
601 | ipc_call(phone, call); |
589 | else |
602 | else |
590 | ipc_backsend_err(phone, call, res); |
603 | ipc_backsend_err(phone, call, res); |
591 | 604 | ||
592 | return (unative_t) call; |
605 | return (unative_t) call; |
Line 807... | Line 820... | ||
807 | if (call->flags & IPC_CALL_ANSWERED) { |
820 | if (call->flags & IPC_CALL_ANSWERED) { |
808 | process_answer(call); |
821 | process_answer(call); |
809 | 822 | ||
810 | ASSERT(! (call->flags & IPC_CALL_STATIC_ALLOC)); |
823 | ASSERT(! (call->flags & IPC_CALL_STATIC_ALLOC)); |
811 | 824 | ||
812 | atomic_dec(&TASK->active_calls); |
- | |
813 | - | ||
814 | if (call->flags & IPC_CALL_DISCARD_ANSWER) { |
825 | if (call->flags & IPC_CALL_DISCARD_ANSWER) { |
815 | ipc_call_free(call); |
826 | ipc_call_free(call); |
816 | goto restart; |
827 | goto restart; |
- | 828 | } else { |
|
- | 829 | /* |
|
- | 830 | * Decrement the counter of active calls only if the |
|
- | 831 | * call is not an answer to IPC_M_PHONE_HUNGUP, |
|
- | 832 | * which doesn't contribute to the counter. |
|
- | 833 | */ |
|
- | 834 | atomic_dec(&TASK->active_calls); |
|
817 | } |
835 | } |
818 | 836 | ||
819 | STRUCT_TO_USPACE(&calldata->args, &call->data.args); |
837 | STRUCT_TO_USPACE(&calldata->args, &call->data.args); |
820 | ipc_call_free(call); |
838 | ipc_call_free(call); |
821 | 839 | ||
Line 866... | Line 884... | ||
866 | ipc_irq_unregister(&TASK->answerbox, inr, devno); |
884 | ipc_irq_unregister(&TASK->answerbox, inr, devno); |
867 | 885 | ||
868 | return 0; |
886 | return 0; |
869 | } |
887 | } |
870 | 888 | ||
- | 889 | #include <console/console.h> |
|
- | 890 | ||
- | 891 | /** |
|
- | 892 | * Syscall connect to a task by id. |
|
- | 893 | * |
|
- | 894 | * @return Phone id on success, or negative error code. |
|
- | 895 | */ |
|
- | 896 | unative_t sys_ipc_connect_kbox(sysarg64_t *uspace_taskid_arg) |
|
- | 897 | { |
|
- | 898 | #ifdef CONFIG_UDEBUG |
|
- | 899 | sysarg64_t taskid_arg; |
|
- | 900 | int rc; |
|
- | 901 | ||
- | 902 | rc = copy_from_uspace(&taskid_arg, uspace_taskid_arg, sizeof(sysarg64_t)); |
|
- | 903 | if (rc != 0) |
|
- | 904 | return (unative_t) rc; |
|
- | 905 | ||
- | 906 | LOG("sys_ipc_connect_kbox(%" PRIu64 ")\n", taskid_arg.value); |
|
- | 907 | ||
- | 908 | return ipc_connect_kbox(taskid_arg.value); |
|
- | 909 | #else |
|
- | 910 | return (unative_t) ENOTSUP; |
|
- | 911 | #endif |
|
- | 912 | } |
|
- | 913 | ||
871 | /** @} |
914 | /** @} |
872 | */ |
915 | */ |