Subversion Repositories HelenOS

Rev

Rev 3403 | Rev 3474 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3403 Rev 3448
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 866... Line 879...
866
    ipc_irq_unregister(&TASK->answerbox, inr, devno);
879
    ipc_irq_unregister(&TASK->answerbox, inr, devno);
867
 
880
 
868
    return 0;
881
    return 0;
869
}
882
}
870
 
883
 
-
 
884
#include <console/console.h>
-
 
885
 
-
 
886
/**
-
 
887
 * Syscall connect to a task by id.
-
 
888
 *
-
 
889
 * @return      Phone id on success, or negative error code.
-
 
890
 */
-
 
891
unative_t sys_ipc_connect_kbox(sysarg64_t *uspace_taskid_arg)
-
 
892
{
-
 
893
#ifdef CONFIG_UDEBUG
-
 
894
    sysarg64_t taskid_arg;
-
 
895
    int rc;
-
 
896
   
-
 
897
    rc = copy_from_uspace(&taskid_arg, uspace_taskid_arg, sizeof(sysarg64_t));
-
 
898
    if (rc != 0)
-
 
899
        return (unative_t) rc;
-
 
900
 
-
 
901
    LOG("sys_ipc_connect_kbox(%" PRIu64 ")\n", taskid_arg.value);
-
 
902
 
-
 
903
    return ipc_connect_kbox(taskid_arg.value);
-
 
904
#else
-
 
905
    return (unative_t) ENOTSUP;
-
 
906
#endif
-
 
907
}
-
 
908
 
871
/** @}
909
/** @}
872
 */
910
 */