Rev 2787 | Rev 2804 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2787 | Rev 2801 | ||
---|---|---|---|
Line 288... | Line 288... | ||
288 | answer->buffer = NULL; |
288 | answer->buffer = NULL; |
289 | } |
289 | } |
290 | return 0; |
290 | return 0; |
291 | } |
291 | } |
292 | 292 | ||
- | 293 | static task_t *get_lock_callee_task(phone_t *phone) |
|
- | 294 | { |
|
- | 295 | answerbox_t *answerbox; |
|
- | 296 | task_t *ta; |
|
- | 297 | ||
- | 298 | // FIXME: locking!!! |
|
- | 299 | ||
- | 300 | answerbox = phone->callee; |
|
- | 301 | ta = answerbox->task; |
|
- | 302 | ||
- | 303 | spinlock_lock(&ta->lock); |
|
- | 304 | ||
- | 305 | return ta; |
|
- | 306 | } |
|
- | 307 | ||
- | 308 | #include <console/klog.h> |
|
- | 309 | ||
- | 310 | static void debug_begin(call_t *call, phone_t *phone) |
|
- | 311 | { |
|
- | 312 | task_t *ta; |
|
- | 313 | ||
- | 314 | klog_printf("debug_begin()"); |
|
- | 315 | ||
- | 316 | ta = get_lock_callee_task(phone); |
|
- | 317 | klog_printf("debugging task %llu\n", ta->taskid); |
|
- | 318 | ||
- | 319 | if (ta->being_debugged != false) { |
|
- | 320 | IPC_SET_RETVAL(call->data, EBUSY); |
|
- | 321 | ipc_answer(&ta->answerbox, call); |
|
- | 322 | ||
- | 323 | spinlock_unlock(&ta->lock); |
|
- | 324 | return; |
|
- | 325 | } |
|
- | 326 | ||
- | 327 | ta->being_debugged = true; |
|
- | 328 | ta->stop_request = true; |
|
- | 329 | ta->debug_begin_call = call; |
|
- | 330 | spinlock_unlock(&ta->lock); |
|
- | 331 | ||
- | 332 | klog_printf("debug_begin() done"); |
|
- | 333 | } |
|
- | 334 | ||
- | 335 | static void debug_go(call_t *call, phone_t *phone) |
|
- | 336 | { |
|
- | 337 | thread_t *t; |
|
- | 338 | link_t *l; |
|
- | 339 | task_t *ta; |
|
- | 340 | ||
- | 341 | klog_printf("debug_go()"); |
|
- | 342 | ta = get_lock_callee_task(phone); |
|
- | 343 | ||
- | 344 | l = ta->th_head.next; |
|
- | 345 | if (l != &TASK->th_head) { |
|
- | 346 | t = list_get_instance(l, thread_t, th_link); |
|
- | 347 | waitq_wakeup(&t->go_wq, WAKEUP_FIRST); |
|
- | 348 | } |
|
- | 349 | ||
- | 350 | ta->debug_go_call = call; |
|
- | 351 | spinlock_unlock(&ta->lock); |
|
- | 352 | } |
|
- | 353 | ||
- | 354 | ||
293 | /** Called before the request is sent. |
355 | /** Called before the request is sent. |
294 | * |
356 | * |
295 | * @param call Call structure with the request. |
357 | * @param call Call structure with the request. |
- | 358 | * @param phone Phone that the call will be sent through. |
|
296 | * |
359 | * |
297 | * @return Return 0 on success, ELIMIT or EPERM on error. |
360 | * @return Return 0 on success, ELIMIT or EPERM on error. |
298 | */ |
361 | */ |
299 | static int request_preprocess(call_t *call) |
362 | static int request_preprocess(call_t *call, phone_t *phone) |
300 | { |
363 | { |
301 | int newphid; |
364 | int newphid; |
302 | size_t size; |
365 | size_t size; |
303 | uintptr_t src; |
366 | uintptr_t src; |
304 | int rc; |
367 | int rc; |
Line 336... | Line 399... | ||
336 | if (rc != 0) { |
399 | if (rc != 0) { |
337 | free(call->buffer); |
400 | free(call->buffer); |
338 | return rc; |
401 | return rc; |
339 | } |
402 | } |
340 | break; |
403 | break; |
- | 404 | case IPC_M_DEBUG_BEGIN: |
|
- | 405 | debug_begin(call, phone); |
|
- | 406 | break; |
|
- | 407 | case IPC_M_DEBUG_GO: |
|
- | 408 | debug_go(call, phone); |
|
- | 409 | break; |
|
341 | default: |
410 | default: |
342 | break; |
411 | break; |
343 | } |
412 | } |
344 | return 0; |
413 | return 0; |
345 | } |
414 | } |
Line 395... | Line 464... | ||
395 | IPC_SET_RETVAL(call->data, ELIMIT); |
464 | IPC_SET_RETVAL(call->data, ELIMIT); |
396 | ipc_answer(box, call); |
465 | ipc_answer(box, call); |
397 | return -1; |
466 | return -1; |
398 | } |
467 | } |
399 | IPC_SET_ARG5(call->data, phoneid); |
468 | IPC_SET_ARG5(call->data, phoneid); |
400 | } |
469 | } |
- | 470 | switch (IPC_GET_METHOD(call->data)) { |
|
- | 471 | case IPC_M_DEBUG_BEGIN: |
|
- | 472 | case IPC_M_DEBUG_END: |
|
- | 473 | case IPC_M_DEBUG_GO: |
|
- | 474 | case IPC_M_DEBUG_STOP: |
|
- | 475 | case IPC_M_DEBUG_GUARD: |
|
- | 476 | return -1; |
|
- | 477 | default: |
|
- | 478 | break; |
|
- | 479 | } |
|
401 | return 0; |
480 | return 0; |
402 | } |
481 | } |
403 | 482 | ||
404 | /** Make a fast call over IPC, wait for reply and return to user. |
483 | /** Make a fast call over IPC, wait for reply and return to user. |
405 | * |
484 | * |
Line 437... | Line 516... | ||
437 | * the limits of the fast version. |
516 | * the limits of the fast version. |
438 | */ |
517 | */ |
439 | IPC_SET_ARG4(call.data, 0); |
518 | IPC_SET_ARG4(call.data, 0); |
440 | IPC_SET_ARG5(call.data, 0); |
519 | IPC_SET_ARG5(call.data, 0); |
441 | 520 | ||
442 | if (!(res = request_preprocess(&call))) { |
521 | if (!(res = request_preprocess(&call, phone))) { |
443 | ipc_call_sync(phone, &call); |
522 | ipc_call_sync(phone, &call); |
444 | process_answer(&call); |
523 | process_answer(&call); |
445 | } else { |
524 | } else { |
446 | IPC_SET_RETVAL(call.data, res); |
525 | IPC_SET_RETVAL(call.data, res); |
447 | } |
526 | } |
Line 475... | Line 554... | ||
475 | if (rc != 0) |
554 | if (rc != 0) |
476 | return (unative_t) rc; |
555 | return (unative_t) rc; |
477 | 556 | ||
478 | GET_CHECK_PHONE(phone, phoneid, return ENOENT); |
557 | GET_CHECK_PHONE(phone, phoneid, return ENOENT); |
479 | 558 | ||
480 | if (!(res = request_preprocess(&call))) { |
559 | if (!(res = request_preprocess(&call, phone))) { |
481 | ipc_call_sync(phone, &call); |
560 | ipc_call_sync(phone, &call); |
482 | process_answer(&call); |
561 | process_answer(&call); |
483 | } else |
562 | } else |
484 | IPC_SET_RETVAL(call.data, res); |
563 | IPC_SET_RETVAL(call.data, res); |
485 | 564 | ||
Line 542... | Line 621... | ||
542 | * To achieve deterministic behavior, zero out arguments that are beyond |
621 | * To achieve deterministic behavior, zero out arguments that are beyond |
543 | * the limits of the fast version. |
622 | * the limits of the fast version. |
544 | */ |
623 | */ |
545 | IPC_SET_ARG5(call->data, 0); |
624 | IPC_SET_ARG5(call->data, 0); |
546 | 625 | ||
547 | if (!(res = request_preprocess(call))) |
626 | if (!(res = request_preprocess(call, phone))) |
548 | ipc_call(phone, call); |
627 | ipc_call(phone, call); |
549 | else |
628 | else |
550 | ipc_backsend_err(phone, call, res); |
629 | ipc_backsend_err(phone, call, res); |
551 | 630 | ||
552 | return (unative_t) call; |
631 | return (unative_t) call; |
Line 576... | Line 655... | ||
576 | sizeof(call->data.args)); |
655 | sizeof(call->data.args)); |
577 | if (rc != 0) { |
656 | if (rc != 0) { |
578 | ipc_call_free(call); |
657 | ipc_call_free(call); |
579 | return (unative_t) rc; |
658 | return (unative_t) rc; |
580 | } |
659 | } |
581 | if (!(res = request_preprocess(call))) |
660 | if (!(res = request_preprocess(call, phone))) |
582 | ipc_call(phone, call); |
661 | ipc_call(phone, call); |
583 | else |
662 | else |
584 | ipc_backsend_err(phone, call, res); |
663 | ipc_backsend_err(phone, call, res); |
585 | 664 | ||
586 | return (unative_t) call; |
665 | return (unative_t) call; |
Line 860... | Line 939... | ||
860 | ipc_irq_unregister(&TASK->answerbox, inr, devno); |
939 | ipc_irq_unregister(&TASK->answerbox, inr, devno); |
861 | 940 | ||
862 | return 0; |
941 | return 0; |
863 | } |
942 | } |
864 | 943 | ||
- | 944 | #include <console/klog.h> |
|
- | 945 | ||
- | 946 | /** |
|
- | 947 | * Syscall connect to a task by id. |
|
- | 948 | * |
|
- | 949 | * @return Phone id on success, or negative error code. |
|
- | 950 | */ |
|
- | 951 | unative_t sys_ipc_connect_task(sysarg64_t *uspace_taskid_arg) |
|
- | 952 | { |
|
- | 953 | sysarg64_t taskid_arg; |
|
- | 954 | int rc; |
|
- | 955 | ||
- | 956 | rc = copy_from_uspace(&taskid_arg, uspace_taskid_arg, sizeof(sysarg64_t)); |
|
- | 957 | if (rc != 0) |
|
- | 958 | return (unative_t) rc; |
|
- | 959 | ||
- | 960 | klog_printf("sys_ipc_connect_kbox(%lld, %d)", taskid_arg.value); |
|
- | 961 | ||
- | 962 | return ipc_connect_task(taskid_arg.value); |
|
- | 963 | } |
|
- | 964 | ||
865 | /** @} |
965 | /** @} |
866 | */ |
966 | */ |