Changeset 79ae36dd in mainline for uspace/lib/usbvirt/src/device.c


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

new async framework with integrated exchange tracking

  • strict isolation between low-level IPC and high-level async framework with integrated exchange tracking
    • each IPC connection is represented by an async_sess_t structure
    • each IPC exchange is represented by an async_exch_t structure
    • exchange management is either based on atomic messages (EXCHANGE_ATOMIC), locking (EXCHANGE_SERIALIZE) or connection cloning (EXCHANGE_CLONE)
  • async_obsolete: temporary compatibility layer to keep old async clients working (several pieces of code are currently broken, but only non-essential functionality)
  • IPC_M_PHONE_HANGUP is now method no. 0 (for elegant boolean evaluation)
  • IPC_M_DEBUG_ALL has been renamed to IPC_M_DEBUG
  • IPC_M_PING has been removed (VFS protocol now has VFS_IN_PING)
  • console routines in libc have been rewritten for better abstraction
  • additional use for libc-private header files (FILE structure opaque to the client)
  • various cstyle changes (typos, indentation, missing externs in header files, improved comments, etc.)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbvirt/src/device.c

    r764d71e r79ae36dd  
    6565                bool processed = usbvirt_ipc_handle_call(DEV, callid, &call);
    6666                if (!processed) {
    67                         switch (IPC_GET_IMETHOD(call)) {
    68                                 case IPC_M_PHONE_HUNGUP:
    69                                         async_answer_0(callid, EOK);
    70                                         return;
    71                                 default:
    72                                         async_answer_0(callid, EINVAL);
    73                                         break;
    74                         }
     67                        if (!IPC_GET_IMETHOD(call)) {
     68                                async_answer_0(callid, EOK);
     69                                return;
     70                        } else
     71                                async_answer_0(callid, EINVAL);
    7572                }
    7673        }
     
    8582int usbvirt_device_plug(usbvirt_device_t *dev, const char *vhc_path)
    8683{
    87         int rc;
     84        if (DEV != NULL)
     85                return ELIMIT;
     86       
    8887        devman_handle_t handle;
    89 
    90         if (DEV != NULL) {
    91                 return ELIMIT;
    92         }
    93 
    94         rc = devman_device_get_handle(vhc_path, &handle, 0);
    95         if (rc != EOK) {
     88        int rc = devman_device_get_handle(vhc_path, &handle, 0);
     89        if (rc != EOK)
    9690                return rc;
    97         }
    98 
    99         int hcd_phone = devman_device_connect(handle, 0);
    100 
    101         if (hcd_phone < 0) {
    102                 return hcd_phone;
    103         }
    104 
     91       
     92        async_sess_t *hcd_sess =
     93            devman_device_connect(EXCHANGE_SERIALIZE, handle, 0);
     94        if (!hcd_sess)
     95                return ENOMEM;
     96       
    10597        DEV = dev;
    106         dev->vhc_phone = hcd_phone;
    107 
    108         rc = async_connect_to_me(hcd_phone, 0, 0, 0, callback_connection);
    109         if (rc != EOK) {
     98        dev->vhc_sess = hcd_sess;
     99       
     100        async_exch_t *exch = async_exchange_begin(hcd_sess);
     101        rc = async_connect_to_me(exch, 0, 0, 0, callback_connection);
     102        async_exchange_end(exch);
     103       
     104        if (rc != EOK)
    110105                DEV = NULL;
    111         }
    112 
     106       
    113107        return rc;
    114108}
     
    120114void usbvirt_device_unplug(usbvirt_device_t *dev)
    121115{
    122         async_hangup(dev->vhc_phone);
     116        async_hangup(dev->vhc_sess);
    123117}
    124118
Note: See TracChangeset for help on using the changeset viewer.