Changeset 5c5c9407 in mainline
- Timestamp:
- 2017-10-03T23:12:40Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 816335c
- Parents:
- 7776cb1
- Location:
- uspace/drv/bus/usb/xhci
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/xhci/hc.c
r7776cb1 r5c5c9407 202 202 goto err_scratch; 203 203 204 if ((err = xhci_rh_init(&hc->rh )))204 if ((err = xhci_rh_init(&hc->rh, hc->op_regs))) 205 205 goto err_cmd; 206 206 -
uspace/drv/bus/usb/xhci/rh.c
r7776cb1 r5c5c9407 51 51 static usbvirt_device_ops_t ops; 52 52 53 int xhci_rh_init(xhci_rh_t *rh) 54 { 53 int xhci_rh_init(xhci_rh_t *rh, xhci_op_regs_t *op_regs) 54 { 55 assert(rh); 56 rh->op_regs = op_regs; 57 55 58 usb_hub_descriptor_header_t *header = &rh->hub_descriptor.header; 56 59 header->length = sizeof(usb_hub_descriptor_header_t); … … 316 319 } 317 320 321 #define XHCI_TO_USB(usb_feat, reg_set, ...) \ 322 (((XHCI_REG_RD(reg_set, ##__VA_ARGS__)) ? 1 : 0) << (usb_feat)) 323 318 324 /** Port status request handler. 319 325 * @param device Virtual hub device … … 328 334 uint8_t *data, size_t *act_size) 329 335 { 330 /* TODO: Implement me! */ 331 usb_log_debug2("Called req_get_port_status()."); 336 xhci_rh_t *hub = virthub_get_data(device); 337 assert(hub); 338 339 const uint16_t ports = 255; /* FIXME: Fetch this from somewhere. */ 340 if (!setup_packet->index || setup_packet->index > ports) { 341 return ESTALL; 342 } 343 344 /* The index is 1-based. */ 345 xhci_port_regs_t* regs = &hub->op_regs->portrs[setup_packet->index - 1]; 346 347 const uint32_t status = uint32_host2usb( 348 XHCI_TO_USB(USB_HUB_FEATURE_C_PORT_CONNECTION, regs, XHCI_PORT_CSC) | 349 XHCI_TO_USB(USB_HUB_FEATURE_C_PORT_ENABLE, regs, XHCI_PORT_PEC) | 350 XHCI_TO_USB(USB_HUB_FEATURE_C_PORT_OVER_CURRENT, regs, XHCI_PORT_OCC) | 351 XHCI_TO_USB(USB_HUB_FEATURE_C_PORT_RESET, regs, XHCI_PORT_PRC) | 352 XHCI_TO_USB(USB_HUB_FEATURE_PORT_CONNECTION, regs, XHCI_PORT_CCS) | 353 XHCI_TO_USB(USB_HUB_FEATURE_PORT_ENABLE, regs, XHCI_PORT_PED) | 354 XHCI_TO_USB(USB_HUB_FEATURE_PORT_OVER_CURRENT, regs, XHCI_PORT_OCA) | 355 XHCI_TO_USB(USB_HUB_FEATURE_PORT_RESET, regs, XHCI_PORT_PR) | 356 XHCI_TO_USB(USB_HUB_FEATURE_PORT_POWER, regs, XHCI_PORT_PP) 357 ); 358 359 usb_log_debug2("RH: GetPortStatus(%hu) = %u.", setup_packet->index, 360 uint32_usb2host(status)); 361 362 memcpy(data, &status, sizeof(status)); 363 *act_size = sizeof(status); 332 364 return EOK; 333 365 } … … 374 406 * @param buffer_size Bytes available in buffer 375 407 * @param actual_size Size us the used part of the dest buffer. 408 * 409 * Produces status mask. Bit 0 indicates hub status change the other bits 410 * represent port status change. 376 411 */ 377 412 static int req_status_change_handler(usbvirt_device_t *device, … … 380 415 { 381 416 usb_log_debug2("Called req_status_change_handler()."); 417 xhci_rh_t *hub = virthub_get_data(device); 418 assert(hub); 419 420 if (buffer_size < 16) 421 return ESTALL; 422 423 /* TODO: Set this based on the received event TRBs. */ 424 memset(buffer, 0, 16); 425 *actual_size = 16; 426 427 /* TODO: Set to EOK if something happened. */ 382 428 return ENAK; 383 429 } -
uspace/drv/bus/usb/xhci/rh.h
r7776cb1 r5c5c9407 48 48 /** Virtual hub instance */ 49 49 virthub_base_t base; 50 /** XHCI operational registers */ 51 xhci_op_regs_t *op_regs; 50 52 /** USB hub descriptor describing the XHCI root hub */ 51 53 struct { … … 62 64 } xhci_rh_t; 63 65 64 int xhci_rh_init(xhci_rh_t * );66 int xhci_rh_init(xhci_rh_t *, xhci_op_regs_t *); 65 67 int xhci_rh_fini(xhci_rh_t *); 66 68 int xhci_handle_port_status_change_event(xhci_hc_t *, xhci_trb_t *);
Note:
See TracChangeset
for help on using the changeset viewer.