Changeset 41924f30 in mainline for uspace/drv/bus
- Timestamp:
- 2017-10-12T14:07:27Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a5976973
- Parents:
- 7e74911
- Location:
- uspace/drv/bus/usb
- Files:
-
- 9 edited
-
usbhub/status.h (modified) (1 diff)
-
xhci/Makefile (modified) (1 diff)
-
xhci/endpoint.c (modified) (1 diff)
-
xhci/endpoint.h (modified) (2 diffs)
-
xhci/hc.c (modified) (2 diffs)
-
xhci/hc.h (modified) (2 diffs)
-
xhci/main.c (modified) (2 diffs)
-
xhci/rh.c (modified) (2 diffs)
-
xhci/transfers.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbhub/status.h
r7e74911 r41924f30 112 112 if ((status & USB_HUB_PORT_STATUS_HIGH_SPEED) != 0) 113 113 return USB_SPEED_HIGH; 114 /* TODO: add super speed */ 114 115 return USB_SPEED_FULL; 115 116 } -
uspace/drv/bus/usb/xhci/Makefile
r7e74911 r41924f30 45 45 46 46 SOURCES = \ 47 bus.c \ 48 commands.c \ 49 debug.c \ 50 endpoint.c \ 47 51 hc.c \ 48 endpoint.c \ 49 debug.c \ 50 trb_ring.c \ 52 main.c \ 53 rh.c \ 51 54 scratchpad.c \ 52 commands.c \53 55 transfers.c \ 54 rh.c \ 55 main.c 56 trb_ring.c 56 57 57 58 TEST_SOURCES = \ -
uspace/drv/bus/usb/xhci/endpoint.c
r7e74911 r41924f30 34 34 */ 35 35 36 #include <usb/host/endpoint.h> 37 36 38 #include <errno.h> 37 39 40 #include "bus.h" 38 41 #include "endpoint.h" 39 42 40 int endpoint_init(hcd_t *hcd, endpoint_t *ep)43 int xhci_endpoint_init(xhci_endpoint_t *xhci_ep, xhci_bus_t *xhci_bus) 41 44 { 42 assert(ep); 43 xhci_endpoint_t *xhci_ep = malloc(sizeof(xhci_endpoint_t)); 44 if (xhci_ep == NULL) 45 return ENOMEM; 45 assert(xhci_ep); 46 assert(xhci_bus); 47 48 bus_t *bus = &xhci_bus->base; 49 endpoint_t *ep = &xhci_ep->base; 50 51 endpoint_init(ep, bus); 46 52 47 53 /* FIXME: Set xhci_ep->slot_id */ 48 54 49 fibril_mutex_lock(&ep->guard); 50 ep->hc_data.data = xhci_ep; 51 /* FIXME: The two handlers below should be implemented. */ 52 ep->hc_data.toggle_get = NULL; 53 ep->hc_data.toggle_set = NULL; 54 fibril_mutex_unlock(&ep->guard); 55 56 usb_log_debug("Endpoint %d:%d initialized.", ep->address, ep->endpoint); 55 usb_log_debug("XHCI Endpoint %d:%d initialized.", ep->target.address, ep->target.endpoint); 57 56 58 57 return EOK; 59 58 } 60 59 61 void endpoint_fini(hcd_t *hcd, endpoint_t *ep)60 void xhci_endpoint_fini(xhci_endpoint_t *xhci_ep) 62 61 { 63 assert(hcd); 64 assert(ep); 65 xhci_endpoint_t *xhci_ep = endpoint_get(ep); 62 assert(xhci_ep); 63 66 64 /* FIXME: Tear down TR's? */ 67 if (xhci_ep) {68 free(xhci_ep);69 }70 65 71 fibril_mutex_lock(&ep->guard); 72 ep->hc_data.data = NULL; 73 ep->hc_data.toggle_get = NULL; 74 ep->hc_data.toggle_set = NULL; 75 fibril_mutex_unlock(&ep->guard); 66 endpoint_t *ep = &xhci_ep->base; 76 67 77 usb_log_debug(" Endpoint %d:%d destroyed.", ep->address, ep->endpoint);68 usb_log_debug("XHCI Endpoint %d:%d destroyed.", ep->target.address, ep->target.endpoint); 78 69 } 79 70 -
uspace/drv/bus/usb/xhci/endpoint.h
r7e74911 r41924f30 43 43 #include <usb/host/hcd.h> 44 44 45 typedef struct xhci_endpoint xhci_endpoint_t; 46 typedef struct xhci_bus xhci_bus_t; 47 45 48 enum { 46 49 EP_TYPE_INVALID = 0, … … 56 59 /** Connector structure linking endpoint context to the endpoint. */ 57 60 typedef struct xhci_endpoint { 61 endpoint_t base; /**< Inheritance. Keep this first. */ 62 58 63 uint32_t slot_id; 59 64 } xhci_endpoint_t; 60 65 61 int endpoint_init(hcd_t *hcd, endpoint_t *ep);62 void endpoint_fini(hcd_t *hcd, endpoint_t *ep);66 int xhci_endpoint_init(xhci_endpoint_t *, xhci_bus_t *); 67 void xhci_endpoint_fini(xhci_endpoint_t *); 63 68 64 static inline xhci_endpoint_t * endpoint_get(constendpoint_t *ep)69 static inline xhci_endpoint_t * xhci_endpoint_get(endpoint_t *ep) 65 70 { 66 71 assert(ep); 67 return ep->hc_data.data;72 return (xhci_endpoint_t *) ep; 68 73 } 69 74 -
uspace/drv/bus/usb/xhci/hc.c
r7e74911 r41924f30 447 447 448 448 /* Check for root hub communication */ 449 if (batch->ep-> address == xhci_rh_get_address(&hc->rh)) {449 if (batch->ep->target.address == xhci_rh_get_address(&hc->rh)) { 450 450 usb_log_debug("XHCI root hub request.\n"); 451 451 return xhci_rh_schedule(&hc->rh, batch); … … 453 453 454 454 usb_log_debug2("EP(%d:%d) started %s transfer of size %lu.", 455 batch->ep-> address, batch->ep->endpoint,455 batch->ep->target.address, batch->ep->target.endpoint, 456 456 usb_str_transfer_type(batch->ep->transfer_type), 457 457 batch->buffer_size); 458 458 459 if (!batch->ep-> address) {459 if (!batch->ep->target.address) { 460 460 usb_log_error("Attempted to schedule transfer to address 0."); 461 461 return EINVAL; -
uspace/drv/bus/usb/xhci/hc.h
r7e74911 r41924f30 43 43 #include "trb_ring.h" 44 44 #include "rh.h" 45 #include "bus.h" 45 46 46 47 typedef struct xhci_virt_device_ctx { … … 72 73 xhci_rh_t rh; 73 74 75 /* Bus bookkeeping */ 76 xhci_bus_t bus; 77 74 78 /* Cached capabilities */ 75 79 unsigned max_slots; -
uspace/drv/bus/usb/xhci/main.c
r7e74911 r41924f30 66 66 .schedule = hcd_schedule, 67 67 .irq_hook = hcd_interrupt, 68 .ep_add_hook = endpoint_init,69 .ep_remove_hook = endpoint_fini,70 68 .status_hook = hcd_status, 71 69 } … … 83 81 goto err; 84 82 83 if ((err = xhci_bus_init(&hc->bus, hcd))) 84 goto err; 85 85 86 if ((err = hc_init_memory(hc))) 86 87 goto err; 87 88 88 hcd_set_implementation(hcd, hc, &xhci_ddf_hc_driver.ops );89 hcd_set_implementation(hcd, hc, &xhci_ddf_hc_driver.ops, &hc->bus.base); 89 90 90 91 return EOK; -
uspace/drv/bus/usb/xhci/rh.c
r7e74911 r41924f30 266 266 assert(rh); 267 267 assert(batch); 268 const usb_target_t target = {{ 269 .address = batch->ep->address, 270 .endpoint = batch->ep->endpoint, 271 }}; 268 const usb_target_t target = batch->ep->target; 272 269 batch->error = virthub_base_request(&rh->base, target, 273 270 usb_transfer_batch_direction(batch), (void*)batch->setup_buffer, … … 294 291 rh->unfinished_interrupt_transfer = NULL; 295 292 if (batch) { 296 const usb_target_t target = {{ 297 .address = batch->ep->address, 298 .endpoint = batch->ep->endpoint, 299 }}; 293 const usb_target_t target = batch->ep->target; 300 294 batch->error = virthub_base_request(&rh->base, target, 301 295 usb_transfer_batch_direction(batch), -
uspace/drv/bus/usb/xhci/transfers.c
r7e74911 r41924f30 36 36 #include <usb/host/utils/malloc32.h> 37 37 #include <usb/debug.h> 38 #include "endpoint.h" 38 39 #include "hc.h" 39 40 #include "hw_struct/trb.h" … … 141 142 return EINVAL; 142 143 } 143 if (batch->ep-> endpoint != 0 || batch->ep->transfer_type != USB_TRANSFER_CONTROL) {144 if (batch->ep->target.endpoint != 0 || batch->ep->transfer_type != USB_TRANSFER_CONTROL) { 144 145 /* This method only works for control transfers. */ 145 146 usb_log_error("Attempted to schedule control transfer to non 0 endpoint."); … … 147 148 } 148 149 149 uint8_t slot_id = batch->ep->hc_data.slot_id; 150 xhci_endpoint_t *xhci_ep = xhci_endpoint_get(batch->ep); 151 152 uint8_t slot_id = xhci_ep->slot_id; 150 153 xhci_trb_ring_t* ring = hc->dcbaa_virt[slot_id].trs[0]; 151 154 … … 230 233 } 231 234 232 uint8_t slot_id = batch->ep->hc_data.slot_id; 233 xhci_trb_ring_t* ring = hc->dcbaa_virt[slot_id].trs[batch->ep->endpoint]; 235 xhci_endpoint_t *xhci_ep = xhci_endpoint_get(batch->ep); 236 uint8_t slot_id = xhci_ep->slot_id; 237 xhci_trb_ring_t* ring = hc->dcbaa_virt[slot_id].trs[batch->ep->target.endpoint]; 234 238 235 239 xhci_transfer_t *transfer = xhci_transfer_alloc(batch);
Note:
See TracChangeset
for help on using the changeset viewer.
