Changeset bc117a5 in mainline


Ignore:
Timestamp:
2016-08-29T12:43:10Z (8 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c32b6f0
Parents:
6d351e6
Message:

Partially revert jakub@…

This changeset reintroduces portions of the synchronous IPC mechanism for
internal use by the kernel / user_backend. The synchronous IPC is not
exported to user space and is simpler than in its original form.

Location:
kernel/generic
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/ipc/ipc.h

    r6d351e6 rbc117a5  
    179179extern void ipc_call_release(call_t *);
    180180
     181extern int ipc_call_sync(phone_t *, call_t *);
    181182extern int ipc_call(phone_t *, call_t *);
    182183extern call_t *ipc_wait_for_call(answerbox_t *, uint32_t, unsigned int);
  • kernel/generic/include/ipc/sysipc.h

    r6d351e6 rbc117a5  
    4040#include <typedefs.h>
    4141
     42extern int ipc_req_internal(int, ipc_data_t *);
     43
    4244extern sysarg_t sys_ipc_call_async_fast(sysarg_t, sysarg_t, sysarg_t,
    4345    sysarg_t, sysarg_t, sysarg_t);
  • kernel/generic/src/ipc/ipc.c

    r6d351e6 rbc117a5  
    188188}
    189189
     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;
     216}
     217
    190218/** Answer a message which was not dispatched and is not listed in any queue.
    191219 *
     
    756784        ipc_cleanup_call_list(&TASK->answerbox,
    757785            &TASK->answerbox.dispatched_calls);
    758 
     786       
    759787        ipc_forget_all_active_calls();
    760788        ipc_wait_for_all_answered_calls();
  • kernel/generic/src/ipc/sysipc.c

    r6d351e6 rbc117a5  
    257257{
    258258        return SYSIPC_OP(request_process, call, box);
     259}
     260
     261/** Make a call over IPC and wait for reply.
     262 *
     263 * @param phoneid     Phone handle for the call.
     264 * @param data[inout] Structure with request/reply data.
     265 *
     266 * @return EOK on success.
     267 * @return ENOENT if there is no such phone handle.
     268 *
     269 */
     270int ipc_req_internal(int phoneid, ipc_data_t *data)
     271{
     272        phone_t *phone;
     273        if (phone_get(phoneid, &phone) != EOK)
     274                return ENOENT;
     275       
     276        call_t *call = ipc_call_alloc(0);
     277        memcpy(call->data.args, data->args, sizeof(data->args));
     278       
     279        int rc = request_preprocess(call, phone);
     280        if (!rc) {
     281#ifdef CONFIG_UDEBUG
     282                udebug_stoppable_begin();
     283#endif
     284
     285                rc = ipc_call_sync(phone, call);
     286
     287#ifdef CONFIG_UDEBUG
     288                udebug_stoppable_end();
     289#endif
     290
     291                if (rc != EOK)
     292                        return EINTR;
     293
     294                process_answer(call);
     295        } else
     296                IPC_SET_RETVAL(call->data, rc);
     297       
     298        memcpy(data->args, call->data.args, sizeof(data->args));
     299        ipc_call_free(call);
     300       
     301        return EOK;
    259302}
    260303
Note: See TracChangeset for help on using the changeset viewer.