Changeset 8db42f7 in mainline
- Timestamp:
- 2017-07-13T15:13:12Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 665bf3c
- Parents:
- 5ac5eb1
- Location:
- uspace/drv/bus/usb/xhci
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/xhci/commands.c
r5ac5eb1 r8db42f7 41 41 #include "debug.h" 42 42 #include "hc.h" 43 #include "hw_struct/context.h" 43 44 #include "hw_struct/trb.h" 44 45 … … 96 97 } 97 98 99 int xhci_send_address_device_command(xhci_hc_t *hc, uint32_t slot_id, 100 xhci_input_ctx_t *ictx) 101 { 102 /** 103 * TODO: Requirements for this command: 104 * dcbaa[slot_id] is properly sized and initialized 105 * ictx has valids slot context and endpoint 0, all 106 * other should be ignored at this point (see section 4.6.5). 107 */ 108 xhci_trb_t trb; 109 memset(&trb, 0, sizeof(trb)); 110 111 uint64_t phys_addr = (uint64_t) addr_to_phys(ictx); 112 trb.parameter = host2xhci(32, phys_addr & 0xFFFFFFFFFFFFFFF0); 113 114 /** 115 * Note: According to section 6.4.3.4, we can set the 9th bit 116 * of the control field of the trb (BSR) to 1 and then the xHC 117 * will not issue the SET_ADDRESS request to the USB device. 118 * This can be used to provide compatibility with legacy USB devices 119 * that require their device descriptor to be read before such request. 120 */ 121 trb.control = host2xhci(32, XHCI_TRB_TYPE_ADDRESS_DEVICE_CMD << 10); 122 trb.control |= host2xhci(32, hc->command_ring.pcs); 123 trb.control |= host2xhci(32, slot_id << 24); 124 125 return enqueue_trb(hc, &trb, 0, 0); 126 } 127 98 128 int xhci_handle_command_completion(xhci_hc_t *hc, xhci_trb_t *trb) 99 129 { … … 123 153 // data structures once it's implemented. 124 154 break; 155 case XHCI_TRB_TYPE_ADDRESS_DEVICE_CMD: 156 if (code == XHCI_TRBC_SLOT_NOT_ENABLED_ERROR) 157 usb_log_debug2("Slot to be addressed was not enabled."); 158 else if (code == XHCI_TRBC_CONTEXT_STATE_ERROR) 159 usb_log_debug2("Slot to be addressed is not in enabled or default state."); 160 else if (code == XHCI_TRBC_USB_TRANSACTION_ERROR) 161 usb_log_debug2("SET_ADDRESS request to the USB device failed."); 162 // TODO: Call set address callback when it's implemented. 163 break; 125 164 default: 126 165 usb_log_debug2("Unsupported command trb."); -
uspace/drv/bus/usb/xhci/commands.h
r5ac5eb1 r8db42f7 39 39 typedef struct xhci_hc xhci_hc_t; 40 40 typedef struct xhci_trb xhci_trb_t; 41 typedef struct xhci_input_ctx xhci_input_ctx_t; 41 42 42 43 int xhci_send_no_op_command(xhci_hc_t *); 43 44 int xhci_send_enable_slot_command(xhci_hc_t *); 44 45 int xhci_send_disable_slot_command(xhci_hc_t *, uint32_t); 46 int xhci_send_address_device_command(xhci_hc_t *, uint32_t, xhci_input_ctx_t *); 45 47 46 48 int xhci_handle_command_completion(xhci_hc_t *, xhci_trb_t *);
Note:
See TracChangeset
for help on using the changeset viewer.