]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.h
MdeModulePkg: Apply uncrustify changes
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / XhciDxe / XhciSched.h
CommitLineData
92870c98 1/** @file\r
2\r
3 This file contains the definition for XHCI host controller schedule routines.\r
4\r
d1102dba 5Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
9d510e61 6SPDX-License-Identifier: BSD-2-Clause-Patent\r
92870c98 7\r
8**/\r
9\r
10#ifndef _EFI_XHCI_SCHED_H_\r
11#define _EFI_XHCI_SCHED_H_\r
12\r
1436aea4
MK
13#define XHC_URB_SIG SIGNATURE_32 ('U', 'S', 'B', 'R')\r
14#define XHC_INIT_DEVICE_SLOT_RETRIES 1\r
92870c98 15\r
16//\r
17// Transfer types, used in URB to identify the transfer type\r
18//\r
1436aea4
MK
19#define XHC_CTRL_TRANSFER 0x01\r
20#define XHC_BULK_TRANSFER 0x02\r
21#define XHC_INT_TRANSFER_SYNC 0x04\r
22#define XHC_INT_TRANSFER_ASYNC 0x08\r
23#define XHC_INT_ONLY_TRANSFER_ASYNC 0x10\r
92870c98 24\r
25//\r
26// 6.4.6 TRB Types\r
27//\r
1436aea4
MK
28#define TRB_TYPE_NORMAL 1\r
29#define TRB_TYPE_SETUP_STAGE 2\r
30#define TRB_TYPE_DATA_STAGE 3\r
31#define TRB_TYPE_STATUS_STAGE 4\r
32#define TRB_TYPE_ISOCH 5\r
33#define TRB_TYPE_LINK 6\r
34#define TRB_TYPE_EVENT_DATA 7\r
35#define TRB_TYPE_NO_OP 8\r
36#define TRB_TYPE_EN_SLOT 9\r
37#define TRB_TYPE_DIS_SLOT 10\r
38#define TRB_TYPE_ADDRESS_DEV 11\r
39#define TRB_TYPE_CON_ENDPOINT 12\r
40#define TRB_TYPE_EVALU_CONTXT 13\r
41#define TRB_TYPE_RESET_ENDPOINT 14\r
42#define TRB_TYPE_STOP_ENDPOINT 15\r
43#define TRB_TYPE_SET_TR_DEQUE 16\r
44#define TRB_TYPE_RESET_DEV 17\r
45#define TRB_TYPE_GET_PORT_BANW 21\r
46#define TRB_TYPE_FORCE_HEADER 22\r
47#define TRB_TYPE_NO_OP_COMMAND 23\r
48#define TRB_TYPE_TRANS_EVENT 32\r
49#define TRB_TYPE_COMMAND_COMPLT_EVENT 33\r
50#define TRB_TYPE_PORT_STATUS_CHANGE_EVENT 34\r
51#define TRB_TYPE_HOST_CONTROLLER_EVENT 37\r
52#define TRB_TYPE_DEVICE_NOTIFI_EVENT 38\r
53#define TRB_TYPE_MFINDEX_WRAP_EVENT 39\r
92870c98 54\r
55//\r
56// Endpoint Type (EP Type).\r
57//\r
1436aea4
MK
58#define ED_NOT_VALID 0\r
59#define ED_ISOCH_OUT 1\r
60#define ED_BULK_OUT 2\r
61#define ED_INTERRUPT_OUT 3\r
62#define ED_CONTROL_BIDIR 4\r
63#define ED_ISOCH_IN 5\r
64#define ED_BULK_IN 6\r
65#define ED_INTERRUPT_IN 7\r
92870c98 66\r
67//\r
68// 6.4.5 TRB Completion Codes\r
69//\r
1436aea4
MK
70#define TRB_COMPLETION_INVALID 0\r
71#define TRB_COMPLETION_SUCCESS 1\r
72#define TRB_COMPLETION_DATA_BUFFER_ERROR 2\r
73#define TRB_COMPLETION_BABBLE_ERROR 3\r
74#define TRB_COMPLETION_USB_TRANSACTION_ERROR 4\r
75#define TRB_COMPLETION_TRB_ERROR 5\r
76#define TRB_COMPLETION_STALL_ERROR 6\r
77#define TRB_COMPLETION_SHORT_PACKET 13\r
78#define TRB_COMPLETION_STOPPED 26\r
79#define TRB_COMPLETION_STOPPED_LENGTH_INVALID 27\r
92870c98 80\r
81//\r
a9292c13 82// The topology string used to present usb device location\r
92870c98 83//\r
a9292c13 84typedef struct _USB_DEV_TOPOLOGY {\r
85 //\r
86 // The tier concatenation of down stream port.\r
87 //\r
1436aea4 88 UINT32 RouteString : 20;\r
a9292c13 89 //\r
90 // The root port number of the chain.\r
91 //\r
1436aea4 92 UINT32 RootPortNum : 8;\r
a9292c13 93 //\r
94 // The Tier the device reside.\r
95 //\r
1436aea4 96 UINT32 TierNum : 4;\r
a9292c13 97} USB_DEV_TOPOLOGY;\r
98\r
99//\r
100// USB Device's RouteChart\r
101//\r
102typedef union _USB_DEV_ROUTE {\r
103 UINT32 Dword;\r
104 USB_DEV_TOPOLOGY Route;\r
92870c98 105} USB_DEV_ROUTE;\r
106\r
107//\r
108// Endpoint address and its capabilities\r
109//\r
110typedef struct _USB_ENDPOINT {\r
6b4483cd 111 //\r
112 // Store logical device address assigned by UsbBus\r
113 // It's because some XHCI host controllers may assign the same physcial device\r
114 // address for those devices inserted at different root port.\r
115 //\r
116 UINT8 BusAddr;\r
92870c98 117 UINT8 DevAddr;\r
118 UINT8 EpAddr;\r
119 EFI_USB_DATA_DIRECTION Direction;\r
120 UINT8 DevSpeed;\r
121 UINTN MaxPacket;\r
122 UINTN Type;\r
123} USB_ENDPOINT;\r
124\r
125//\r
a9292c13 126// TRB Template\r
92870c98 127//\r
a9292c13 128typedef struct _TRB_TEMPLATE {\r
1436aea4 129 UINT32 Parameter1;\r
a9292c13 130\r
1436aea4 131 UINT32 Parameter2;\r
a9292c13 132\r
1436aea4 133 UINT32 Status;\r
a9292c13 134\r
1436aea4
MK
135 UINT32 CycleBit : 1;\r
136 UINT32 RsvdZ1 : 9;\r
137 UINT32 Type : 6;\r
138 UINT32 Control : 16;\r
a9292c13 139} TRB_TEMPLATE;\r
92870c98 140\r
141typedef struct _TRANSFER_RING {\r
1436aea4
MK
142 VOID *RingSeg0;\r
143 UINTN TrbNumber;\r
144 TRB_TEMPLATE *RingEnqueue;\r
145 TRB_TEMPLATE *RingDequeue;\r
146 UINT32 RingPCS;\r
92870c98 147} TRANSFER_RING;\r
148\r
149typedef struct _EVENT_RING {\r
1436aea4
MK
150 VOID *ERSTBase;\r
151 VOID *EventRingSeg0;\r
152 UINTN TrbNumber;\r
153 TRB_TEMPLATE *EventRingEnqueue;\r
154 TRB_TEMPLATE *EventRingDequeue;\r
155 UINT32 EventRingCCS;\r
92870c98 156} EVENT_RING;\r
157\r
158//\r
159// URB (Usb Request Block) contains information for all kinds of\r
160// usb requests.\r
161//\r
162typedef struct _URB {\r
1436aea4
MK
163 UINT32 Signature;\r
164 LIST_ENTRY UrbList;\r
92870c98 165 //\r
166 // Usb Device URB related information\r
167 //\r
1436aea4
MK
168 USB_ENDPOINT Ep;\r
169 EFI_USB_DEVICE_REQUEST *Request;\r
170 VOID *Data;\r
171 UINTN DataLen;\r
172 VOID *DataPhy;\r
173 VOID *DataMap;\r
174 EFI_ASYNC_USB_TRANSFER_CALLBACK Callback;\r
175 VOID *Context;\r
92870c98 176 //\r
177 // Execute result\r
178 //\r
1436aea4 179 UINT32 Result;\r
92870c98 180 //\r
181 // completed data length\r
182 //\r
1436aea4 183 UINTN Completed;\r
92870c98 184 //\r
185 // Command/Tranfer Ring info\r
186 //\r
1436aea4
MK
187 TRANSFER_RING *Ring;\r
188 TRB_TEMPLATE *TrbStart;\r
189 TRB_TEMPLATE *TrbEnd;\r
190 UINTN TrbNum;\r
191 BOOLEAN StartDone;\r
192 BOOLEAN EndDone;\r
193 BOOLEAN Finished;\r
194\r
195 TRB_TEMPLATE *EvtTrb;\r
92870c98 196} URB;\r
197\r
92870c98 198//\r
199// 6.5 Event Ring Segment Table\r
200// The Event Ring Segment Table is used to define multi-segment Event Rings and to enable runtime\r
201// expansion and shrinking of the Event Ring. The location of the Event Ring Segment Table is defined by the\r
202// Event Ring Segment Table Base Address Register (5.5.2.3.2). The size of the Event Ring Segment Table\r
203// is defined by the Event Ring Segment Table Base Size Register (5.5.2.3.1).\r
204//\r
205typedef struct _EVENT_RING_SEG_TABLE_ENTRY {\r
1436aea4
MK
206 UINT32 PtrLo;\r
207 UINT32 PtrHi;\r
208 UINT32 RingTrbSize : 16;\r
209 UINT32 RsvdZ1 : 16;\r
210 UINT32 RsvdZ2;\r
92870c98 211} EVENT_RING_SEG_TABLE_ENTRY;\r
212\r
213//\r
214// 6.4.1.1 Normal TRB\r
215// A Normal TRB is used in several ways; exclusively on Bulk and Interrupt Transfer Rings for normal and\r
216// Scatter/Gather operations, to define additional data buffers for Scatter/Gather operations on Isoch Transfer\r
217// Rings, and to define the Data stage information for Control Transfer Rings.\r
218//\r
219typedef struct _TRANSFER_TRB_NORMAL {\r
1436aea4
MK
220 UINT32 TRBPtrLo;\r
221\r
222 UINT32 TRBPtrHi;\r
223\r
224 UINT32 Length : 17;\r
225 UINT32 TDSize : 5;\r
226 UINT32 IntTarget : 10;\r
227\r
228 UINT32 CycleBit : 1;\r
229 UINT32 ENT : 1;\r
230 UINT32 ISP : 1;\r
231 UINT32 NS : 1;\r
232 UINT32 CH : 1;\r
233 UINT32 IOC : 1;\r
234 UINT32 IDT : 1;\r
235 UINT32 RsvdZ1 : 2;\r
236 UINT32 BEI : 1;\r
237 UINT32 Type : 6;\r
238 UINT32 RsvdZ2 : 16;\r
92870c98 239} TRANSFER_TRB_NORMAL;\r
240\r
241//\r
242// 6.4.1.2.1 Setup Stage TRB\r
243// A Setup Stage TRB is created by system software to initiate a USB Setup packet on a control endpoint.\r
244//\r
a9292c13 245typedef struct _TRANSFER_TRB_CONTROL_SETUP {\r
1436aea4
MK
246 UINT32 bmRequestType : 8;\r
247 UINT32 bRequest : 8;\r
248 UINT32 wValue : 16;\r
249\r
250 UINT32 wIndex : 16;\r
251 UINT32 wLength : 16;\r
252\r
253 UINT32 Length : 17;\r
254 UINT32 RsvdZ1 : 5;\r
255 UINT32 IntTarget : 10;\r
256\r
257 UINT32 CycleBit : 1;\r
258 UINT32 RsvdZ2 : 4;\r
259 UINT32 IOC : 1;\r
260 UINT32 IDT : 1;\r
261 UINT32 RsvdZ3 : 3;\r
262 UINT32 Type : 6;\r
263 UINT32 TRT : 2;\r
264 UINT32 RsvdZ4 : 14;\r
92870c98 265} TRANSFER_TRB_CONTROL_SETUP;\r
266\r
267//\r
268// 6.4.1.2.2 Data Stage TRB\r
269// A Data Stage TRB is used generate the Data stage transaction of a USB Control transfer.\r
270//\r
271typedef struct _TRANSFER_TRB_CONTROL_DATA {\r
1436aea4
MK
272 UINT32 TRBPtrLo;\r
273\r
274 UINT32 TRBPtrHi;\r
275\r
276 UINT32 Length : 17;\r
277 UINT32 TDSize : 5;\r
278 UINT32 IntTarget : 10;\r
279\r
280 UINT32 CycleBit : 1;\r
281 UINT32 ENT : 1;\r
282 UINT32 ISP : 1;\r
283 UINT32 NS : 1;\r
284 UINT32 CH : 1;\r
285 UINT32 IOC : 1;\r
286 UINT32 IDT : 1;\r
287 UINT32 RsvdZ1 : 3;\r
288 UINT32 Type : 6;\r
289 UINT32 DIR : 1;\r
290 UINT32 RsvdZ2 : 15;\r
92870c98 291} TRANSFER_TRB_CONTROL_DATA;\r
292\r
293//\r
294// 6.4.1.2.2 Data Stage TRB\r
295// A Data Stage TRB is used generate the Data stage transaction of a USB Control transfer.\r
296//\r
297typedef struct _TRANSFER_TRB_CONTROL_STATUS {\r
1436aea4
MK
298 UINT32 RsvdZ1;\r
299 UINT32 RsvdZ2;\r
300\r
301 UINT32 RsvdZ3 : 22;\r
302 UINT32 IntTarget : 10;\r
303\r
304 UINT32 CycleBit : 1;\r
305 UINT32 ENT : 1;\r
306 UINT32 RsvdZ4 : 2;\r
307 UINT32 CH : 1;\r
308 UINT32 IOC : 1;\r
309 UINT32 RsvdZ5 : 4;\r
310 UINT32 Type : 6;\r
311 UINT32 DIR : 1;\r
312 UINT32 RsvdZ6 : 15;\r
92870c98 313} TRANSFER_TRB_CONTROL_STATUS;\r
314\r
315//\r
316// 6.4.2.1 Transfer Event TRB\r
317// A Transfer Event provides the completion status associated with a Transfer TRB. Refer to section 4.11.3.1\r
318// for more information on the use and operation of Transfer Events.\r
319//\r
320typedef struct _EVT_TRB_TRANSFER {\r
1436aea4 321 UINT32 TRBPtrLo;\r
a9292c13 322\r
1436aea4 323 UINT32 TRBPtrHi;\r
a9292c13 324\r
1436aea4
MK
325 UINT32 Length : 24;\r
326 UINT32 Completecode : 8;\r
a9292c13 327\r
1436aea4
MK
328 UINT32 CycleBit : 1;\r
329 UINT32 RsvdZ1 : 1;\r
330 UINT32 ED : 1;\r
331 UINT32 RsvdZ2 : 7;\r
332 UINT32 Type : 6;\r
333 UINT32 EndpointId : 5;\r
334 UINT32 RsvdZ3 : 3;\r
335 UINT32 SlotId : 8;\r
92870c98 336} EVT_TRB_TRANSFER;\r
337\r
338//\r
339// 6.4.2.2 Command Completion Event TRB\r
340// A Command Completion Event TRB shall be generated by the xHC when a command completes on the\r
341// Command Ring. Refer to section 4.11.4 for more information on the use of Command Completion Events.\r
342//\r
a9292c13 343typedef struct _EVT_TRB_COMMAND_COMPLETION {\r
1436aea4 344 UINT32 TRBPtrLo;\r
a9292c13 345\r
1436aea4 346 UINT32 TRBPtrHi;\r
a9292c13 347\r
1436aea4
MK
348 UINT32 RsvdZ2 : 24;\r
349 UINT32 Completecode : 8;\r
a9292c13 350\r
1436aea4
MK
351 UINT32 CycleBit : 1;\r
352 UINT32 RsvdZ3 : 9;\r
353 UINT32 Type : 6;\r
354 UINT32 VFID : 8;\r
355 UINT32 SlotId : 8;\r
a9292c13 356} EVT_TRB_COMMAND_COMPLETION;\r
357\r
358typedef union _TRB {\r
1436aea4
MK
359 TRB_TEMPLATE TrbTemplate;\r
360 TRANSFER_TRB_NORMAL TrbNormal;\r
361 TRANSFER_TRB_CONTROL_SETUP TrbCtrSetup;\r
362 TRANSFER_TRB_CONTROL_DATA TrbCtrData;\r
363 TRANSFER_TRB_CONTROL_STATUS TrbCtrStatus;\r
a9292c13 364} TRB;\r
92870c98 365\r
366//\r
367// 6.4.3.1 No Op Command TRB\r
368// The No Op Command TRB provides a simple means for verifying the operation of the Command Ring\r
a9292c13 369// mechanisms offered by the xHCI.\r
92870c98 370//\r
371typedef struct _CMD_TRB_NO_OP {\r
1436aea4
MK
372 UINT32 RsvdZ0;\r
373 UINT32 RsvdZ1;\r
374 UINT32 RsvdZ2;\r
375\r
376 UINT32 CycleBit : 1;\r
377 UINT32 RsvdZ3 : 9;\r
378 UINT32 Type : 6;\r
379 UINT32 RsvdZ4 : 16;\r
92870c98 380} CMD_TRB_NO_OP;\r
381\r
382//\r
383// 6.4.3.2 Enable Slot Command TRB\r
384// The Enable Slot Command TRB causes the xHC to select an available Device Slot and return the ID of the\r
385// selected slot to the host in a Command Completion Event.\r
386//\r
a9292c13 387typedef struct _CMD_TRB_ENABLE_SLOT {\r
1436aea4
MK
388 UINT32 RsvdZ0;\r
389 UINT32 RsvdZ1;\r
390 UINT32 RsvdZ2;\r
391\r
392 UINT32 CycleBit : 1;\r
393 UINT32 RsvdZ3 : 9;\r
394 UINT32 Type : 6;\r
395 UINT32 RsvdZ4 : 16;\r
a9292c13 396} CMD_TRB_ENABLE_SLOT;\r
92870c98 397\r
398//\r
399// 6.4.3.3 Disable Slot Command TRB\r
400// The Disable Slot Command TRB releases any bandwidth assigned to the disabled slot and frees any\r
401// internal xHC resources assigned to the slot.\r
402//\r
a9292c13 403typedef struct _CMD_TRB_DISABLE_SLOT {\r
1436aea4
MK
404 UINT32 RsvdZ0;\r
405 UINT32 RsvdZ1;\r
406 UINT32 RsvdZ2;\r
407\r
408 UINT32 CycleBit : 1;\r
409 UINT32 RsvdZ3 : 9;\r
410 UINT32 Type : 6;\r
411 UINT32 RsvdZ4 : 8;\r
412 UINT32 SlotId : 8;\r
a9292c13 413} CMD_TRB_DISABLE_SLOT;\r
92870c98 414\r
415//\r
416// 6.4.3.4 Address Device Command TRB\r
417// The Address Device Command TRB transitions the selected Device Context from the Default to the\r
418// Addressed state and causes the xHC to select an address for the USB device in the Default State and\r
419// issue a SET_ADDRESS request to the USB device.\r
420//\r
a9292c13 421typedef struct _CMD_TRB_ADDRESS_DEVICE {\r
1436aea4 422 UINT32 PtrLo;\r
a9292c13 423\r
1436aea4 424 UINT32 PtrHi;\r
a9292c13 425\r
1436aea4 426 UINT32 RsvdZ1;\r
a9292c13 427\r
1436aea4
MK
428 UINT32 CycleBit : 1;\r
429 UINT32 RsvdZ2 : 8;\r
430 UINT32 BSR : 1;\r
431 UINT32 Type : 6;\r
432 UINT32 RsvdZ3 : 8;\r
433 UINT32 SlotId : 8;\r
a9292c13 434} CMD_TRB_ADDRESS_DEVICE;\r
92870c98 435\r
436//\r
437// 6.4.3.5 Configure Endpoint Command TRB\r
438// The Configure Endpoint Command TRB evaluates the bandwidth and resource requirements of the\r
439// endpoints selected by the command.\r
440//\r
a9292c13 441typedef struct _CMD_TRB_CONFIG_ENDPOINT {\r
1436aea4 442 UINT32 PtrLo;\r
a9292c13 443\r
1436aea4 444 UINT32 PtrHi;\r
a9292c13 445\r
1436aea4 446 UINT32 RsvdZ1;\r
a9292c13 447\r
1436aea4
MK
448 UINT32 CycleBit : 1;\r
449 UINT32 RsvdZ2 : 8;\r
450 UINT32 DC : 1;\r
451 UINT32 Type : 6;\r
452 UINT32 RsvdZ3 : 8;\r
453 UINT32 SlotId : 8;\r
a9292c13 454} CMD_TRB_CONFIG_ENDPOINT;\r
92870c98 455\r
456//\r
457// 6.4.3.6 Evaluate Context Command TRB\r
458// The Evaluate Context Command TRB is used by system software to inform the xHC that the selected\r
459// Context data structures in the Device Context have been modified by system software and that the xHC\r
460// shall evaluate any changes\r
461//\r
a9292c13 462typedef struct _CMD_TRB_EVALUATE_CONTEXT {\r
1436aea4 463 UINT32 PtrLo;\r
a9292c13 464\r
1436aea4 465 UINT32 PtrHi;\r
a9292c13 466\r
1436aea4 467 UINT32 RsvdZ1;\r
a9292c13 468\r
1436aea4
MK
469 UINT32 CycleBit : 1;\r
470 UINT32 RsvdZ2 : 9;\r
471 UINT32 Type : 6;\r
472 UINT32 RsvdZ3 : 8;\r
473 UINT32 SlotId : 8;\r
a9292c13 474} CMD_TRB_EVALUATE_CONTEXT;\r
92870c98 475\r
476//\r
477// 6.4.3.7 Reset Endpoint Command TRB\r
478// The Reset Endpoint Command TRB is used by system software to reset a specified Transfer Ring\r
479//\r
a9292c13 480typedef struct _CMD_TRB_RESET_ENDPOINT {\r
1436aea4
MK
481 UINT32 RsvdZ0;\r
482 UINT32 RsvdZ1;\r
483 UINT32 RsvdZ2;\r
484\r
485 UINT32 CycleBit : 1;\r
486 UINT32 RsvdZ3 : 8;\r
487 UINT32 TSP : 1;\r
488 UINT32 Type : 6;\r
489 UINT32 EDID : 5;\r
490 UINT32 RsvdZ4 : 3;\r
491 UINT32 SlotId : 8;\r
a9292c13 492} CMD_TRB_RESET_ENDPOINT;\r
92870c98 493\r
494//\r
495// 6.4.3.8 Stop Endpoint Command TRB\r
496// The Stop Endpoint Command TRB command allows software to stop the xHC execution of the TDs on a\r
497// Transfer Ring and temporarily take ownership of TDs that had previously been passed to the xHC.\r
498//\r
a9292c13 499typedef struct _CMD_TRB_STOP_ENDPOINT {\r
1436aea4
MK
500 UINT32 RsvdZ0;\r
501 UINT32 RsvdZ1;\r
502 UINT32 RsvdZ2;\r
503\r
504 UINT32 CycleBit : 1;\r
505 UINT32 RsvdZ3 : 9;\r
506 UINT32 Type : 6;\r
507 UINT32 EDID : 5;\r
508 UINT32 RsvdZ4 : 2;\r
509 UINT32 SP : 1;\r
510 UINT32 SlotId : 8;\r
a9292c13 511} CMD_TRB_STOP_ENDPOINT;\r
92870c98 512\r
513//\r
514// 6.4.3.9 Set TR Dequeue Pointer Command TRB\r
515// The Set TR Dequeue Pointer Command TRB is used by system software to modify the TR Dequeue\r
516// Pointer and DCS fields of an Endpoint or Stream Context.\r
517//\r
a9292c13 518typedef struct _CMD_SET_TR_DEQ_POINTER {\r
1436aea4 519 UINT32 PtrLo;\r
a9292c13 520\r
1436aea4 521 UINT32 PtrHi;\r
a9292c13 522\r
1436aea4
MK
523 UINT32 RsvdZ1 : 16;\r
524 UINT32 StreamID : 16;\r
a9292c13 525\r
1436aea4
MK
526 UINT32 CycleBit : 1;\r
527 UINT32 RsvdZ2 : 9;\r
528 UINT32 Type : 6;\r
529 UINT32 Endpoint : 5;\r
530 UINT32 RsvdZ3 : 3;\r
531 UINT32 SlotId : 8;\r
a9292c13 532} CMD_SET_TR_DEQ_POINTER;\r
92870c98 533\r
534//\r
a9292c13 535// 6.4.4.1 Link TRB\r
92870c98 536// A Link TRB provides support for non-contiguous TRB Rings.\r
537//\r
a9292c13 538typedef struct _LINK_TRB {\r
1436aea4 539 UINT32 PtrLo;\r
a9292c13 540\r
1436aea4 541 UINT32 PtrHi;\r
a9292c13 542\r
1436aea4
MK
543 UINT32 RsvdZ1 : 22;\r
544 UINT32 InterTarget : 10;\r
a9292c13 545\r
1436aea4
MK
546 UINT32 CycleBit : 1;\r
547 UINT32 TC : 1;\r
548 UINT32 RsvdZ2 : 2;\r
549 UINT32 CH : 1;\r
550 UINT32 IOC : 1;\r
551 UINT32 RsvdZ3 : 4;\r
552 UINT32 Type : 6;\r
553 UINT32 RsvdZ4 : 16;\r
a9292c13 554} LINK_TRB;\r
92870c98 555\r
556//\r
557// 6.2.2 Slot Context\r
558//\r
559typedef struct _SLOT_CONTEXT {\r
1436aea4
MK
560 UINT32 RouteString : 20;\r
561 UINT32 Speed : 4;\r
562 UINT32 RsvdZ1 : 1;\r
563 UINT32 MTT : 1;\r
564 UINT32 Hub : 1;\r
565 UINT32 ContextEntries : 5;\r
566\r
567 UINT32 MaxExitLatency : 16;\r
568 UINT32 RootHubPortNum : 8;\r
569 UINT32 PortNum : 8;\r
570\r
571 UINT32 TTHubSlotId : 8;\r
572 UINT32 TTPortNum : 8;\r
573 UINT32 TTT : 2;\r
574 UINT32 RsvdZ2 : 4;\r
575 UINT32 InterTarget : 10;\r
576\r
577 UINT32 DeviceAddress : 8;\r
578 UINT32 RsvdZ3 : 19;\r
579 UINT32 SlotState : 5;\r
580\r
581 UINT32 RsvdZ4;\r
582 UINT32 RsvdZ5;\r
583 UINT32 RsvdZ6;\r
584 UINT32 RsvdZ7;\r
92870c98 585} SLOT_CONTEXT;\r
586\r
6b4483cd 587typedef struct _SLOT_CONTEXT_64 {\r
1436aea4
MK
588 UINT32 RouteString : 20;\r
589 UINT32 Speed : 4;\r
590 UINT32 RsvdZ1 : 1;\r
591 UINT32 MTT : 1;\r
592 UINT32 Hub : 1;\r
593 UINT32 ContextEntries : 5;\r
594\r
595 UINT32 MaxExitLatency : 16;\r
596 UINT32 RootHubPortNum : 8;\r
597 UINT32 PortNum : 8;\r
598\r
599 UINT32 TTHubSlotId : 8;\r
600 UINT32 TTPortNum : 8;\r
601 UINT32 TTT : 2;\r
602 UINT32 RsvdZ2 : 4;\r
603 UINT32 InterTarget : 10;\r
604\r
605 UINT32 DeviceAddress : 8;\r
606 UINT32 RsvdZ3 : 19;\r
607 UINT32 SlotState : 5;\r
608\r
609 UINT32 RsvdZ4;\r
610 UINT32 RsvdZ5;\r
611 UINT32 RsvdZ6;\r
612 UINT32 RsvdZ7;\r
613\r
614 UINT32 RsvdZ8;\r
615 UINT32 RsvdZ9;\r
616 UINT32 RsvdZ10;\r
617 UINT32 RsvdZ11;\r
618\r
619 UINT32 RsvdZ12;\r
620 UINT32 RsvdZ13;\r
621 UINT32 RsvdZ14;\r
622 UINT32 RsvdZ15;\r
6b4483cd 623} SLOT_CONTEXT_64;\r
624\r
92870c98 625//\r
626// 6.2.3 Endpoint Context\r
627//\r
628typedef struct _ENDPOINT_CONTEXT {\r
1436aea4
MK
629 UINT32 EPState : 3;\r
630 UINT32 RsvdZ1 : 5;\r
631 UINT32 Mult : 2;\r
632 UINT32 MaxPStreams : 5;\r
633 UINT32 LSA : 1;\r
634 UINT32 Interval : 8;\r
635 UINT32 RsvdZ2 : 8;\r
636\r
637 UINT32 RsvdZ3 : 1;\r
638 UINT32 CErr : 2;\r
639 UINT32 EPType : 3;\r
640 UINT32 RsvdZ4 : 1;\r
641 UINT32 HID : 1;\r
642 UINT32 MaxBurstSize : 8;\r
643 UINT32 MaxPacketSize : 16;\r
644\r
645 UINT32 PtrLo;\r
646\r
647 UINT32 PtrHi;\r
648\r
649 UINT32 AverageTRBLength : 16;\r
650 UINT32 MaxESITPayload : 16;\r
651\r
652 UINT32 RsvdZ5;\r
653 UINT32 RsvdZ6;\r
654 UINT32 RsvdZ7;\r
92870c98 655} ENDPOINT_CONTEXT;\r
656\r
6b4483cd 657typedef struct _ENDPOINT_CONTEXT_64 {\r
1436aea4
MK
658 UINT32 EPState : 3;\r
659 UINT32 RsvdZ1 : 5;\r
660 UINT32 Mult : 2;\r
661 UINT32 MaxPStreams : 5;\r
662 UINT32 LSA : 1;\r
663 UINT32 Interval : 8;\r
664 UINT32 RsvdZ2 : 8;\r
665\r
666 UINT32 RsvdZ3 : 1;\r
667 UINT32 CErr : 2;\r
668 UINT32 EPType : 3;\r
669 UINT32 RsvdZ4 : 1;\r
670 UINT32 HID : 1;\r
671 UINT32 MaxBurstSize : 8;\r
672 UINT32 MaxPacketSize : 16;\r
673\r
674 UINT32 PtrLo;\r
675\r
676 UINT32 PtrHi;\r
677\r
678 UINT32 AverageTRBLength : 16;\r
679 UINT32 MaxESITPayload : 16;\r
680\r
681 UINT32 RsvdZ5;\r
682 UINT32 RsvdZ6;\r
683 UINT32 RsvdZ7;\r
684\r
685 UINT32 RsvdZ8;\r
686 UINT32 RsvdZ9;\r
687 UINT32 RsvdZ10;\r
688 UINT32 RsvdZ11;\r
689\r
690 UINT32 RsvdZ12;\r
691 UINT32 RsvdZ13;\r
692 UINT32 RsvdZ14;\r
693 UINT32 RsvdZ15;\r
6b4483cd 694} ENDPOINT_CONTEXT_64;\r
695\r
92870c98 696//\r
697// 6.2.5.1 Input Control Context\r
698//\r
699typedef struct _INPUT_CONTRL_CONTEXT {\r
1436aea4
MK
700 UINT32 Dword1;\r
701 UINT32 Dword2;\r
702 UINT32 RsvdZ1;\r
703 UINT32 RsvdZ2;\r
704 UINT32 RsvdZ3;\r
705 UINT32 RsvdZ4;\r
706 UINT32 RsvdZ5;\r
707 UINT32 RsvdZ6;\r
92870c98 708} INPUT_CONTRL_CONTEXT;\r
709\r
6b4483cd 710typedef struct _INPUT_CONTRL_CONTEXT_64 {\r
1436aea4
MK
711 UINT32 Dword1;\r
712 UINT32 Dword2;\r
713 UINT32 RsvdZ1;\r
714 UINT32 RsvdZ2;\r
715 UINT32 RsvdZ3;\r
716 UINT32 RsvdZ4;\r
717 UINT32 RsvdZ5;\r
718 UINT32 RsvdZ6;\r
719 UINT32 RsvdZ7;\r
720 UINT32 RsvdZ8;\r
721 UINT32 RsvdZ9;\r
722 UINT32 RsvdZ10;\r
723 UINT32 RsvdZ11;\r
724 UINT32 RsvdZ12;\r
725 UINT32 RsvdZ13;\r
726 UINT32 RsvdZ14;\r
6b4483cd 727} INPUT_CONTRL_CONTEXT_64;\r
728\r
92870c98 729//\r
730// 6.2.1 Device Context\r
731//\r
732typedef struct _DEVICE_CONTEXT {\r
1436aea4
MK
733 SLOT_CONTEXT Slot;\r
734 ENDPOINT_CONTEXT EP[31];\r
92870c98 735} DEVICE_CONTEXT;\r
736\r
6b4483cd 737typedef struct _DEVICE_CONTEXT_64 {\r
1436aea4
MK
738 SLOT_CONTEXT_64 Slot;\r
739 ENDPOINT_CONTEXT_64 EP[31];\r
6b4483cd 740} DEVICE_CONTEXT_64;\r
741\r
92870c98 742//\r
743// 6.2.5 Input Context\r
744//\r
745typedef struct _INPUT_CONTEXT {\r
746 INPUT_CONTRL_CONTEXT InputControlContext;\r
747 SLOT_CONTEXT Slot;\r
748 ENDPOINT_CONTEXT EP[31];\r
749} INPUT_CONTEXT;\r
750\r
6b4483cd 751typedef struct _INPUT_CONTEXT_64 {\r
1436aea4
MK
752 INPUT_CONTRL_CONTEXT_64 InputControlContext;\r
753 SLOT_CONTEXT_64 Slot;\r
754 ENDPOINT_CONTEXT_64 EP[31];\r
6b4483cd 755} INPUT_CONTEXT_64;\r
756\r
92870c98 757/**\r
758 Initialize the XHCI host controller for schedule.\r
759\r
a9292c13 760 @param Xhc The XHCI Instance to be initialized.\r
92870c98 761\r
762**/\r
763VOID\r
764XhcInitSched (\r
1436aea4 765 IN USB_XHCI_INSTANCE *Xhc\r
92870c98 766 );\r
767\r
768/**\r
769 Free the resouce allocated at initializing schedule.\r
770\r
a9292c13 771 @param Xhc The XHCI Instance.\r
92870c98 772\r
773**/\r
774VOID\r
775XhcFreeSched (\r
1436aea4 776 IN USB_XHCI_INSTANCE *Xhc\r
92870c98 777 );\r
778\r
779/**\r
780 Ring the door bell to notify XHCI there is a transaction to be executed through URB.\r
781\r
a9292c13 782 @param Xhc The XHCI Instance.\r
92870c98 783 @param Urb The URB to be rung.\r
784\r
785 @retval EFI_SUCCESS Successfully ring the door bell.\r
786\r
787**/\r
788EFI_STATUS\r
789RingIntTransferDoorBell (\r
1436aea4
MK
790 IN USB_XHCI_INSTANCE *Xhc,\r
791 IN URB *Urb\r
92870c98 792 );\r
793\r
794/**\r
795 Execute the transfer by polling the URB. This is a synchronous operation.\r
796\r
a9292c13 797 @param Xhc The XHCI Instance.\r
92870c98 798 @param CmdTransfer The executed URB is for cmd transfer or not.\r
799 @param Urb The URB to execute.\r
a9292c13 800 @param Timeout The time to wait before abort, in millisecond.\r
92870c98 801\r
802 @return EFI_DEVICE_ERROR The transfer failed due to transfer error.\r
803 @return EFI_TIMEOUT The transfer failed due to time out.\r
804 @return EFI_SUCCESS The transfer finished OK.\r
805\r
806**/\r
807EFI_STATUS\r
808XhcExecTransfer (\r
1436aea4
MK
809 IN USB_XHCI_INSTANCE *Xhc,\r
810 IN BOOLEAN CmdTransfer,\r
811 IN URB *Urb,\r
812 IN UINTN Timeout\r
92870c98 813 );\r
814\r
815/**\r
816 Delete a single asynchronous interrupt transfer for\r
817 the device and endpoint.\r
818\r
a9292c13 819 @param Xhc The XHCI Instance.\r
6b4483cd 820 @param BusAddr The logical device address assigned by UsbBus driver.\r
92870c98 821 @param EpNum The endpoint of the target.\r
822\r
823 @retval EFI_SUCCESS An asynchronous transfer is removed.\r
824 @retval EFI_NOT_FOUND No transfer for the device is found.\r
825\r
826**/\r
827EFI_STATUS\r
828XhciDelAsyncIntTransfer (\r
1436aea4
MK
829 IN USB_XHCI_INSTANCE *Xhc,\r
830 IN UINT8 BusAddr,\r
831 IN UINT8 EpNum\r
92870c98 832 );\r
833\r
834/**\r
835 Remove all the asynchronous interrupt transfers.\r
836\r
a9292c13 837 @param Xhc The XHCI Instance.\r
92870c98 838\r
839**/\r
840VOID\r
841XhciDelAllAsyncIntTransfers (\r
1436aea4 842 IN USB_XHCI_INSTANCE *Xhc\r
92870c98 843 );\r
844\r
6681582d
SZ
845/**\r
846 Insert a single asynchronous interrupt transfer for\r
847 the device and endpoint.\r
848\r
849 @param Xhc The XHCI Instance\r
850 @param BusAddr The logical device address assigned by UsbBus driver\r
851 @param EpAddr Endpoint addrress\r
852 @param DevSpeed The device speed\r
853 @param MaxPacket The max packet length of the endpoint\r
854 @param DataLen The length of data buffer\r
855 @param Callback The function to call when data is transferred\r
856 @param Context The context to the callback\r
857\r
858 @return Created URB or NULL\r
859\r
860**/\r
861URB *\r
862XhciInsertAsyncIntTransfer (\r
1436aea4
MK
863 IN USB_XHCI_INSTANCE *Xhc,\r
864 IN UINT8 BusAddr,\r
865 IN UINT8 EpAddr,\r
866 IN UINT8 DevSpeed,\r
867 IN UINTN MaxPacket,\r
868 IN UINTN DataLen,\r
869 IN EFI_ASYNC_USB_TRANSFER_CALLBACK Callback,\r
870 IN VOID *Context\r
6681582d
SZ
871 );\r
872\r
92870c98 873/**\r
874 Set Bios Ownership\r
875\r
a9292c13 876 @param Xhc The XHCI Instance.\r
92870c98 877\r
878**/\r
879VOID\r
880XhcSetBiosOwnership (\r
1436aea4 881 IN USB_XHCI_INSTANCE *Xhc\r
92870c98 882 );\r
883\r
884/**\r
885 Clear Bios Ownership\r
886\r
a9292c13 887 @param Xhc The XHCI Instance.\r
92870c98 888\r
889**/\r
890VOID\r
891XhcClearBiosOwnership (\r
1436aea4 892 IN USB_XHCI_INSTANCE *Xhc\r
92870c98 893 );\r
894\r
92870c98 895/**\r
896 Find out the slot id according to the device's route string.\r
897\r
a9292c13 898 @param Xhc The XHCI Instance.\r
899 @param RouteString The route string described the device location.\r
92870c98 900\r
901 @return The slot id used by the device.\r
902\r
903**/\r
904UINT8\r
905EFIAPI\r
906XhcRouteStringToSlotId (\r
a9292c13 907 IN USB_XHCI_INSTANCE *Xhc,\r
908 IN USB_DEV_ROUTE RouteString\r
92870c98 909 );\r
910\r
911/**\r
912 Calculate the device context index by endpoint address and direction.\r
913\r
914 @param EpAddr The target endpoint number.\r
915 @param Direction The direction of the target endpoint.\r
916\r
917 @return The device context index of endpoint.\r
918\r
919**/\r
920UINT8\r
921XhcEndpointToDci (\r
1436aea4
MK
922 IN UINT8 EpAddr,\r
923 IN UINT8 Direction\r
92870c98 924 );\r
925\r
926/**\r
927 Ring the door bell to notify XHCI there is a transaction to be executed.\r
928\r
a9292c13 929 @param Xhc The XHCI Instance.\r
92870c98 930 @param SlotId The slot id of the target device.\r
931 @param Dci The device context index of the target slot or endpoint.\r
932\r
933 @retval EFI_SUCCESS Successfully ring the door bell.\r
934\r
935**/\r
936EFI_STATUS\r
937EFIAPI\r
938XhcRingDoorBell (\r
1436aea4
MK
939 IN USB_XHCI_INSTANCE *Xhc,\r
940 IN UINT8 SlotId,\r
941 IN UINT8 Dci\r
92870c98 942 );\r
943\r
944/**\r
945 Interrupt transfer periodic check handler.\r
946\r
947 @param Event Interrupt event.\r
a9292c13 948 @param Context Pointer to USB_XHCI_INSTANCE.\r
92870c98 949\r
950**/\r
951VOID\r
952EFIAPI\r
953XhcMonitorAsyncRequests (\r
1436aea4
MK
954 IN EFI_EVENT Event,\r
955 IN VOID *Context\r
92870c98 956 );\r
957\r
958/**\r
959 Monitor the port status change. Enable/Disable device slot if there is a device attached/detached.\r
960\r
a9292c13 961 @param Xhc The XHCI Instance.\r
92870c98 962 @param ParentRouteChart The route string pointed to the parent device if it exists.\r
963 @param Port The port to be polled.\r
964 @param PortState The port state.\r
965\r
966 @retval EFI_SUCCESS Successfully enable/disable device slot according to port state.\r
967 @retval Others Should not appear.\r
968\r
969**/\r
970EFI_STATUS\r
971EFIAPI\r
972XhcPollPortStatusChange (\r
1436aea4
MK
973 IN USB_XHCI_INSTANCE *Xhc,\r
974 IN USB_DEV_ROUTE ParentRouteChart,\r
975 IN UINT8 Port,\r
976 IN EFI_USB_PORT_STATUS *PortState\r
92870c98 977 );\r
978\r
979/**\r
980 Evaluate the slot context for hub device through XHCI's Configure_Endpoint cmd.\r
981\r
a9292c13 982 @param Xhc The XHCI Instance.\r
92870c98 983 @param SlotId The slot id to be configured.\r
984 @param PortNum The total number of downstream port supported by the hub.\r
985 @param TTT The TT think time of the hub device.\r
986 @param MTT The multi-TT of the hub device.\r
987\r
988 @retval EFI_SUCCESS Successfully configure the hub device's slot context.\r
989\r
990**/\r
991EFI_STATUS\r
992XhcConfigHubContext (\r
1436aea4
MK
993 IN USB_XHCI_INSTANCE *Xhc,\r
994 IN UINT8 SlotId,\r
995 IN UINT8 PortNum,\r
996 IN UINT8 TTT,\r
997 IN UINT8 MTT\r
92870c98 998 );\r
999\r
6b4483cd 1000/**\r
1001 Evaluate the slot context for hub device through XHCI's Configure_Endpoint cmd.\r
1002\r
1003 @param Xhc The XHCI Instance.\r
1004 @param SlotId The slot id to be configured.\r
1005 @param PortNum The total number of downstream port supported by the hub.\r
1006 @param TTT The TT think time of the hub device.\r
1007 @param MTT The multi-TT of the hub device.\r
1008\r
1009 @retval EFI_SUCCESS Successfully configure the hub device's slot context.\r
1010\r
1011**/\r
1012EFI_STATUS\r
1013XhcConfigHubContext64 (\r
1436aea4
MK
1014 IN USB_XHCI_INSTANCE *Xhc,\r
1015 IN UINT8 SlotId,\r
1016 IN UINT8 PortNum,\r
1017 IN UINT8 TTT,\r
1018 IN UINT8 MTT\r
6b4483cd 1019 );\r
1020\r
92870c98 1021/**\r
1022 Configure all the device endpoints through XHCI's Configure_Endpoint cmd.\r
1023\r
a9292c13 1024 @param Xhc The XHCI Instance.\r
92870c98 1025 @param SlotId The slot id to be configured.\r
1026 @param DeviceSpeed The device's speed.\r
1027 @param ConfigDesc The pointer to the usb device configuration descriptor.\r
1028\r
1029 @retval EFI_SUCCESS Successfully configure all the device endpoints.\r
1030\r
1031**/\r
1032EFI_STATUS\r
1033EFIAPI\r
1034XhcSetConfigCmd (\r
1436aea4
MK
1035 IN USB_XHCI_INSTANCE *Xhc,\r
1036 IN UINT8 SlotId,\r
1037 IN UINT8 DeviceSpeed,\r
1038 IN USB_CONFIG_DESCRIPTOR *ConfigDesc\r
92870c98 1039 );\r
1040\r
6b4483cd 1041/**\r
1042 Configure all the device endpoints through XHCI's Configure_Endpoint cmd.\r
1043\r
1044 @param Xhc The XHCI Instance.\r
1045 @param SlotId The slot id to be configured.\r
1046 @param DeviceSpeed The device's speed.\r
1047 @param ConfigDesc The pointer to the usb device configuration descriptor.\r
1048\r
1049 @retval EFI_SUCCESS Successfully configure all the device endpoints.\r
1050\r
1051**/\r
1052EFI_STATUS\r
1053EFIAPI\r
1054XhcSetConfigCmd64 (\r
1436aea4
MK
1055 IN USB_XHCI_INSTANCE *Xhc,\r
1056 IN UINT8 SlotId,\r
1057 IN UINT8 DeviceSpeed,\r
1058 IN USB_CONFIG_DESCRIPTOR *ConfigDesc\r
6b4483cd 1059 );\r
1060\r
e1f2dfec
SZ
1061/**\r
1062 Set interface through XHCI's Configure_Endpoint cmd.\r
1063\r
1064 @param Xhc The XHCI Instance.\r
1065 @param SlotId The slot id to be configured.\r
1066 @param DeviceSpeed The device's speed.\r
1067 @param ConfigDesc The pointer to the usb device configuration descriptor.\r
1068 @param Request USB device request to send.\r
1069\r
1070 @retval EFI_SUCCESS Successfully set interface.\r
1071\r
1072**/\r
1073EFI_STATUS\r
1074EFIAPI\r
1075XhcSetInterface (\r
1436aea4
MK
1076 IN USB_XHCI_INSTANCE *Xhc,\r
1077 IN UINT8 SlotId,\r
1078 IN UINT8 DeviceSpeed,\r
1079 IN USB_CONFIG_DESCRIPTOR *ConfigDesc,\r
1080 IN EFI_USB_DEVICE_REQUEST *Request\r
e1f2dfec
SZ
1081 );\r
1082\r
1083/**\r
1084 Set interface through XHCI's Configure_Endpoint cmd.\r
1085\r
1086 @param Xhc The XHCI Instance.\r
1087 @param SlotId The slot id to be configured.\r
1088 @param DeviceSpeed The device's speed.\r
1089 @param ConfigDesc The pointer to the usb device configuration descriptor.\r
1090 @param Request USB device request to send.\r
1091\r
1092 @retval EFI_SUCCESS Successfully set interface.\r
1093\r
1094**/\r
1095EFI_STATUS\r
1096EFIAPI\r
1097XhcSetInterface64 (\r
1436aea4
MK
1098 IN USB_XHCI_INSTANCE *Xhc,\r
1099 IN UINT8 SlotId,\r
1100 IN UINT8 DeviceSpeed,\r
1101 IN USB_CONFIG_DESCRIPTOR *ConfigDesc,\r
1102 IN EFI_USB_DEVICE_REQUEST *Request\r
e1f2dfec 1103 );\r
6b4483cd 1104\r
92870c98 1105/**\r
1106 Find out the actual device address according to the requested device address from UsbBus.\r
1107\r
a9292c13 1108 @param Xhc The XHCI Instance.\r
1109 @param BusDevAddr The requested device address by UsbBus upper driver.\r
92870c98 1110\r
1111 @return The actual device address assigned to the device.\r
1112\r
1113**/\r
1114UINT8\r
1115EFIAPI\r
1116XhcBusDevAddrToSlotId (\r
a9292c13 1117 IN USB_XHCI_INSTANCE *Xhc,\r
1118 IN UINT8 BusDevAddr\r
92870c98 1119 );\r
1120\r
1121/**\r
1122 Assign and initialize the device slot for a new device.\r
1123\r
a9292c13 1124 @param Xhc The XHCI Instance.\r
92870c98 1125 @param ParentRouteChart The route string pointed to the parent device.\r
1126 @param ParentPort The port at which the device is located.\r
1127 @param RouteChart The route string pointed to the device.\r
1128 @param DeviceSpeed The device speed.\r
1129\r
1130 @retval EFI_SUCCESS Successfully assign a slot to the device and assign an address to it.\r
1131\r
1132**/\r
1133EFI_STATUS\r
1134EFIAPI\r
1135XhcInitializeDeviceSlot (\r
1436aea4
MK
1136 IN USB_XHCI_INSTANCE *Xhc,\r
1137 IN USB_DEV_ROUTE ParentRouteChart,\r
1138 IN UINT16 ParentPort,\r
1139 IN USB_DEV_ROUTE RouteChart,\r
1140 IN UINT8 DeviceSpeed\r
92870c98 1141 );\r
1142\r
6b4483cd 1143/**\r
1144 Assign and initialize the device slot for a new device.\r
1145\r
1146 @param Xhc The XHCI Instance.\r
1147 @param ParentRouteChart The route string pointed to the parent device.\r
1148 @param ParentPort The port at which the device is located.\r
1149 @param RouteChart The route string pointed to the device.\r
1150 @param DeviceSpeed The device speed.\r
1151\r
1152 @retval EFI_SUCCESS Successfully assign a slot to the device and assign an address to it.\r
1153\r
1154**/\r
1155EFI_STATUS\r
1156EFIAPI\r
1157XhcInitializeDeviceSlot64 (\r
1436aea4
MK
1158 IN USB_XHCI_INSTANCE *Xhc,\r
1159 IN USB_DEV_ROUTE ParentRouteChart,\r
1160 IN UINT16 ParentPort,\r
1161 IN USB_DEV_ROUTE RouteChart,\r
1162 IN UINT8 DeviceSpeed\r
6b4483cd 1163 );\r
1164\r
92870c98 1165/**\r
1166 Evaluate the endpoint 0 context through XHCI's Evaluate_Context cmd.\r
1167\r
a9292c13 1168 @param Xhc The XHCI Instance.\r
92870c98 1169 @param SlotId The slot id to be evaluated.\r
1170 @param MaxPacketSize The max packet size supported by the device control transfer.\r
1171\r
1172 @retval EFI_SUCCESS Successfully evaluate the device endpoint 0.\r
1173\r
1174**/\r
1175EFI_STATUS\r
1176EFIAPI\r
1177XhcEvaluateContext (\r
1436aea4
MK
1178 IN USB_XHCI_INSTANCE *Xhc,\r
1179 IN UINT8 SlotId,\r
1180 IN UINT32 MaxPacketSize\r
92870c98 1181 );\r
1182\r
6b4483cd 1183/**\r
1184 Evaluate the endpoint 0 context through XHCI's Evaluate_Context cmd.\r
1185\r
1186 @param Xhc The XHCI Instance.\r
1187 @param SlotId The slot id to be evaluated.\r
1188 @param MaxPacketSize The max packet size supported by the device control transfer.\r
1189\r
1190 @retval EFI_SUCCESS Successfully evaluate the device endpoint 0.\r
1191\r
1192**/\r
1193EFI_STATUS\r
1194EFIAPI\r
1195XhcEvaluateContext64 (\r
1436aea4
MK
1196 IN USB_XHCI_INSTANCE *Xhc,\r
1197 IN UINT8 SlotId,\r
1198 IN UINT32 MaxPacketSize\r
6b4483cd 1199 );\r
1200\r
92870c98 1201/**\r
1202 Disable the specified device slot.\r
1203\r
a9292c13 1204 @param Xhc The XHCI Instance.\r
92870c98 1205 @param SlotId The slot id to be disabled.\r
1206\r
1207 @retval EFI_SUCCESS Successfully disable the device slot.\r
1208\r
1209**/\r
1210EFI_STATUS\r
1211EFIAPI\r
1212XhcDisableSlotCmd (\r
1436aea4
MK
1213 IN USB_XHCI_INSTANCE *Xhc,\r
1214 IN UINT8 SlotId\r
92870c98 1215 );\r
1216\r
6b4483cd 1217/**\r
1218 Disable the specified device slot.\r
1219\r
1220 @param Xhc The XHCI Instance.\r
1221 @param SlotId The slot id to be disabled.\r
1222\r
1223 @retval EFI_SUCCESS Successfully disable the device slot.\r
1224\r
1225**/\r
1226EFI_STATUS\r
1227EFIAPI\r
1228XhcDisableSlotCmd64 (\r
1436aea4
MK
1229 IN USB_XHCI_INSTANCE *Xhc,\r
1230 IN UINT8 SlotId\r
6b4483cd 1231 );\r
1232\r
92870c98 1233/**\r
1234 Synchronize the specified transfer ring to update the enqueue and dequeue pointer.\r
1235\r
a9292c13 1236 @param Xhc The XHCI Instance.\r
92870c98 1237 @param TrsRing The transfer ring to sync.\r
1238\r
1239 @retval EFI_SUCCESS The transfer ring is synchronized successfully.\r
1240\r
1241**/\r
1242EFI_STATUS\r
1243EFIAPI\r
1244XhcSyncTrsRing (\r
1436aea4
MK
1245 IN USB_XHCI_INSTANCE *Xhc,\r
1246 TRANSFER_RING *TrsRing\r
92870c98 1247 );\r
1248\r
1249/**\r
1250 Synchronize the specified event ring to update the enqueue and dequeue pointer.\r
1251\r
a9292c13 1252 @param Xhc The XHCI Instance.\r
92870c98 1253 @param EvtRing The event ring to sync.\r
1254\r
1255 @retval EFI_SUCCESS The event ring is synchronized successfully.\r
1256\r
1257**/\r
1258EFI_STATUS\r
1259EFIAPI\r
1260XhcSyncEventRing (\r
1436aea4
MK
1261 IN USB_XHCI_INSTANCE *Xhc,\r
1262 EVENT_RING *EvtRing\r
92870c98 1263 );\r
1264\r
1265/**\r
1266 Check if there is a new generated event.\r
1267\r
a9292c13 1268 @param Xhc The XHCI Instance.\r
92870c98 1269 @param EvtRing The event ring to check.\r
1270 @param NewEvtTrb The new event TRB found.\r
1271\r
1272 @retval EFI_SUCCESS Found a new event TRB at the event ring.\r
1273 @retval EFI_NOT_READY The event ring has no new event.\r
1274\r
1275**/\r
1276EFI_STATUS\r
1277EFIAPI\r
1278XhcCheckNewEvent (\r
1436aea4
MK
1279 IN USB_XHCI_INSTANCE *Xhc,\r
1280 IN EVENT_RING *EvtRing,\r
1281 OUT TRB_TEMPLATE **NewEvtTrb\r
92870c98 1282 );\r
1283\r
1284/**\r
1285 Create XHCI transfer ring.\r
1286\r
a9292c13 1287 @param Xhc The XHCI Instance.\r
92870c98 1288 @param TrbNum The number of TRB in the ring.\r
1289 @param TransferRing The created transfer ring.\r
1290\r
1291**/\r
1292VOID\r
1293CreateTransferRing (\r
1436aea4
MK
1294 IN USB_XHCI_INSTANCE *Xhc,\r
1295 IN UINTN TrbNum,\r
1296 OUT TRANSFER_RING *TransferRing\r
92870c98 1297 );\r
1298\r
1299/**\r
1300 Create XHCI event ring.\r
1301\r
a9292c13 1302 @param Xhc The XHCI Instance.\r
92870c98 1303 @param EventRing The created event ring.\r
1304\r
1305**/\r
1306VOID\r
1307CreateEventRing (\r
1436aea4
MK
1308 IN USB_XHCI_INSTANCE *Xhc,\r
1309 OUT EVENT_RING *EventRing\r
92870c98 1310 );\r
1311\r
1312/**\r
1313 System software shall use a Reset Endpoint Command (section 4.11.4.7) to remove the Halted\r
1314 condition in the xHC. After the successful completion of the Reset Endpoint Command, the Endpoint\r
1315 Context is transitioned from the Halted to the Stopped state and the Transfer Ring of the endpoint is\r
1316 reenabled. The next write to the Doorbell of the Endpoint will transition the Endpoint Context from the\r
1317 Stopped to the Running state.\r
1318\r
a9292c13 1319 @param Xhc The XHCI Instance.\r
92870c98 1320 @param Urb The urb which makes the endpoint halted.\r
1321\r
1322 @retval EFI_SUCCESS The recovery is successful.\r
1323 @retval Others Failed to recovery halted endpoint.\r
1324\r
1325**/\r
1326EFI_STATUS\r
1327EFIAPI\r
1328XhcRecoverHaltedEndpoint (\r
1436aea4
MK
1329 IN USB_XHCI_INSTANCE *Xhc,\r
1330 IN URB *Urb\r
92870c98 1331 );\r
1332\r
12e6c738
FT
1333/**\r
1334 System software shall use a Stop Endpoint Command (section 4.6.9) and the Set TR Dequeue Pointer\r
1335 Command (section 4.6.10) to remove the timed-out TDs from the xHC transfer ring. The next write to\r
1336 the Doorbell of the Endpoint will transition the Endpoint Context from the Stopped to the Running\r
1337 state.\r
1338\r
1339 @param Xhc The XHCI Instance.\r
1340 @param Urb The urb which doesn't get completed in a specified timeout range.\r
1341\r
1342 @retval EFI_SUCCESS The dequeuing of the TDs is successful.\r
1343 @retval Others Failed to stop the endpoint and dequeue the TDs.\r
1344\r
1345**/\r
1346EFI_STATUS\r
1347EFIAPI\r
1348XhcDequeueTrbFromEndpoint (\r
1436aea4
MK
1349 IN USB_XHCI_INSTANCE *Xhc,\r
1350 IN URB *Urb\r
12e6c738
FT
1351 );\r
1352\r
1353/**\r
1354 Stop endpoint through XHCI's Stop_Endpoint cmd.\r
1355\r
1356 @param Xhc The XHCI Instance.\r
1357 @param SlotId The slot id to be configured.\r
1358 @param Dci The device context index of endpoint.\r
49be9c3c 1359 @param PendingUrb The pending URB to check completion status when stopping the end point.\r
12e6c738
FT
1360\r
1361 @retval EFI_SUCCESS Stop endpoint successfully.\r
1362 @retval Others Failed to stop endpoint.\r
1363\r
1364**/\r
1365EFI_STATUS\r
1366EFIAPI\r
1367XhcStopEndpoint (\r
1436aea4
MK
1368 IN USB_XHCI_INSTANCE *Xhc,\r
1369 IN UINT8 SlotId,\r
1370 IN UINT8 Dci,\r
1371 IN URB *PendingUrb OPTIONAL\r
12e6c738
FT
1372 );\r
1373\r
1374/**\r
1375 Reset endpoint through XHCI's Reset_Endpoint cmd.\r
1376\r
1377 @param Xhc The XHCI Instance.\r
1378 @param SlotId The slot id to be configured.\r
1379 @param Dci The device context index of endpoint.\r
1380\r
1381 @retval EFI_SUCCESS Reset endpoint successfully.\r
1382 @retval Others Failed to reset endpoint.\r
1383\r
1384**/\r
1385EFI_STATUS\r
1386EFIAPI\r
1387XhcResetEndpoint (\r
1436aea4
MK
1388 IN USB_XHCI_INSTANCE *Xhc,\r
1389 IN UINT8 SlotId,\r
1390 IN UINT8 Dci\r
12e6c738
FT
1391 );\r
1392\r
1393/**\r
1394 Set transfer ring dequeue pointer through XHCI's Set_Tr_Dequeue_Pointer cmd.\r
1395\r
1396 @param Xhc The XHCI Instance.\r
1397 @param SlotId The slot id to be configured.\r
1398 @param Dci The device context index of endpoint.\r
1399 @param Urb The dequeue pointer of the transfer ring specified\r
1400 by the urb to be updated.\r
1401\r
1402 @retval EFI_SUCCESS Set transfer ring dequeue pointer succeeds.\r
1403 @retval Others Failed to set transfer ring dequeue pointer.\r
1404\r
1405**/\r
1406EFI_STATUS\r
1407EFIAPI\r
1408XhcSetTrDequeuePointer (\r
1436aea4
MK
1409 IN USB_XHCI_INSTANCE *Xhc,\r
1410 IN UINT8 SlotId,\r
1411 IN UINT8 Dci,\r
1412 IN URB *Urb\r
12e6c738
FT
1413 );\r
1414\r
92870c98 1415/**\r
1416 Create a new URB for a new transaction.\r
1417\r
d98fc9ad
SZ
1418 @param Xhc The XHCI Instance\r
1419 @param DevAddr The device address\r
1420 @param EpAddr Endpoint addrress\r
1421 @param DevSpeed The device speed\r
1422 @param MaxPacket The max packet length of the endpoint\r
1423 @param Type The transaction type\r
1424 @param Request The standard USB request for control transfer\r
1425 @param Data The user data to transfer\r
1426 @param DataLen The length of data buffer\r
1427 @param Callback The function to call when data is transferred\r
1428 @param Context The context to the callback\r
92870c98 1429\r
1430 @return Created URB or NULL\r
1431\r
1432**/\r
1436aea4 1433URB *\r
92870c98 1434XhcCreateUrb (\r
1436aea4
MK
1435 IN USB_XHCI_INSTANCE *Xhc,\r
1436 IN UINT8 DevAddr,\r
1437 IN UINT8 EpAddr,\r
1438 IN UINT8 DevSpeed,\r
1439 IN UINTN MaxPacket,\r
1440 IN UINTN Type,\r
1441 IN EFI_USB_DEVICE_REQUEST *Request,\r
1442 IN VOID *Data,\r
1443 IN UINTN DataLen,\r
1444 IN EFI_ASYNC_USB_TRANSFER_CALLBACK Callback,\r
1445 IN VOID *Context\r
92870c98 1446 );\r
1447\r
1847ed0b
EL
1448/**\r
1449 Free an allocated URB.\r
1450\r
1451 @param Xhc The XHCI device.\r
1452 @param Urb The URB to free.\r
1453\r
1454**/\r
1455VOID\r
1456XhcFreeUrb (\r
1436aea4
MK
1457 IN USB_XHCI_INSTANCE *Xhc,\r
1458 IN URB *Urb\r
1847ed0b
EL
1459 );\r
1460\r
92870c98 1461/**\r
1462 Create a transfer TRB.\r
1463\r
a9292c13 1464 @param Xhc The XHCI Instance\r
92870c98 1465 @param Urb The urb used to construct the transfer TRB.\r
1466\r
1467 @return Created TRB or NULL\r
1468\r
1469**/\r
1470EFI_STATUS\r
1471XhcCreateTransferTrb (\r
1436aea4
MK
1472 IN USB_XHCI_INSTANCE *Xhc,\r
1473 IN URB *Urb\r
92870c98 1474 );\r
1475\r
1476#endif\r