Changeset f1d6866 in mainline for uspace/lib/usbdev/src/pipesio.c


Ignore:
Timestamp:
2011-09-18T21:22:59Z (13 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
dcc44ca1
Parents:
85ff862 (diff), 45a9cf4 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbdev/src/pipesio.c

    r85ff862 rf1d6866  
    6565    void *buffer, size_t size, size_t *size_transfered)
    6666{
    67         /*
    68          * Get corresponding IPC method.
    69          * In future, replace with static array of mappings
    70          * transfer type -> method.
    71          */
    72         usbhc_iface_funcs_t ipc_method;
    73         switch (pipe->transfer_type) {
    74                 case USB_TRANSFER_INTERRUPT:
    75                         ipc_method = IPC_M_USBHC_INTERRUPT_IN;
    76                         break;
    77                 case USB_TRANSFER_BULK:
    78                         ipc_method = IPC_M_USBHC_BULK_IN;
    79                         break;
    80                 default:
    81                         return ENOTSUP;
    82         }
     67        /* Only interrupt and bulk transfers are supported */
     68        if (pipe->transfer_type != USB_TRANSFER_INTERRUPT &&
     69            pipe->transfer_type != USB_TRANSFER_BULK)
     70            return ENOTSUP;
     71
     72        const usb_target_t target =
     73            {{ .address = pipe->wire->address, .endpoint = pipe->endpoint_no }};
    8374       
    8475        /* Ensure serialization over the phone. */
     
    8980         * Make call identifying target USB device and type of transfer.
    9081         */
    91         aid_t opening_request = async_send_3(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
    92             ipc_method, pipe->wire->address, pipe->endpoint_no, NULL);
     82        aid_t opening_request = async_send_2(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
     83            IPC_M_USBHC_READ, target.packed, NULL);
    9384       
    9485        if (opening_request == 0) {
     
    213204    void *buffer, size_t size)
    214205{
    215         /*
    216          * Get corresponding IPC method.
    217          * In future, replace with static array of mappings
    218          * transfer type -> method.
    219          */
    220         usbhc_iface_funcs_t ipc_method;
    221         switch (pipe->transfer_type) {
    222                 case USB_TRANSFER_INTERRUPT:
    223                         ipc_method = IPC_M_USBHC_INTERRUPT_OUT;
    224                         break;
    225                 case USB_TRANSFER_BULK:
    226                         ipc_method = IPC_M_USBHC_BULK_OUT;
    227                         break;
    228                 default:
    229                         return ENOTSUP;
    230         }
     206        /* Only interrupt and bulk transfers are supported */
     207        if (pipe->transfer_type != USB_TRANSFER_INTERRUPT &&
     208            pipe->transfer_type != USB_TRANSFER_BULK)
     209            return ENOTSUP;
     210
     211        const usb_target_t target =
     212            {{ .address = pipe->wire->address, .endpoint = pipe->endpoint_no }};
    231213
    232214        /* Ensure serialization over the phone. */
     
    238220         */
    239221        aid_t opening_request = async_send_3(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
    240             ipc_method, pipe->wire->address, pipe->endpoint_no, NULL);
     222            IPC_M_USBHC_WRITE, target.packed, size, NULL);
    241223       
    242224        if (opening_request == 0) {
     
    352334        pipe_start_transaction(pipe);
    353335
     336        const usb_target_t target =
     337            {{ .address = pipe->wire->address, .endpoint = pipe->endpoint_no }};
     338
     339        assert(setup_buffer_size == 8);
     340        uint64_t setup_packet;
     341        memcpy(&setup_packet, setup_buffer, 8);
    354342        /*
    355343         * Make call identifying target USB device and control transfer type.
    356344         */
    357345        async_exch_t *exch = async_exchange_begin(pipe->hc_sess);
    358         aid_t opening_request = async_send_3(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
    359             IPC_M_USBHC_CONTROL_READ, pipe->wire->address, pipe->endpoint_no,
    360             NULL);
    361        
     346        aid_t opening_request = async_send_4(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
     347            IPC_M_USBHC_READ, target.packed,
     348            (setup_packet & UINT32_MAX), (setup_packet >> 32), NULL);
     349
    362350        if (opening_request == 0) {
    363351                async_exchange_end(exch);
    364352                return ENOMEM;
    365353        }
    366        
    367         /*
    368          * Send the setup packet.
    369          */
    370         int rc = async_data_write_start(exch, setup_buffer, setup_buffer_size);
    371         if (rc != EOK) {
    372                 async_exchange_end(exch);
    373                 pipe_end_transaction(pipe);
    374                 async_wait_for(opening_request, NULL);
    375                 return rc;
    376         }
    377        
     354
    378355        /*
    379356         * Retrieve the data.
     
    498475        pipe_start_transaction(pipe);
    499476
     477        const usb_target_t target =
     478            {{ .address = pipe->wire->address, .endpoint = pipe->endpoint_no }};
     479        assert(setup_buffer_size == 8);
     480        uint64_t setup_packet;
     481        memcpy(&setup_packet, setup_buffer, 8);
     482
    500483        /*
    501484         * Make call identifying target USB device and control transfer type.
    502485         */
    503486        async_exch_t *exch = async_exchange_begin(pipe->hc_sess);
    504         aid_t opening_request = async_send_4(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
    505             IPC_M_USBHC_CONTROL_WRITE, pipe->wire->address, pipe->endpoint_no,
    506             data_buffer_size, NULL);
     487        aid_t opening_request = async_send_5(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
     488            IPC_M_USBHC_WRITE, target.packed, data_buffer_size,
     489            (setup_packet & UINT32_MAX), (setup_packet >> 32), NULL);
    507490       
    508491        if (opening_request == 0) {
     
    511494                return ENOMEM;
    512495        }
    513        
    514         /*
    515          * Send the setup packet.
    516          */
    517         int rc = async_data_write_start(exch, setup_buffer, setup_buffer_size);
    518         if (rc != EOK) {
    519                 async_exchange_end(exch);
    520                 pipe_end_transaction(pipe);
    521                 async_wait_for(opening_request, NULL);
    522                 return rc;
    523         }
    524        
     496
    525497        /*
    526498         * Send the data (if any).
    527499         */
    528500        if (data_buffer_size > 0) {
    529                 rc = async_data_write_start(exch, data_buffer, data_buffer_size);
     501                int rc = async_data_write_start(exch, data_buffer, data_buffer_size);
    530502               
    531503                /* All data sent, pipe can be released. */
Note: See TracChangeset for help on using the changeset viewer.