Subversion Repositories HelenOS

Rev

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

Rev 3191 Rev 3403
Line 169... Line 169...
169
 
169
 
170
/** Helper function to facilitate synchronous calls.
170
/** Helper function to facilitate synchronous calls.
171
 *
171
 *
172
 * @param phone     Destination kernel phone structure.
172
 * @param phone     Destination kernel phone structure.
173
 * @param request   Call structure with request.
173
 * @param request   Call structure with request.
-
 
174
 *
-
 
175
 * @return      EOK on success or EINTR if the sleep was interrupted.
174
 */
176
 */
175
void ipc_call_sync(phone_t *phone, call_t *request)
177
int ipc_call_sync(phone_t *phone, call_t *request)
176
{
178
{
177
    answerbox_t sync_box;
179
    answerbox_t sync_box;
178
 
180
 
179
    ipc_answerbox_init(&sync_box, TASK);
181
    ipc_answerbox_init(&sync_box, TASK);
180
 
182
 
181
    /* We will receive data in a special box. */
183
    /* We will receive data in a special box. */
182
    request->callerbox = &sync_box;
184
    request->callerbox = &sync_box;
183
 
185
 
184
    ipc_call(phone, request);
186
    ipc_call(phone, request);
185
    ipc_wait_for_call(&sync_box, SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE);
187
    if (!ipc_wait_for_call(&sync_box, SYNCH_NO_TIMEOUT,
-
 
188
        SYNCH_FLAGS_INTERRUPTIBLE))
-
 
189
        return EINTR;
-
 
190
    return EOK;
186
}
191
}
187
 
192
 
188
/** Answer a message which was not dispatched and is not listed in any queue.
193
/** Answer a message which was not dispatched and is not listed in any queue.
189
 *
194
 *
190
 * @param call      Call structure to be answered.
195
 * @param call      Call structure to be answered.
Line 193... Line 198...
193
{
198
{
194
    answerbox_t *callerbox = call->callerbox;
199
    answerbox_t *callerbox = call->callerbox;
195
 
200
 
196
    call->flags |= IPC_CALL_ANSWERED;
201
    call->flags |= IPC_CALL_ANSWERED;
197
 
202
 
-
 
203
    if (call->flags & IPC_CALL_FORWARDED) {
-
 
204
        if (call->caller_phone) {
-
 
205
            /* Demasquerade the caller phone. */
-
 
206
            call->data.phone = call->caller_phone;
-
 
207
        }
-
 
208
    }
-
 
209
 
198
    spinlock_lock(&callerbox->lock);
210
    spinlock_lock(&callerbox->lock);
199
    list_append(&call->link, &callerbox->answers);
211
    list_append(&call->link, &callerbox->answers);
200
    spinlock_unlock(&callerbox->lock);
212
    spinlock_unlock(&callerbox->lock);
201
    waitq_wakeup(&callerbox->wq, WAKEUP_FIRST);
213
    waitq_wakeup(&callerbox->wq, WAKEUP_FIRST);
202
}
214
}
Line 345... Line 357...
345
{
357
{
346
    spinlock_lock(&oldbox->lock);
358
    spinlock_lock(&oldbox->lock);
347
    list_remove(&call->link);
359
    list_remove(&call->link);
348
    spinlock_unlock(&oldbox->lock);
360
    spinlock_unlock(&oldbox->lock);
349
 
361
 
350
    if (mode & IPC_FF_ROUTE_FROM_ME)
362
    if (mode & IPC_FF_ROUTE_FROM_ME) {
-
 
363
        if (!call->caller_phone)
-
 
364
            call->caller_phone = call->data.phone;
351
        call->data.phone = newphone;
365
        call->data.phone = newphone;
-
 
366
    }
352
 
367
 
353
    return ipc_call(newphone, call);
368
    return ipc_call(newphone, call);
354
}
369
}
355
 
370
 
356
 
371
 
Line 575... Line 590...
575
    printf("ABOX - CALLS:\n");
590
    printf("ABOX - CALLS:\n");
576
    for (tmp = task->answerbox.calls.next; tmp != &task->answerbox.calls;
591
    for (tmp = task->answerbox.calls.next; tmp != &task->answerbox.calls;
577
        tmp = tmp->next) {
592
        tmp = tmp->next) {
578
        call = list_get_instance(tmp, call_t, link);
593
        call = list_get_instance(tmp, call_t, link);
579
        printf("Callid: %p Srctask:%" PRIu64 " M:%" PRIun
594
        printf("Callid: %p Srctask:%" PRIu64 " M:%" PRIun
580
            " A1:%" PRIun " A2:%" PRIun " A3:%" PRIun
595
            " A1:%" PRIun " A2:%" PRIun " A3:%" PRIun
581
            " A4:%" PRIun " A5:%" PRIun " Flags:%x\n", call, call->sender->taskid,
596
            " A4:%" PRIun " A5:%" PRIun " Flags:%x\n", call,
-
 
597
            call->sender->taskid,
582
            IPC_GET_METHOD(call->data), IPC_GET_ARG1(call->data),
598
            IPC_GET_METHOD(call->data), IPC_GET_ARG1(call->data),
583
            IPC_GET_ARG2(call->data), IPC_GET_ARG3(call->data),
599
            IPC_GET_ARG2(call->data), IPC_GET_ARG3(call->data),
584
            IPC_GET_ARG4(call->data), IPC_GET_ARG5(call->data),
600
            IPC_GET_ARG4(call->data), IPC_GET_ARG5(call->data),
585
            call->flags);
601
            call->flags);
586
    }
602
    }
Line 589... Line 605...
589
    for (tmp = task->answerbox.dispatched_calls.next;
605
    for (tmp = task->answerbox.dispatched_calls.next;
590
        tmp != &task->answerbox.dispatched_calls;
606
        tmp != &task->answerbox.dispatched_calls;
591
        tmp = tmp->next) {
607
        tmp = tmp->next) {
592
        call = list_get_instance(tmp, call_t, link);
608
        call = list_get_instance(tmp, call_t, link);
593
        printf("Callid: %p Srctask:%" PRIu64 " M:%" PRIun
609
        printf("Callid: %p Srctask:%" PRIu64 " M:%" PRIun
594
            " A1:%" PRIun " A2:%" PRIun " A3:%" PRIun
610
            " A1:%" PRIun " A2:%" PRIun " A3:%" PRIun
595
            " A4:%" PRIun " A5:%" PRIun " Flags:%x\n", call, call->sender->taskid,
611
            " A4:%" PRIun " A5:%" PRIun " Flags:%x\n", call,
-
 
612
            call->sender->taskid,
596
            IPC_GET_METHOD(call->data), IPC_GET_ARG1(call->data),
613
            IPC_GET_METHOD(call->data), IPC_GET_ARG1(call->data),
597
            IPC_GET_ARG2(call->data), IPC_GET_ARG3(call->data),
614
            IPC_GET_ARG2(call->data), IPC_GET_ARG3(call->data),
598
            IPC_GET_ARG4(call->data), IPC_GET_ARG5(call->data),
615
            IPC_GET_ARG4(call->data), IPC_GET_ARG5(call->data),
599
            call->flags);
616
            call->flags);
600
    }
617
    }
601
    /* Print answerbox - calls */
618
    /* Print answerbox - calls */
602
    printf("ABOX - ANSWERS:\n");
619
    printf("ABOX - ANSWERS:\n");
603
    for (tmp = task->answerbox.answers.next; tmp != &task->answerbox.answers;
620
    for (tmp = task->answerbox.answers.next;
-
 
621
        tmp != &task->answerbox.answers;
604
        tmp = tmp->next) {
622
        tmp = tmp->next) {
605
        call = list_get_instance(tmp, call_t, link);
623
        call = list_get_instance(tmp, call_t, link);
606
        printf("Callid:%p M:%" PRIun " A1:%" PRIun " A2:%" PRIun
624
        printf("Callid:%p M:%" PRIun " A1:%" PRIun " A2:%" PRIun
607
            " A3:%" PRIun " A4:%" PRIun " A5:%" PRIun " Flags:%x\n",
625
            " A3:%" PRIun " A4:%" PRIun " A5:%" PRIun " Flags:%x\n",
608
            call, IPC_GET_METHOD(call->data), IPC_GET_ARG1(call->data),
626
            call, IPC_GET_METHOD(call->data), IPC_GET_ARG1(call->data),
609
            IPC_GET_ARG2(call->data), IPC_GET_ARG3(call->data),
627
            IPC_GET_ARG2(call->data), IPC_GET_ARG3(call->data),
610
            IPC_GET_ARG4(call->data), IPC_GET_ARG5(call->data),
628
            IPC_GET_ARG4(call->data), IPC_GET_ARG5(call->data),
611
            call->flags);
629
            call->flags);
612
    }
630
    }