Changeset 79ae36dd in mainline for uspace/lib/usb/src


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.)
Location:
uspace/lib/usb/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usb/src/ddfiface.c

    r764d71e r79ae36dd  
    7878{
    7979        assert(fun != NULL);
    80 
    81         int parent_phone = devman_parent_device_connect(fun->handle,
     80       
     81        async_sess_t *parent_sess =
     82            devman_parent_device_connect(EXCHANGE_SERIALIZE, fun->handle,
    8283            IPC_FLAG_BLOCKING);
    83         if (parent_phone < 0) {
    84                 return parent_phone;
    85         }
    86 
     84        if (!parent_sess)
     85                return ENOMEM;
     86       
     87        async_exch_t *exch = async_exchange_begin(parent_sess);
     88       
    8789        sysarg_t hc_handle;
    88         int rc = async_req_1_1(parent_phone, DEV_IFACE_ID(USB_DEV_IFACE),
     90        int rc = async_req_1_1(exch, DEV_IFACE_ID(USB_DEV_IFACE),
    8991            IPC_M_USB_GET_HOST_CONTROLLER_HANDLE, &hc_handle);
    90 
    91         async_hangup(parent_phone);
    92 
    93         if (rc != EOK) {
     92       
     93        async_exchange_end(exch);
     94        async_hangup(parent_sess);
     95       
     96        if (rc != EOK)
    9497                return rc;
    95         }
    96 
     98       
    9799        *handle = hc_handle;
    98 
    99100        return EOK;
    100101}
     
    128129{
    129130        assert(fun);
    130         int parent_phone = devman_parent_device_connect(fun->handle,
     131       
     132        async_sess_t *parent_sess =
     133            devman_parent_device_connect(EXCHANGE_SERIALIZE, fun->handle,
    131134            IPC_FLAG_BLOCKING);
    132         if (parent_phone < 0) {
    133                 return parent_phone;
    134         }
    135 
     135        if (!parent_sess)
     136                return ENOMEM;
     137       
     138        async_exch_t *exch = async_exchange_begin(parent_sess);
     139       
    136140        sysarg_t addr;
    137         int rc = async_req_2_1(parent_phone, DEV_IFACE_ID(USB_DEV_IFACE),
     141        int rc = async_req_2_1(exch, DEV_IFACE_ID(USB_DEV_IFACE),
    138142            IPC_M_USB_GET_ADDRESS, handle, &addr);
    139 
    140         async_hangup(parent_phone);
    141 
    142         if (rc != EOK) {
     143       
     144        async_exchange_end(exch);
     145        async_hangup(parent_sess);
     146       
     147        if (rc != EOK)
    143148                return rc;
    144         }
    145 
    146         if (address != NULL) {
     149       
     150        if (address != NULL)
    147151                *address = (usb_address_t) addr;
    148         }
    149 
     152       
    150153        return EOK;
    151154}
  • uspace/lib/usb/src/hc.c

    r764d71e r79ae36dd  
    8181
    8282        connection->hc_handle = hc_handle;
    83         connection->hc_phone = -1;
     83        connection->hc_sess = NULL;
    8484
    8585        return EOK;
     
    9494{
    9595        assert(connection);
    96 
    97         if (usb_hc_connection_is_opened(connection)) {
     96       
     97        if (usb_hc_connection_is_opened(connection))
    9898                return EBUSY;
    99         }
    100 
    101         int phone = devman_device_connect(connection->hc_handle, 0);
    102         if (phone < 0) {
    103                 return phone;
    104         }
    105 
    106         connection->hc_phone = phone;
    107 
     99       
     100        async_sess_t *sess = devman_device_connect(EXCHANGE_SERIALIZE,
     101            connection->hc_handle, 0);
     102        if (!sess)
     103                return ENOMEM;
     104       
     105        connection->hc_sess = sess;
    108106        return EOK;
    109107}
     
    117115{
    118116        assert(connection);
    119 
    120         return (connection->hc_phone >= 0);
     117        return (connection->hc_sess != NULL);
    121118}
    122119
     
    134131        }
    135132
    136         int rc = async_hangup(connection->hc_phone);
     133        int rc = async_hangup(connection->hc_sess);
    137134        if (rc != EOK) {
    138135                return rc;
    139136        }
    140137
    141         connection->hc_phone = -1;
     138        connection->hc_sess = NULL;
    142139
    143140        return EOK;
     
    154151    usb_address_t address, devman_handle_t *handle)
    155152{
    156         if (!usb_hc_connection_is_opened(connection)) {
     153        if (!usb_hc_connection_is_opened(connection))
    157154                return ENOENT;
    158         }
    159 
     155       
     156        async_exch_t *exch = async_exchange_begin(connection->hc_sess);
     157       
    160158        sysarg_t tmp;
    161         int rc = async_req_2_1(connection->hc_phone,
    162             DEV_IFACE_ID(USBHC_DEV_IFACE),
     159        int rc = async_req_2_1(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
    163160            IPC_M_USBHC_GET_HANDLE_BY_ADDRESS,
    164161            address, &tmp);
    165         if ((rc == EOK) && (handle != NULL)) {
     162       
     163        async_exchange_end(exch);
     164       
     165        if ((rc == EOK) && (handle != NULL))
    166166                *handle = tmp;
    167         }
    168 
     167       
    169168        return rc;
    170169}
     
    177176usb_address_t usb_hc_get_address_by_handle(devman_handle_t dev_handle)
    178177{
    179         int parent_phone = devman_parent_device_connect(dev_handle,
     178        async_sess_t *parent_sess =
     179            devman_parent_device_connect(EXCHANGE_SERIALIZE, dev_handle,
    180180            IPC_FLAG_BLOCKING);
    181         if (parent_phone < 0) {
    182                 return parent_phone;
    183         }
    184 
     181        if (!parent_sess)
     182                return ENOMEM;
     183       
     184        async_exch_t *exch = async_exchange_begin(parent_sess);
     185       
    185186        sysarg_t address;
    186 
    187         int rc = async_req_2_1(parent_phone, DEV_IFACE_ID(USB_DEV_IFACE),
     187        int rc = async_req_2_1(exch, DEV_IFACE_ID(USB_DEV_IFACE),
    188188            IPC_M_USB_GET_ADDRESS,
    189189            dev_handle, &address);
    190 
    191         if (rc != EOK) {
    192                 return rc;
    193         }
    194 
    195         async_hangup(parent_phone);
    196 
     190       
     191        async_exchange_end(exch);
     192        async_hangup(parent_sess);
     193       
     194        if (rc != EOK)
     195                return rc;
     196       
    197197        return (usb_address_t) address;
    198198}
     
    240240int usb_hc_find(devman_handle_t device_handle, devman_handle_t *hc_handle)
    241241{
    242         int parent_phone = devman_parent_device_connect(device_handle,
     242        async_sess_t *parent_sess =
     243            devman_parent_device_connect(EXCHANGE_SERIALIZE, device_handle,
    243244            IPC_FLAG_BLOCKING);
    244         if (parent_phone < 0) {
    245                 return parent_phone;
    246         }
    247 
     245        if (!parent_sess)
     246                return ENOMEM;
     247       
     248        async_exch_t *exch = async_exchange_begin(parent_sess);
     249       
    248250        devman_handle_t h;
    249         int rc = async_req_1_1(parent_phone, DEV_IFACE_ID(USB_DEV_IFACE),
     251        int rc = async_req_1_1(exch, DEV_IFACE_ID(USB_DEV_IFACE),
    250252            IPC_M_USB_GET_HOST_CONTROLLER_HANDLE, &h);
    251 
    252         async_hangup(parent_phone);
    253 
    254         if (rc != EOK) {
    255                 return rc;
    256         }
    257 
    258         if (hc_handle != NULL) {
     253       
     254        async_exchange_end(exch);
     255        async_hangup(parent_sess);
     256       
     257        if (rc != EOK)
     258                return rc;
     259       
     260        if (hc_handle != NULL)
    259261                *hc_handle = h;
    260         }
    261 
     262       
    262263        return EOK;
    263264}
Note: See TracChangeset for help on using the changeset viewer.