Changeset 1252e81 in mainline
- Timestamp:
- 2017-10-20T09:52:48Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d1d7a92
- Parents:
- 03936831
- Location:
- uspace/drv/bus/usb/xhci
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/xhci/hc.c
r03936831 r1252e81 476 476 return xhci_schedule_control_transfer(hc, batch); 477 477 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); 481 479 case USB_TRANSFER_BULK: 482 480 return xhci_schedule_bulk_transfer(hc, batch); -
uspace/drv/bus/usb/xhci/transfers.c
r03936831 r1252e81 144 144 } 145 145 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 151 146 usb_device_request_setup_packet_t* setup = 152 147 (usb_device_request_setup_packet_t*) batch->setup_buffer; … … 197 192 TRB_CTRL_SET_TRB_TYPE(trb_data, XHCI_TRB_TYPE_DATA_STAGE); 198 193 199 transfer->direction = REQUEST_TYPE_IS_DEVICE_TO_HOST(setup->request_type) 194 transfer->direction = REQUEST_TYPE_IS_DEVICE_TO_HOST(setup->request_type) 200 195 ? STAGE_IN : STAGE_OUT; 201 196 TRB_CTRL_SET_DIR(trb_data, transfer->direction); … … 214 209 TRB_CTRL_SET_TRB_TYPE(trb_status, XHCI_TRB_TYPE_STATUS_STAGE); 215 210 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]; 216 215 217 216 uintptr_t dummy = 0; … … 238 237 { 239 238 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 } 246 246 247 247 xhci_transfer_t *transfer = xhci_transfer_alloc(batch); … … 265 265 TRB_CTRL_SET_TRB_TYPE(trb, XHCI_TRB_TYPE_NORMAL); 266 266 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 267 271 xhci_trb_ring_enqueue(ring, &trb, &transfer->interrupt_trb_phys); 268 272 list_append(&transfer->link, &hc->transfers); … … 276 280 { 277 281 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 } 284 289 285 290 xhci_transfer_t *transfer = xhci_transfer_alloc(batch); … … 303 308 TRB_CTRL_SET_TRB_TYPE(trb, XHCI_TRB_TYPE_NORMAL); 304 309 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 305 314 xhci_trb_ring_enqueue(ring, &trb, &transfer->interrupt_trb_phys); 306 315 list_append(&transfer->link, &hc->transfers); … … 308 317 const uint8_t target = xhci_endpoint_index(xhci_ep) + 1; /* EP Doorbells start at 1 */ 309 318 return hc_ring_doorbell(hc, slot_id, target); 319 } 320 321 int 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; 310 335 } 311 336 -
uspace/drv/bus/usb/xhci/transfers.h
r03936831 r1252e81 50 50 int xhci_init_transfers(xhci_hc_t*); 51 51 void xhci_fini_transfers(xhci_hc_t*); 52 52 53 xhci_transfer_t* xhci_transfer_alloc(usb_transfer_batch_t*); 53 54 void xhci_transfer_fini(xhci_transfer_t*); 55 56 int xhci_handle_transfer_event(xhci_hc_t*, xhci_trb_t*); 57 54 58 int xhci_schedule_control_transfer(xhci_hc_t*, usb_transfer_batch_t*); 55 59 int xhci_schedule_bulk_transfer(xhci_hc_t*, usb_transfer_batch_t*); 56 60 int xhci_schedule_interrupt_transfer(xhci_hc_t*, usb_transfer_batch_t*); 57 int xhci_ handle_transfer_event(xhci_hc_t*, xhci_trb_t*);61 int xhci_schedule_isochronous_transfer(xhci_hc_t* , usb_transfer_batch_t* );
Note:
See TracChangeset
for help on using the changeset viewer.