Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset bdd8ad2f in mainline


Ignore:
Timestamp:
2011-09-14T20:15:03Z (10 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master
Children:
bbce2c2
Parents:
365e29e2
Message:

usb: Send any setup data during initial opening call.

NOTE: receiving function uses those parameters even if they were not sent, this is rather ugly but it does not matter, because any value that might appear in setup data will be ignored.

Location:
uspace/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/drv/generic/remote_usbhc.c

    r365e29e2 rbdd8ad2f  
    230230ipc_callid_t callid, ipc_call_t *call)
    231231{
     232        assert(false);
    232233        usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;
    233234        assert(usb_iface != NULL);
     
    291292ipc_callid_t callid, ipc_call_t *call)
    292293{
     294        assert(false);
    293295        usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;
    294296        assert(usb_iface != NULL);
     
    388390#undef _INIT_FROM_LOW_DATA3
    389391
    390         int rc = usb_iface->register_endpoint(fun, target.address,
    391             speed, target.endpoint,
    392             transfer_type, direction, max_packet_size, interval);
     392        int rc = usb_iface->register_endpoint(fun, target.address, speed,
     393            target.endpoint, transfer_type, direction, max_packet_size, interval);
    393394
    394395        async_answer_0(callid, rc);
     
    431432
    432433        const usb_target_t target = { .packed = DEV_IPC_GET_ARG1(*call) };
     434        const uint64_t setup =
     435            ((uint64_t)DEV_IPC_GET_ARG2(*call)) |
     436            (((uint64_t)DEV_IPC_GET_ARG3(*call)) << 32);
    433437
    434438        async_transaction_t *trans = async_transaction_create(callid);
     
    451455
    452456        const int rc = hc_iface->read(
    453             fun, target, 0, trans->buffer, trans->size, callback_in, trans);
     457            fun, target, setup, trans->buffer, trans->size, callback_in, trans);
    454458
    455459        if (rc != EOK) {
     
    475479
    476480        const usb_target_t target = { .packed = DEV_IPC_GET_ARG1(*call) };
     481        const size_t data_buffer_len = DEV_IPC_GET_ARG2(*call);
     482        const uint64_t setup =
     483            ((uint64_t)DEV_IPC_GET_ARG3(*call)) |
     484            (((uint64_t)DEV_IPC_GET_ARG4(*call)) << 32);
    477485
    478486        async_transaction_t *trans = async_transaction_create(callid);
     
    482490        }
    483491
    484         int rc = async_data_write_accept(&trans->buffer, false,
    485             1, USB_MAX_PAYLOAD_SIZE,
    486             0, &trans->size);
    487 
    488         if (rc != EOK) {
    489                 async_answer_0(callid, rc);
    490                 async_transaction_destroy(trans);
    491                 return;
    492         }
    493 
    494         rc = hc_iface->write(
    495             fun, target, 0, trans->buffer, trans->size, callback_out, trans);
     492        if (data_buffer_len > 0) {
     493                int rc = async_data_write_accept(&trans->buffer, false,
     494                    1, USB_MAX_PAYLOAD_SIZE,
     495                    0, &trans->size);
     496
     497                if (rc != EOK) {
     498                        async_answer_0(callid, rc);
     499                        async_transaction_destroy(trans);
     500                        return;
     501                }
     502        }
     503
     504        int rc = hc_iface->write(
     505            fun, target, setup, trans->buffer, trans->size, callback_out, trans);
    496506
    497507        if (rc != EOK) {
  • uspace/lib/usbdev/src/pipesio.c

    r365e29e2 rbdd8ad2f  
    219219         * Make call identifying target USB device and type of transfer.
    220220         */
    221         aid_t opening_request = async_send_2(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
    222             IPC_M_USBHC_DATA_WRITE, target.packed, NULL);
     221        aid_t opening_request = async_send_3(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
     222            IPC_M_USBHC_DATA_WRITE, target.packed, size, NULL);
    223223       
    224224        if (opening_request == 0) {
     
    337337            {{ .address = pipe->wire->address, .endpoint = pipe->endpoint_no }};
    338338
     339        assert(setup_buffer_size == 8);
     340        uint64_t setup_packet;
     341        memcpy(&setup_packet, setup_buffer, 8);
    339342        /*
    340343         * Make call identifying target USB device and control transfer type.
    341344         */
    342345        async_exch_t *exch = async_exchange_begin(pipe->hc_sess);
    343         aid_t opening_request = async_send_2(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
    344             IPC_M_USBHC_CONTROL_READ, target.packed, NULL);
    345        
     346        aid_t opening_request = async_send_4(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
     347            IPC_M_USBHC_DATA_READ, target.packed,
     348            (setup_packet & UINT32_MAX), (setup_packet >> 32), NULL);
     349
    346350        if (opening_request == 0) {
    347351                async_exchange_end(exch);
    348352                return ENOMEM;
    349353        }
    350        
    351         /*
    352          * Send the setup packet.
    353          */
    354         int rc = async_data_write_start(exch, setup_buffer, setup_buffer_size);
    355         if (rc != EOK) {
    356                 async_exchange_end(exch);
    357                 pipe_end_transaction(pipe);
    358                 async_wait_for(opening_request, NULL);
    359                 return rc;
    360         }
    361        
     354
    362355        /*
    363356         * Retrieve the data.
     
    484477        const usb_target_t target =
    485478            {{ .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);
    486482
    487483        /*
     
    489485         */
    490486        async_exch_t *exch = async_exchange_begin(pipe->hc_sess);
    491         aid_t opening_request = async_send_3(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
    492             IPC_M_USBHC_CONTROL_WRITE, target.packed,
    493             data_buffer_size, NULL);
     487        aid_t opening_request = async_send_5(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
     488            IPC_M_USBHC_DATA_WRITE, target.packed, data_buffer_size,
     489            (setup_packet & UINT32_MAX), (setup_packet >> 32), NULL);
    494490       
    495491        if (opening_request == 0) {
     
    498494                return ENOMEM;
    499495        }
    500        
    501         /*
    502          * Send the setup packet.
    503          */
    504         int rc = async_data_write_start(exch, setup_buffer, setup_buffer_size);
    505         if (rc != EOK) {
    506                 async_exchange_end(exch);
    507                 pipe_end_transaction(pipe);
    508                 async_wait_for(opening_request, NULL);
    509                 return rc;
    510         }
    511        
     496
    512497        /*
    513498         * Send the data (if any).
    514499         */
    515500        if (data_buffer_size > 0) {
    516                 rc = async_data_write_start(exch, data_buffer, data_buffer_size);
     501                int rc = async_data_write_start(exch, data_buffer, data_buffer_size);
    517502               
    518503                /* All data sent, pipe can be released. */
Note: See TracChangeset for help on using the changeset viewer.