Ignore:
Timestamp:
2012-08-20T23:21:41Z (12 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0343a1b
Parents:
642dc72
Message:

Separate system IPC logic into dedicated ops structure hooks.

File:
1 edited

Legend:

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

    r642dc72 re8039a86  
    11/*
     2 * Copyright (c) 2006 Ondrej Palkovsky
    23 * Copyright (c) 2012 Jakub Jermar
    34 * All rights reserved.
     
    3435
    3536#include <ipc/sysipc_ops.h>
     37#include <ipc/ipc.h>
     38#include <ipc/ipcrsc.h>
     39#include <abi/errno.h>
     40#include <arch.h>
     41
     42static int request_process(call_t *call, answerbox_t *box)
     43{
     44        int phoneid = phone_alloc(TASK);
     45
     46        if (phoneid < 0) {  /* Failed to allocate phone */
     47                IPC_SET_RETVAL(call->data, ELIMIT);
     48                ipc_answer(box, call);
     49                return -1;
     50        }
     51               
     52        IPC_SET_ARG5(call->data, phoneid);
     53       
     54        return EOK;
     55}
     56
     57static int answer_preprocess(call_t *answer, ipc_data_t *olddata)
     58{
     59        int phoneid = (int) IPC_GET_ARG5(*olddata);
     60
     61        if (IPC_GET_RETVAL(answer->data) != EOK) {
     62                /* The connection was not accepted */
     63                int phoneid = (int) IPC_GET_ARG5(*olddata);
     64       
     65                phone_dealloc(phoneid);
     66        } else {
     67                /* The connection was accepted */
     68                phone_connect(phoneid, &answer->sender->answerbox);
     69                /* Set 'phone hash' as arg5 of response */
     70                IPC_SET_ARG5(answer->data, (sysarg_t) &TASK->phones[phoneid]);
     71        }
     72
     73        return EOK;
     74}
     75
    3676
    3777sysipc_ops_t ipc_m_connect_to_me_ops = {
    3878        .request_preprocess = null_request_preprocess,
    39         .request_process = null_request_process,
    40         .answer_preprocess = null_answer_preprocess,
     79        .request_process = request_process,
     80        .answer_preprocess = answer_preprocess,
    4181        .answer_process = null_answer_process,
    4282};
Note: See TracChangeset for help on using the changeset viewer.