Changeset 0dd16778 in mainline for uspace/lib/c/generic


Ignore:
Timestamp:
2015-08-22T14:32:11Z (10 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f9b2cb4c
Parents:
78bb04b
Message:

start migrating devman to interfaces

Location:
uspace/lib/c/generic
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/async.c

    r78bb04b r0dd16778  
    22722272        sess->phone = phone;
    22732273        sess->arg1 = arg1;
     2274        sess->arg2 = arg2;
     2275        sess->arg3 = arg3;
     2276       
     2277        fibril_mutex_initialize(&sess->remote_state_mtx);
     2278        sess->remote_state_data = NULL;
     2279       
     2280        list_initialize(&sess->exch_list);
     2281        fibril_mutex_initialize(&sess->mutex);
     2282        atomic_set(&sess->refcnt, 0);
     2283       
     2284        return sess;
     2285}
     2286
     2287/** Wrapper for making IPC_M_CONNECT_ME_TO calls using the async framework.
     2288 *
     2289 * Ask through phone for a new connection to some service and block until
     2290 * success.
     2291 *
     2292 * @param exch  Exchange for sending the message.
     2293 * @param iface Connection interface.
     2294 * @param arg2  User defined argument.
     2295 * @param arg3  User defined argument.
     2296 *
     2297 * @return New session on success or NULL on error.
     2298 *
     2299 */
     2300async_sess_t *async_connect_me_to_iface(async_exch_t *exch, iface_t iface,
     2301    sysarg_t arg2, sysarg_t arg3)
     2302{
     2303        if (exch == NULL) {
     2304                errno = ENOENT;
     2305                return NULL;
     2306        }
     2307       
     2308        async_sess_t *sess = (async_sess_t *) malloc(sizeof(async_sess_t));
     2309        if (sess == NULL) {
     2310                errno = ENOMEM;
     2311                return NULL;
     2312        }
     2313       
     2314        int phone = async_connect_me_to_internal(exch->phone, iface, arg2,
     2315            arg3, 0);
     2316        if (phone < 0) {
     2317                errno = phone;
     2318                free(sess);
     2319                return NULL;
     2320        }
     2321       
     2322        sess->iface = iface;
     2323        sess->phone = phone;
     2324        sess->arg1 = iface;
    22742325        sess->arg2 = arg2;
    22752326        sess->arg3 = arg3;
  • uspace/lib/c/generic/loc.c

    r78bb04b r0dd16778  
    569569}
    570570
     571async_sess_t *loc_service_connect_iface(service_id_t handle, iface_t iface,
     572    unsigned int flags)
     573{
     574        async_sess_t *sess;
     575       
     576        if (flags & IPC_FLAG_BLOCKING)
     577                sess = service_connect_blocking_iface_extended(SERVICE_LOC, iface, handle);
     578        else
     579                sess = service_connect_iface_extended(SERVICE_LOC, iface, handle);
     580       
     581        return sess;
     582}
     583
    571584async_sess_t *loc_service_connect(exch_mgmt_t mgmt, service_id_t handle,
    572585    unsigned int flags)
  • uspace/lib/c/generic/ns.c

    r78bb04b r0dd16778  
    5858        async_sess_t *sess =
    5959            async_connect_me_to(mgmt, exch, iface, service, arg3);
     60        async_exchange_end(exch);
     61       
     62        if (!sess)
     63                return NULL;
     64       
     65        /*
     66         * FIXME Ugly hack to work around limitation of implementing
     67         * parallel exchanges using multiple connections. Shift out
     68         * first argument for non-initial connections.
     69         */
     70        async_sess_args_set(sess, iface, arg3, 0);
     71       
     72        return sess;
     73}
     74
     75async_sess_t *service_connect_iface_extended(service_t service, iface_t iface,
     76    sysarg_t arg3)
     77{
     78        async_exch_t *exch = async_exchange_begin(session_ns);
     79        if (!exch)
     80                return NULL;
     81       
     82        async_sess_t *sess =
     83            async_connect_me_to_iface(exch, iface, service, arg3);
    6084        async_exchange_end(exch);
    6185       
Note: See TracChangeset for help on using the changeset viewer.