Changeset 665bf3c in mainline for uspace/drv/bus/usb/xhci/commands.c
- Timestamp:
- 2017-07-13T18:28:19Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c9ce62a
- Parents:
- 8db42f7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/xhci/commands.c
r8db42f7 r665bf3c 126 126 } 127 127 128 int xhci_send_configure_endpoint_command(xhci_hc_t *hc, uint32_t slot_id, 129 xhci_input_ctx_t *ictx) 130 { 131 xhci_trb_t trb; 132 memset(&trb, 0, sizeof(trb)); 133 134 uint64_t phys_addr = (uint64_t) addr_to_phys(ictx); 135 trb.parameter = host2xhci(32, phys_addr & 0xFFFFFFFFFFFFFFF0); 136 137 trb.control = host2xhci(32, XHCI_TRB_TYPE_CONFIGURE_ENDPOINT_CMD << 10); 138 trb.control |= host2xhci(32, hc->command_ring.pcs); 139 trb.control |= host2xhci(32, slot_id << 24); 140 141 return enqueue_trb(hc, &trb, 0, 0); 142 } 143 144 static int report_error(int code) 145 { 146 // TODO: Order these by their value. 147 switch (code) { 148 case XHCI_TRBC_NO_SLOTS_ERROR: 149 usb_log_error("Device slot not available."); 150 break; 151 case XHCI_TRBC_SLOT_NOT_ENABLE_ERROR: 152 usb_log_error("Slot ID is not enabled."); 153 break; 154 case XHCI_TRBC_CONTEXT_STATE_ERROR: 155 usb_log_error("Slot is not in enabled or default state."); 156 break; 157 case XHCI_TRBC_TRANSACTION_ERROR: 158 usb_log_error("Request to the USB device failed."); 159 break; 160 case XHCI_TRBC_BANDWIDTH_ERROR: 161 usb_log_error("Bandwidth required is not available."); 162 break; 163 case XHCI_TRBC_SECONDARY_BANDWIDTH_ERROR: 164 usb_log_error("Bandwidth error encountered in secondary domain."); 165 break; 166 case XHCI_TRBC_RESOURCE_ERROR: 167 usb_log_error("Resource required is not available."); 168 break; 169 case XHCI_TRBC_PARAMETER_ERROR: 170 usb_log_error("Parameter given is invalid."); 171 break; 172 default: 173 usb_log_error("Unknown error code."); 174 break; 175 } 176 return ENAK; 177 } 178 128 179 int xhci_handle_command_completion(xhci_hc_t *hc, xhci_trb_t *trb) 129 180 { … … 138 189 command = (xhci_trb_t *) XHCI_QWORD_EXTRACT(trb->parameter, 63, 4); 139 190 slot_id = XHCI_DWORD_EXTRACT(trb->control, 31, 24); 140 (void) slot_id; 191 192 if (TRB_TYPE(*command) != XHCI_TRB_TYPE_NO_OP_CMD) { 193 if (code != XHCI_TRBC_SUCCESS) { 194 usb_log_debug2("Command resulted in failure."); 195 xhci_dump_trb(command); 196 } 197 } 141 198 142 199 switch (TRB_TYPE(*command)) { 143 200 case XHCI_TRB_TYPE_NO_OP_CMD: 144 assert(code = =XHCI_TRBC_TRB_ERROR);145 break;201 assert(code = XHCI_TRBC_TRB_ERROR); 202 return EOK; 146 203 case XHCI_TRB_TYPE_ENABLE_SLOT_CMD: 147 // TODO: Call a device addition callback once it's implemented. 148 break; 204 return EOK; 149 205 case XHCI_TRB_TYPE_DISABLE_SLOT_CMD: 150 if (code == XHCI_TRBC_SLOT_NOT_ENABLED_ERROR) 151 usb_log_debug2("Slot ID to be disabled was not enabled."); 152 // TODO: Call a device removal callback that will deallocate associated 153 // data structures once it's implemented. 154 break; 206 return EOK; 155 207 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; 208 return EOK; 209 case XHCI_TRB_TYPE_CONFIGURE_ENDPOINT_CMD: 210 return EOK; 164 211 default: 165 212 usb_log_debug2("Unsupported command trb."); 166 213 xhci_dump_trb(command); 167 break;214 return ENAK; 168 215 } 169 170 return EOK;171 216 } 172 217
Note:
See TracChangeset
for help on using the changeset viewer.