]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.h
1. Remove “Force clear PK” feature in AuthVarialbe driver.
[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
5Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
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
192 EVENT_RING *EvtRing;\r
a9292c13 193 TRB_TEMPLATE *EvtTrbStart;\r
92870c98 194} URB;\r
195\r
92870c98 196//\r
197// 6.5 Event Ring Segment Table\r
198// The Event Ring Segment Table is used to define multi-segment Event Rings and to enable runtime\r
199// expansion and shrinking of the Event Ring. The location of the Event Ring Segment Table is defined by the\r
200// Event Ring Segment Table Base Address Register (5.5.2.3.2). The size of the Event Ring Segment Table\r
201// is defined by the Event Ring Segment Table Base Size Register (5.5.2.3.1).\r
202//\r
203typedef struct _EVENT_RING_SEG_TABLE_ENTRY {\r
204 UINT32 PtrLo;\r
205 UINT32 PtrHi;\r
206 UINT32 RingTrbSize:16;\r
207 UINT32 RsvdZ1:16;\r
208 UINT32 RsvdZ2;\r
209} EVENT_RING_SEG_TABLE_ENTRY;\r
210\r
211//\r
212// 6.4.1.1 Normal TRB\r
213// A Normal TRB is used in several ways; exclusively on Bulk and Interrupt Transfer Rings for normal and\r
214// Scatter/Gather operations, to define additional data buffers for Scatter/Gather operations on Isoch Transfer\r
215// Rings, and to define the Data stage information for Control Transfer Rings.\r
216//\r
217typedef struct _TRANSFER_TRB_NORMAL {\r
218 UINT32 TRBPtrLo;\r
a9292c13 219\r
92870c98 220 UINT32 TRBPtrHi;\r
a9292c13 221\r
92870c98 222 UINT32 Lenth:17;\r
223 UINT32 TDSize:5;\r
224 UINT32 IntTarget:10;\r
a9292c13 225\r
92870c98 226 UINT32 CycleBit:1;\r
227 UINT32 ENT:1;\r
228 UINT32 ISP:1;\r
229 UINT32 NS:1;\r
230 UINT32 CH:1;\r
231 UINT32 IOC:1;\r
232 UINT32 IDT:1;\r
233 UINT32 RsvdZ1:2;\r
234 UINT32 BEI:1;\r
235 UINT32 Type:6;\r
236 UINT32 RsvdZ2:16;\r
237} TRANSFER_TRB_NORMAL;\r
238\r
239//\r
240// 6.4.1.2.1 Setup Stage TRB\r
241// A Setup Stage TRB is created by system software to initiate a USB Setup packet on a control endpoint.\r
242//\r
a9292c13 243typedef struct _TRANSFER_TRB_CONTROL_SETUP {\r
92870c98 244 UINT32 bmRequestType:8;\r
245 UINT32 bRequest:8;\r
246 UINT32 wValue:16;\r
247\r
248 UINT32 wIndex:16;\r
249 UINT32 wLength:16;\r
250\r
251 UINT32 Lenth:17;\r
252 UINT32 RsvdZ1:5;\r
253 UINT32 IntTarget:10;\r
254\r
255 UINT32 CycleBit:1;\r
256 UINT32 RsvdZ2:4;\r
257 UINT32 IOC:1;\r
258 UINT32 IDT:1;\r
259 UINT32 RsvdZ3:3;\r
260 UINT32 Type:6;\r
261 UINT32 TRT:2;\r
262 UINT32 RsvdZ4:14;\r
263} TRANSFER_TRB_CONTROL_SETUP;\r
264\r
265//\r
266// 6.4.1.2.2 Data Stage TRB\r
267// A Data Stage TRB is used generate the Data stage transaction of a USB Control transfer.\r
268//\r
269typedef struct _TRANSFER_TRB_CONTROL_DATA {\r
270 UINT32 TRBPtrLo;\r
a9292c13 271\r
92870c98 272 UINT32 TRBPtrHi;\r
a9292c13 273\r
92870c98 274 UINT32 Lenth:17;\r
275 UINT32 TDSize:5;\r
276 UINT32 IntTarget:10;\r
a9292c13 277\r
92870c98 278 UINT32 CycleBit:1;\r
279 UINT32 ENT:1;\r
280 UINT32 ISP:1;\r
281 UINT32 NS:1;\r
282 UINT32 CH:1;\r
283 UINT32 IOC:1;\r
284 UINT32 IDT:1;\r
285 UINT32 RsvdZ1:3;\r
286 UINT32 Type:6;\r
287 UINT32 DIR:1;\r
288 UINT32 RsvdZ2:15;\r
289} TRANSFER_TRB_CONTROL_DATA;\r
290\r
291//\r
292// 6.4.1.2.2 Data Stage TRB\r
293// A Data Stage TRB is used generate the Data stage transaction of a USB Control transfer.\r
294//\r
295typedef struct _TRANSFER_TRB_CONTROL_STATUS {\r
296 UINT32 RsvdZ1;\r
297 UINT32 RsvdZ2;\r
a9292c13 298\r
92870c98 299 UINT32 RsvdZ3:22;\r
300 UINT32 IntTarget:10;\r
a9292c13 301\r
92870c98 302 UINT32 CycleBit:1;\r
303 UINT32 ENT:1;\r
304 UINT32 RsvdZ4:2;\r
305 UINT32 CH:1;\r
306 UINT32 IOC:1;\r
307 UINT32 RsvdZ5:4;\r
308 UINT32 Type:6;\r
309 UINT32 DIR:1;\r
310 UINT32 RsvdZ6:15;\r
311} TRANSFER_TRB_CONTROL_STATUS;\r
312\r
313//\r
314// 6.4.2.1 Transfer Event TRB\r
315// A Transfer Event provides the completion status associated with a Transfer TRB. Refer to section 4.11.3.1\r
316// for more information on the use and operation of Transfer Events.\r
317//\r
318typedef struct _EVT_TRB_TRANSFER {\r
319 UINT32 TRBPtrLo;\r
a9292c13 320\r
92870c98 321 UINT32 TRBPtrHi;\r
a9292c13 322\r
92870c98 323 UINT32 Lenth:24;\r
a9292c13 324 UINT32 Completecode:8;\r
325\r
92870c98 326 UINT32 CycleBit:1;\r
327 UINT32 RsvdZ1:1;\r
328 UINT32 ED:1;\r
329 UINT32 RsvdZ2:7;\r
330 UINT32 Type:6;\r
a9292c13 331 UINT32 EndpointId:5;\r
92870c98 332 UINT32 RsvdZ3:3;\r
333 UINT32 SlotId:8;\r
334} EVT_TRB_TRANSFER;\r
335\r
336//\r
337// 6.4.2.2 Command Completion Event TRB\r
338// A Command Completion Event TRB shall be generated by the xHC when a command completes on the\r
339// Command Ring. Refer to section 4.11.4 for more information on the use of Command Completion Events.\r
340//\r
a9292c13 341typedef struct _EVT_TRB_COMMAND_COMPLETION {\r
92870c98 342 UINT32 TRBPtrLo;\r
a9292c13 343\r
92870c98 344 UINT32 TRBPtrHi;\r
a9292c13 345\r
92870c98 346 UINT32 RsvdZ2:24;\r
a9292c13 347 UINT32 Completecode:8;\r
348\r
92870c98 349 UINT32 CycleBit:1;\r
350 UINT32 RsvdZ3:9;\r
351 UINT32 Type:6;\r
352 UINT32 VFID:8;\r
353 UINT32 SlotId:8;\r
a9292c13 354} EVT_TRB_COMMAND_COMPLETION;\r
355\r
356typedef union _TRB {\r
357 TRB_TEMPLATE TrbTemplate;\r
358 TRANSFER_TRB_NORMAL TrbNormal;\r
359 TRANSFER_TRB_CONTROL_SETUP TrbCtrSetup;\r
360 TRANSFER_TRB_CONTROL_DATA TrbCtrData;\r
361 TRANSFER_TRB_CONTROL_STATUS TrbCtrStatus;\r
362} TRB;\r
92870c98 363\r
364//\r
365// 6.4.3.1 No Op Command TRB\r
366// The No Op Command TRB provides a simple means for verifying the operation of the Command Ring\r
a9292c13 367// mechanisms offered by the xHCI.\r
92870c98 368//\r
369typedef struct _CMD_TRB_NO_OP {\r
370 UINT32 RsvdZ0;\r
371 UINT32 RsvdZ1;\r
372 UINT32 RsvdZ2;\r
a9292c13 373\r
92870c98 374 UINT32 CycleBit:1;\r
375 UINT32 RsvdZ3:9;\r
376 UINT32 Type:6;\r
377 UINT32 RsvdZ4:16;\r
378} CMD_TRB_NO_OP;\r
379\r
380//\r
381// 6.4.3.2 Enable Slot Command TRB\r
382// The Enable Slot Command TRB causes the xHC to select an available Device Slot and return the ID of the\r
383// selected slot to the host in a Command Completion Event.\r
384//\r
a9292c13 385typedef struct _CMD_TRB_ENABLE_SLOT {\r
92870c98 386 UINT32 RsvdZ0;\r
387 UINT32 RsvdZ1;\r
388 UINT32 RsvdZ2;\r
a9292c13 389\r
92870c98 390 UINT32 CycleBit:1;\r
391 UINT32 RsvdZ3:9;\r
392 UINT32 Type:6;\r
393 UINT32 RsvdZ4:16;\r
a9292c13 394} CMD_TRB_ENABLE_SLOT;\r
92870c98 395\r
396//\r
397// 6.4.3.3 Disable Slot Command TRB\r
398// The Disable Slot Command TRB releases any bandwidth assigned to the disabled slot and frees any\r
399// internal xHC resources assigned to the slot.\r
400//\r
a9292c13 401typedef struct _CMD_TRB_DISABLE_SLOT {\r
92870c98 402 UINT32 RsvdZ0;\r
403 UINT32 RsvdZ1;\r
404 UINT32 RsvdZ2;\r
a9292c13 405\r
92870c98 406 UINT32 CycleBit:1;\r
407 UINT32 RsvdZ3:9;\r
408 UINT32 Type:6;\r
409 UINT32 RsvdZ4:8;\r
410 UINT32 SlotId:8;\r
a9292c13 411} CMD_TRB_DISABLE_SLOT;\r
92870c98 412\r
413//\r
414// 6.4.3.4 Address Device Command TRB\r
415// The Address Device Command TRB transitions the selected Device Context from the Default to the\r
416// Addressed state and causes the xHC to select an address for the USB device in the Default State and\r
417// issue a SET_ADDRESS request to the USB device.\r
418//\r
a9292c13 419typedef struct _CMD_TRB_ADDRESS_DEVICE {\r
92870c98 420 UINT32 PtrLo;\r
a9292c13 421\r
92870c98 422 UINT32 PtrHi;\r
a9292c13 423\r
92870c98 424 UINT32 RsvdZ1;\r
a9292c13 425\r
92870c98 426 UINT32 CycleBit:1;\r
427 UINT32 RsvdZ2:8;\r
428 UINT32 BSR:1;\r
429 UINT32 Type:6;\r
430 UINT32 RsvdZ3:8;\r
431 UINT32 SlotId:8;\r
a9292c13 432} CMD_TRB_ADDRESS_DEVICE;\r
92870c98 433\r
434//\r
435// 6.4.3.5 Configure Endpoint Command TRB\r
436// The Configure Endpoint Command TRB evaluates the bandwidth and resource requirements of the\r
437// endpoints selected by the command.\r
438//\r
a9292c13 439typedef struct _CMD_TRB_CONFIG_ENDPOINT {\r
92870c98 440 UINT32 PtrLo;\r
a9292c13 441\r
92870c98 442 UINT32 PtrHi;\r
a9292c13 443\r
92870c98 444 UINT32 RsvdZ1;\r
a9292c13 445\r
92870c98 446 UINT32 CycleBit:1;\r
447 UINT32 RsvdZ2:8;\r
448 UINT32 DC:1;\r
449 UINT32 Type:6;\r
450 UINT32 RsvdZ3:8;\r
451 UINT32 SlotId:8;\r
a9292c13 452} CMD_TRB_CONFIG_ENDPOINT;\r
92870c98 453\r
454//\r
455// 6.4.3.6 Evaluate Context Command TRB\r
456// The Evaluate Context Command TRB is used by system software to inform the xHC that the selected\r
457// Context data structures in the Device Context have been modified by system software and that the xHC\r
458// shall evaluate any changes\r
459//\r
a9292c13 460typedef struct _CMD_TRB_EVALUATE_CONTEXT {\r
92870c98 461 UINT32 PtrLo;\r
a9292c13 462\r
92870c98 463 UINT32 PtrHi;\r
a9292c13 464\r
92870c98 465 UINT32 RsvdZ1;\r
a9292c13 466\r
92870c98 467 UINT32 CycleBit:1;\r
468 UINT32 RsvdZ2:9;\r
469 UINT32 Type:6;\r
470 UINT32 RsvdZ3:8;\r
471 UINT32 SlotId:8;\r
a9292c13 472} CMD_TRB_EVALUATE_CONTEXT;\r
92870c98 473\r
474//\r
475// 6.4.3.7 Reset Endpoint Command TRB\r
476// The Reset Endpoint Command TRB is used by system software to reset a specified Transfer Ring\r
477//\r
a9292c13 478typedef struct _CMD_TRB_RESET_ENDPOINT {\r
92870c98 479 UINT32 RsvdZ0;\r
480 UINT32 RsvdZ1;\r
481 UINT32 RsvdZ2;\r
a9292c13 482\r
92870c98 483 UINT32 CycleBit:1;\r
484 UINT32 RsvdZ3:8;\r
485 UINT32 TSP:1;\r
486 UINT32 Type:6;\r
487 UINT32 EDID:5;\r
488 UINT32 RsvdZ4:3;\r
489 UINT32 SlotId:8;\r
a9292c13 490} CMD_TRB_RESET_ENDPOINT;\r
92870c98 491\r
492//\r
493// 6.4.3.8 Stop Endpoint Command TRB\r
494// The Stop Endpoint Command TRB command allows software to stop the xHC execution of the TDs on a\r
495// Transfer Ring and temporarily take ownership of TDs that had previously been passed to the xHC.\r
496//\r
a9292c13 497typedef struct _CMD_TRB_STOP_ENDPOINT {\r
92870c98 498 UINT32 RsvdZ0;\r
499 UINT32 RsvdZ1;\r
500 UINT32 RsvdZ2;\r
a9292c13 501\r
92870c98 502 UINT32 CycleBit:1;\r
503 UINT32 RsvdZ3:9;\r
504 UINT32 Type:6;\r
505 UINT32 EDID:5;\r
506 UINT32 RsvdZ4:2;\r
507 UINT32 SP:1;\r
508 UINT32 SlotId:8;\r
a9292c13 509} CMD_TRB_STOP_ENDPOINT;\r
92870c98 510\r
511//\r
512// 6.4.3.9 Set TR Dequeue Pointer Command TRB\r
513// The Set TR Dequeue Pointer Command TRB is used by system software to modify the TR Dequeue\r
514// Pointer and DCS fields of an Endpoint or Stream Context.\r
515//\r
a9292c13 516typedef struct _CMD_SET_TR_DEQ_POINTER {\r
92870c98 517 UINT32 PtrLo;\r
a9292c13 518\r
92870c98 519 UINT32 PtrHi;\r
a9292c13 520\r
92870c98 521 UINT32 RsvdZ1:16;\r
522 UINT32 StreamID:16;\r
a9292c13 523\r
92870c98 524 UINT32 CycleBit:1;\r
525 UINT32 RsvdZ2:9;\r
526 UINT32 Type:6;\r
527 UINT32 Endpoint:5;\r
528 UINT32 RsvdZ3:3;\r
529 UINT32 SlotId:8;\r
a9292c13 530} CMD_SET_TR_DEQ_POINTER;\r
92870c98 531\r
532//\r
a9292c13 533// 6.4.4.1 Link TRB\r
92870c98 534// A Link TRB provides support for non-contiguous TRB Rings.\r
535//\r
a9292c13 536typedef struct _LINK_TRB {\r
92870c98 537 UINT32 PtrLo;\r
a9292c13 538\r
92870c98 539 UINT32 PtrHi;\r
a9292c13 540\r
92870c98 541 UINT32 RsvdZ1:22;\r
542 UINT32 InterTarget:10;\r
a9292c13 543\r
92870c98 544 UINT32 CycleBit:1;\r
545 UINT32 TC:1;\r
546 UINT32 RsvdZ2:2;\r
547 UINT32 CH:1;\r
548 UINT32 IOC:1;\r
549 UINT32 RsvdZ3:4;\r
550 UINT32 Type:6;\r
551 UINT32 RsvdZ4:16;\r
a9292c13 552} LINK_TRB;\r
92870c98 553\r
554//\r
555// 6.2.2 Slot Context\r
556//\r
557typedef struct _SLOT_CONTEXT {\r
a9292c13 558 UINT32 RouteString:20;\r
92870c98 559 UINT32 Speed:4;\r
560 UINT32 RsvdZ1:1;\r
561 UINT32 MTT:1;\r
562 UINT32 Hub:1;\r
563 UINT32 ContextEntries:5;\r
564\r
565 UINT32 MaxExitLatency:16;\r
566 UINT32 RootHubPortNum:8;\r
567 UINT32 PortNum:8;\r
568\r
569 UINT32 TTHubSlotId:8;\r
570 UINT32 TTPortNum:8;\r
571 UINT32 TTT:2;\r
572 UINT32 RsvdZ2:4;\r
573 UINT32 InterTarget:10;\r
574\r
575 UINT32 DeviceAddress:8;\r
576 UINT32 RsvdZ3:19;\r
577 UINT32 SlotState:5;\r
578\r
579 UINT32 RsvdZ4;\r
580 UINT32 RsvdZ5;\r
581 UINT32 RsvdZ6;\r
582 UINT32 RsvdZ7;\r
583} SLOT_CONTEXT;\r
584\r
6b4483cd 585typedef struct _SLOT_CONTEXT_64 {\r
586 UINT32 RouteString:20;\r
587 UINT32 Speed:4;\r
588 UINT32 RsvdZ1:1;\r
589 UINT32 MTT:1;\r
590 UINT32 Hub:1;\r
591 UINT32 ContextEntries:5;\r
592\r
593 UINT32 MaxExitLatency:16;\r
594 UINT32 RootHubPortNum:8;\r
595 UINT32 PortNum:8;\r
596\r
597 UINT32 TTHubSlotId:8;\r
598 UINT32 TTPortNum:8;\r
599 UINT32 TTT:2;\r
600 UINT32 RsvdZ2:4;\r
601 UINT32 InterTarget:10;\r
602\r
603 UINT32 DeviceAddress:8;\r
604 UINT32 RsvdZ3:19;\r
605 UINT32 SlotState:5;\r
606\r
607 UINT32 RsvdZ4;\r
608 UINT32 RsvdZ5;\r
609 UINT32 RsvdZ6;\r
610 UINT32 RsvdZ7;\r
611\r
612 UINT32 RsvdZ8;\r
613 UINT32 RsvdZ9;\r
614 UINT32 RsvdZ10;\r
615 UINT32 RsvdZ11;\r
616 \r
617 UINT32 RsvdZ12;\r
618 UINT32 RsvdZ13;\r
619 UINT32 RsvdZ14;\r
620 UINT32 RsvdZ15;\r
621\r
622} SLOT_CONTEXT_64;\r
623\r
624\r
92870c98 625//\r
626// 6.2.3 Endpoint Context\r
627//\r
628typedef struct _ENDPOINT_CONTEXT {\r
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
655} ENDPOINT_CONTEXT;\r
656\r
6b4483cd 657typedef struct _ENDPOINT_CONTEXT_64 {\r
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
694\r
695} ENDPOINT_CONTEXT_64;\r
696\r
697\r
92870c98 698//\r
699// 6.2.5.1 Input Control Context\r
700//\r
701typedef struct _INPUT_CONTRL_CONTEXT {\r
702 UINT32 Dword1;\r
703 UINT32 Dword2;\r
704 UINT32 RsvdZ1;\r
705 UINT32 RsvdZ2;\r
706 UINT32 RsvdZ3;\r
707 UINT32 RsvdZ4;\r
708 UINT32 RsvdZ5;\r
709 UINT32 RsvdZ6;\r
710} INPUT_CONTRL_CONTEXT;\r
711\r
6b4483cd 712typedef struct _INPUT_CONTRL_CONTEXT_64 {\r
713 UINT32 Dword1;\r
714 UINT32 Dword2;\r
715 UINT32 RsvdZ1;\r
716 UINT32 RsvdZ2;\r
717 UINT32 RsvdZ3;\r
718 UINT32 RsvdZ4;\r
719 UINT32 RsvdZ5;\r
720 UINT32 RsvdZ6;\r
721 UINT32 RsvdZ7;\r
722 UINT32 RsvdZ8;\r
723 UINT32 RsvdZ9;\r
724 UINT32 RsvdZ10;\r
725 UINT32 RsvdZ11;\r
726 UINT32 RsvdZ12;\r
727 UINT32 RsvdZ13;\r
728 UINT32 RsvdZ14;\r
729} INPUT_CONTRL_CONTEXT_64;\r
730\r
92870c98 731//\r
732// 6.2.1 Device Context\r
733//\r
734typedef struct _DEVICE_CONTEXT {\r
735 SLOT_CONTEXT Slot;\r
736 ENDPOINT_CONTEXT EP[31];\r
737} DEVICE_CONTEXT;\r
738\r
6b4483cd 739typedef struct _DEVICE_CONTEXT_64 {\r
740 SLOT_CONTEXT_64 Slot;\r
741 ENDPOINT_CONTEXT_64 EP[31];\r
742} DEVICE_CONTEXT_64;\r
743\r
92870c98 744//\r
745// 6.2.5 Input Context\r
746//\r
747typedef struct _INPUT_CONTEXT {\r
748 INPUT_CONTRL_CONTEXT InputControlContext;\r
749 SLOT_CONTEXT Slot;\r
750 ENDPOINT_CONTEXT EP[31];\r
751} INPUT_CONTEXT;\r
752\r
6b4483cd 753typedef struct _INPUT_CONTEXT_64 {\r
754 INPUT_CONTRL_CONTEXT_64 InputControlContext;\r
755 SLOT_CONTEXT_64 Slot;\r
756 ENDPOINT_CONTEXT_64 EP[31];\r
757} INPUT_CONTEXT_64;\r
758\r
759\r
92870c98 760/**\r
761 Initialize the XHCI host controller for schedule.\r
762\r
a9292c13 763 @param Xhc The XHCI Instance to be initialized.\r
92870c98 764\r
765**/\r
766VOID\r
767XhcInitSched (\r
a9292c13 768 IN USB_XHCI_INSTANCE *Xhc\r
92870c98 769 );\r
770\r
771/**\r
772 Free the resouce allocated at initializing schedule.\r
773\r
a9292c13 774 @param Xhc The XHCI Instance.\r
92870c98 775\r
776**/\r
777VOID\r
778XhcFreeSched (\r
a9292c13 779 IN USB_XHCI_INSTANCE *Xhc\r
92870c98 780 );\r
781\r
782/**\r
783 Ring the door bell to notify XHCI there is a transaction to be executed through URB.\r
784\r
a9292c13 785 @param Xhc The XHCI Instance.\r
92870c98 786 @param Urb The URB to be rung.\r
787\r
788 @retval EFI_SUCCESS Successfully ring the door bell.\r
789\r
790**/\r
791EFI_STATUS\r
792RingIntTransferDoorBell (\r
a9292c13 793 IN USB_XHCI_INSTANCE *Xhc,\r
92870c98 794 IN URB *Urb\r
795 );\r
796\r
797/**\r
798 Execute the transfer by polling the URB. This is a synchronous operation.\r
799\r
a9292c13 800 @param Xhc The XHCI Instance.\r
92870c98 801 @param CmdTransfer The executed URB is for cmd transfer or not.\r
802 @param Urb The URB to execute.\r
a9292c13 803 @param Timeout The time to wait before abort, in millisecond.\r
92870c98 804\r
805 @return EFI_DEVICE_ERROR The transfer failed due to transfer error.\r
806 @return EFI_TIMEOUT The transfer failed due to time out.\r
807 @return EFI_SUCCESS The transfer finished OK.\r
808\r
809**/\r
810EFI_STATUS\r
811XhcExecTransfer (\r
a9292c13 812 IN USB_XHCI_INSTANCE *Xhc,\r
92870c98 813 IN BOOLEAN CmdTransfer,\r
814 IN URB *Urb,\r
a9292c13 815 IN UINTN Timeout\r
92870c98 816 );\r
817\r
818/**\r
819 Delete a single asynchronous interrupt transfer for\r
820 the device and endpoint.\r
821\r
a9292c13 822 @param Xhc The XHCI Instance.\r
6b4483cd 823 @param BusAddr The logical device address assigned by UsbBus driver.\r
92870c98 824 @param EpNum The endpoint of the target.\r
825\r
826 @retval EFI_SUCCESS An asynchronous transfer is removed.\r
827 @retval EFI_NOT_FOUND No transfer for the device is found.\r
828\r
829**/\r
830EFI_STATUS\r
831XhciDelAsyncIntTransfer (\r
a9292c13 832 IN USB_XHCI_INSTANCE *Xhc,\r
6b4483cd 833 IN UINT8 BusAddr,\r
92870c98 834 IN UINT8 EpNum\r
835 );\r
836\r
837/**\r
838 Remove all the asynchronous interrupt transfers.\r
839\r
a9292c13 840 @param Xhc The XHCI Instance.\r
92870c98 841\r
842**/\r
843VOID\r
844XhciDelAllAsyncIntTransfers (\r
a9292c13 845 IN USB_XHCI_INSTANCE *Xhc\r
92870c98 846 );\r
847\r
848/**\r
849 Set Bios Ownership\r
850\r
a9292c13 851 @param Xhc The XHCI Instance.\r
92870c98 852\r
853**/\r
854VOID\r
855XhcSetBiosOwnership (\r
a9292c13 856 IN USB_XHCI_INSTANCE *Xhc\r
92870c98 857 );\r
858\r
859/**\r
860 Clear Bios Ownership\r
861\r
a9292c13 862 @param Xhc The XHCI Instance.\r
92870c98 863\r
864**/\r
865VOID\r
866XhcClearBiosOwnership (\r
a9292c13 867 IN USB_XHCI_INSTANCE *Xhc\r
92870c98 868 );\r
869\r
92870c98 870/**\r
871 Find out the slot id according to the device's route string.\r
872\r
a9292c13 873 @param Xhc The XHCI Instance.\r
874 @param RouteString The route string described the device location.\r
92870c98 875\r
876 @return The slot id used by the device.\r
877\r
878**/\r
879UINT8\r
880EFIAPI\r
881XhcRouteStringToSlotId (\r
a9292c13 882 IN USB_XHCI_INSTANCE *Xhc,\r
883 IN USB_DEV_ROUTE RouteString\r
92870c98 884 );\r
885\r
886/**\r
887 Calculate the device context index by endpoint address and direction.\r
888\r
889 @param EpAddr The target endpoint number.\r
890 @param Direction The direction of the target endpoint.\r
891\r
892 @return The device context index of endpoint.\r
893\r
894**/\r
895UINT8\r
896XhcEndpointToDci (\r
897 IN UINT8 EpAddr,\r
898 IN UINT8 Direction\r
899 );\r
900\r
901/**\r
902 Ring the door bell to notify XHCI there is a transaction to be executed.\r
903\r
a9292c13 904 @param Xhc The XHCI Instance.\r
92870c98 905 @param SlotId The slot id of the target device.\r
906 @param Dci The device context index of the target slot or endpoint.\r
907\r
908 @retval EFI_SUCCESS Successfully ring the door bell.\r
909\r
910**/\r
911EFI_STATUS\r
912EFIAPI\r
913XhcRingDoorBell (\r
a9292c13 914 IN USB_XHCI_INSTANCE *Xhc,\r
92870c98 915 IN UINT8 SlotId,\r
916 IN UINT8 Dci\r
917 );\r
918\r
919/**\r
920 Interrupt transfer periodic check handler.\r
921\r
922 @param Event Interrupt event.\r
a9292c13 923 @param Context Pointer to USB_XHCI_INSTANCE.\r
92870c98 924\r
925**/\r
926VOID\r
927EFIAPI\r
928XhcMonitorAsyncRequests (\r
929 IN EFI_EVENT Event,\r
930 IN VOID *Context\r
931 );\r
932\r
933/**\r
934 Monitor the port status change. Enable/Disable device slot if there is a device attached/detached.\r
935\r
a9292c13 936 @param Xhc The XHCI Instance.\r
92870c98 937 @param ParentRouteChart The route string pointed to the parent device if it exists.\r
938 @param Port The port to be polled.\r
939 @param PortState The port state.\r
940\r
941 @retval EFI_SUCCESS Successfully enable/disable device slot according to port state.\r
942 @retval Others Should not appear.\r
943\r
944**/\r
945EFI_STATUS\r
946EFIAPI\r
947XhcPollPortStatusChange (\r
a9292c13 948 IN USB_XHCI_INSTANCE *Xhc,\r
92870c98 949 IN USB_DEV_ROUTE ParentRouteChart,\r
950 IN UINT8 Port,\r
951 IN EFI_USB_PORT_STATUS *PortState\r
952 );\r
953\r
954/**\r
955 Evaluate the slot context for hub device through XHCI's Configure_Endpoint cmd.\r
956\r
a9292c13 957 @param Xhc The XHCI Instance.\r
92870c98 958 @param SlotId The slot id to be configured.\r
959 @param PortNum The total number of downstream port supported by the hub.\r
960 @param TTT The TT think time of the hub device.\r
961 @param MTT The multi-TT of the hub device.\r
962\r
963 @retval EFI_SUCCESS Successfully configure the hub device's slot context.\r
964\r
965**/\r
966EFI_STATUS\r
967XhcConfigHubContext (\r
a9292c13 968 IN USB_XHCI_INSTANCE *Xhc,\r
92870c98 969 IN UINT8 SlotId,\r
970 IN UINT8 PortNum,\r
971 IN UINT8 TTT,\r
972 IN UINT8 MTT\r
973 );\r
974\r
6b4483cd 975\r
976/**\r
977 Evaluate the slot context for hub device through XHCI's Configure_Endpoint cmd.\r
978\r
979 @param Xhc The XHCI Instance.\r
980 @param SlotId The slot id to be configured.\r
981 @param PortNum The total number of downstream port supported by the hub.\r
982 @param TTT The TT think time of the hub device.\r
983 @param MTT The multi-TT of the hub device.\r
984\r
985 @retval EFI_SUCCESS Successfully configure the hub device's slot context.\r
986\r
987**/\r
988EFI_STATUS\r
989XhcConfigHubContext64 (\r
990 IN USB_XHCI_INSTANCE *Xhc,\r
991 IN UINT8 SlotId,\r
992 IN UINT8 PortNum,\r
993 IN UINT8 TTT,\r
994 IN UINT8 MTT\r
995 );\r
996\r
997\r
92870c98 998/**\r
999 Configure all the device endpoints through XHCI's Configure_Endpoint cmd.\r
1000\r
a9292c13 1001 @param Xhc The XHCI Instance.\r
92870c98 1002 @param SlotId The slot id to be configured.\r
1003 @param DeviceSpeed The device's speed.\r
1004 @param ConfigDesc The pointer to the usb device configuration descriptor.\r
1005\r
1006 @retval EFI_SUCCESS Successfully configure all the device endpoints.\r
1007\r
1008**/\r
1009EFI_STATUS\r
1010EFIAPI\r
1011XhcSetConfigCmd (\r
a9292c13 1012 IN USB_XHCI_INSTANCE *Xhc,\r
92870c98 1013 IN UINT8 SlotId,\r
1014 IN UINT8 DeviceSpeed,\r
1015 IN USB_CONFIG_DESCRIPTOR *ConfigDesc\r
1016 );\r
1017\r
6b4483cd 1018\r
1019/**\r
1020 Configure all the device endpoints through XHCI's Configure_Endpoint cmd.\r
1021\r
1022 @param Xhc The XHCI Instance.\r
1023 @param SlotId The slot id to be configured.\r
1024 @param DeviceSpeed The device's speed.\r
1025 @param ConfigDesc The pointer to the usb device configuration descriptor.\r
1026\r
1027 @retval EFI_SUCCESS Successfully configure all the device endpoints.\r
1028\r
1029**/\r
1030EFI_STATUS\r
1031EFIAPI\r
1032XhcSetConfigCmd64 (\r
1033 IN USB_XHCI_INSTANCE *Xhc,\r
1034 IN UINT8 SlotId,\r
1035 IN UINT8 DeviceSpeed,\r
1036 IN USB_CONFIG_DESCRIPTOR *ConfigDesc\r
1037 );\r
1038\r
1039\r
92870c98 1040/**\r
1041 Find out the actual device address according to the requested device address from UsbBus.\r
1042\r
a9292c13 1043 @param Xhc The XHCI Instance.\r
1044 @param BusDevAddr The requested device address by UsbBus upper driver.\r
92870c98 1045\r
1046 @return The actual device address assigned to the device.\r
1047\r
1048**/\r
1049UINT8\r
1050EFIAPI\r
1051XhcBusDevAddrToSlotId (\r
a9292c13 1052 IN USB_XHCI_INSTANCE *Xhc,\r
1053 IN UINT8 BusDevAddr\r
92870c98 1054 );\r
1055\r
1056/**\r
1057 Assign and initialize the device slot for a new device.\r
1058\r
a9292c13 1059 @param Xhc The XHCI Instance.\r
92870c98 1060 @param ParentRouteChart The route string pointed to the parent device.\r
1061 @param ParentPort The port at which the device is located.\r
1062 @param RouteChart The route string pointed to the device.\r
1063 @param DeviceSpeed The device speed.\r
1064\r
1065 @retval EFI_SUCCESS Successfully assign a slot to the device and assign an address to it.\r
1066\r
1067**/\r
1068EFI_STATUS\r
1069EFIAPI\r
1070XhcInitializeDeviceSlot (\r
a9292c13 1071 IN USB_XHCI_INSTANCE *Xhc,\r
92870c98 1072 IN USB_DEV_ROUTE ParentRouteChart,\r
1073 IN UINT16 ParentPort,\r
1074 IN USB_DEV_ROUTE RouteChart,\r
1075 IN UINT8 DeviceSpeed\r
1076 );\r
1077\r
6b4483cd 1078/**\r
1079 Assign and initialize the device slot for a new device.\r
1080\r
1081 @param Xhc The XHCI Instance.\r
1082 @param ParentRouteChart The route string pointed to the parent device.\r
1083 @param ParentPort The port at which the device is located.\r
1084 @param RouteChart The route string pointed to the device.\r
1085 @param DeviceSpeed The device speed.\r
1086\r
1087 @retval EFI_SUCCESS Successfully assign a slot to the device and assign an address to it.\r
1088\r
1089**/\r
1090EFI_STATUS\r
1091EFIAPI\r
1092XhcInitializeDeviceSlot64 (\r
1093 IN USB_XHCI_INSTANCE *Xhc,\r
1094 IN USB_DEV_ROUTE ParentRouteChart,\r
1095 IN UINT16 ParentPort,\r
1096 IN USB_DEV_ROUTE RouteChart,\r
1097 IN UINT8 DeviceSpeed\r
1098 );\r
1099\r
92870c98 1100/**\r
1101 Evaluate the endpoint 0 context through XHCI's Evaluate_Context cmd.\r
1102\r
a9292c13 1103 @param Xhc The XHCI Instance.\r
92870c98 1104 @param SlotId The slot id to be evaluated.\r
1105 @param MaxPacketSize The max packet size supported by the device control transfer.\r
1106\r
1107 @retval EFI_SUCCESS Successfully evaluate the device endpoint 0.\r
1108\r
1109**/\r
1110EFI_STATUS\r
1111EFIAPI\r
1112XhcEvaluateContext (\r
a9292c13 1113 IN USB_XHCI_INSTANCE *Xhc,\r
92870c98 1114 IN UINT8 SlotId,\r
1115 IN UINT32 MaxPacketSize\r
1116 );\r
1117\r
6b4483cd 1118\r
1119/**\r
1120 Evaluate the endpoint 0 context through XHCI's Evaluate_Context cmd.\r
1121\r
1122 @param Xhc The XHCI Instance.\r
1123 @param SlotId The slot id to be evaluated.\r
1124 @param MaxPacketSize The max packet size supported by the device control transfer.\r
1125\r
1126 @retval EFI_SUCCESS Successfully evaluate the device endpoint 0.\r
1127\r
1128**/\r
1129EFI_STATUS\r
1130EFIAPI\r
1131XhcEvaluateContext64 (\r
1132 IN USB_XHCI_INSTANCE *Xhc,\r
1133 IN UINT8 SlotId,\r
1134 IN UINT32 MaxPacketSize\r
1135 );\r
1136\r
1137\r
92870c98 1138/**\r
1139 Disable the specified device slot.\r
1140\r
a9292c13 1141 @param Xhc The XHCI Instance.\r
92870c98 1142 @param SlotId The slot id to be disabled.\r
1143\r
1144 @retval EFI_SUCCESS Successfully disable the device slot.\r
1145\r
1146**/\r
1147EFI_STATUS\r
1148EFIAPI\r
1149XhcDisableSlotCmd (\r
a9292c13 1150 IN USB_XHCI_INSTANCE *Xhc,\r
92870c98 1151 IN UINT8 SlotId\r
1152 );\r
1153\r
6b4483cd 1154\r
1155/**\r
1156 Disable the specified device slot.\r
1157\r
1158 @param Xhc The XHCI Instance.\r
1159 @param SlotId The slot id to be disabled.\r
1160\r
1161 @retval EFI_SUCCESS Successfully disable the device slot.\r
1162\r
1163**/\r
1164EFI_STATUS\r
1165EFIAPI\r
1166XhcDisableSlotCmd64 (\r
1167 IN USB_XHCI_INSTANCE *Xhc,\r
1168 IN UINT8 SlotId\r
1169 );\r
1170\r
1171\r
92870c98 1172/**\r
1173 Synchronize the specified transfer ring to update the enqueue and dequeue pointer.\r
1174\r
a9292c13 1175 @param Xhc The XHCI Instance.\r
92870c98 1176 @param TrsRing The transfer ring to sync.\r
1177\r
1178 @retval EFI_SUCCESS The transfer ring is synchronized successfully.\r
1179\r
1180**/\r
1181EFI_STATUS\r
1182EFIAPI\r
1183XhcSyncTrsRing (\r
a9292c13 1184 IN USB_XHCI_INSTANCE *Xhc,\r
92870c98 1185 TRANSFER_RING *TrsRing\r
1186 );\r
1187\r
1188/**\r
1189 Synchronize the specified event ring to update the enqueue and dequeue pointer.\r
1190\r
a9292c13 1191 @param Xhc The XHCI Instance.\r
92870c98 1192 @param EvtRing The event ring to sync.\r
1193\r
1194 @retval EFI_SUCCESS The event ring is synchronized successfully.\r
1195\r
1196**/\r
1197EFI_STATUS\r
1198EFIAPI\r
1199XhcSyncEventRing (\r
a9292c13 1200 IN USB_XHCI_INSTANCE *Xhc,\r
92870c98 1201 EVENT_RING *EvtRing\r
1202 );\r
1203\r
1204/**\r
1205 Check if there is a new generated event.\r
1206\r
a9292c13 1207 @param Xhc The XHCI Instance.\r
92870c98 1208 @param EvtRing The event ring to check.\r
1209 @param NewEvtTrb The new event TRB found.\r
1210\r
1211 @retval EFI_SUCCESS Found a new event TRB at the event ring.\r
1212 @retval EFI_NOT_READY The event ring has no new event.\r
1213\r
1214**/\r
1215EFI_STATUS\r
1216EFIAPI\r
1217XhcCheckNewEvent (\r
a9292c13 1218 IN USB_XHCI_INSTANCE *Xhc,\r
92870c98 1219 IN EVENT_RING *EvtRing,\r
a9292c13 1220 OUT TRB_TEMPLATE **NewEvtTrb\r
92870c98 1221 );\r
1222\r
1223/**\r
1224 Create XHCI transfer ring.\r
1225\r
a9292c13 1226 @param Xhc The XHCI Instance.\r
92870c98 1227 @param TrbNum The number of TRB in the ring.\r
1228 @param TransferRing The created transfer ring.\r
1229\r
1230**/\r
1231VOID\r
1232CreateTransferRing (\r
a9292c13 1233 IN USB_XHCI_INSTANCE *Xhc,\r
92870c98 1234 IN UINTN TrbNum,\r
1235 OUT TRANSFER_RING *TransferRing\r
1236 );\r
1237\r
1238/**\r
1239 Create XHCI event ring.\r
1240\r
a9292c13 1241 @param Xhc The XHCI Instance.\r
92870c98 1242 @param EventRing The created event ring.\r
1243\r
1244**/\r
1245VOID\r
1246CreateEventRing (\r
a9292c13 1247 IN USB_XHCI_INSTANCE *Xhc,\r
92870c98 1248 OUT EVENT_RING *EventRing\r
1249 );\r
1250\r
1251/**\r
1252 System software shall use a Reset Endpoint Command (section 4.11.4.7) to remove the Halted\r
1253 condition in the xHC. After the successful completion of the Reset Endpoint Command, the Endpoint\r
1254 Context is transitioned from the Halted to the Stopped state and the Transfer Ring of the endpoint is\r
1255 reenabled. The next write to the Doorbell of the Endpoint will transition the Endpoint Context from the\r
1256 Stopped to the Running state.\r
1257\r
a9292c13 1258 @param Xhc The XHCI Instance.\r
92870c98 1259 @param Urb The urb which makes the endpoint halted.\r
1260\r
1261 @retval EFI_SUCCESS The recovery is successful.\r
1262 @retval Others Failed to recovery halted endpoint.\r
1263\r
1264**/\r
1265EFI_STATUS\r
1266EFIAPI\r
1267XhcRecoverHaltedEndpoint (\r
a9292c13 1268 IN USB_XHCI_INSTANCE *Xhc,\r
92870c98 1269 IN URB *Urb\r
1270 );\r
1271\r
1272/**\r
1273 Create a new URB for a new transaction.\r
1274\r
a9292c13 1275 @param Xhc The XHCI Instance\r
92870c98 1276 @param DevAddr The device address\r
1277 @param EpAddr Endpoint addrress\r
1278 @param DevSpeed The device speed\r
1279 @param MaxPacket The max packet length of the endpoint\r
1280 @param Type The transaction type\r
1281 @param Request The standard USB request for control transfer\r
1282 @param Data The user data to transfer\r
1283 @param DataLen The length of data buffer\r
1284 @param Callback The function to call when data is transferred\r
1285 @param Context The context to the callback\r
1286\r
1287 @return Created URB or NULL\r
1288\r
1289**/\r
1290URB*\r
1291XhcCreateUrb (\r
a9292c13 1292 IN USB_XHCI_INSTANCE *Xhc,\r
92870c98 1293 IN UINT8 DevAddr,\r
1294 IN UINT8 EpAddr,\r
1295 IN UINT8 DevSpeed,\r
1296 IN UINTN MaxPacket,\r
1297 IN UINTN Type,\r
1298 IN EFI_USB_DEVICE_REQUEST *Request,\r
1299 IN VOID *Data,\r
1300 IN UINTN DataLen,\r
1301 IN EFI_ASYNC_USB_TRANSFER_CALLBACK Callback,\r
1302 IN VOID *Context\r
1303 );\r
1304\r
1305/**\r
1306 Create a transfer TRB.\r
1307\r
a9292c13 1308 @param Xhc The XHCI Instance\r
92870c98 1309 @param Urb The urb used to construct the transfer TRB.\r
1310\r
1311 @return Created TRB or NULL\r
1312\r
1313**/\r
1314EFI_STATUS\r
1315XhcCreateTransferTrb (\r
a9292c13 1316 IN USB_XHCI_INSTANCE *Xhc,\r
92870c98 1317 IN URB *Urb\r
1318 );\r
1319\r
1320#endif\r