Changeset 37c57f2 in mainline for generic/src/ipc/sysipc.c


Ignore:
Timestamp:
2006-03-16T20:56:22Z (19 years ago)
Author:
Ondrej Palkovsky <ondrap@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ff14c520
Parents:
6a22fcb
Message:

Added task_print.
Fixed ipc to support connect_me_to.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • generic/src/ipc/sysipc.c

    r6a22fcb r37c57f2  
    3636#include <ipc/ipc.h>
    3737#include <ipc/sysipc.h>
     38
     39
    3840#include <print.h>
     41#include <arch.h>
     42#include <proc/thread.h>
    3943
    4044/* TODO: multi-threaded connect-to-me can cause race condition
     
    138142{
    139143        if (IPC_GET_METHOD(call->data) == IPC_M_CONNECTTOME)
     144                return 1;
     145        if (IPC_GET_METHOD(call->data) == IPC_M_CONNECTMETO)
    140146                return 1;
    141147        return 0;
     
    156162                        phone_connect(phoneid,&answer->sender->answerbox);
    157163                }
     164        } else if (IPC_GET_METHOD(*olddata) == IPC_M_CONNECTMETO) {
     165                /* If the users accepted call, connect */
     166                if (!IPC_GET_RETVAL(answer->data)) {
     167                        printf("Connecting Phone %P\n",IPC_GET_ARG3(*olddata));
     168                        ipc_phone_connect((phone_t *)IPC_GET_ARG3(*olddata),
     169                                          &TASK->answerbox);
     170                }
    158171        }
    159172}
     
    319332 *
    320333 * The arg1 and arg2 are changed in the forwarded message
     334 *
     335 * Warning: If implementing non-fast version, make sure that
     336 *          arg3 is not rewritten for certain system IPC
    321337 */
    322338__native sys_ipc_forward_fast(__native callid, __native phoneid,
     
    437453                               &phone->callee->task->taskid,
    438454                               sizeof(TASK->taskid));
     455
    439456        return IPC_GET_RETVAL(call.data);
    440457}
     
    449466        call_t call;
    450467        phone_t *phone;
     468        int newphid;
    451469
    452470        phone = get_phone(phoneid);
    453471        if (!phone)
    454472                return ENOENT;
     473
     474        newphid = phone_alloc();
     475        if (newphid < 0)
     476                return ELIMIT;
    455477
    456478        ipc_call_init(&call);
     
    458480        IPC_SET_ARG1(call.data, arg1);
    459481        IPC_SET_ARG2(call.data, arg2);
     482        IPC_SET_ARG3(call.data, (__native)&TASK->phones[newphid]);
    460483
    461484        ipc_call_sync(phone, &call);
    462         if (!IPC_GET_RETVAL(call.data)) {
    463                 /* Everybody accepted, we should be connected by now */
    464         }
    465 
    466         return 0;
     485
     486        if (IPC_GET_RETVAL(call.data)) { /* Connection failed */
     487                phone_dealloc(newphid);
     488                return IPC_GET_RETVAL(call.data);
     489        }
     490
     491        return newphid;
    467492}
    468493
     
    486511restart:       
    487512        call = ipc_wait_for_call(&TASK->answerbox, flags);
    488         printf("Received call %P from sender: %P\n", call, call->sender);
    489513
    490514        if (call->flags & IPC_CALL_ANSWERED) {
Note: See TracChangeset for help on using the changeset viewer.