source: mainline/uspace/drv/bus/usb/uhci/hc.c

Last change on this file was 8300c72, checked in by Jiri Svoboda <jiri@…>, 5 months ago

Quiesce devices before proceeding with shutdown.

Only implemented for e1k, uhci and xhci.

  • Property mode set to 100644
File size: 19.6 KB
Line 
1/*
2 * Copyright (c) 2025 Jiri Svoboda
3 * Copyright (c) 2011 Jan Vesely
4 * Copyright (c) 2018 Ondrej Hlavaty, Petr Manek
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * - Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * - Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * - The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31/** @addtogroup drvusbuhci
32 * @{
33 */
34/** @file
35 * @brief UHCI Host controller driver routines
36 */
37
38#include <adt/list.h>
39#include <assert.h>
40#include <async.h>
41#include <ddi.h>
42#include <device/hw_res_parsed.h>
43#include <fibril.h>
44#include <errno.h>
45#include <macros.h>
46#include <mem.h>
47#include <stdbool.h>
48#include <stdlib.h>
49#include <stdint.h>
50#include <str_error.h>
51
52#include <usb/debug.h>
53#include <usb/usb.h>
54#include <usb/host/utils/malloc32.h>
55#include <usb/host/bandwidth.h>
56#include <usb/host/utility.h>
57
58#include "uhci_batch.h"
59#include "transfer_list.h"
60#include "hc.h"
61
62#define UHCI_INTR_ALLOW_INTERRUPTS \
63 (UHCI_INTR_CRC | UHCI_INTR_COMPLETE | UHCI_INTR_SHORT_PACKET)
64#define UHCI_STATUS_USED_INTERRUPTS \
65 (UHCI_STATUS_INTERRUPT | UHCI_STATUS_ERROR_INTERRUPT)
66
67static const irq_pio_range_t uhci_irq_pio_ranges[] = {
68 {
69 .base = 0,
70 .size = sizeof(uhci_regs_t)
71 }
72};
73
74static const irq_cmd_t uhci_irq_commands[] = {
75 {
76 .cmd = CMD_PIO_READ_16,
77 .dstarg = 1,
78 .addr = NULL
79 },
80 {
81 .cmd = CMD_AND,
82 .srcarg = 1,
83 .dstarg = 2,
84 .value = UHCI_STATUS_USED_INTERRUPTS | UHCI_STATUS_NM_INTERRUPTS
85 },
86 {
87 .cmd = CMD_PREDICATE,
88 .srcarg = 2,
89 .value = 2
90 },
91 {
92 .cmd = CMD_PIO_WRITE_A_16,
93 .srcarg = 1,
94 .addr = NULL
95 },
96 {
97 .cmd = CMD_ACCEPT
98 }
99};
100
101static void hc_init_hw(const hc_t *instance);
102static errno_t hc_init_mem_structures(hc_t *instance);
103static errno_t hc_init_transfer_lists(hc_t *instance);
104
105static errno_t hc_debug_checker(void *arg);
106
107/** Generate IRQ code.
108 * @param[out] code IRQ code structure.
109 * @param[in] hw_res Device's resources.
110 * @param[out] irq
111 *
112 * @return Error code.
113 */
114errno_t hc_gen_irq_code(irq_code_t *code, hc_device_t *hcd, const hw_res_list_parsed_t *hw_res, int *irq)
115{
116 assert(code);
117 assert(hw_res);
118
119 if (hw_res->irqs.count != 1 || hw_res->io_ranges.count != 1)
120 return EINVAL;
121 const addr_range_t regs = hw_res->io_ranges.ranges[0];
122
123 if (RNGSZ(regs) < sizeof(uhci_regs_t))
124 return EOVERFLOW;
125
126 code->ranges = malloc(sizeof(uhci_irq_pio_ranges));
127 if (code->ranges == NULL)
128 return ENOMEM;
129
130 code->cmds = malloc(sizeof(uhci_irq_commands));
131 if (code->cmds == NULL) {
132 free(code->ranges);
133 return ENOMEM;
134 }
135
136 code->rangecount = ARRAY_SIZE(uhci_irq_pio_ranges);
137 code->cmdcount = ARRAY_SIZE(uhci_irq_commands);
138
139 memcpy(code->ranges, uhci_irq_pio_ranges, sizeof(uhci_irq_pio_ranges));
140 code->ranges[0].base = RNGABS(regs);
141
142 memcpy(code->cmds, uhci_irq_commands, sizeof(uhci_irq_commands));
143 uhci_regs_t *registers = (uhci_regs_t *) RNGABSPTR(regs);
144 code->cmds[0].addr = (void *)&registers->usbsts;
145 code->cmds[3].addr = (void *)&registers->usbsts;
146
147 usb_log_debug("I/O regs at %p (size %zu), IRQ %d.",
148 RNGABSPTR(regs), RNGSZ(regs), hw_res->irqs.irqs[0]);
149
150 *irq = hw_res->irqs.irqs[0];
151 return EOK;
152}
153
154/** Take action based on the interrupt cause.
155 *
156 * @param[in] hcd HCD structure to use.
157 * @param[in] status Value of the status register at the time of interrupt.
158 *
159 * Interrupt might indicate:
160 * - transaction completed, either by triggering IOC, SPD, or an error
161 * - some kind of device error
162 * - resume from suspend state (not implemented)
163 */
164static void hc_interrupt(bus_t *bus, uint32_t status)
165{
166 hc_t *instance = bus_to_hc(bus);
167
168 /* Lower 2 bits are transaction error and transaction complete */
169 if (status & (UHCI_STATUS_INTERRUPT | UHCI_STATUS_ERROR_INTERRUPT)) {
170 transfer_list_check_finished(&instance->transfers_interrupt);
171 transfer_list_check_finished(&instance->transfers_control_slow);
172 transfer_list_check_finished(&instance->transfers_control_full);
173 transfer_list_check_finished(&instance->transfers_bulk_full);
174 }
175
176 /* Resume interrupts are not supported */
177 if (status & UHCI_STATUS_RESUME) {
178 usb_log_error("Resume interrupt!");
179 }
180
181 /* Bits 4 and 5 indicate hc error */
182 if (status & (UHCI_STATUS_PROCESS_ERROR | UHCI_STATUS_SYSTEM_ERROR)) {
183 usb_log_error("UHCI hardware failure!.");
184 ++instance->hw_failures;
185 transfer_list_abort_all(&instance->transfers_interrupt);
186 transfer_list_abort_all(&instance->transfers_control_slow);
187 transfer_list_abort_all(&instance->transfers_control_full);
188 transfer_list_abort_all(&instance->transfers_bulk_full);
189
190 if (instance->hw_failures < UHCI_ALLOWED_HW_FAIL) {
191 /* reinitialize hw, this triggers virtual disconnect */
192 hc_init_hw(instance);
193 } else {
194 usb_log_fatal("Too many UHCI hardware failures!.");
195 hc_gone(&instance->base);
196 }
197 }
198}
199
200/** Initialize UHCI hc driver structure
201 *
202 * @param[in] instance Memory place to initialize.
203 * @param[in] regs Range of device's I/O control registers.
204 * @param[in] interrupts True if hw interrupts should be used.
205 * @return Error code.
206 * @note Should be called only once on any structure.
207 *
208 * Initializes memory structures, starts up hw, and launches debugger and
209 * interrupt fibrils.
210 */
211errno_t hc_add(hc_device_t *hcd, const hw_res_list_parsed_t *hw_res)
212{
213 hc_t *instance = hcd_to_hc(hcd);
214 assert(hw_res);
215 if (hw_res->io_ranges.count != 1 ||
216 hw_res->io_ranges.ranges[0].size < sizeof(uhci_regs_t))
217 return EINVAL;
218
219 instance->hw_failures = 0;
220
221 /* allow access to hc control registers */
222 errno_t ret = pio_enable_range(&hw_res->io_ranges.ranges[0],
223 (void **) &instance->registers);
224 if (ret != EOK) {
225 usb_log_error("Failed to gain access to registers: %s.",
226 str_error(ret));
227 return ret;
228 }
229
230 usb_log_debug("Device registers at %" PRIx64 " (%zuB) accessible.",
231 hw_res->io_ranges.ranges[0].address.absolute,
232 hw_res->io_ranges.ranges[0].size);
233
234 ret = hc_init_mem_structures(instance);
235 if (ret != EOK) {
236 usb_log_error("Failed to init UHCI memory structures: %s.",
237 str_error(ret));
238 // TODO: we should disable pio here
239 return ret;
240 }
241
242 return EOK;
243}
244
245int hc_start(hc_device_t *hcd)
246{
247 hc_t *instance = hcd_to_hc(hcd);
248 hc_init_hw(instance);
249 (void)hc_debug_checker;
250
251 return uhci_rh_init(&instance->rh, instance->registers->ports, "uhci");
252}
253
254int hc_setup_roothub(hc_device_t *hcd)
255{
256 return hc_setup_virtual_root_hub(hcd, USB_SPEED_FULL);
257}
258
259/** Safely dispose host controller internal structures
260 *
261 * @param[in] instance Host controller structure to use.
262 */
263int hc_gone(hc_device_t *instance)
264{
265 assert(instance);
266 //TODO Implement
267 return ENOTSUP;
268}
269
270/** Quiesce host controller.
271 *
272 * @param[in] instance Host controller structure to use.
273 */
274int hc_quiesce(hc_device_t *hcd)
275{
276 hc_t *instance = hcd_to_hc(hcd);
277 uhci_regs_t *registers = instance->registers;
278
279 /* Reset everything, who knows what touched it before us */
280 pio_write_16(&registers->usbcmd, UHCI_CMD_GLOBAL_RESET);
281 fibril_usleep(50000); /* 50ms according to USB spec(root hub reset) */
282 pio_write_16(&registers->usbcmd, 0);
283
284 /* Reset hc, all states and counters. Hope that hw is not broken */
285 pio_write_16(&registers->usbcmd, UHCI_CMD_HCRESET);
286 do {
287 fibril_usleep(10);
288 } while ((pio_read_16(&registers->usbcmd) & UHCI_CMD_HCRESET) != 0);
289
290 return EOK;
291}
292
293/** Initialize UHCI hc hw resources.
294 *
295 * @param[in] instance UHCI structure to use.
296 * For magic values see UHCI Design Guide
297 */
298void hc_init_hw(const hc_t *instance)
299{
300 assert(instance);
301 uhci_regs_t *registers = instance->registers;
302
303 /* Reset everything, who knows what touched it before us */
304 pio_write_16(&registers->usbcmd, UHCI_CMD_GLOBAL_RESET);
305 fibril_usleep(50000); /* 50ms according to USB spec(root hub reset) */
306 pio_write_16(&registers->usbcmd, 0);
307
308 /* Reset hc, all states and counters. Hope that hw is not broken */
309 pio_write_16(&registers->usbcmd, UHCI_CMD_HCRESET);
310 do {
311 fibril_usleep(10);
312 } while ((pio_read_16(&registers->usbcmd) & UHCI_CMD_HCRESET) != 0);
313
314 /* Set frame to exactly 1ms */
315 pio_write_8(&registers->sofmod, 64);
316
317 /* Set frame list pointer */
318 const uint32_t pa = addr_to_phys(instance->frame_list);
319 pio_write_32(&registers->flbaseadd, pa);
320
321 if (cap_handle_valid(instance->base.irq_handle)) {
322 /* Enable all interrupts, but resume interrupt */
323 pio_write_16(&instance->registers->usbintr,
324 UHCI_INTR_ALLOW_INTERRUPTS);
325 }
326
327 const uint16_t cmd = pio_read_16(&registers->usbcmd);
328 if (cmd != 0)
329 usb_log_warning("Previous command value: %x.", cmd);
330
331 /* Start the hc with large(64B) packet FSBR */
332 pio_write_16(&registers->usbcmd,
333 UHCI_CMD_RUN_STOP | UHCI_CMD_MAX_PACKET | UHCI_CMD_CONFIGURE);
334}
335
336static usb_transfer_batch_t *create_transfer_batch(endpoint_t *ep)
337{
338 uhci_transfer_batch_t *batch = uhci_transfer_batch_create(ep);
339 return &batch->base;
340}
341
342static void destroy_transfer_batch(usb_transfer_batch_t *batch)
343{
344 uhci_transfer_batch_destroy(uhci_transfer_batch_get(batch));
345}
346
347static endpoint_t *endpoint_create(device_t *device, const usb_endpoint_descriptors_t *desc)
348{
349 endpoint_t *ep = calloc(1, sizeof(uhci_endpoint_t));
350 if (ep)
351 endpoint_init(ep, device, desc);
352 return ep;
353}
354
355static errno_t endpoint_register(endpoint_t *ep)
356{
357 hc_t *const hc = bus_to_hc(endpoint_get_bus(ep));
358
359 const errno_t err = usb2_bus_endpoint_register(&hc->bus_helper, ep);
360 if (err)
361 return err;
362
363 transfer_list_t *list = hc->transfers[ep->device->speed][ep->transfer_type];
364 if (!list)
365 /*
366 * We don't support this combination (e.g. isochronous). Do not
367 * fail early, because that would block any device with these
368 * endpoints from connecting. Instead, make sure these transfers
369 * are denied soon enough with ENOTSUP not to fail on asserts.
370 */
371 return EOK;
372
373 endpoint_set_online(ep, &list->guard);
374 return EOK;
375}
376
377static void endpoint_unregister(endpoint_t *ep)
378{
379 hc_t *const hc = bus_to_hc(endpoint_get_bus(ep));
380 usb2_bus_endpoint_unregister(&hc->bus_helper, ep);
381
382 // Check for the roothub, as it does not schedule into lists
383 if (ep->device->address == uhci_rh_get_address(&hc->rh)) {
384 // FIXME: We shall check the roothub for active transfer. But
385 // as it is polling, there is no way to make it stop doing so.
386 // Return after rewriting uhci rh.
387 return;
388 }
389
390 transfer_list_t *list = hc->transfers[ep->device->speed][ep->transfer_type];
391 if (!list)
392 /*
393 * We don't support this combination (e.g. isochronous),
394 * so no transfer can be active.
395 */
396 return;
397
398 fibril_mutex_lock(&list->guard);
399
400 endpoint_set_offline_locked(ep);
401 /* From now on, no other transfer will be scheduled. */
402
403 if (!ep->active_batch) {
404 fibril_mutex_unlock(&list->guard);
405 return;
406 }
407
408 /* First, offer the batch a short chance to be finished. */
409 endpoint_wait_timeout_locked(ep, 10000);
410
411 if (!ep->active_batch) {
412 fibril_mutex_unlock(&list->guard);
413 return;
414 }
415
416 uhci_transfer_batch_t *const batch =
417 uhci_transfer_batch_get(ep->active_batch);
418
419 /* Remove the batch from the schedule to stop it from being finished. */
420 endpoint_deactivate_locked(ep);
421 transfer_list_remove_batch(list, batch);
422
423 fibril_mutex_unlock(&list->guard);
424
425 /*
426 * We removed the batch from software schedule only, it's still possible
427 * that HC has it in its caches. Better wait a while before we release
428 * the buffers.
429 */
430 fibril_usleep(20000);
431 batch->base.error = EINTR;
432 batch->base.transferred_size = 0;
433 usb_transfer_batch_finish(&batch->base);
434}
435
436static int device_enumerate(device_t *dev)
437{
438 hc_t *const hc = bus_to_hc(dev->bus);
439 return usb2_bus_device_enumerate(&hc->bus_helper, dev);
440}
441
442static void device_gone(device_t *dev)
443{
444 hc_t *const hc = bus_to_hc(dev->bus);
445 usb2_bus_device_gone(&hc->bus_helper, dev);
446}
447
448static int hc_status(bus_t *, uint32_t *);
449static int hc_schedule(usb_transfer_batch_t *);
450
451static const bus_ops_t uhci_bus_ops = {
452 .interrupt = hc_interrupt,
453 .status = hc_status,
454
455 .device_enumerate = device_enumerate,
456 .device_gone = device_gone,
457
458 .endpoint_create = endpoint_create,
459 .endpoint_register = endpoint_register,
460 .endpoint_unregister = endpoint_unregister,
461
462 .batch_create = create_transfer_batch,
463 .batch_schedule = hc_schedule,
464 .batch_destroy = destroy_transfer_batch,
465};
466
467/** Initialize UHCI hc memory structures.
468 *
469 * @param[in] instance UHCI structure to use.
470 * @return Error code
471 * @note Should be called only once on any structure.
472 *
473 * Structures:
474 * - transfer lists (queue heads need to be accessible by the hw)
475 * - frame list page (needs to be one UHCI hw accessible 4K page)
476 */
477errno_t hc_init_mem_structures(hc_t *instance)
478{
479 assert(instance);
480
481 usb2_bus_helper_init(&instance->bus_helper, &bandwidth_accounting_usb11);
482
483 bus_init(&instance->bus, sizeof(device_t));
484 instance->bus.ops = &uhci_bus_ops;
485
486 hc_device_setup(&instance->base, &instance->bus);
487
488 /* Init USB frame list page */
489 instance->frame_list = get_page();
490 if (!instance->frame_list) {
491 return ENOMEM;
492 }
493 usb_log_debug("Initialized frame list at %p.", instance->frame_list);
494
495 /* Init transfer lists */
496 errno_t ret = hc_init_transfer_lists(instance);
497 if (ret != EOK) {
498 usb_log_error("Failed to initialize transfer lists.");
499 return_page(instance->frame_list);
500 return ENOMEM;
501 }
502 list_initialize(&instance->pending_endpoints);
503 usb_log_debug("Initialized transfer lists.");
504
505 /* Set all frames to point to the first queue head */
506 const uint32_t queue = LINK_POINTER_QH(
507 addr_to_phys(instance->transfers_interrupt.queue_head));
508
509 for (unsigned i = 0; i < UHCI_FRAME_LIST_COUNT; ++i) {
510 instance->frame_list[i] = queue;
511 }
512
513 return EOK;
514}
515
516/** Initialize UHCI hc transfer lists.
517 *
518 * @param[in] instance UHCI structure to use.
519 * @return Error code
520 * @note Should be called only once on any structure.
521 *
522 * Initializes transfer lists and sets them in one chain to support proper
523 * USB scheduling. Sets pointer table for quick access.
524 */
525errno_t hc_init_transfer_lists(hc_t *instance)
526{
527 assert(instance);
528#define SETUP_TRANSFER_LIST(type, name) \
529do { \
530 errno_t ret = transfer_list_init(&instance->transfers_##type, name); \
531 if (ret != EOK) { \
532 usb_log_error("Failed to setup %s transfer list: %s.", \
533 name, str_error(ret)); \
534 transfer_list_fini(&instance->transfers_bulk_full); \
535 transfer_list_fini(&instance->transfers_control_full); \
536 transfer_list_fini(&instance->transfers_control_slow); \
537 transfer_list_fini(&instance->transfers_interrupt); \
538 return ret; \
539 } \
540} while (0)
541
542 SETUP_TRANSFER_LIST(bulk_full, "BULK FULL");
543 SETUP_TRANSFER_LIST(control_full, "CONTROL FULL");
544 SETUP_TRANSFER_LIST(control_slow, "CONTROL LOW");
545 SETUP_TRANSFER_LIST(interrupt, "INTERRUPT");
546#undef SETUP_TRANSFER_LIST
547 /* Connect lists into one schedule */
548 transfer_list_set_next(&instance->transfers_control_full,
549 &instance->transfers_bulk_full);
550 transfer_list_set_next(&instance->transfers_control_slow,
551 &instance->transfers_control_full);
552 transfer_list_set_next(&instance->transfers_interrupt,
553 &instance->transfers_control_slow);
554
555 /*
556 * FSBR, This feature is not needed (adds no benefit) and is supposedly
557 * buggy on certain hw, enable at your own risk.
558 */
559#ifdef FSBR
560 transfer_list_set_next(&instance->transfers_bulk_full,
561 &instance->transfers_control_full);
562#endif
563
564 /* Assign pointers to be used during scheduling */
565 instance->transfers[USB_SPEED_FULL][USB_TRANSFER_INTERRUPT] =
566 &instance->transfers_interrupt;
567 instance->transfers[USB_SPEED_LOW][USB_TRANSFER_INTERRUPT] =
568 &instance->transfers_interrupt;
569 instance->transfers[USB_SPEED_FULL][USB_TRANSFER_CONTROL] =
570 &instance->transfers_control_full;
571 instance->transfers[USB_SPEED_LOW][USB_TRANSFER_CONTROL] =
572 &instance->transfers_control_slow;
573 instance->transfers[USB_SPEED_FULL][USB_TRANSFER_BULK] =
574 &instance->transfers_bulk_full;
575
576 return EOK;
577}
578
579static errno_t hc_status(bus_t *bus, uint32_t *status)
580{
581 hc_t *instance = bus_to_hc(bus);
582 assert(status);
583
584 *status = 0;
585 if (instance->registers) {
586 uint16_t s = pio_read_16(&instance->registers->usbsts);
587 pio_write_16(&instance->registers->usbsts, s);
588 *status = s;
589 }
590 return EOK;
591}
592
593/**
594 * Schedule batch for execution.
595 *
596 * @param[in] instance UHCI structure to use.
597 * @param[in] batch Transfer batch to schedule.
598 * @return Error code
599 */
600static errno_t hc_schedule(usb_transfer_batch_t *batch)
601{
602 uhci_transfer_batch_t *uhci_batch = uhci_transfer_batch_get(batch);
603 endpoint_t *ep = batch->ep;
604 hc_t *hc = bus_to_hc(endpoint_get_bus(ep));
605
606 if (batch->target.address == uhci_rh_get_address(&hc->rh))
607 return uhci_rh_schedule(&hc->rh, batch);
608
609 transfer_list_t *const list =
610 hc->transfers[ep->device->speed][ep->transfer_type];
611
612 if (!list)
613 return ENOTSUP;
614
615 errno_t err;
616 if ((err = uhci_transfer_batch_prepare(uhci_batch)))
617 return err;
618
619 return transfer_list_add_batch(list, uhci_batch);
620}
621
622/** Debug function, checks consistency of memory structures.
623 *
624 * @param[in] arg UHCI structure to use.
625 * @return EOK (should never return)
626 */
627errno_t hc_debug_checker(void *arg)
628{
629 hc_t *instance = arg;
630 assert(instance);
631
632#define QH(queue) \
633 instance->transfers_##queue.queue_head
634
635 while (true) {
636 const uint16_t cmd = pio_read_16(&instance->registers->usbcmd);
637 const uint16_t sts = pio_read_16(&instance->registers->usbsts);
638 const uint16_t intr =
639 pio_read_16(&instance->registers->usbintr);
640
641 if (((cmd & UHCI_CMD_RUN_STOP) != 1) || (sts != 0)) {
642 usb_log_debug2("Command: %X Status: %X Intr: %x",
643 cmd, sts, intr);
644 }
645
646 const uintptr_t frame_list =
647 pio_read_32(&instance->registers->flbaseadd) & ~0xfff;
648 if (frame_list != addr_to_phys(instance->frame_list)) {
649 usb_log_debug("Framelist address: %p vs. %p.",
650 (void *) frame_list,
651 (void *) addr_to_phys(instance->frame_list));
652 }
653
654 int frnum = pio_read_16(&instance->registers->frnum) & 0x3ff;
655
656 uintptr_t expected_pa = instance->frame_list[frnum] &
657 LINK_POINTER_ADDRESS_MASK;
658 uintptr_t real_pa = addr_to_phys(QH(interrupt));
659 if (expected_pa != real_pa) {
660 usb_log_debug("Interrupt QH: %p (frame %d) vs. %p.",
661 (void *) expected_pa, frnum, (void *) real_pa);
662 }
663
664 expected_pa = QH(interrupt)->next & LINK_POINTER_ADDRESS_MASK;
665 real_pa = addr_to_phys(QH(control_slow));
666 if (expected_pa != real_pa) {
667 usb_log_debug("Control Slow QH: %p vs. %p.",
668 (void *) expected_pa, (void *) real_pa);
669 }
670
671 expected_pa = QH(control_slow)->next & LINK_POINTER_ADDRESS_MASK;
672 real_pa = addr_to_phys(QH(control_full));
673 if (expected_pa != real_pa) {
674 usb_log_debug("Control Full QH: %p vs. %p.",
675 (void *) expected_pa, (void *) real_pa);
676 }
677
678 expected_pa = QH(control_full)->next & LINK_POINTER_ADDRESS_MASK;
679 real_pa = addr_to_phys(QH(bulk_full));
680 if (expected_pa != real_pa) {
681 usb_log_debug("Bulk QH: %p vs. %p.",
682 (void *) expected_pa, (void *) real_pa);
683 }
684 fibril_usleep(UHCI_DEBUGER_TIMEOUT);
685 }
686 return EOK;
687#undef QH
688}
689/**
690 * @}
691 */
Note: See TracBrowser for help on using the repository browser.