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