Changeset be79a663 in mainline for kernel/generic/src/ipc/sysipc.c


Ignore:
Timestamp:
2011-08-19T17:37:54Z (13 years ago)
Author:
Petr Koupy <petr.koupy@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ac7c7e36
Parents:
d7427a7e (diff), f00af83 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge libposix changes.

File:
1 edited

Legend:

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

    rd7427a7e rbe79a663  
    4444#include <ipc/irq.h>
    4545#include <ipc/ipcrsc.h>
     46#include <ipc/event.h>
    4647#include <ipc/kbox.h>
    4748#include <synch/waitq.h>
     
    5354#include <mm/as.h>
    5455#include <print.h>
     56#include <macros.h>
    5557
    5658/**
     
    134136        case IPC_M_DATA_WRITE:
    135137        case IPC_M_DATA_READ:
     138        case IPC_M_STATE_CHANGE_AUTHORIZE:
    136139                return true;
    137140        default:
     
    164167        case IPC_M_DATA_WRITE:
    165168        case IPC_M_DATA_READ:
     169        case IPC_M_STATE_CHANGE_AUTHORIZE:
    166170                return true;
    167171        default:
     
    249253                        /* The connection was accepted */
    250254                        phone_connect(phoneid, &answer->sender->answerbox);
    251                         /* Set 'task hash' as arg4 of response */
    252                         IPC_SET_ARG4(answer->data, (sysarg_t) TASK);
     255                        /* Set 'task ID' as arg3 and arg4 of response */
     256                        IPC_SET_ARG3(answer->data, LOWER32(TASK->taskid));
     257                        IPC_SET_ARG4(answer->data, UPPER32(TASK->taskid));
    253258                        /* Set 'phone hash' as arg5 of response */
    254259                        IPC_SET_ARG5(answer->data,
     
    334339                free(answer->buffer);
    335340                answer->buffer = NULL;
     341        } else if (IPC_GET_IMETHOD(*olddata) == IPC_M_STATE_CHANGE_AUTHORIZE) {
     342                if (!IPC_GET_RETVAL(answer->data)) {
     343                        /* The recipient authorized the change of state. */
     344                        phone_t *recipient_phone;
     345                        task_t *other_task_s;
     346                        task_t *other_task_r;
     347                        int rc;
     348
     349                        rc = phone_get(IPC_GET_ARG1(answer->data),
     350                            &recipient_phone);
     351                        if (rc != EOK) {
     352                                IPC_SET_RETVAL(answer->data, ENOENT);
     353                                return ENOENT;
     354                        }
     355
     356                        mutex_lock(&recipient_phone->lock);
     357                        if (recipient_phone->state != IPC_PHONE_CONNECTED) {
     358                                mutex_unlock(&recipient_phone->lock);
     359                                IPC_SET_RETVAL(answer->data, EINVAL);
     360                                return EINVAL;
     361                        }
     362
     363                        other_task_r = recipient_phone->callee->task;
     364                        other_task_s = (task_t *) IPC_GET_ARG5(*olddata);
     365
     366                        /*
     367                         * See if both the sender and the recipient meant the
     368                         * same third party task.
     369                         */
     370                        if (other_task_r != other_task_s) {
     371                                IPC_SET_RETVAL(answer->data, EINVAL);
     372                                rc = EINVAL;
     373                        } else {
     374                                rc = event_task_notify_5(other_task_r,
     375                                    EVENT_TASK_STATE_CHANGE, false,
     376                                    IPC_GET_ARG1(*olddata),
     377                                    IPC_GET_ARG2(*olddata),
     378                                    IPC_GET_ARG3(*olddata),
     379                                    LOWER32(olddata->task_id),
     380                                    UPPER32(olddata->task_id));
     381                                IPC_SET_RETVAL(answer->data, rc);
     382                        }
     383
     384                        mutex_unlock(&recipient_phone->lock);
     385                        return rc;
     386                }
    336387        }
    337388       
     
    456507                }
    457508               
     509                break;
     510        }
     511        case IPC_M_STATE_CHANGE_AUTHORIZE: {
     512                phone_t *sender_phone;
     513                task_t *other_task_s;
     514
     515                if (phone_get(IPC_GET_ARG5(call->data), &sender_phone) != EOK)
     516                        return ENOENT;
     517
     518                mutex_lock(&sender_phone->lock);
     519                if (sender_phone->state != IPC_PHONE_CONNECTED) {
     520                        mutex_unlock(&sender_phone->lock);
     521                        return EINVAL;
     522                }
     523
     524                other_task_s = sender_phone->callee->task;
     525
     526                mutex_unlock(&sender_phone->lock);
     527
     528                /* Remember the third party task hash. */
     529                IPC_SET_ARG5(call->data, (sysarg_t) other_task_s);
    458530                break;
    459531        }
Note: See TracChangeset for help on using the changeset viewer.