Changeset 1252e81 in mainline


Ignore:
Timestamp:
2017-10-20T09:52:48Z (7 years ago)
Author:
Petr Manek <petr.manek@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d1d7a92
Parents:
03936831
Message:

Added boilerplate function for isoch transfers. Some more checks.

Location:
uspace/drv/bus/usb/xhci
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/xhci/hc.c

    r03936831 r1252e81  
    476476                return xhci_schedule_control_transfer(hc, batch);
    477477        case USB_TRANSFER_ISOCHRONOUS:
    478                 /* TODO: Implement me. */
    479                 usb_log_error("Isochronous transfers are not yet implemented!");
    480                 return ENOTSUP;
     478                return xhci_schedule_isochronous_transfer(hc, batch);
    481479        case USB_TRANSFER_BULK:
    482480                return xhci_schedule_bulk_transfer(hc, batch);
  • uspace/drv/bus/usb/xhci/transfers.c

    r03936831 r1252e81  
    144144        }
    145145
    146         xhci_endpoint_t *xhci_ep = xhci_endpoint_get(batch->ep);
    147 
    148         uint8_t slot_id = xhci_ep->device->slot_id;
    149         xhci_trb_ring_t* ring = hc->dcbaa_virt[slot_id].trs[batch->ep->target.endpoint];
    150 
    151146        usb_device_request_setup_packet_t* setup =
    152147                (usb_device_request_setup_packet_t*) batch->setup_buffer;
     
    197192                TRB_CTRL_SET_TRB_TYPE(trb_data, XHCI_TRB_TYPE_DATA_STAGE);
    198193
    199                 transfer->direction = REQUEST_TYPE_IS_DEVICE_TO_HOST(setup->request_type) 
     194                transfer->direction = REQUEST_TYPE_IS_DEVICE_TO_HOST(setup->request_type)
    200195                                        ? STAGE_IN : STAGE_OUT;
    201196                TRB_CTRL_SET_DIR(trb_data, transfer->direction);
     
    214209        TRB_CTRL_SET_TRB_TYPE(trb_status, XHCI_TRB_TYPE_STATUS_STAGE);
    215210        TRB_CTRL_SET_DIR(trb_status, get_status_direction_flag(&trb_setup, setup->request_type, setup->length));
     211
     212        xhci_endpoint_t *xhci_ep = xhci_endpoint_get(batch->ep);
     213        uint8_t slot_id = xhci_ep->device->slot_id;
     214        xhci_trb_ring_t* ring = hc->dcbaa_virt[slot_id].trs[batch->ep->target.endpoint];
    216215
    217216        uintptr_t dummy = 0;
     
    238237{
    239238        if (batch->setup_size) {
    240                 usb_log_warning("Setup packet present for a bulk transfer.");
    241         }
    242 
    243         xhci_endpoint_t *xhci_ep = xhci_endpoint_get(batch->ep);
    244         uint8_t slot_id = xhci_ep->device->slot_id;
    245         xhci_trb_ring_t* ring = hc->dcbaa_virt[slot_id].trs[batch->ep->target.endpoint];
     239                usb_log_warning("Setup packet present for a bulk transfer. Ignored.");
     240        }
     241        if (batch->ep->transfer_type != USB_TRANSFER_BULK) {
     242                /* This method only works for bulk transfers. */
     243                usb_log_error("Attempted to schedule a bulk transfer to non bulk endpoint.");
     244                return EINVAL;
     245        }
    246246
    247247        xhci_transfer_t *transfer = xhci_transfer_alloc(batch);
     
    265265        TRB_CTRL_SET_TRB_TYPE(trb, XHCI_TRB_TYPE_NORMAL);
    266266
     267        xhci_endpoint_t *xhci_ep = xhci_endpoint_get(batch->ep);
     268        uint8_t slot_id = xhci_ep->device->slot_id;
     269        xhci_trb_ring_t* ring = hc->dcbaa_virt[slot_id].trs[batch->ep->target.endpoint];
     270
    267271        xhci_trb_ring_enqueue(ring, &trb, &transfer->interrupt_trb_phys);
    268272        list_append(&transfer->link, &hc->transfers);
     
    276280{
    277281        if (batch->setup_size) {
    278                 usb_log_warning("Setup packet present for a interrupt transfer.");
    279         }
    280 
    281         xhci_endpoint_t *xhci_ep = xhci_endpoint_get(batch->ep);
    282         uint8_t slot_id = xhci_ep->device->slot_id;
    283         xhci_trb_ring_t* ring = hc->dcbaa_virt[slot_id].trs[batch->ep->target.endpoint];
     282                usb_log_warning("Setup packet present for a interrupt transfer. Ignored.");
     283        }
     284        if (batch->ep->transfer_type != USB_TRANSFER_INTERRUPT) {
     285                /* This method only works for interrupt transfers. */
     286                usb_log_error("Attempted to schedule a interrupt transfer to non interrupt endpoint.");
     287                return EINVAL;
     288        }
    284289
    285290        xhci_transfer_t *transfer = xhci_transfer_alloc(batch);
     
    303308        TRB_CTRL_SET_TRB_TYPE(trb, XHCI_TRB_TYPE_NORMAL);
    304309
     310        xhci_endpoint_t *xhci_ep = xhci_endpoint_get(batch->ep);
     311        uint8_t slot_id = xhci_ep->device->slot_id;
     312        xhci_trb_ring_t* ring = hc->dcbaa_virt[slot_id].trs[batch->ep->target.endpoint];
     313
    305314        xhci_trb_ring_enqueue(ring, &trb, &transfer->interrupt_trb_phys);
    306315        list_append(&transfer->link, &hc->transfers);
     
    308317        const uint8_t target = xhci_endpoint_index(xhci_ep) + 1; /* EP Doorbells start at 1 */
    309318        return hc_ring_doorbell(hc, slot_id, target);
     319}
     320
     321int xhci_schedule_isochronous_transfer(xhci_hc_t* hc, usb_transfer_batch_t* batch)
     322{
     323        if (batch->setup_size) {
     324                usb_log_warning("Setup packet present for a isochronous transfer. Ignored.");
     325        }
     326        if (batch->ep->transfer_type != USB_TRANSFER_ISOCHRONOUS) {
     327                /* This method only works for isochronous transfers. */
     328                usb_log_error("Attempted to schedule a isochronous transfer to non isochronous endpoint.");
     329                return EINVAL;
     330        }
     331
     332        /* TODO: Implement me. */
     333        usb_log_error("Isochronous transfers are not yet implemented!");
     334        return ENOTSUP;
    310335}
    311336
  • uspace/drv/bus/usb/xhci/transfers.h

    r03936831 r1252e81  
    5050int xhci_init_transfers(xhci_hc_t*);
    5151void xhci_fini_transfers(xhci_hc_t*);
     52
    5253xhci_transfer_t* xhci_transfer_alloc(usb_transfer_batch_t*);
    5354void xhci_transfer_fini(xhci_transfer_t*);
     55
     56int xhci_handle_transfer_event(xhci_hc_t*, xhci_trb_t*);
     57
    5458int xhci_schedule_control_transfer(xhci_hc_t*, usb_transfer_batch_t*);
    5559int xhci_schedule_bulk_transfer(xhci_hc_t*, usb_transfer_batch_t*);
    5660int xhci_schedule_interrupt_transfer(xhci_hc_t*, usb_transfer_batch_t*);
    57 int xhci_handle_transfer_event(xhci_hc_t*, xhci_trb_t*);
     61int xhci_schedule_isochronous_transfer(xhci_hc_t* , usb_transfer_batch_t* );
Note: See TracChangeset for help on using the changeset viewer.