Rev 3370 | Rev 3441 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 3370 | Rev 3438 | ||
|---|---|---|---|
| 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/ipc_kbox.h> |
|
| - | 46 | #include <udebug/udebug_ipc.h> |
|
| 45 | #include <arch/interrupt.h> |
47 | #include <arch/interrupt.h> |
| 46 | #include <print.h> |
48 | #include <print.h> |
| 47 | #include <syscall/copy.h> |
49 | #include <syscall/copy.h> |
| 48 | #include <security/cap.h> |
50 | #include <security/cap.h> |
| 49 | #include <mm/as.h> |
51 | #include <mm/as.h> |
| Line 293... | Line 295... | ||
| 293 | } |
295 | } |
| 294 | 296 | ||
| 295 | /** Called before the request is sent. |
297 | /** Called before the request is sent. |
| 296 | * |
298 | * |
| 297 | * @param call Call structure with the request. |
299 | * @param call Call structure with the request. |
| - | 300 | * @param phone Phone that the call will be sent through. |
|
| 298 | * |
301 | * |
| 299 | * @return Return 0 on success, ELIMIT or EPERM on error. |
302 | * @return Return 0 on success, ELIMIT or EPERM on error. |
| 300 | */ |
303 | */ |
| 301 | static int request_preprocess(call_t *call) |
304 | static int request_preprocess(call_t *call, phone_t *phone) |
| 302 | { |
305 | { |
| 303 | int newphid; |
306 | int newphid; |
| 304 | size_t size; |
307 | size_t size; |
| 305 | uintptr_t src; |
308 | uintptr_t src; |
| 306 | int rc; |
309 | int rc; |
| Line 338... | Line 341... | ||
| 338 | if (rc != 0) { |
341 | if (rc != 0) { |
| 339 | free(call->buffer); |
342 | free(call->buffer); |
| 340 | return rc; |
343 | return rc; |
| 341 | } |
344 | } |
| 342 | break; |
345 | break; |
| - | 346 | #ifdef CONFIG_UDEBUG |
|
| - | 347 | case IPC_M_DEBUG_ALL: |
|
| - | 348 | return udebug_request_preprocess(call, phone); |
|
| - | 349 | #endif |
|
| 343 | default: |
350 | default: |
| 344 | break; |
351 | break; |
| 345 | } |
352 | } |
| 346 | return 0; |
353 | return 0; |
| 347 | } |
354 | } |
| Line 367... | Line 374... | ||
| 367 | IPC_SET_ARG5(call->data, call->priv); |
374 | IPC_SET_ARG5(call->data, call->priv); |
| 368 | } |
375 | } |
| 369 | 376 | ||
| 370 | if (call->buffer) { |
377 | if (call->buffer) { |
| 371 | /* This must be an affirmative answer to IPC_M_DATA_READ. */ |
378 | /* This must be an affirmative answer to IPC_M_DATA_READ. */ |
| - | 379 | /* or IPC_M_DEBUG_ALL/UDEBUG_M_MEM_READ... */ |
|
| 372 | uintptr_t dst = IPC_GET_ARG1(call->data); |
380 | uintptr_t dst = IPC_GET_ARG1(call->data); |
| 373 | size_t size = IPC_GET_ARG2(call->data); |
381 | size_t size = IPC_GET_ARG2(call->data); |
| 374 | int rc = copy_to_uspace((void *) dst, call->buffer, size); |
382 | int rc = copy_to_uspace((void *) dst, call->buffer, size); |
| 375 | if (rc) |
383 | if (rc) |
| 376 | IPC_SET_RETVAL(call->data, rc); |
384 | IPC_SET_RETVAL(call->data, rc); |
| Line 397... | Line 405... | ||
| 397 | IPC_SET_RETVAL(call->data, ELIMIT); |
405 | IPC_SET_RETVAL(call->data, ELIMIT); |
| 398 | ipc_answer(box, call); |
406 | ipc_answer(box, call); |
| 399 | return -1; |
407 | return -1; |
| 400 | } |
408 | } |
| 401 | IPC_SET_ARG5(call->data, phoneid); |
409 | IPC_SET_ARG5(call->data, phoneid); |
| 402 | } |
410 | } |
| - | 411 | switch (IPC_GET_METHOD(call->data)) { |
|
| - | 412 | case IPC_M_DEBUG_ALL: |
|
| - | 413 | return -1; |
|
| - | 414 | default: |
|
| - | 415 | break; |
|
| - | 416 | } |
|
| 403 | return 0; |
417 | return 0; |
| 404 | } |
418 | } |
| 405 | 419 | ||
| 406 | /** Make a fast call over IPC, wait for reply and return to user. |
420 | /** Make a fast call over IPC, wait for reply and return to user. |
| 407 | * |
421 | * |
| Line 439... | Line 453... | ||
| 439 | * the limits of the fast version. |
453 | * the limits of the fast version. |
| 440 | */ |
454 | */ |
| 441 | IPC_SET_ARG4(call.data, 0); |
455 | IPC_SET_ARG4(call.data, 0); |
| 442 | IPC_SET_ARG5(call.data, 0); |
456 | IPC_SET_ARG5(call.data, 0); |
| 443 | 457 | ||
| 444 | if (!(res = request_preprocess(&call))) { |
458 | if (!(res = request_preprocess(&call, phone))) { |
| 445 | rc = ipc_call_sync(phone, &call); |
459 | rc = ipc_call_sync(phone, &call); |
| 446 | if (rc != EOK) |
460 | if (rc != EOK) |
| 447 | return rc; |
461 | return rc; |
| 448 | process_answer(&call); |
462 | process_answer(&call); |
| 449 | } else { |
463 | } else { |
| Line 479... | Line 493... | ||
| 479 | if (rc != 0) |
493 | if (rc != 0) |
| 480 | return (unative_t) rc; |
494 | return (unative_t) rc; |
| 481 | 495 | ||
| 482 | GET_CHECK_PHONE(phone, phoneid, return ENOENT); |
496 | GET_CHECK_PHONE(phone, phoneid, return ENOENT); |
| 483 | 497 | ||
| 484 | if (!(res = request_preprocess(&call))) { |
498 | if (!(res = request_preprocess(&call, phone))) { |
| 485 | rc = ipc_call_sync(phone, &call); |
499 | rc = ipc_call_sync(phone, &call); |
| 486 | if (rc != EOK) |
500 | if (rc != EOK) |
| 487 | return rc; |
501 | return rc; |
| 488 | process_answer(&call); |
502 | process_answer(&call); |
| 489 | } else |
503 | } else |
| Line 548... | Line 562... | ||
| 548 | * To achieve deterministic behavior, zero out arguments that are beyond |
562 | * To achieve deterministic behavior, zero out arguments that are beyond |
| 549 | * the limits of the fast version. |
563 | * the limits of the fast version. |
| 550 | */ |
564 | */ |
| 551 | IPC_SET_ARG5(call->data, 0); |
565 | IPC_SET_ARG5(call->data, 0); |
| 552 | 566 | ||
| 553 | if (!(res = request_preprocess(call))) |
567 | if (!(res = request_preprocess(call, phone))) |
| 554 | ipc_call(phone, call); |
568 | ipc_call(phone, call); |
| 555 | else |
569 | else |
| 556 | ipc_backsend_err(phone, call, res); |
570 | ipc_backsend_err(phone, call, res); |
| 557 | 571 | ||
| 558 | return (unative_t) call; |
572 | return (unative_t) call; |
| Line 582... | Line 596... | ||
| 582 | sizeof(call->data.args)); |
596 | sizeof(call->data.args)); |
| 583 | if (rc != 0) { |
597 | if (rc != 0) { |
| 584 | ipc_call_free(call); |
598 | ipc_call_free(call); |
| 585 | return (unative_t) rc; |
599 | return (unative_t) rc; |
| 586 | } |
600 | } |
| 587 | if (!(res = request_preprocess(call))) |
601 | if (!(res = request_preprocess(call, phone))) |
| 588 | ipc_call(phone, call); |
602 | ipc_call(phone, call); |
| 589 | else |
603 | else |
| 590 | ipc_backsend_err(phone, call, res); |
604 | ipc_backsend_err(phone, call, res); |
| 591 | 605 | ||
| 592 | return (unative_t) call; |
606 | return (unative_t) call; |
| Line 866... | Line 880... | ||
| 866 | ipc_irq_unregister(&TASK->answerbox, inr, devno); |
880 | ipc_irq_unregister(&TASK->answerbox, inr, devno); |
| 867 | 881 | ||
| 868 | return 0; |
882 | return 0; |
| 869 | } |
883 | } |
| 870 | 884 | ||
| - | 885 | #include <console/console.h> |
|
| - | 886 | ||
| - | 887 | /** |
|
| - | 888 | * Syscall connect to a task by id. |
|
| - | 889 | * |
|
| - | 890 | * @return Phone id on success, or negative error code. |
|
| - | 891 | */ |
|
| - | 892 | unative_t sys_ipc_connect_kbox(sysarg64_t *uspace_taskid_arg) |
|
| - | 893 | { |
|
| - | 894 | #ifdef CONFIG_UDEBUG |
|
| - | 895 | sysarg64_t taskid_arg; |
|
| - | 896 | int rc; |
|
| - | 897 | ||
| - | 898 | rc = copy_from_uspace(&taskid_arg, uspace_taskid_arg, sizeof(sysarg64_t)); |
|
| - | 899 | if (rc != 0) |
|
| - | 900 | return (unative_t) rc; |
|
| - | 901 | ||
| - | 902 | printf("sys_ipc_connect_kbox(%lld, %d)\n", taskid_arg.value); |
|
| - | 903 | ||
| - | 904 | return ipc_connect_kbox(taskid_arg.value); |
|
| - | 905 | #else |
|
| - | 906 | return (unative_t) ENOTSUP; |
|
| - | 907 | #endif |
|
| - | 908 | } |
|
| - | 909 | ||
| 871 | /** @} |
910 | /** @} |
| 872 | */ |
911 | */ |