source: mainline/uspace/drv/bus/usb/xhci/commands.c@ 327f147

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 327f147 was 74b852b, checked in by Jaroslav Jindrak <dzejrou@…>, 8 years ago

Added synchronization to command list.

  • Property mode set to 100644
File size: 13.6 KB
RevLine 
[c9c0e41]1/*
2 * Copyright (c) 2017 Jaroslav Jindrak
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup drvusbxhci
30 * @{
31 */
32/** @file
33 * @brief Command sending functions.
34 */
35
36#include <errno.h>
37#include <str_error.h>
38#include <usb/debug.h>
39#include <usb/host/utils/malloc32.h>
40#include "commands.h"
41#include "debug.h"
42#include "hc.h"
[8db42f7]43#include "hw_struct/context.h"
[c9c0e41]44#include "hw_struct/trb.h"
45
[1b78a7c1]46#define TRB_SET_TCS(trb, tcs) (trb).control |= host2xhci(32, ((tcs &0x1) << 9))
47#define TRB_SET_TYPE(trb, type) (trb).control |= host2xhci(32, (type) << 10)
48#define TRB_SET_EP(trb, ep) (trb).control |= host2xhci(32, ((ep) & 0x5) << 16)
[0cabd10]49#define TRB_SET_STREAM(trb, st) (trb).control |= host2xhci(32, ((st) & 0xFFFF) << 16)
[1b78a7c1]50#define TRB_SET_SUSP(trb, susp) (trb).control |= host2xhci(32, ((susp) & 0x1) << 23)
51#define TRB_SET_SLOT(trb, slot) (trb).control |= host2xhci(32, (slot) << 24)
[60af4cdb]52#define TRB_SET_DEV_SPEED(trb, speed) (trb).control |= host2xhci(32, (speed & 0xF) << 16)
[1b78a7c1]53
[0cabd10]54/**
55 * TODO: Not sure about SCT and DCS (see section 6.4.3.9).
56 */
57#define TRB_SET_DEQUEUE_PTR(trb, dptr) (trb).parameter |= host2xhci(64, (dptr))
[548c123]58#define TRB_SET_ICTX(trb, phys) (trb).parameter |= host2xhci(64, phys_addr & (~0xF))
[1b78a7c1]59
60#define TRB_GET_CODE(trb) XHCI_DWORD_EXTRACT((trb).status, 31, 24)
61#define TRB_GET_SLOT(trb) XHCI_DWORD_EXTRACT((trb).control, 31, 24)
62#define TRB_GET_PHYS(trb) (XHCI_QWORD_EXTRACT((trb).parameter, 63, 4) << 4)
63
[110d795]64int xhci_init_commands(xhci_hc_t *hc)
65{
66 assert(hc);
67
68 list_initialize(&hc->commands);
[74b852b]69
70 fibril_mutex_initialize(&hc->commands_mtx);
71
[110d795]72 return EOK;
73}
74
[c46c356]75void xhci_fini_commands(xhci_hc_t *hc)
76{
77 // Note: Untested.
78 assert(hc);
79}
80
[913007f]81int xhci_cmd_wait(xhci_cmd_t *cmd, suseconds_t timeout)
[110d795]82{
[4688350b]83 int rv = EOK;
84
85 fibril_mutex_lock(&cmd->completed_mtx);
[110d795]86 while (!cmd->completed) {
[4688350b]87 usb_log_debug2("Waiting for event completion: going to sleep.");
88 rv = fibril_condvar_wait_timeout(&cmd->completed_cv, &cmd->completed_mtx, timeout);
[110d795]89
[4688350b]90 usb_log_debug2("Waiting for event completion: woken: %s", str_error(rv));
91 if (rv == ETIMEOUT)
92 break;
[110d795]93 }
[1f76b7d]94 fibril_mutex_unlock(&cmd->completed_mtx);
[110d795]95
[4688350b]96 return rv;
[110d795]97}
98
[04df063]99xhci_cmd_t *xhci_cmd_alloc(void)
[110d795]100{
[078e0e6]101 xhci_cmd_t *cmd = malloc(sizeof(xhci_cmd_t));
[4688350b]102 xhci_cmd_init(cmd);
[04df063]103
104 usb_log_debug2("Allocating cmd on the heap. Don't forget to deallocate it!");
[4688350b]105 return cmd;
106}
107
108void xhci_cmd_init(xhci_cmd_t *cmd)
109{
110 memset(cmd, 0, sizeof(*cmd));
[110d795]111
112 link_initialize(&cmd->link);
113
[4688350b]114 fibril_mutex_initialize(&cmd->completed_mtx);
115 fibril_condvar_initialize(&cmd->completed_cv);
[110d795]116}
117
[04df063]118void xhci_cmd_fini(xhci_cmd_t *cmd)
[110d795]119{
[9304b66]120 list_remove(&cmd->link);
[04df063]121}
[9304b66]122
[04df063]123void xhci_cmd_free(xhci_cmd_t *cmd)
124{
125 xhci_cmd_fini(cmd);
[078e0e6]126 free(cmd);
[110d795]127}
128
[2fa43d1]129static inline xhci_cmd_t *get_command(xhci_hc_t *hc, uint64_t phys)
[110d795]130{
[74b852b]131 fibril_mutex_lock(&hc->commands_mtx);
132
[110d795]133 link_t *cmd_link = list_first(&hc->commands);
134
[2fa43d1]135 while (cmd_link != NULL) {
136 xhci_cmd_t *cmd = list_get_instance(cmd_link, xhci_cmd_t, link);
137
[548c123]138 if (cmd->trb_phys == phys)
[2fa43d1]139 break;
140
141 cmd_link = list_next(cmd_link, &hc->commands);
142 }
143
[110d795]144 if (cmd_link != NULL) {
145 list_remove(cmd_link);
[74b852b]146 fibril_mutex_unlock(&hc->commands_mtx);
[9f5b613]147
[110d795]148 return list_get_instance(cmd_link, xhci_cmd_t, link);
149 }
150
[74b852b]151 fibril_mutex_unlock(&hc->commands_mtx);
[110d795]152 return NULL;
153}
154
[548c123]155static inline int enqueue_command(xhci_hc_t *hc, xhci_cmd_t *cmd, unsigned doorbell, unsigned target)
[481af21e]156{
[c058a388]157 assert(hc);
[548c123]158 assert(cmd);
159
[74b852b]160 fibril_mutex_lock(&hc->commands_mtx);
[548c123]161 list_append(&cmd->link, &hc->commands);
[74b852b]162 fibril_mutex_unlock(&hc->commands_mtx);
[c058a388]163
[548c123]164 xhci_trb_ring_enqueue(&hc->command_ring, &cmd->trb, &cmd->trb_phys);
[a0be5d0]165 hc_ring_doorbell(hc, doorbell, target);
[481af21e]166
[548c123]167 usb_log_debug2("HC(%p): Sent command:", hc);
168 xhci_dump_trb(&cmd->trb);
[481af21e]169
170 return EOK;
171}
172
[3dc519f]173void xhci_stop_command_ring(xhci_hc_t *hc)
174{
175 assert(hc);
176
177 XHCI_REG_SET(hc->op_regs, XHCI_OP_CS, 1);
178
179 /**
180 * Note: There is a bug in qemu that checks CS only when CRCR_HI
181 * is written, this (and the read/write in abort) ensures
182 * the command rings stops.
183 */
184 XHCI_REG_WR(hc->op_regs, XHCI_OP_CRCR_HI, XHCI_REG_RD(hc->op_regs, XHCI_OP_CRCR_HI));
185}
186
187void xhci_abort_command_ring(xhci_hc_t *hc)
188{
189 assert(hc);
190
191 XHCI_REG_WR(hc->op_regs, XHCI_OP_CA, 1);
192 XHCI_REG_WR(hc->op_regs, XHCI_OP_CRCR_HI, XHCI_REG_RD(hc->op_regs, XHCI_OP_CRCR_HI));
193}
194
195void xhci_start_command_ring(xhci_hc_t *hc)
196{
197 assert(hc);
198
199 XHCI_REG_WR(hc->op_regs, XHCI_OP_CRR, 1);
[a0be5d0]200 hc_ring_doorbell(hc, 0, 0);
[3dc519f]201}
202
[4fa5342]203static const char *trb_codes [] = {
204#define TRBC(t) [XHCI_TRBC_##t] = #t
205 TRBC(INVALID),
206 TRBC(SUCCESS),
207 TRBC(DATA_BUFFER_ERROR),
208 TRBC(BABBLE_DETECTED_ERROR),
209 TRBC(USB_TRANSACTION_ERROR),
210 TRBC(TRB_ERROR),
211 TRBC(STALL_ERROR),
212 TRBC(RESOURCE_ERROR),
213 TRBC(BANDWIDTH_ERROR),
214 TRBC(NO_SLOTS_ERROR),
215 TRBC(INVALID_STREAM_ERROR),
216 TRBC(SLOT_NOT_ENABLED_ERROR),
217 TRBC(EP_NOT_ENABLED_ERROR),
218 TRBC(SHORT_PACKET),
219 TRBC(RING_UNDERRUN),
220 TRBC(RING_OVERRUN),
221 TRBC(VF_EVENT_RING_FULL),
222 TRBC(PARAMETER_ERROR),
223 TRBC(BANDWIDTH_OVERRUN_ERROR),
224 TRBC(CONTEXT_STATE_ERROR),
225 TRBC(NO_PING_RESPONSE_ERROR),
226 TRBC(EVENT_RING_FULL_ERROR),
227 TRBC(INCOMPATIBLE_DEVICE_ERROR),
228 TRBC(MISSED_SERVICE_ERROR),
229 TRBC(COMMAND_RING_STOPPED),
230 TRBC(COMMAND_ABORTED),
231 TRBC(STOPPED),
232 TRBC(STOPPED_LENGTH_INVALID),
233 TRBC(STOPPED_SHORT_PACKET),
234 TRBC(MAX_EXIT_LATENCY_TOO_LARGE_ERROR),
235 [30] = "<reserved>",
236 TRBC(ISOCH_BUFFER_OVERRUN),
237 TRBC(EVENT_LOST_ERROR),
238 TRBC(UNDEFINED_ERROR),
239 TRBC(INVALID_STREAM_ID_ERROR),
240 TRBC(SECONDARY_BANDWIDTH_ERROR),
241 TRBC(SPLIT_TRANSACTION_ERROR),
242 [XHCI_TRBC_MAX] = NULL
243#undef TRBC
244};
245
246static void report_error(int code)
247{
248 if (code < XHCI_TRBC_MAX && trb_codes[code] != NULL)
249 usb_log_error("Command resulted in error: %s.", trb_codes[code]);
250 else
251 usb_log_error("Command resulted in reserved or vendor specific error.");
252}
253
[110d795]254int xhci_send_no_op_command(xhci_hc_t *hc, xhci_cmd_t *cmd)
[c9c0e41]255{
[c058a388]256 assert(hc);
257
[548c123]258 xhci_trb_clean(&cmd->trb);
[c9c0e41]259
[548c123]260 TRB_SET_TYPE(cmd->trb, XHCI_TRB_TYPE_NO_OP_CMD);
[110d795]261
[548c123]262 return enqueue_command(hc, cmd, 0, 0);
[c9c0e41]263}
264
[110d795]265int xhci_send_enable_slot_command(xhci_hc_t *hc, xhci_cmd_t *cmd)
[c9c0e41]266{
[c058a388]267 assert(hc);
268
[548c123]269 xhci_trb_clean(&cmd->trb);
[c9c0e41]270
[548c123]271 TRB_SET_TYPE(cmd->trb, XHCI_TRB_TYPE_ENABLE_SLOT_CMD);
272 cmd->trb.control |= host2xhci(32, XHCI_REG_RD(hc->xecp, XHCI_EC_SP_SLOT_TYPE) << 16);
[110d795]273
[548c123]274 return enqueue_command(hc, cmd, 0, 0);
[5ac5eb1]275}
276
[110d795]277int xhci_send_disable_slot_command(xhci_hc_t *hc, xhci_cmd_t *cmd)
[5ac5eb1]278{
[c058a388]279 assert(hc);
[110d795]280 assert(cmd);
[c058a388]281
[548c123]282 xhci_trb_clean(&cmd->trb);
[5ac5eb1]283
[548c123]284 TRB_SET_TYPE(cmd->trb, XHCI_TRB_TYPE_DISABLE_SLOT_CMD);
285 TRB_SET_SLOT(cmd->trb, cmd->slot_id);
[110d795]286
[548c123]287 return enqueue_command(hc, cmd, 0, 0);
[c9c0e41]288}
289
[04df063]290int xhci_send_address_device_command(xhci_hc_t *hc, xhci_cmd_t *cmd, xhci_input_ctx_t *ictx)
[8db42f7]291{
[c058a388]292 assert(hc);
[110d795]293 assert(cmd);
[04df063]294 assert(ictx);
[c058a388]295
[8db42f7]296 /**
297 * TODO: Requirements for this command:
298 * dcbaa[slot_id] is properly sized and initialized
299 * ictx has valids slot context and endpoint 0, all
300 * other should be ignored at this point (see section 4.6.5).
301 */
[04df063]302
[548c123]303 xhci_trb_clean(&cmd->trb);
[8db42f7]304
[04df063]305 uint64_t phys_addr = (uint64_t) addr_to_phys(ictx);
[548c123]306 TRB_SET_ICTX(cmd->trb, phys_addr);
[8db42f7]307
308 /**
309 * Note: According to section 6.4.3.4, we can set the 9th bit
310 * of the control field of the trb (BSR) to 1 and then the xHC
311 * will not issue the SET_ADDRESS request to the USB device.
312 * This can be used to provide compatibility with legacy USB devices
313 * that require their device descriptor to be read before such request.
314 */
[548c123]315 TRB_SET_TYPE(cmd->trb, XHCI_TRB_TYPE_ADDRESS_DEVICE_CMD);
316 TRB_SET_SLOT(cmd->trb, cmd->slot_id);
[8db42f7]317
[548c123]318 return enqueue_command(hc, cmd, 0, 0);
[8db42f7]319}
320
[04df063]321int xhci_send_configure_endpoint_command(xhci_hc_t *hc, xhci_cmd_t *cmd, xhci_input_ctx_t *ictx)
[665bf3c]322{
[c058a388]323 assert(hc);
[110d795]324 assert(cmd);
[04df063]325 assert(ictx);
[c058a388]326
[548c123]327 xhci_trb_clean(&cmd->trb);
[665bf3c]328
[04df063]329 uint64_t phys_addr = (uint64_t) addr_to_phys(ictx);
[548c123]330 TRB_SET_ICTX(cmd->trb, phys_addr);
[110d795]331
[548c123]332 TRB_SET_TYPE(cmd->trb, XHCI_TRB_TYPE_CONFIGURE_ENDPOINT_CMD);
333 TRB_SET_SLOT(cmd->trb, cmd->slot_id);
[665bf3c]334
[548c123]335 return enqueue_command(hc, cmd, 0, 0);
[665bf3c]336}
337
[04df063]338int xhci_send_evaluate_context_command(xhci_hc_t *hc, xhci_cmd_t *cmd, xhci_input_ctx_t *ictx)
[c9ce62ae]339{
[c058a388]340 assert(hc);
[110d795]341 assert(cmd);
[04df063]342 assert(ictx);
[c058a388]343
[c9ce62ae]344 /**
345 * Note: All Drop Context flags of the input context shall be 0,
346 * all Add Context flags shall be initialize to indicate IDs
347 * of the contexts affected by the command.
348 * Refer to sections 6.2.2.3 and 6.3.3.3 for further info.
349 */
[548c123]350 xhci_trb_clean(&cmd->trb);
[c9ce62ae]351
[04df063]352 uint64_t phys_addr = (uint64_t) addr_to_phys(ictx);
[548c123]353 TRB_SET_ICTX(cmd->trb, phys_addr);
[c9ce62ae]354
[548c123]355 TRB_SET_TYPE(cmd->trb, XHCI_TRB_TYPE_EVALUATE_CONTEXT_CMD);
356 TRB_SET_SLOT(cmd->trb, cmd->slot_id);
[110d795]357
[548c123]358 return enqueue_command(hc, cmd, 0, 0);
[c9ce62ae]359}
360
[110d795]361int xhci_send_reset_endpoint_command(xhci_hc_t *hc, xhci_cmd_t *cmd, uint32_t ep_id, uint8_t tcs)
[05aeee0e]362{
[c058a388]363 assert(hc);
[110d795]364 assert(cmd);
[c058a388]365
[05aeee0e]366 /**
367 * Note: TCS can have values 0 or 1. If it is set to 0, see sectuon 4.5.8 for
368 * information about this flag.
369 */
[548c123]370 xhci_trb_clean(&cmd->trb);
[05aeee0e]371
[548c123]372 TRB_SET_TYPE(cmd->trb, XHCI_TRB_TYPE_RESET_ENDPOINT_CMD);
373 TRB_SET_TCS(cmd->trb, tcs);
374 TRB_SET_EP(cmd->trb, ep_id);
375 TRB_SET_SLOT(cmd->trb, cmd->slot_id);
[c9bec1c]376
[548c123]377 return enqueue_command(hc, cmd, 0, 0);
[05aeee0e]378}
379
[110d795]380int xhci_send_stop_endpoint_command(xhci_hc_t *hc, xhci_cmd_t *cmd, uint32_t ep_id, uint8_t susp)
[05aeee0e]381{
[c058a388]382 assert(hc);
[110d795]383 assert(cmd);
[c058a388]384
[548c123]385 xhci_trb_clean(&cmd->trb);
[110d795]386
[548c123]387 TRB_SET_TYPE(cmd->trb, XHCI_TRB_TYPE_STOP_ENDPOINT_CMD);
388 TRB_SET_EP(cmd->trb, ep_id);
389 TRB_SET_SUSP(cmd->trb, susp);
390 TRB_SET_SLOT(cmd->trb, cmd->slot_id);
[05aeee0e]391
[548c123]392 return enqueue_command(hc, cmd, 0, 0);
[c058a388]393}
[05aeee0e]394
[0cabd10]395int xhci_send_set_dequeue_ptr_command(xhci_hc_t *hc, xhci_cmd_t *cmd,
396 uintptr_t dequeue_ptr, uint16_t stream_id,
397 uint32_t ep_id)
398{
399 assert(hc);
400 assert(cmd);
401
[548c123]402 xhci_trb_clean(&cmd->trb);
[0cabd10]403
[548c123]404 TRB_SET_TYPE(cmd->trb, XHCI_TRB_TYPE_SET_TR_DEQUEUE_POINTER_CMD);
405 TRB_SET_EP(cmd->trb, ep_id);
406 TRB_SET_STREAM(cmd->trb, stream_id);
407 TRB_SET_SLOT(cmd->trb, cmd->slot_id);
408 TRB_SET_DEQUEUE_PTR(cmd->trb, dequeue_ptr);
[0cabd10]409
410 /**
411 * TODO: Set DCS (see section 4.6.10).
412 */
413
[548c123]414 return enqueue_command(hc, cmd, 0, 0);
[0cabd10]415}
416
[110d795]417int xhci_send_reset_device_command(xhci_hc_t *hc, xhci_cmd_t *cmd)
[c058a388]418{
419 assert(hc);
[110d795]420 assert(cmd);
[c058a388]421
[548c123]422 xhci_trb_clean(&cmd->trb);
[c058a388]423
[548c123]424 TRB_SET_TYPE(cmd->trb, XHCI_TRB_TYPE_RESET_DEVICE_CMD);
425 TRB_SET_SLOT(cmd->trb, cmd->slot_id);
[c9bec1c]426
[548c123]427 return enqueue_command(hc, cmd, 0, 0);
[05aeee0e]428}
429
[60af4cdb]430int xhci_get_port_bandwidth_command(xhci_hc_t *hc, xhci_cmd_t *cmd,
431 xhci_port_bandwidth_ctx_t *ctx, uint8_t device_speed)
432{
433 assert(hc);
434 assert(cmd);
435
436 xhci_trb_clean(&cmd->trb);
437
438 uint64_t phys_addr = (uint64_t) addr_to_phys(ctx);
439 TRB_SET_ICTX(cmd->trb, phys_addr);
440
441 TRB_SET_TYPE(cmd->trb, XHCI_TRB_TYPE_GET_PORT_BANDWIDTH_CMD);
442 TRB_SET_SLOT(cmd->trb, cmd->slot_id);
443 TRB_SET_DEV_SPEED(cmd->trb, device_speed);
444
445 return enqueue_command(hc, cmd, 0, 0);
446}
447
[f9e7fe8]448int xhci_handle_command_completion(xhci_hc_t *hc, xhci_trb_t *trb)
449{
[110d795]450 // TODO: Update dequeue ptrs.
[c058a388]451 assert(hc);
452 assert(trb);
453
[d1d7a92]454 usb_log_debug2("HC(%p) Command completed.", hc);
[f9e7fe8]455
[5ac5eb1]456 int code;
[2fa43d1]457 uint64_t phys;
[110d795]458 xhci_cmd_t *command;
[f711f06]459
[1b78a7c1]460 code = TRB_GET_CODE(*trb);
461 phys = TRB_GET_PHYS(*trb);;
[2fa43d1]462 command = get_command(hc, phys);
463 if (command == NULL) {
464 // TODO: STOP & ABORT may not have command structs in the list!
[d1d7a92]465 usb_log_warning("No command struct for this completion event found.");
[2fa43d1]466
467 if (code != XHCI_TRBC_SUCCESS)
468 report_error(code);
469
470 return EOK;
471 }
[110d795]472
473 command->status = code;
[1b78a7c1]474 command->slot_id = TRB_GET_SLOT(*trb);
[110d795]475
[548c123]476 usb_log_debug2("Completed command trb: %s", xhci_trb_str_type(TRB_TYPE(command->trb)));
477 if (TRB_TYPE(command->trb) != XHCI_TRB_TYPE_NO_OP_CMD) {
[665bf3c]478 if (code != XHCI_TRBC_SUCCESS) {
[4fa5342]479 report_error(code);
[548c123]480 xhci_dump_trb(&command->trb);
[665bf3c]481 }
482 }
[c362127]483
[548c123]484 switch (TRB_TYPE(command->trb)) {
[c362127]485 case XHCI_TRB_TYPE_NO_OP_CMD:
[9f5b613]486 assert(code == XHCI_TRBC_TRB_ERROR);
[110d795]487 break;
[c362127]488 case XHCI_TRB_TYPE_ENABLE_SLOT_CMD:
[110d795]489 break;
[5ac5eb1]490 case XHCI_TRB_TYPE_DISABLE_SLOT_CMD:
[110d795]491 break;
[8db42f7]492 case XHCI_TRB_TYPE_ADDRESS_DEVICE_CMD:
[110d795]493 break;
[665bf3c]494 case XHCI_TRB_TYPE_CONFIGURE_ENDPOINT_CMD:
[110d795]495 break;
[c9ce62ae]496 case XHCI_TRB_TYPE_EVALUATE_CONTEXT_CMD:
[110d795]497 break;
[05aeee0e]498 case XHCI_TRB_TYPE_RESET_ENDPOINT_CMD:
[110d795]499 break;
[05aeee0e]500 case XHCI_TRB_TYPE_STOP_ENDPOINT_CMD:
501 // Note: If the endpoint was in the middle of a transfer, then the xHC
502 // will add a Transfer TRB before the Event TRB, research that and
503 // handle it appropriately!
[110d795]504 break;
[c058a388]505 case XHCI_TRB_TYPE_RESET_DEVICE_CMD:
[110d795]506 break;
[c362127]507 default:
[548c123]508 usb_log_debug2("Unsupported command trb: %s", xhci_trb_str_type(TRB_TYPE(command->trb)));
[110d795]509
510 command->completed = true;
[665bf3c]511 return ENAK;
[f711f06]512 }
[110d795]513
[4688350b]514 fibril_mutex_lock(&command->completed_mtx);
[110d795]515 command->completed = true;
[4688350b]516 fibril_condvar_broadcast(&command->completed_cv);
517 fibril_mutex_unlock(&command->completed_mtx);
518
[110d795]519 return EOK;
[f9e7fe8]520}
[c9c0e41]521
522
523/**
524 * @}
525 */
Note: See TracBrowser for help on using the repository browser.