Changeset 05ffb41 in mainline for kernel/generic/src/ipc/ops


Ignore:
Timestamp:
2017-08-17T19:11:14Z (8 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1c85bae
Parents:
7e3826d9
Message:

Turn IPC phones into kobjects

Location:
kernel/generic/src/ipc/ops
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/ipc/ops/conctmeto.c

    r7e3826d9 r05ffb41  
    4242static int request_preprocess(call_t *call, phone_t *phone)
    4343{
    44         int newphid = phone_alloc(TASK);
     44        int cap = phone_alloc(TASK);
    4545
    46         /* Remember the phoneid or the error. */
    47         call->priv = newphid;
    48         if (newphid < 0)
     46        /* Remember the phone capability or the error. */
     47        call->priv = cap;
     48        if (cap < 0)
    4949                return ELIMIT;
    5050               
    5151        /* Set arg5 for server */
    52         IPC_SET_ARG5(call->data, (sysarg_t) &TASK->phones[newphid]);
     52        IPC_SET_ARG5(call->data, (sysarg_t) phone_get_current(cap));
    5353
    5454        return EOK;
     
    7474static int answer_process(call_t *answer)
    7575{
    76         int newphid = (int) answer->priv;
     76        int cap = (int) answer->priv;
    7777
    7878        if (IPC_GET_RETVAL(answer->data)) {
    79                 if (newphid >= 0) {
     79                if (cap >= 0) {
    8080                        /*
    8181                         * The phone was indeed allocated and now needs
    8282                         * to be deallocated.
    8383                         */
    84                         phone_dealloc(newphid);
     84                        phone_dealloc(cap);
    8585                }
    8686        } else {
    87                 IPC_SET_ARG5(answer->data, newphid);
     87                IPC_SET_ARG5(answer->data, cap);
    8888        }
    8989       
  • kernel/generic/src/ipc/ops/concttome.c

    r7e3826d9 r05ffb41  
    4242static int request_process(call_t *call, answerbox_t *box)
    4343{
    44         int phoneid = phone_alloc(TASK);
     44        int cap = phone_alloc(TASK);
    4545
    46         IPC_SET_ARG5(call->data, phoneid);
     46        IPC_SET_ARG5(call->data, cap);
    4747       
    4848        return EOK;
     
    5151static int answer_cleanup(call_t *answer, ipc_data_t *olddata)
    5252{
    53         int phoneid = (int) IPC_GET_ARG5(*olddata);
     53        int cap = (int) IPC_GET_ARG5(*olddata);
    5454
    55         if (phoneid >= 0)
    56                 phone_dealloc(phoneid);
     55        if (cap >= 0)
     56                phone_dealloc(cap);
    5757
    5858        return EOK;
     
    6161static int answer_preprocess(call_t *answer, ipc_data_t *olddata)
    6262{
    63         int phoneid = (int) IPC_GET_ARG5(*olddata);
     63        int cap = (int) IPC_GET_ARG5(*olddata);
    6464
    6565        if (IPC_GET_RETVAL(answer->data) != EOK) {
    6666                /* The connection was not accepted */
    6767                answer_cleanup(answer, olddata);
    68         } else if (phoneid >= 0) {
     68        } else if (cap >= 0) {
    6969                /* The connection was accepted */
    70                 if (phone_connect(phoneid, &answer->sender->answerbox)) {
     70                if (phone_connect(cap, &answer->sender->answerbox)) {
    7171                        /* Set 'phone hash' as arg5 of response */
    7272                        IPC_SET_ARG5(answer->data,
    73                             (sysarg_t) &TASK->phones[phoneid]);
     73                            (sysarg_t) phone_get_current(cap));
    7474                } else {
    7575                        /* The answerbox is shutting down. */
  • kernel/generic/src/ipc/ops/connclone.c

    r7e3826d9 r05ffb41  
    6161static int request_preprocess(call_t *call, phone_t *phone)
    6262{
    63         phone_t *cloned_phone;
    64 
    65         if (phone_get(IPC_GET_ARG1(call->data), &cloned_phone) != EOK)
     63        phone_t *cloned_phone = phone_get_current(IPC_GET_ARG1(call->data));
     64        if (!cloned_phone)
    6665                return ENOENT;
    67                
     66       
    6867        phones_lock(cloned_phone, phone);
    69                
     68       
    7069        if ((cloned_phone->state != IPC_PHONE_CONNECTED) ||
    7170            phone->state != IPC_PHONE_CONNECTED) {
     
    7372                return EINVAL;
    7473        }
    75                
     74       
    7675        /*
    7776         * We can be pretty sure now that both tasks exist and we are
     
    8180         *
    8281         */
    83         int newphid = phone_alloc(phone->callee->task);
    84         if (newphid < 0) {
     82        int cap = phone_alloc(phone->callee->task);
     83        if (cap < 0) {
    8584                phones_unlock(cloned_phone, phone);
    8685                return ELIMIT;
    8786        }
    88                
    89         (void) ipc_phone_connect(&phone->callee->task->phones[newphid],
     87       
     88        (void) ipc_phone_connect(phone_get(phone->callee->task, cap),
    9089            cloned_phone->callee);
    9190        phones_unlock(cloned_phone, phone);
    92                
     91       
    9392        /* Set the new phone for the callee. */
    94         IPC_SET_ARG1(call->data, newphid);
     93        IPC_SET_ARG1(call->data, cap);
    9594
    9695        return EOK;
     
    9998static int answer_cleanup(call_t *answer, ipc_data_t *olddata)
    10099{
    101         int phoneid = (int) IPC_GET_ARG1(*olddata);
    102         phone_t *phone = &TASK->phones[phoneid];
     100        int cap = (int) IPC_GET_ARG1(*olddata);
     101        phone_t *phone = phone_get_current(cap);
    103102
    104103        /*
  • kernel/generic/src/ipc/ops/stchngath.c

    r7e3826d9 r05ffb41  
    4343static int request_preprocess(call_t *call, phone_t *phone)
    4444{
    45         phone_t *sender_phone;
    4645        task_t *other_task_s;
    4746
    48         if (phone_get(IPC_GET_ARG5(call->data), &sender_phone) != EOK)
     47        phone_t *sender_phone = phone_get_current(IPC_GET_ARG5(call->data));
     48        if (!sender_phone)
    4949                return ENOENT;
    5050
     
    7575                task_t *other_task_r;
    7676
    77                 rc = phone_get(IPC_GET_ARG1(answer->data),
    78                     &recipient_phone);
    79                 if (rc != EOK) {
     77                recipient_phone = phone_get_current(IPC_GET_ARG1(answer->data));
     78                if (!recipient_phone) {
    8079                        IPC_SET_RETVAL(answer->data, ENOENT);
    8180                        return ENOENT;
Note: See TracChangeset for help on using the changeset viewer.