iPXE
xhci.h
Go to the documentation of this file.
1 #ifndef _IPXE_XHCI_H
2 #define _IPXE_XHCI_H
3 
4 /** @file
5  *
6  * USB eXtensible Host Controller Interface (xHCI) driver
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 
12 #include <assert.h>
13 #include <ipxe/pci.h>
14 #include <ipxe/usb.h>
15 
16 /** Minimum alignment required for data structures
17  *
18  * With the exception of the scratchpad buffer pages (which are
19  * page-aligned), data structures used by xHCI generally require from
20  * 16 to 64 byte alignment and must not cross an (xHCI) page boundary.
21  * We simplify this requirement by aligning each structure on its own
22  * size, with a minimum of a 64 byte alignment.
23  */
24 #define XHCI_MIN_ALIGN 64
25 
26 /** Maximum transfer size */
27 #define XHCI_MTU 65536
28 
29 /** xHCI PCI BAR */
30 #define XHCI_BAR PCI_BASE_ADDRESS_0
31 
32 /** Capability register length */
33 #define XHCI_CAP_CAPLENGTH 0x00
34 
35 /** Host controller interface version number */
36 #define XHCI_CAP_HCIVERSION 0x02
37 
38 /** Structural parameters 1 */
39 #define XHCI_CAP_HCSPARAMS1 0x04
40 
41 /** Number of device slots */
42 #define XHCI_HCSPARAMS1_SLOTS(params) ( ( (params) >> 0 ) & 0xff )
43 
44 /** Number of interrupters */
45 #define XHCI_HCSPARAMS1_INTRS(params) ( ( (params) >> 8 ) & 0x3ff )
46 
47 /** Number of ports */
48 #define XHCI_HCSPARAMS1_PORTS(params) ( ( (params) >> 24 ) & 0xff )
49 
50 /** Structural parameters 2 */
51 #define XHCI_CAP_HCSPARAMS2 0x08
52 
53 /** Number of page-sized scratchpad buffers */
54 #define XHCI_HCSPARAMS2_SCRATCHPADS(params) \
55  ( ( ( (params) >> 16 ) & 0x3e0 ) | ( ( (params) >> 27 ) & 0x1f ) )
56 
57 /** Capability parameters */
58 #define XHCI_CAP_HCCPARAMS1 0x10
59 
60 /** 64-bit addressing capability */
61 #define XHCI_HCCPARAMS1_ADDR64(params) ( ( (params) >> 0 ) & 0x1 )
62 
63 /** Context size shift */
64 #define XHCI_HCCPARAMS1_CSZ_SHIFT(params) ( 5 + ( ( (params) >> 2 ) & 0x1 ) )
65 
66 /** xHCI extended capabilities pointer */
67 #define XHCI_HCCPARAMS1_XECP(params) ( ( ( (params) >> 16 ) & 0xffff ) << 2 )
68 
69 /** Doorbell offset */
70 #define XHCI_CAP_DBOFF 0x14
71 
72 /** Runtime register space offset */
73 #define XHCI_CAP_RTSOFF 0x18
74 
75 /** xHCI extended capability ID */
76 #define XHCI_XECP_ID(xecp) ( ( (xecp) >> 0 ) & 0xff )
77 
78 /** Next xHCI extended capability pointer */
79 #define XHCI_XECP_NEXT(xecp) ( ( ( (xecp) >> 8 ) & 0xff ) << 2 )
80 
81 /** USB legacy support extended capability */
82 #define XHCI_XECP_ID_LEGACY 1
83 
84 /** USB legacy support BIOS owned semaphore */
85 #define XHCI_USBLEGSUP_BIOS 0x02
86 
87 /** USB legacy support BIOS ownership flag */
88 #define XHCI_USBLEGSUP_BIOS_OWNED 0x01
89 
90 /** USB legacy support OS owned semaphore */
91 #define XHCI_USBLEGSUP_OS 0x03
92 
93 /** USB legacy support OS ownership flag */
94 #define XHCI_USBLEGSUP_OS_OWNED 0x01
95 
96 /** USB legacy support control/status */
97 #define XHCI_USBLEGSUP_CTLSTS 0x04
98 
99 /** Supported protocol extended capability */
100 #define XHCI_XECP_ID_SUPPORTED 2
101 
102 /** Supported protocol revision */
103 #define XHCI_SUPPORTED_REVISION 0x00
104 
105 /** Supported protocol minor revision */
106 #define XHCI_SUPPORTED_REVISION_VER(revision) ( ( (revision) >> 16 ) & 0xffff )
107 
108 /** Supported protocol name */
109 #define XHCI_SUPPORTED_NAME 0x04
110 
111 /** Supported protocol ports */
112 #define XHCI_SUPPORTED_PORTS 0x08
113 
114 /** Supported protocol port offset */
115 #define XHCI_SUPPORTED_PORTS_OFFSET(ports) ( ( (ports) >> 0 ) & 0xff )
116 
117 /** Supported protocol port count */
118 #define XHCI_SUPPORTED_PORTS_COUNT(ports) ( ( (ports) >> 8 ) & 0xff )
119 
120 /** Supported protocol PSI count */
121 #define XHCI_SUPPORTED_PORTS_PSIC(ports) ( ( (ports) >> 28 ) & 0x0f )
122 
123 /** Supported protocol slot */
124 #define XHCI_SUPPORTED_SLOT 0x0c
125 
126 /** Supported protocol slot type */
127 #define XHCI_SUPPORTED_SLOT_TYPE(slot) ( ( (slot) >> 0 ) & 0x1f )
128 
129 /** Supported protocol PSI */
130 #define XHCI_SUPPORTED_PSI(index) ( 0x10 + ( (index) * 4 ) )
131 
132 /** Supported protocol PSI value */
133 #define XHCI_SUPPORTED_PSI_VALUE(psi) ( ( (psi) >> 0 ) & 0x0f )
134 
135 /** Supported protocol PSI mantissa */
136 #define XHCI_SUPPORTED_PSI_MANTISSA(psi) ( ( (psi) >> 16 ) & 0xffff )
137 
138 /** Supported protocol PSI exponent */
139 #define XHCI_SUPPORTED_PSI_EXPONENT(psi) ( ( (psi) >> 4 ) & 0x03 )
140 
141 /** Default PSI values */
143  /** Full speed (12Mbps) */
145  /** Low speed (1.5Mbps) */
147  /** High speed (480Mbps) */
149  /** Super speed */
151 };
152 
153 /** USB command register */
154 #define XHCI_OP_USBCMD 0x00
155 
156 /** Run/stop */
157 #define XHCI_USBCMD_RUN 0x00000001UL
158 
159 /** Host controller reset */
160 #define XHCI_USBCMD_HCRST 0x00000002UL
161 
162 /** USB status register */
163 #define XHCI_OP_USBSTS 0x04
164 
165 /** Host controller halted */
166 #define XHCI_USBSTS_HCH 0x00000001UL
167 
168 /** Page size register */
169 #define XHCI_OP_PAGESIZE 0x08
170 
171 /** Page size */
172 #define XHCI_PAGESIZE(pagesize) ( (pagesize) << 12 )
173 
174 /** Device notifcation control register */
175 #define XHCI_OP_DNCTRL 0x14
176 
177 /** Command ring control register */
178 #define XHCI_OP_CRCR 0x18
179 
180 /** Command ring cycle state */
181 #define XHCI_CRCR_RCS 0x00000001UL
182 
183 /** Command abort */
184 #define XHCI_CRCR_CA 0x00000004UL
185 
186 /** Command ring running */
187 #define XHCI_CRCR_CRR 0x00000008UL
188 
189 /** Device context base address array pointer */
190 #define XHCI_OP_DCBAAP 0x30
191 
192 /** Configure register */
193 #define XHCI_OP_CONFIG 0x38
194 
195 /** Maximum device slots enabled */
196 #define XHCI_CONFIG_MAX_SLOTS_EN(slots) ( (slots) << 0 )
197 
198 /** Maximum device slots enabled mask */
199 #define XHCI_CONFIG_MAX_SLOTS_EN_MASK \
200  XHCI_CONFIG_MAX_SLOTS_EN ( 0xff )
201 
202 /** Port status and control register */
203 #define XHCI_OP_PORTSC(port) ( 0x400 - 0x10 + ( (port) << 4 ) )
204 
205 /** Current connect status */
206 #define XHCI_PORTSC_CCS 0x00000001UL
207 
208 /** Port enabled */
209 #define XHCI_PORTSC_PED 0x00000002UL
210 
211 /** Port reset */
212 #define XHCI_PORTSC_PR 0x00000010UL
213 
214 /** Port link state */
215 #define XHCI_PORTSC_PLS(pls) ( (pls) << 5 )
216 
217 /** Disabled port link state */
218 #define XHCI_PORTSC_PLS_DISABLED XHCI_PORTSC_PLS ( 4 )
219 
220 /** RxDetect port link state */
221 #define XHCI_PORTSC_PLS_RXDETECT XHCI_PORTSC_PLS ( 5 )
222 
223 /** Port link state mask */
224 #define XHCI_PORTSC_PLS_MASK XHCI_PORTSC_PLS ( 0xf )
225 
226 /** Port power */
227 #define XHCI_PORTSC_PP 0x00000200UL
228 
229 /** Time to delay after enabling power to a port */
230 #define XHCI_PORT_POWER_DELAY_MS 20
231 
232 /** Port speed ID value */
233 #define XHCI_PORTSC_PSIV(portsc) ( ( (portsc) >> 10 ) & 0xf )
234 
235 /** Port indicator control */
236 #define XHCI_PORTSC_PIC(indicators) ( (indicators) << 14 )
237 
238 /** Port indicator control mask */
239 #define XHCI_PORTSC_PIC_MASK XHCI_PORTSC_PIC ( 3 )
240 
241 /** Port link state write strobe */
242 #define XHCI_PORTSC_LWS 0x00010000UL
243 
244 /** Time to delay after writing the port link state */
245 #define XHCI_LINK_STATE_DELAY_MS 100
246 
247 /** Connect status change */
248 #define XHCI_PORTSC_CSC 0x00020000UL
249 
250 /** Port enabled/disabled change */
251 #define XHCI_PORTSC_PEC 0x00040000UL
252 
253 /** Warm port reset change */
254 #define XHCI_PORTSC_WRC 0x00080000UL
255 
256 /** Over-current change */
257 #define XHCI_PORTSC_OCC 0x00100000UL
258 
259 /** Port reset change */
260 #define XHCI_PORTSC_PRC 0x00200000UL
261 
262 /** Port link state change */
263 #define XHCI_PORTSC_PLC 0x00400000UL
264 
265 /** Port config error change */
266 #define XHCI_PORTSC_CEC 0x00800000UL
267 
268 /** Port status change mask */
269 #define XHCI_PORTSC_CHANGE \
270  ( XHCI_PORTSC_CSC | XHCI_PORTSC_PEC | XHCI_PORTSC_WRC | \
271  XHCI_PORTSC_OCC | XHCI_PORTSC_PRC | XHCI_PORTSC_PLC | \
272  XHCI_PORTSC_CEC )
273 
274 /** Port status and control bits which should be preserved
275  *
276  * The port status and control register is a horrendous mix of
277  * differing semantics. Some bits are written to only when a separate
278  * write strobe bit is set. Some bits should be preserved when
279  * modifying other bits. Some bits will be cleared if written back as
280  * a one. Most excitingly, the "port enabled" bit has the semantics
281  * that 1=enabled, 0=disabled, yet writing a 1 will disable the port.
282  */
283 #define XHCI_PORTSC_PRESERVE ( XHCI_PORTSC_PP | XHCI_PORTSC_PIC_MASK )
284 
285 /** Port power management status and control register */
286 #define XHCI_OP_PORTPMSC(port) ( 0x404 - 0x10 + ( (port) << 4 ) )
287 
288 /** Port link info register */
289 #define XHCI_OP_PORTLI(port) ( 0x408 - 0x10 + ( (port) << 4 ) )
290 
291 /** Port hardware link power management control register */
292 #define XHCI_OP_PORTHLPMC(port) ( 0x40c - 0x10 + ( (port) << 4 ) )
293 
294 /** Event ring segment table size register */
295 #define XHCI_RUN_ERSTSZ(intr) ( 0x28 + ( (intr) << 5 ) )
296 
297 /** Event ring segment table base address register */
298 #define XHCI_RUN_ERSTBA(intr) ( 0x30 + ( (intr) << 5 ) )
299 
300 /** Event ring dequeue pointer register */
301 #define XHCI_RUN_ERDP(intr) ( 0x38 + ( (intr) << 5 ) )
302 
303 /** A transfer request block template */
305  /** Parameter */
307  /** Status */
309  /** Control */
311 };
312 
313 /** A transfer request block */
315  /** Reserved */
317  /** Reserved */
319  /** Flags */
321  /** Type */
323  /** Reserved */
325 } __attribute__ (( packed ));
326 
327 /** Transfer request block cycle bit flag */
328 #define XHCI_TRB_C 0x01
329 
330 /** Transfer request block toggle cycle bit flag */
331 #define XHCI_TRB_TC 0x02
332 
333 /** Transfer request block chain flag */
334 #define XHCI_TRB_CH 0x10
335 
336 /** Transfer request block interrupt on completion flag */
337 #define XHCI_TRB_IOC 0x20
338 
339 /** Transfer request block immediate data flag */
340 #define XHCI_TRB_IDT 0x40
341 
342 /** Transfer request block type */
343 #define XHCI_TRB_TYPE(type) ( (type) << 2 )
344 
345 /** Transfer request block type mask */
346 #define XHCI_TRB_TYPE_MASK XHCI_TRB_TYPE ( 0x3f )
347 
348 /** A normal transfer request block */
350  /** Data buffer */
352  /** Length */
354  /** Flags */
356  /** Type */
358  /** Reserved */
360 } __attribute__ (( packed ));
361 
362 /** A normal transfer request block */
363 #define XHCI_TRB_NORMAL XHCI_TRB_TYPE ( 1 )
364 
365 /** Construct TD size field */
366 #define XHCI_TD_SIZE(remaining) \
367  ( ( ( (remaining) <= 0xf ) ? remaining : 0xf ) << 17 )
368 
369 /** A setup stage transfer request block */
371  /** Setup packet */
373  /** Length */
375  /** Flags */
377  /** Type */
379  /** Transfer direction */
381  /** Reserved */
383 } __attribute__ (( packed ));
384 
385 /** A setup stage transfer request block */
386 #define XHCI_TRB_SETUP XHCI_TRB_TYPE ( 2 )
387 
388 /** Setup stage input data direction */
389 #define XHCI_SETUP_IN 3
390 
391 /** Setup stage output data direction */
392 #define XHCI_SETUP_OUT 2
393 
394 /** A data stage transfer request block */
396  /** Data buffer */
398  /** Length */
400  /** Flags */
402  /** Type */
404  /** Transfer direction */
406  /** Reserved */
408 } __attribute__ (( packed ));
409 
410 /** A data stage transfer request block */
411 #define XHCI_TRB_DATA XHCI_TRB_TYPE ( 3 )
412 
413 /** Input data direction */
414 #define XHCI_DATA_IN 0x01
415 
416 /** Output data direction */
417 #define XHCI_DATA_OUT 0x00
418 
419 /** A status stage transfer request block */
421  /** Reserved */
423  /** Reserved */
425  /** Flags */
427  /** Type */
429  /** Direction */
431  /** Reserved */
433 } __attribute__ (( packed ));
434 
435 /** A status stage transfer request block */
436 #define XHCI_TRB_STATUS XHCI_TRB_TYPE ( 4 )
437 
438 /** Input status direction */
439 #define XHCI_STATUS_IN 0x01
440 
441 /** Output status direction */
442 #define XHCI_STATUS_OUT 0x00
443 
444 /** A link transfer request block */
446  /** Next ring segment */
448  /** Reserved */
450  /** Flags */
452  /** Type */
454  /** Reserved */
456 } __attribute__ (( packed ));
457 
458 /** A link transfer request block */
459 #define XHCI_TRB_LINK XHCI_TRB_TYPE ( 6 )
460 
461 /** A no-op transfer request block */
462 #define XHCI_TRB_NOP XHCI_TRB_TYPE ( 8 )
463 
464 /** An enable slot transfer request block */
466  /** Reserved */
468  /** Reserved */
470  /** Flags */
472  /** Type */
474  /** Slot type */
476  /** Reserved */
478 } __attribute__ (( packed ));
479 
480 /** An enable slot transfer request block */
481 #define XHCI_TRB_ENABLE_SLOT XHCI_TRB_TYPE ( 9 )
482 
483 /** A disable slot transfer request block */
485  /** Reserved */
487  /** Reserved */
489  /** Flags */
491  /** Type */
493  /** Reserved */
495  /** Slot ID */
497 } __attribute__ (( packed ));
498 
499 /** A disable slot transfer request block */
500 #define XHCI_TRB_DISABLE_SLOT XHCI_TRB_TYPE ( 10 )
501 
502 /** A context transfer request block */
504  /** Input context */
506  /** Reserved */
508  /** Flags */
510  /** Type */
512  /** Reserved */
514  /** Slot ID */
516 } __attribute__ (( packed ));
517 
518 /** An address device transfer request block */
519 #define XHCI_TRB_ADDRESS_DEVICE XHCI_TRB_TYPE ( 11 )
520 
521 /** A configure endpoint transfer request block */
522 #define XHCI_TRB_CONFIGURE_ENDPOINT XHCI_TRB_TYPE ( 12 )
523 
524 /** An evaluate context transfer request block */
525 #define XHCI_TRB_EVALUATE_CONTEXT XHCI_TRB_TYPE ( 13 )
526 
527 /** A reset endpoint transfer request block */
529  /** Reserved */
531  /** Reserved */
533  /** Flags */
535  /** Type */
537  /** Endpoint ID */
539  /** Slot ID */
541 } __attribute__ (( packed ));
542 
543 /** A reset endpoint transfer request block */
544 #define XHCI_TRB_RESET_ENDPOINT XHCI_TRB_TYPE ( 14 )
545 
546 /** A stop endpoint transfer request block */
548  /** Reserved */
550  /** Reserved */
552  /** Flags */
554  /** Type */
556  /** Endpoint ID */
558  /** Slot ID */
560 } __attribute__ (( packed ));
561 
562 /** A stop endpoint transfer request block */
563 #define XHCI_TRB_STOP_ENDPOINT XHCI_TRB_TYPE ( 15 )
564 
565 /** A set transfer ring dequeue pointer transfer request block */
567  /** Dequeue pointer */
569  /** Reserved */
571  /** Flags */
573  /** Type */
575  /** Endpoint ID */
577  /** Slot ID */
579 } __attribute__ (( packed ));
580 
581 /** A set transfer ring dequeue pointer transfer request block */
582 #define XHCI_TRB_SET_TR_DEQUEUE_POINTER XHCI_TRB_TYPE ( 16 )
583 
584 /** A no-op command transfer request block */
585 #define XHCI_TRB_NOP_CMD XHCI_TRB_TYPE ( 23 )
586 
587 /** A transfer event transfer request block */
589  /** Transfer TRB pointer */
591  /** Residual transfer length */
593  /** Reserved */
595  /** Completion code */
597  /** Flags */
599  /** Type */
601  /** Endpoint ID */
603  /** Slot ID */
605 } __attribute__ (( packed ));
606 
607 /** A transfer event transfer request block */
608 #define XHCI_TRB_TRANSFER XHCI_TRB_TYPE ( 32 )
609 
610 /** A command completion event transfer request block */
612  /** Command TRB pointer */
614  /** Parameter */
616  /** Completion code */
618  /** Flags */
620  /** Type */
622  /** Virtual function ID */
624  /** Slot ID */
626 } __attribute__ (( packed ));
627 
628 /** A command completion event transfer request block */
629 #define XHCI_TRB_COMPLETE XHCI_TRB_TYPE ( 33 )
630 
631 /** xHCI completion codes */
633  /** Success */
635  /** Short packet */
637  /** Command ring stopped */
639 };
640 
641 /** A port status change transfer request block */
643  /** Reserved */
645  /** Port ID */
647  /** Reserved */
649  /** Completion code */
651  /** Flags */
653  /** Type */
655  /** Reserved */
657 } __attribute__ (( packed ));
658 
659 /** A port status change transfer request block */
660 #define XHCI_TRB_PORT_STATUS XHCI_TRB_TYPE ( 34 )
661 
662 /** A port status change transfer request block */
664  /** Reserved */
666  /** Reserved */
668  /** Completion code */
670  /** Flags */
672  /** Type */
674  /** Reserved */
676 } __attribute__ (( packed ));
677 
678 /** A port status change transfer request block */
679 #define XHCI_TRB_HOST_CONTROLLER XHCI_TRB_TYPE ( 37 )
680 
681 /** A transfer request block */
682 union xhci_trb {
683  /** Template */
685  /** Common fields */
687  /** Normal TRB */
689  /** Setup stage TRB */
691  /** Data stage TRB */
693  /** Status stage TRB */
695  /** Link TRB */
697  /** Enable slot TRB */
699  /** Disable slot TRB */
701  /** Input context TRB */
703  /** Reset endpoint TRB */
705  /** Stop endpoint TRB */
707  /** Set transfer ring dequeue pointer TRB */
709  /** Transfer event */
711  /** Command completion event */
713  /** Port status changed event */
715  /** Host controller event */
717 } __attribute__ (( packed ));
718 
719 /** An input control context */
721  /** Drop context flags */
723  /** Add context flags */
725  /** Reserved */
727  /** Configuration value */
729  /** Interface number */
731  /** Alternate setting */
733  /** Reserved */
735 } __attribute__ (( packed ));
736 
737 /** A slot context */
739  /** Device info */
741  /** Maximum exit latency */
743  /** Root hub port number */
745  /** Number of downstream ports */
747  /** TT hub slot ID */
749  /** TT port number */
751  /** Interrupter target */
753  /** USB address */
755  /** Reserved */
757  /** Slot state */
759  /** Reserved */
761 } __attribute__ (( packed ));
762 
763 /** Construct slot context device info */
764 #define XHCI_SLOT_INFO( entries, hub, speed, route ) \
765  ( ( (entries) << 27 ) | ( (hub) << 26 ) | ( (speed) << 20 ) | (route) )
766 
767 /** An endpoint context */
769  /** Endpoint state */
771  /** Stream configuration */
773  /** Polling interval */
775  /** Max ESIT payload high */
777  /** Endpoint type */
779  /** Maximum burst size */
781  /** Maximum packet size */
783  /** Transfer ring dequeue pointer */
785  /** Average TRB length */
787  /** Max ESIT payload low */
789  /** Reserved */
791 } __attribute__ (( packed ));
792 
793 /** Endpoint states */
795  /** Endpoint is disabled */
797  /** Endpoint is running */
799  /** Endpoint is halted due to a USB Halt condition */
801  /** Endpoint is stopped */
803  /** Endpoint is halted due to a TRB error */
805 };
806 
807 /** Endpoint state mask */
808 #define XHCI_ENDPOINT_STATE_MASK 0x07
809 
810 /** Endpoint type */
811 #define XHCI_EP_TYPE(type) ( (type) << 3 )
812 
813 /** Control endpoint type */
814 #define XHCI_EP_TYPE_CONTROL XHCI_EP_TYPE ( 4 )
815 
816 /** Input endpoint type */
817 #define XHCI_EP_TYPE_IN XHCI_EP_TYPE ( 4 )
818 
819 /** Periodic endpoint type */
820 #define XHCI_EP_TYPE_PERIODIC XHCI_EP_TYPE ( 1 )
821 
822 /** Endpoint dequeue cycle state */
823 #define XHCI_EP_DCS 0x00000001UL
824 
825 /** Control endpoint average TRB length */
826 #define XHCI_EP0_TRB_LEN 8
827 
828 /** An event ring segment */
830  /** Base address */
832  /** Number of TRBs */
834  /** Reserved */
836 } __attribute__ (( packed ));
837 
838 /** A transfer request block command/transfer ring */
840  /** Producer counter */
841  unsigned int prod;
842  /** Consumer counter */
843  unsigned int cons;
844  /** Ring size (log2) */
845  unsigned int shift;
846  /** Ring counter mask */
847  unsigned int mask;
848 
849  /** I/O buffers */
850  struct io_buffer **iobuf;
851 
852  /** Transfer request blocks */
853  union xhci_trb *trb;
854  /** Length of transfer request blocks */
855  size_t len;
856  /** DMA mapping */
857  struct dma_mapping map;
858  /** Link TRB (if applicable) */
860 
861  /** Doorbell register */
862  void *db;
863  /** Doorbell register value */
865 };
866 
867 /** An event ring */
869  /** Consumer counter */
870  unsigned int cons;
871  /** Event ring segment table */
873  /** Event ring segment table DMA mapping */
875  /** Transfer request blocks */
876  union xhci_trb *trb;
877  /** Transfer request blocks DMA mapping */
879 };
880 
881 /**
882  * Calculate doorbell register value
883  *
884  * @v target Doorbell target
885  * @v stream Doorbell stream ID
886  * @ret dbval Doorbell register value
887  */
888 #define XHCI_DBVAL( target, stream ) ( (target) | ( (stream) << 16 ) )
889 
890 /**
891  * Calculate space used in TRB ring
892  *
893  * @v ring TRB ring
894  * @ret fill Number of entries used
895  */
896 static inline __attribute__ (( always_inline )) unsigned int
897 xhci_ring_fill ( struct xhci_trb_ring *ring ) {
898 
899  return ( ring->prod - ring->cons );
900 }
901 
902 /**
903  * Calculate space remaining in TRB ring
904  *
905  * @v ring TRB ring
906  * @ret remaining Number of entries remaining
907  *
908  * xHCI does not allow us to completely fill a ring; there must be at
909  * least one free entry (excluding the Link TRB).
910  */
911 static inline __attribute__ (( always_inline )) unsigned int
913  unsigned int fill = xhci_ring_fill ( ring );
914 
915  /* We choose to utilise rings with ( 2^n + 1 ) entries, with
916  * the final entry being a Link TRB. The maximum fill level
917  * is therefore
918  *
919  * ( ( 2^n + 1 ) - 1 (Link TRB) - 1 (one slot always empty)
920  * == ( 2^n - 1 )
921  *
922  * which is therefore equal to the ring mask.
923  */
924  assert ( fill <= ring->mask );
925  return ( ring->mask - fill );
926 }
927 
928 /**
929  * Calculate physical address of most recently consumed TRB
930  *
931  * @v ring TRB ring
932  * @ret trb TRB physical address
933  */
934 static inline __attribute__ (( always_inline )) physaddr_t
936  unsigned int index = ( ( ring->cons - 1 ) & ring->mask );
937 
938  return virt_to_phys ( &ring->trb[index] );
939 }
940 
941 /** Slot context index */
942 #define XHCI_CTX_SLOT 0
943 
944 /** Calculate context index from USB endpoint address */
945 #define XHCI_CTX(address) \
946  ( (address) ? ( ( ( (address) & 0x0f ) << 1 ) | \
947  ( ( (address) & 0x80 ) >> 7 ) ) : 1 )
948 
949 /** Endpoint zero context index */
950 #define XHCI_CTX_EP0 XHCI_CTX ( 0x00 )
951 
952 /** End of contexts */
953 #define XHCI_CTX_END 32
954 
955 /** Device context index */
956 #define XHCI_DCI(ctx) ( (ctx) + 0 )
957 
958 /** Input context index */
959 #define XHCI_ICI(ctx) ( (ctx) + 1 )
960 
961 /** Number of TRBs (excluding Link TRB) in the command ring
962  *
963  * This is a policy decision.
964  */
965 #define XHCI_CMD_TRBS_LOG2 2
966 
967 /** Number of TRBs in the event ring
968  *
969  * This is a policy decision.
970  */
971 #define XHCI_EVENT_TRBS_LOG2 6
972 
973 /** Number of TRBs in a transfer ring
974  *
975  * This is a policy decision.
976  */
977 #define XHCI_TRANSFER_TRBS_LOG2 6
978 
979 /** Maximum time to wait for BIOS to release ownership
980  *
981  * This is a policy decision.
982  */
983 #define XHCI_USBLEGSUP_MAX_WAIT_MS 100
984 
985 /** Maximum time to wait for host controller to stop
986  *
987  * This is a policy decision.
988  */
989 #define XHCI_STOP_MAX_WAIT_MS 100
990 
991 /** Maximum time to wait for reset to complete
992  *
993  * This is a policy decision.
994  */
995 #define XHCI_RESET_MAX_WAIT_MS 500
996 
997 /** Maximum time to wait for a command to complete
998  *
999  * The "address device" command involves waiting for a response to a
1000  * USB control transaction, and so we must wait for up to the 5000ms
1001  * that USB allows for devices to respond to control transactions.
1002  */
1003 #define XHCI_COMMAND_MAX_WAIT_MS USB_CONTROL_MAX_WAIT_MS
1004 
1005 /** Time to delay after aborting a command
1006  *
1007  * This is a policy decision
1008  */
1009 #define XHCI_COMMAND_ABORT_DELAY_MS 500
1010 
1011 /** Maximum time to wait for a port reset to complete
1012  *
1013  * This is a policy decision.
1014  */
1015 #define XHCI_PORT_RESET_MAX_WAIT_MS 500
1016 
1017 /** Intel PCH quirk */
1018 struct xhci_pch {
1019  /** USB2 port routing register original value */
1021  /** USB3 port SuperSpeed enable register original value */
1023 };
1024 
1025 /** Intel PCH quirk flag */
1026 #define XHCI_PCH 0x0001
1027 
1028 /** Intel PCH USB2 port routing register */
1029 #define XHCI_PCH_XUSB2PR 0xd0
1030 
1031 /** Intel PCH USB2 port routing mask register */
1032 #define XHCI_PCH_XUSB2PRM 0xd4
1033 
1034 /** Intel PCH SuperSpeed enable register */
1035 #define XHCI_PCH_USB3PSSEN 0xd8
1036 
1037 /** Intel PCH USB3 port routing mask register */
1038 #define XHCI_PCH_USB3PRM 0xdc
1039 
1040 /** Invalid protocol speed ID values quirk */
1041 #define XHCI_BAD_PSIV 0x0002
1042 
1043 /** Device context base address array */
1044 struct xhci_dcbaa {
1045  /** Context base addresses */
1047  /** DMA mapping */
1049 };
1050 
1051 /** Scratchpad buffer */
1053  /** Number of page-sized scratchpad buffers */
1054  unsigned int count;
1055  /** Scratchpad buffer area */
1056  void *buffer;
1057  /** Buffer DMA mapping */
1059  /** Scratchpad array */
1061  /** Array DMA mapping */
1063 };
1064 
1065 /** An xHCI device */
1066 struct xhci_device {
1067  /** Registers */
1068  void *regs;
1069  /** Underlying hardware device */
1070  struct device *dev;
1071  /** DMA device */
1072  struct dma_device *dma;
1073  /** Name */
1074  const char *name;
1075  /** Quirks */
1076  unsigned int quirks;
1077 
1078  /** Capability registers */
1079  void *cap;
1080  /** Operational registers */
1081  void *op;
1082  /** Runtime registers */
1083  void *run;
1084  /** Doorbell registers */
1085  void *db;
1086 
1087  /** Number of device slots */
1088  unsigned int slots;
1089  /** Number of interrupters */
1090  unsigned int intrs;
1091  /** Number of ports */
1092  unsigned int ports;
1093 
1094  /** 64-bit addressing capability */
1095  int addr64;
1096  /** Context size shift */
1097  unsigned int csz_shift;
1098  /** xHCI extended capabilities offset */
1099  unsigned int xecp;
1100 
1101  /** Page size */
1102  size_t pagesize;
1103 
1104  /** USB legacy support capability (if present and enabled) */
1105  unsigned int legacy;
1106 
1107  /** Device context base address array */
1109 
1110  /** Scratchpad buffer */
1112 
1113  /** Command ring */
1115  /** Event ring */
1117  /** Current command (if any) */
1119  /** Command mechanism has permanently failed */
1120  int failed;
1121 
1122  /** Device slots, indexed by slot ID */
1123  struct xhci_slot **slot;
1124 
1125  /** USB bus */
1126  struct usb_bus *bus;
1127 
1128  /** Intel PCH quirk */
1129  struct xhci_pch pch;
1130 };
1131 
1132 /** An xHCI device slot */
1133 struct xhci_slot {
1134  /** xHCI device */
1136  /** USB device */
1137  struct usb_device *usb;
1138  /** Slot ID */
1139  unsigned int id;
1140  /** Slot context */
1142  /** DMA mapping */
1144  /** Route string */
1145  unsigned int route;
1146  /** Root hub port number */
1147  unsigned int port;
1148  /** Protocol speed ID */
1149  unsigned int psiv;
1150  /** Number of ports (if this device is a hub) */
1151  unsigned int ports;
1152  /** Transaction translator slot ID */
1153  unsigned int tt_id;
1154  /** Transaction translator port */
1155  unsigned int tt_port;
1156  /** Endpoints, indexed by context ID */
1158 };
1159 
1160 /** An xHCI endpoint */
1162  /** xHCI device */
1164  /** xHCI slot */
1165  struct xhci_slot *slot;
1166  /** USB endpoint */
1167  struct usb_endpoint *ep;
1168  /** Context index */
1169  unsigned int ctx;
1170  /** Endpoint type */
1171  unsigned int type;
1172  /** Endpoint interval */
1173  unsigned int interval;
1174  /** Endpoint context */
1176  /** Transfer ring */
1178 };
1179 
1180 extern void xhci_init ( struct xhci_device *xhci );
1181 extern int xhci_register ( struct xhci_device *xhci );
1182 extern void xhci_unregister ( struct xhci_device *xhci );
1183 
1184 #endif /* _IPXE_XHCI_H */
uint8_t intf
Interface number.
Definition: xhci.h:730
An endpoint context.
Definition: xhci.h:768
Short packet.
Definition: xhci.h:636
uint8_t burst
Maximum burst size.
Definition: xhci.h:780
#define __attribute__(x)
Definition: compiler.h:10
An event ring.
Definition: xhci.h:868
uint32_t reserved
Reserved.
Definition: xhci.h:835
A disable slot transfer request block.
Definition: xhci.h:484
uint32_t reserved_b
Reserved.
Definition: xhci.h:424
uint8_t type
Endpoint type.
Definition: xhci.h:778
unsigned short uint16_t
Definition: stdint.h:11
A status stage transfer request block.
Definition: xhci.h:420
struct xhci_trb_context context
Input context TRB.
Definition: xhci.h:702
uint64_t command
Command TRB pointer.
Definition: xhci.h:613
A transfer request block.
Definition: xhci.h:314
uint32_t dbval
Doorbell register value.
Definition: xhci.h:864
struct xhci_trb_common common
Common fields.
Definition: xhci.h:686
uint8_t flags
Flags.
Definition: xhci.h:509
unsigned int ports
Number of ports.
Definition: xhci.h:1092
void * buffer
Scratchpad buffer area.
Definition: xhci.h:1056
struct xhci_dcbaa dcbaa
Device context base address array.
Definition: xhci.h:1108
uint8_t reserved
Reserved.
Definition: xhci.h:594
uint8_t direction
Direction.
Definition: xhci.h:430
uint64_t data
Data buffer.
Definition: xhci.h:351
static physaddr_t xhci_ring_consumed(struct xhci_trb_ring *ring)
Calculate physical address of most recently consumed TRB.
Definition: xhci.h:935
#define XHCI_CTX_END
End of contexts.
Definition: xhci.h:953
uint32_t reserved_b
Reserved.
Definition: xhci.h:532
uint8_t reserved_c
Reserved.
Definition: xhci.h:494
struct xhci_device * xhci
xHCI device
Definition: xhci.h:1135
unsigned int cons
Consumer counter.
Definition: xhci.h:843
void * run
Runtime registers.
Definition: xhci.h:1083
An xHCI device.
Definition: xhci.h:1066
A set transfer ring dequeue pointer transfer request block.
Definition: xhci.h:566
size_t len
Length of transfer request blocks.
Definition: xhci.h:855
void * regs
Registers.
Definition: xhci.h:1068
An input control context.
Definition: xhci.h:720
uint8_t reserved_b
Reserved.
Definition: xhci.h:734
unsigned int port
Root hub port number.
Definition: xhci.h:1147
A command-line command.
Definition: command.h:9
xhci_endpoint_state
Endpoint states.
Definition: xhci.h:794
uint8_t slot
Slot type.
Definition: xhci.h:475
static unsigned int xhci_ring_fill(struct xhci_trb_ring *ring)
Calculate space used in TRB ring.
Definition: xhci.h:897
A command completion event transfer request block.
Definition: xhci.h:611
struct dma_mapping segment_map
Event ring segment table DMA mapping.
Definition: xhci.h:874
uint8_t state
Endpoint state.
Definition: xhci.h:770
uint8_t reserved_a[3]
Reserved.
Definition: xhci.h:644
struct xhci_trb_transfer transfer
Transfer event.
Definition: xhci.h:710
A port status change transfer request block.
Definition: xhci.h:663
uint16_t trb_len
Average TRB length.
Definition: xhci.h:786
union xhci_trb * pending
Current command (if any)
Definition: xhci.h:1118
uint64_t reserved_a
Reserved.
Definition: xhci.h:422
struct xhci_endpoint * endpoint[XHCI_CTX_END]
Endpoints, indexed by context ID.
Definition: xhci.h:1157
struct device * dev
Underlying hardware device.
Definition: xhci.h:1070
uint8_t type
Type.
Definition: xhci.h:322
uint8_t flags
Flags.
Definition: xhci.h:355
struct dma_mapping map
DMA mapping.
Definition: xhci.h:857
xhci_completion_code
xHCI completion codes
Definition: xhci.h:632
uint8_t code
Completion code.
Definition: xhci.h:669
struct xhci_trb_disable_slot disable
Disable slot TRB.
Definition: xhci.h:700
uint16_t reserved_c
Reserved.
Definition: xhci.h:324
long index
Definition: bigint.h:62
uint16_t reserved_c
Reserved.
Definition: xhci.h:656
unsigned int route
Route string.
Definition: xhci.h:1145
An enable slot transfer request block.
Definition: xhci.h:465
unsigned long long uint64_t
Definition: stdint.h:13
struct usb_bus * bus
USB bus.
Definition: xhci.h:1126
struct xhci_trb_enable_slot enable
Enable slot TRB.
Definition: xhci.h:698
uint8_t slot
Slot ID.
Definition: xhci.h:496
struct dma_mapping buffer_map
Buffer DMA mapping.
Definition: xhci.h:1058
struct xhci_trb_setup setup
Setup stage TRB.
Definition: xhci.h:690
unsigned int count
Number of page-sized scratchpad buffers.
Definition: xhci.h:1054
A data stage transfer request block.
Definition: xhci.h:395
uint8_t code
Completion code.
Definition: xhci.h:596
Intel PCH quirk.
Definition: xhci.h:1018
void * db
Doorbell register.
Definition: xhci.h:862
xhci_default_psi_value
Default PSI values.
Definition: xhci.h:142
Full speed (12Mbps)
Definition: xhci.h:144
uint8_t slot
Slot ID.
Definition: xhci.h:625
uint8_t flags
Flags.
Definition: xhci.h:320
An xHCI endpoint.
Definition: xhci.h:1161
uint8_t type
Type.
Definition: xhci.h:536
uint8_t direction
Transfer direction.
Definition: xhci.h:380
unsigned int psiv
Protocol speed ID.
Definition: xhci.h:1149
Success.
Definition: xhci.h:634
uint8_t reserved_b[3]
Reserved.
Definition: xhci.h:667
uint8_t endpoint
Endpoint ID.
Definition: xhci.h:602
uint64_t dequeue
Dequeue pointer.
Definition: xhci.h:568
unsigned int slots
Number of device slots.
Definition: xhci.h:1088
uint32_t add
Add context flags.
Definition: xhci.h:724
uint64_t dequeue
Transfer ring dequeue pointer.
Definition: xhci.h:784
struct xhci_scratchpad scratch
Scratchpad buffer.
Definition: xhci.h:1111
static unsigned int xhci_ring_remaining(struct xhci_trb_ring *ring)
Calculate space remaining in TRB ring.
Definition: xhci.h:912
uint8_t esit_high
Max ESIT payload high.
Definition: xhci.h:776
uint64_t * array
Scratchpad array.
Definition: xhci.h:1060
uint8_t address
USB address.
Definition: xhci.h:754
uint8_t ports
Number of downstream ports.
Definition: xhci.h:746
Endpoint is halted due to a TRB error.
Definition: xhci.h:804
unsigned int type
Endpoint type.
Definition: xhci.h:1171
struct xhci_trb_host_controller host
Host controller event.
Definition: xhci.h:716
uint64_t input
Input context.
Definition: xhci.h:505
uint8_t type
Type.
Definition: xhci.h:403
uint32_t len
Length.
Definition: xhci.h:399
uint8_t type
Type.
Definition: xhci.h:654
uint8_t type
Type.
Definition: xhci.h:673
uint16_t reserved_a
Reserved.
Definition: xhci.h:756
A hardware device.
Definition: device.h:76
A USB endpoint.
Definition: usb.h:403
struct dma_mapping array_map
Array DMA mapping.
Definition: xhci.h:1062
uint8_t endpoint
Endpoint ID.
Definition: xhci.h:557
uint32_t reserved_b
Reserved.
Definition: xhci.h:469
union xhci_trb * trb
Transfer request blocks.
Definition: xhci.h:853
Endpoint is halted due to a USB Halt condition.
Definition: xhci.h:800
uint8_t slot
Slot ID.
Definition: xhci.h:604
uint8_t reserved_c
Reserved.
Definition: xhci.h:477
uint8_t flags
Flags.
Definition: xhci.h:619
struct xhci_pch pch
Intel PCH quirk.
Definition: xhci.h:1129
uint8_t slot
Slot ID.
Definition: xhci.h:540
A reset endpoint transfer request block.
Definition: xhci.h:528
Assertions.
union xhci_trb * trb
Transfer request blocks.
Definition: xhci.h:876
uint8_t slot
Slot ID.
Definition: xhci.h:559
uint32_t drop
Drop context flags.
Definition: xhci.h:722
uint8_t alt
Alternate setting.
Definition: xhci.h:732
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
unsigned int ports
Number of ports (if this device is a hub)
Definition: xhci.h:1151
uint64_t reserved_a
Reserved.
Definition: xhci.h:316
uint8_t reserved_c
Reserved.
Definition: xhci.h:432
struct xhci_trb_stop_endpoint stop
Stop endpoint TRB.
Definition: xhci.h:706
struct xhci_trb_template template
Template.
Definition: xhci.h:684
unsigned int ctx
Context index.
Definition: xhci.h:1169
uint32_t len
Length.
Definition: xhci.h:374
struct usb_device * usb
USB device.
Definition: xhci.h:1137
uint32_t xusb2pr
USB2 port routing register original value.
Definition: xhci.h:1020
uint8_t vf
Virtual function ID.
Definition: xhci.h:623
uint64_t reserved_a
Reserved.
Definition: xhci.h:549
uint8_t flags
Flags.
Definition: xhci.h:553
uint8_t port
Root hub port number.
Definition: xhci.h:744
uint64_t reserved_a
Reserved.
Definition: xhci.h:665
uint64_t data
Data buffer.
Definition: xhci.h:397
A setup stage transfer request block.
Definition: xhci.h:370
uint16_t mtu
Maximum packet size.
Definition: xhci.h:782
A transfer event transfer request block.
Definition: xhci.h:588
uint8_t direction
Transfer direction.
Definition: xhci.h:405
Endpoint is disabled.
Definition: xhci.h:796
uint8_t flags
Flags.
Definition: xhci.h:490
uint8_t type
Type.
Definition: xhci.h:378
uint32_t usb3pssen
USB3 port SuperSpeed enable register original value.
Definition: xhci.h:1022
uint8_t flags
Flags.
Definition: xhci.h:598
uint8_t config
Configuration value.
Definition: xhci.h:728
uint32_t info
Device info.
Definition: xhci.h:740
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
struct xhci_slot * slot
xHCI slot
Definition: xhci.h:1165
struct xhci_endpoint_context * context
Endpoint context.
Definition: xhci.h:1175
A USB device.
Definition: usb.h:722
uint8_t type
Type.
Definition: xhci.h:428
uint8_t flags
Flags.
Definition: xhci.h:376
uint32_t reserved_b
Reserved.
Definition: xhci.h:318
An xHCI device slot.
Definition: xhci.h:1133
uint32_t reserved_a[5]
Reserved.
Definition: xhci.h:726
A context transfer request block.
Definition: xhci.h:503
uint16_t reserved_c
Reserved.
Definition: xhci.h:675
uint64_t reserved_a
Reserved.
Definition: xhci.h:467
uint32_t status
Status.
Definition: xhci.h:308
int failed
Command mechanism has permanently failed.
Definition: xhci.h:1120
void xhci_unregister(struct xhci_device *xhci)
Unregister xHCI controller.
Definition: xhci.c:3363
uint64_t base
Base address.
Definition: xhci.h:831
A transfer request block.
Definition: xhci.h:682
const char * name
Name.
Definition: xhci.h:1074
PCI bus.
uint8_t slot
Slot ID.
Definition: xhci.h:578
uint8_t type
Type.
Definition: xhci.h:621
unsigned int id
Slot ID.
Definition: xhci.h:1139
Endpoint is stopped.
Definition: xhci.h:802
uint64_t * context
Context base addresses.
Definition: xhci.h:1046
Device context base address array.
Definition: xhci.h:1044
unsigned char uint8_t
Definition: stdint.h:10
struct xhci_trb_data data
Data stage TRB.
Definition: xhci.h:692
unsigned int intrs
Number of interrupters.
Definition: xhci.h:1090
unsigned int tt_id
Transaction translator slot ID.
Definition: xhci.h:1153
unsigned int prod
Producer counter.
Definition: xhci.h:841
uint8_t type
Type.
Definition: xhci.h:492
struct xhci_trb_complete complete
Command completion event.
Definition: xhci.h:712
struct xhci_trb_set_tr_dequeue_pointer dequeue
Set transfer ring dequeue pointer TRB.
Definition: xhci.h:708
uint8_t type
Type.
Definition: xhci.h:357
unsigned int uint32_t
Definition: stdint.h:12
A USB setup data packet.
Definition: usb.h:82
Scratchpad buffer.
Definition: xhci.h:1052
void * cap
Capability registers.
Definition: xhci.h:1079
unsigned int xecp
xHCI extended capabilities offset
Definition: xhci.h:1099
A normal transfer request block.
Definition: xhci.h:349
int addr64
64-bit addressing capability
Definition: xhci.h:1095
A port status change transfer request block.
Definition: xhci.h:642
uint8_t flags
Flags.
Definition: xhci.h:471
uint8_t port
Port ID.
Definition: xhci.h:646
struct xhci_trb_normal normal
Normal TRB.
Definition: xhci.h:688
uint8_t stream
Stream configuration.
Definition: xhci.h:772
unsigned long physaddr_t
Definition: stdint.h:20
uint64_t reserved_a
Reserved.
Definition: xhci.h:530
Endpoint is running.
Definition: xhci.h:798
uint8_t type
Type.
Definition: xhci.h:555
struct xhci_trb_reset_endpoint reset
Reset endpoint TRB.
Definition: xhci.h:704
uint32_t reserved
Reserved.
Definition: xhci.h:570
uint8_t code
Completion code.
Definition: xhci.h:650
Command ring stopped.
Definition: xhci.h:638
uint8_t flags
Flags.
Definition: xhci.h:652
uint8_t tt_id
TT hub slot ID.
Definition: xhci.h:748
struct usb_endpoint * ep
USB endpoint.
Definition: xhci.h:1167
uint8_t flags
Flags.
Definition: xhci.h:534
uint32_t control
Control.
Definition: xhci.h:310
uint64_t reserved_a
Reserved.
Definition: xhci.h:486
struct xhci_event_ring_segment * segment
Event ring segment table.
Definition: xhci.h:872
size_t pagesize
Page size.
Definition: xhci.h:1102
Universal Serial Bus (USB)
uint16_t latency
Maximum exit latency.
Definition: xhci.h:742
uint16_t intr
Interrupter target.
Definition: xhci.h:752
A stop endpoint transfer request block.
Definition: xhci.h:547
unsigned int mask
Ring counter mask.
Definition: xhci.h:847
uint8_t interval
Polling interval.
Definition: xhci.h:774
uint8_t reserved_b[7]
Reserved.
Definition: xhci.h:648
uint8_t tt_port
TT port number.
Definition: xhci.h:750
uint32_t reserved_b[4]
Reserved.
Definition: xhci.h:760
struct dma_mapping map
DMA mapping.
Definition: xhci.h:1048
uint8_t state
Slot state.
Definition: xhci.h:758
uint32_t reserved_b
Reserved.
Definition: xhci.h:488
struct io_buffer ** iobuf
I/O buffers.
Definition: xhci.h:850
uint32_t len
Length.
Definition: xhci.h:353
unsigned int cons
Consumer counter.
Definition: xhci.h:870
struct xhci_trb_ring ring
Transfer ring.
Definition: xhci.h:1177
unsigned int tt_port
Transaction translator port.
Definition: xhci.h:1155
struct xhci_slot_context * context
Slot context.
Definition: xhci.h:1141
struct dma_mapping map
DMA mapping.
Definition: xhci.h:1143
struct xhci_trb_port_status port
Port status changed event.
Definition: xhci.h:714
struct dma_device * dma
DMA device.
Definition: xhci.h:1072
uint8_t flags
Flags.
Definition: xhci.h:401
uint16_t residual
Residual transfer length.
Definition: xhci.h:592
Super speed.
Definition: xhci.h:150
uint8_t flags
Flags.
Definition: xhci.h:426
unsigned int legacy
USB legacy support capability (if present and enabled)
Definition: xhci.h:1105
struct xhci_trb_link * link
Link TRB (if applicable)
Definition: xhci.h:859
Low speed (1.5Mbps)
Definition: xhci.h:146
unsigned int shift
Ring size (log2)
Definition: xhci.h:845
A transfer request block command/transfer ring.
Definition: xhci.h:839
int xhci_register(struct xhci_device *xhci)
Register xHCI controller.
Definition: xhci.c:3318
struct xhci_trb_status status
Status stage TRB.
Definition: xhci.h:694
uint16_t reserved
Reserved.
Definition: xhci.h:359
uint8_t type
Type.
Definition: xhci.h:600
uint32_t reserved[3]
Reserved.
Definition: xhci.h:790
A request parameter.
Definition: params.h:28
uint64_t transfer
Transfer TRB pointer.
Definition: xhci.h:590
unsigned int csz_shift
Context size shift.
Definition: xhci.h:1097
struct usb_setup_packet packet
Setup packet.
Definition: xhci.h:372
void * db
Doorbell registers.
Definition: xhci.h:1085
uint8_t reserved
Reserved.
Definition: xhci.h:382
unsigned int interval
Endpoint interval.
Definition: xhci.h:1173
uint8_t endpoint
Endpoint ID.
Definition: xhci.h:538
uint8_t code
Completion code.
Definition: xhci.h:617
uint8_t reserved
Reserved.
Definition: xhci.h:407
uint16_t esit_low
Max ESIT payload low.
Definition: xhci.h:788
struct xhci_trb_link link
Link TRB.
Definition: xhci.h:696
struct xhci_slot ** slot
Device slots, indexed by slot ID.
Definition: xhci.h:1123
uint32_t count
Number of TRBs.
Definition: xhci.h:833
High speed (480Mbps)
Definition: xhci.h:148
A DMA mapping.
Definition: dma.h:32
A transfer request block template.
Definition: xhci.h:304
unsigned int quirks
Quirks.
Definition: xhci.h:1076
uint64_t parameter
Parameter.
Definition: xhci.h:306
struct xhci_device * xhci
xHCI device
Definition: xhci.h:1163
struct xhci_event_ring event
Event ring.
Definition: xhci.h:1116
A USB bus.
Definition: usb.h:965
static int fill
Definition: string.h:208
void * op
Operational registers.
Definition: xhci.h:1081
uint8_t type
Type.
Definition: xhci.h:473
A slot context.
Definition: xhci.h:738
uint8_t endpoint
Endpoint ID.
Definition: xhci.h:576
uint8_t flags
Flags.
Definition: xhci.h:671
uint8_t reserved_b
Reserved.
Definition: xhci.h:513
void xhci_init(struct xhci_device *xhci)
Initialise device.
Definition: xhci.c:263
uint8_t type
Type.
Definition: xhci.h:511
An event ring segment.
Definition: xhci.h:829
uint8_t slot
Slot ID.
Definition: xhci.h:515
struct dma_mapping trb_map
Transfer request blocks DMA mapping.
Definition: xhci.h:878
A DMA-capable device.
Definition: dma.h:47
uint32_t reserved_a
Reserved.
Definition: xhci.h:507
A persistent I/O buffer.
Definition: iobuf.h:37
uint32_t reserved_b
Reserved.
Definition: xhci.h:551