Changeset 2c2d54a in mainline for kernel/generic/src/ipc


Ignore:
Timestamp:
2016-09-02T17:58:05Z (9 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4c3602c4
Parents:
4bf0926e (diff), 3233adb (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 from lp:~jakub/helenos/pager

Location:
kernel/generic/src/ipc
Files:
1 added
3 edited

Legend:

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

    r4bf0926e r2c2d54a  
    7777        call->forget = false;
    7878        call->sender = NULL;
     79        call->callerbox = &TASK->answerbox;
    7980        call->buffer = NULL;
    8081}
     
    185186        phone->state = IPC_PHONE_FREE;
    186187        atomic_set(&phone->active_calls, 0);
     188}
     189
     190/** Helper function to facilitate synchronous calls.
     191 *
     192 * @param phone   Destination kernel phone structure.
     193 * @param request Call structure with request.
     194 *
     195 * @return EOK on success or a negative error code.
     196 *
     197 */
     198int ipc_call_sync(phone_t *phone, call_t *request)
     199{
     200        answerbox_t *mybox = slab_alloc(ipc_answerbox_slab, 0);
     201        ipc_answerbox_init(mybox, TASK);
     202       
     203        /* We will receive data in a special box. */
     204        request->callerbox = mybox;
     205       
     206        int rc = ipc_call(phone, request);
     207        if (rc != EOK) {
     208                slab_free(ipc_answerbox_slab, mybox);
     209                return rc;
     210        }
     211        // TODO: forget the call if interrupted
     212        (void) ipc_wait_for_call(mybox, SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE);
     213       
     214        slab_free(ipc_answerbox_slab, mybox);
     215        return EOK;
    187216}
    188217
     
    220249        spinlock_unlock(&call->forget_lock);
    221250
    222         answerbox_t *callerbox = &call->sender->answerbox;
     251        answerbox_t *callerbox = call->callerbox;
    223252        bool do_lock = ((!selflocked) || (callerbox != &TASK->answerbox));
    224253       
     
    755784        ipc_cleanup_call_list(&TASK->answerbox,
    756785            &TASK->answerbox.dispatched_calls);
    757 
     786       
    758787        ipc_forget_all_active_calls();
    759788        ipc_wait_for_all_answered_calls();
  • kernel/generic/src/ipc/sysipc.c

    r4bf0926e r2c2d54a  
    106106{
    107107        switch (imethod) {
     108        case IPC_M_PAGE_IN:
    108109        case IPC_M_SHARE_OUT:
    109110        case IPC_M_SHARE_IN:
     
    137138        case IPC_M_CONNECT_TO_ME:
    138139        case IPC_M_CONNECT_ME_TO:
     140        case IPC_M_PAGE_IN:
    139141        case IPC_M_SHARE_OUT:
    140142        case IPC_M_SHARE_IN:
     
    257259{
    258260        return SYSIPC_OP(request_process, call, box);
     261}
     262
     263/** Make a call over IPC and wait for reply.
     264 *
     265 * @param phoneid     Phone handle for the call.
     266 * @param data[inout] Structure with request/reply data.
     267 *
     268 * @return EOK on success.
     269 * @return ENOENT if there is no such phone handle.
     270 *
     271 */
     272int ipc_req_internal(int phoneid, ipc_data_t *data)
     273{
     274        phone_t *phone;
     275        if (phone_get(phoneid, &phone) != EOK)
     276                return ENOENT;
     277       
     278        call_t *call = ipc_call_alloc(0);
     279        memcpy(call->data.args, data->args, sizeof(data->args));
     280       
     281        int rc = request_preprocess(call, phone);
     282        if (!rc) {
     283#ifdef CONFIG_UDEBUG
     284                udebug_stoppable_begin();
     285#endif
     286
     287                rc = ipc_call_sync(phone, call);
     288
     289#ifdef CONFIG_UDEBUG
     290                udebug_stoppable_end();
     291#endif
     292
     293                if (rc != EOK)
     294                        return EINTR;
     295
     296                process_answer(call);
     297        } else
     298                IPC_SET_RETVAL(call->data, rc);
     299       
     300        memcpy(data->args, call->data.args, sizeof(data->args));
     301        ipc_call_free(call);
     302       
     303        return EOK;
    259304}
    260305
  • kernel/generic/src/ipc/sysipc_ops.c

    r4bf0926e r2c2d54a  
    4242sysipc_ops_t ipc_m_connect_to_me_ops;
    4343sysipc_ops_t ipc_m_connect_me_to_ops;
     44sysipc_ops_t ipc_m_page_in_ops;
    4445sysipc_ops_t ipc_m_share_out_ops;
    4546sysipc_ops_t ipc_m_share_in_ops;
     
    5455        [IPC_M_CONNECT_TO_ME] = &ipc_m_connect_to_me_ops,
    5556        [IPC_M_CONNECT_ME_TO] = &ipc_m_connect_me_to_ops,
     57        [IPC_M_PAGE_IN] = &ipc_m_page_in_ops,
    5658        [IPC_M_SHARE_OUT] = &ipc_m_share_out_ops,
    5759        [IPC_M_SHARE_IN] = &ipc_m_share_in_ops,
Note: See TracChangeset for help on using the changeset viewer.