Changeset 8869f7b in mainline


Ignore:
Timestamp:
2011-06-08T19:44:33Z (13 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4a4c8bcf
Parents:
0eff68e
Message:

async framework: add support for in-band IPC_M_CONNECT_TO_ME processing

Location:
uspace
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/vhc/conndev.c

    r0eff68e r8869f7b  
    4545static fibril_local char plugged_device_name[PLUGGED_DEVICE_NAME_MAXLEN + 1] = "<unknown>";
    4646
    47 #if 0
    4847/** Receive device name.
    4948 *
     
    8584        plugged_device_name[len] = 0;
    8685}
    87 #endif
    8886
    8987/** Default handler for IPC methods not handled by DDF.
     
    9391 * @param icall Call data.
    9492 */
    95 void default_connection_handler(ddf_fun_t *fun,
    96     ipc_callid_t icallid, ipc_call_t *icall)
     93void default_connection_handler(ddf_fun_t *fun, ipc_callid_t icallid,
     94    ipc_call_t *icall)
    9795{
    98 // FIXME:
    99 // This code needs to be refactored since the async
    100 // framework does not support automatic callback connections
    101 // yet.
    102 
    103 #if 0
    10496        vhc_data_t *vhc = fun->dev->driver_data;
    105         sysarg_t method = IPC_GET_IMETHOD(*icall);
    106 
    107         if (method == IPC_M_CONNECT_TO_ME) {
    108                 int callback = IPC_GET_ARG5(*icall);
    109                 int rc = vhc_virtdev_plug(vhc, callback,
    110                     &plugged_device_handle);
     97       
     98        async_sess_t *callback =
     99            async_callback_receive_start(EXCHANGE_SERIALIZE, icall);
     100       
     101        if (callback) {
     102                int rc = vhc_virtdev_plug(vhc, callback, &plugged_device_handle);
    111103                if (rc != EOK) {
    112104                        async_answer_0(icallid, rc);
     
    114106                        return;
    115107                }
    116 
     108               
    117109                async_answer_0(icallid, EOK);
    118 
     110               
    119111                receive_device_name(callback);
    120 
     112               
    121113                usb_log_info("New virtual device `%s' (id: %" PRIxn ").\n",
    122114                    plugged_device_name, plugged_device_handle);
    123 
    124                 return;
    125         }
    126 #endif
    127 
    128         async_answer_0(icallid, EINVAL);
     115        } else
     116                async_answer_0(icallid, EINVAL);
    129117}
    130118
  • uspace/lib/c/generic/async.c

    r0eff68e r8869f7b  
    23392339 * @param mgmt Exchange management style.
    23402340 *
    2341  * @return New async session or NULL on failure.
     2341 * @return New async session.
     2342 * @return NULL on failure.
    23422343 *
    23432344 */
     
    23772378}
    23782379
     2380/** Wrapper for receiving the IPC_M_CONNECT_TO_ME calls.
     2381 *
     2382 * If the call is IPC_M_CONNECT_TO_ME then a new
     2383 * async session is created. However, the phone is
     2384 * not accepted automatically.
     2385 *
     2386 * @param mgmt   Exchange management style.
     2387 * @param call   Call data.
     2388 *
     2389 * @return New async session.
     2390 * @return NULL on failure.
     2391 * @return NULL if the call is not IPC_M_CONNECT_TO_ME.
     2392 *
     2393 */
     2394async_sess_t *async_callback_receive_start(exch_mgmt_t mgmt, ipc_call_t *call)
     2395{
     2396        int phone = (int) IPC_GET_ARG5(*call);
     2397       
     2398        if ((IPC_GET_IMETHOD(*call) != IPC_M_CONNECT_TO_ME) ||
     2399            (phone < 0))
     2400                return NULL;
     2401       
     2402        async_sess_t *sess = (async_sess_t *) malloc(sizeof(async_sess_t));
     2403        if (sess == NULL)
     2404                return NULL;
     2405       
     2406        sess->mgmt = mgmt;
     2407        sess->phone = phone;
     2408        sess->arg1 = 0;
     2409        sess->arg2 = 0;
     2410        sess->arg3 = 0;
     2411       
     2412        list_initialize(&sess->exch_list);
     2413        fibril_mutex_initialize(&sess->mutex);
     2414        atomic_set(&sess->refcnt, 0);
     2415       
     2416        return sess;
     2417}
     2418
    23792419/** @}
    23802420 */
  • uspace/lib/c/include/async.h

    r0eff68e r8869f7b  
    464464extern async_sess_t *async_clone_receive(exch_mgmt_t);
    465465extern async_sess_t *async_callback_receive(exch_mgmt_t);
     466extern async_sess_t *async_callback_receive_start(exch_mgmt_t, ipc_call_t *);
    466467
    467468#endif
Note: See TracChangeset for help on using the changeset viewer.