Changeset d7869d7e in mainline
- Timestamp:
- 2017-10-14T17:21:26Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 867b375
- Parents:
- 2297fab
- Location:
- uspace/drv/bus/usb/xhci
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/xhci/endpoint.c
r2297fab rd7869d7e 39 39 40 40 #include "bus.h" 41 #include "commands.h" 41 42 #include "endpoint.h" 42 43 … … 114 115 } 115 116 117 int xhci_device_configure(xhci_device_t *dev, xhci_hc_t *hc) 118 { 119 int err; 120 121 // Prepare input context. 122 xhci_input_ctx_t *ictx = malloc(sizeof(xhci_input_ctx_t)); 123 if (!ictx) { 124 return ENOMEM; 125 } 126 127 memset(ictx, 0, sizeof(xhci_input_ctx_t)); 128 129 // Quoting sec. 4.6.6: A1, D0, D1 are down, A0 is up. 130 XHCI_INPUT_CTRL_CTX_ADD_CLEAR(ictx->ctrl_ctx, 1); 131 XHCI_INPUT_CTRL_CTX_DROP_CLEAR(ictx->ctrl_ctx, 0); 132 XHCI_INPUT_CTRL_CTX_DROP_CLEAR(ictx->ctrl_ctx, 1); 133 XHCI_INPUT_CTRL_CTX_ADD_SET(ictx->ctrl_ctx, 0); 134 135 // TODO: Set slot context and other flags. (probably forgot a lot of 'em) 136 137 // Issue configure endpoint command (sec 4.3.5). 138 xhci_cmd_t cmd; 139 xhci_cmd_init(&cmd); 140 141 cmd.slot_id = dev->slot_id; 142 xhci_send_configure_endpoint_command(hc, &cmd, ictx); 143 if ((err = xhci_cmd_wait(&cmd, 100000)) != EOK) 144 goto err_cmd; 145 146 xhci_cmd_fini(&cmd); 147 return EOK; 148 149 err_cmd: 150 free(ictx); 151 return err; 152 } 153 116 154 /** 117 155 * @} -
uspace/drv/bus/usb/xhci/endpoint.h
r2297fab rd7869d7e 43 43 #include <usb/host/hcd.h> 44 44 45 #include "hc.h" 46 45 47 typedef struct xhci_device xhci_device_t; 46 48 typedef struct xhci_endpoint xhci_endpoint_t; … … 85 87 int xhci_device_remove_endpoint(xhci_device_t *, xhci_endpoint_t *); 86 88 xhci_endpoint_t * xhci_device_get_endpoint(xhci_device_t *, usb_endpoint_t); 89 int xhci_device_configure(xhci_device_t *, xhci_hc_t *); 87 90 88 91 static inline xhci_endpoint_t * xhci_endpoint_get(endpoint_t *ep) -
uspace/drv/bus/usb/xhci/hw_struct/context.h
r2297fab rd7869d7e 166 166 167 167 #define XHCI_INPUT_CTRL_CTX_DROP_SET(ctx, idx) (ctx).data[0] |= (1 << (idx)) 168 #define XHCI_INPUT_CTRL_CTX_DROP_CLEAR(ctx, idx) (ctx).data[0] &= ~(1 << (idx)) 168 169 169 170 #define XHCI_INPUT_CTRL_CTX_ADD(ctx, idx) \ … … 171 172 172 173 #define XHCI_INPUT_CTRL_CTX_ADD_SET(ctx, idx) (ctx).data[1] |= (1 << (idx)) 174 #define XHCI_INPUT_CTRL_CTX_ADD_CLEAR(ctx, idx) (ctx).data[1] &= ~(1 << (idx)) 173 175 174 176 #define XHCI_INPUT_CTRL_CTX_CONFIG_VALUE(ctx) XHCI_DWORD_EXTRACT((ctx).data[7], 7, 0) -
uspace/drv/bus/usb/xhci/rh.c
r2297fab rd7869d7e 149 149 xhci_cmd_fini(&cmd); 150 150 151 // TODO: Issue configure endpoint commands (sec 4.3.5). 151 usb_address_t address = XHCI_SLOT_DEVICE_ADDRESS(dctx->slot_ctx); 152 usb_log_debug2("Obtained USB address: %d.\n", address); 153 154 // TODO: Ask libusbhost to create a control endpoint for EP0. 155 156 // TODO: Save all data structures in the corresponding xhci_device_t. 152 157 153 158 return EOK; -
uspace/drv/bus/usb/xhci/transfers.c
r2297fab rd7869d7e 103 103 } 104 104 105 static inline bool configure_endpoint_needed(usb_device_request_setup_packet_t *setup) 106 { 107 usb_request_type_t request_type = SETUP_REQUEST_TYPE_GET_TYPE(setup->request_type); 108 109 if (request_type == USB_REQUEST_TYPE_STANDARD) { 110 usb_stddevreq_t request = setup->request; 111 112 switch (request) { 113 case USB_DEVREQ_SET_CONFIGURATION: 114 case USB_DEVREQ_SET_INTERFACE: 115 return true; 116 117 default: 118 return false; 119 } 120 } 121 122 return false; 123 } 124 105 125 int xhci_init_transfers(xhci_hc_t *hc) 106 126 { … … 225 245 226 246 /* For control transfers, the target is always 1. */ 247 // FIXME: ignoring return code 227 248 hc_ring_doorbell(hc, slot_id, 1); 249 250 // Issue a Configure Endpoint command, if needed. 251 if (configure_endpoint_needed(setup)) { 252 // TODO: figure out the best time to issue this command 253 // FIXME: ignoring return code 254 xhci_device_configure(xhci_ep->device, hc); 255 } 256 228 257 return EOK; 229 258 }
Note:
See TracChangeset
for help on using the changeset viewer.