3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
26 // Universal Host Controller Interface data structures and defines
28 #include <IndustryStandard/pci22.h>
31 extern UINTN gEHCDebugLevel
;
32 extern UINTN gEHCErrorLevel
;
35 #define STALL_1_MACRO_SECOND 1
36 #define STALL_1_MILLI_SECOND 1000 * STALL_1_MACRO_SECOND
37 #define STALL_1_SECOND 1000 * STALL_1_MILLI_SECOND
39 #define SETUP_PACKET_PID_CODE 0x02
40 #define INPUT_PACKET_PID_CODE 0x01
41 #define OUTPUT_PACKET_PID_CODE 0x0
43 #define ITD_SELECT_TYPE 0x0
44 #define QH_SELECT_TYPE 0x01
45 #define SITD_SELECT_TYPE 0x02
46 #define FSTN_SELECT_TYPE 0x03
48 #define EHCI_SET_PORT_RESET_RECOVERY_TIME 50 * STALL_1_MILLI_SECOND
49 #define EHCI_CLEAR_PORT_RESET_RECOVERY_TIME STALL_1_MILLI_SECOND
50 #define EHCI_GENERIC_TIMEOUT 50 * STALL_1_MILLI_SECOND
51 #define EHCI_GENERIC_RECOVERY_TIME 50 * STALL_1_MACRO_SECOND
52 #define EHCI_SYNC_REQUEST_POLLING_TIME 50 * STALL_1_MACRO_SECOND
53 #define EHCI_ASYNC_REQUEST_POLLING_TIME 50 * STALL_1_MILLI_SECOND
55 #define USB_BAR_INDEX 0 /* how many bytes away from USB_BASE to 0x10 */
57 #define NORMAL_MEMORY_BLOCK_UNIT_IN_PAGES 1
59 #define EHCI_MIN_PACKET_SIZE 8
60 #define EHCI_MAX_PACKET_SIZE 1024
61 #define EHCI_MAX_FRAME_LIST_LENGTH 1024
62 #define EHCI_BLOCK_SIZE_WITH_TT 64
63 #define EHCI_BLOCK_SIZE 512
64 #define EHCI_MAX_QTD_CAPACITY (EFI_PAGE_SIZE * 5)
66 #define NAK_COUNT_RELOAD 3
67 #define QTD_ERROR_COUNTER 1
68 #define HIGH_BANDWIDTH_PIPE_MULTIPLIER 1
70 #define QTD_STATUS_ACTIVE 0x80
71 #define QTD_STATUS_HALTED 0x40
72 #define QTD_STATUS_BUFFER_ERR 0x20
73 #define QTD_STATUS_BABBLE_ERR 0x10
74 #define QTD_STATUS_TRANSACTION_ERR 0x08
75 #define QTD_STATUS_DO_STOP_SPLIT 0x02
76 #define QTD_STATUS_DO_START_SPLIT 0
77 #define QTD_STATUS_DO_PING 0x01
78 #define QTD_STATUS_DO_OUT 0
83 #define MICRO_FRAME_0_CHANNEL 0x01
84 #define MICRO_FRAME_1_CHANNEL 0x02
85 #define MICRO_FRAME_2_CHANNEL 0x04
86 #define MICRO_FRAME_3_CHANNEL 0x08
87 #define MICRO_FRAME_4_CHANNEL 0x10
88 #define MICRO_FRAME_5_CHANNEL 0x20
89 #define MICRO_FRAME_6_CHANNEL 0x40
90 #define MICRO_FRAME_7_CHANNEL 0x80
92 #define CONTROL_TRANSFER 0x01
93 #define BULK_TRANSFER 0x02
94 #define SYNC_INTERRUPT_TRANSFER 0x04
95 #define ASYNC_INTERRUPT_TRANSFER 0x08
96 #define SYNC_ISOCHRONOUS_TRANSFER 0x10
97 #define ASYNC_ISOCHRONOUS_TRANSFER 0x20
101 // Enhanced Host Controller Registers definitions
103 extern EFI_DRIVER_BINDING_PROTOCOL gEhciDriverBinding
;
104 extern EFI_COMPONENT_NAME_PROTOCOL gEhciComponentName
;
106 #define USBCMD 0x0 /* Command Register Offset 00-03h */
107 #define USBCMD_RS 0x01 /* Run / Stop */
108 #define USBCMD_HCRESET 0x02 /* Host controller reset */
109 #define USBCMD_FLS_512 0x04 /* 512 elements (2048bytes) in Frame List */
110 #define USBCMD_FLS_256 0x08 /* 256 elements (1024bytes) in Frame List */
111 #define USBCMD_PSE 0x10 /* Periodic schedule enable */
112 #define USBCMD_ASE 0x20 /* Asynchronous schedule enable */
113 #define USBCMD_IAAD 0x40 /* Interrupt on async advance doorbell */
115 #define USBSTS 0x04 /* Statue Register Offset 04-07h */
116 #define USBSTS_HSE 0x10 /* Host system error */
117 #define USBSTS_IAA 0x20 /* Interrupt on async advance */
118 #define USBSTS_HCH 0x1000 /* Host controller halted */
119 #define USBSTS_PSS 0x4000 /* Periodic schedule status */
120 #define USBSTS_ASS 0x8000 /* Asynchronous schedule status */
122 #define USBINTR 0x08 /* Command Register Offset 08-0bh */
124 #define FRINDEX 0x0c /* Frame Index Offset 0c-0fh */
126 #define CTRLDSSGMENT 0x10 /* 4G Segment Selector Offset 10-13h */
128 #define PERIODICLISTBASE 0x14 /* Frame List Base Address Offset 14-17h */
130 #define ASYNCLISTADDR 0x18 /* Next Asynchronous List Address Offset 18-1bh */
132 #define CONFIGFLAG 0x40 /* Configured Flag Register Offset 40-43h */
133 #define CONFIGFLAG_CF 0x01 /* Configure Flag */
135 #define PORTSC 0x44 /* Port Status/Control Offset 44-47h */
136 #define PORTSC_CCS 0x01 /* Current Connect Status*/
137 #define PORTSC_CSC 0x02 /* Connect Status Change */
138 #define PORTSC_PED 0x04 /* Port Enable / Disable */
139 #define PORTSC_PEDC 0x08 /* Port Enable / Disable Change */
140 #define PORTSC_OCA 0x10 /* Over current Active */
141 #define PORTSC_OCC 0x20 /* Over current Change */
142 #define PORTSC_FPR 0x40 /* Force Port Resume */
143 #define PORTSC_SUSP 0x80 /* Port Suspend State */
144 #define PORTSC_PR 0x100 /* Port Reset */
145 #define PORTSC_LS_KSTATE 0x400 /* Line Status K-state */
146 #define PORTSC_LS_JSTATE 0x800 /* Line Status J-state */
147 #define PORTSC_PP 0x1000 /* Port Power */
148 #define PORTSC_PO 0x2000 /* Port Owner */
150 #define CAPLENGTH 0 /* Capability Register Length 00h */
152 #define HCIVERSION 0x02 /* Interface Version Number 02-03h */
154 #define HCSPARAMS 0x04 /* Structural Parameters 04-07h */
155 #define HCSP_NPORTS 0x0f /* Number of physical downstream ports on host controller */
157 #define HCCPARAMS 0x08 /* Capability Parameters 08-0bh */
158 #define HCCP_64BIT 0x01 /* 64-bit Addressing Capability */
159 #define HCCP_PFLF 0x02 /* Programmable Frame List Flag */
160 #define HCCP_EECP 0xff00 /* EHCI Extemded Capabilities Pointer */
162 #define HCSPPORTROUTE 0x0c /* Companion Port Route Description 60b */
164 #define CLASSC 0x09 /* Class Code 09-0bh */
166 #define USBBASE 0x10 /* Base Address to Memory-mapped Host Controller Register Space 10-13h */
168 #define SBRN 0x60 /* Serial Bus Release Number 60h */
170 #define FLADJ 0x61 /* Frame Length Adjustment Register 61h */
172 #define PORTWAKECAP 0x62 /* Port wake capablilities register(OPIONAL) 61-62h */
175 // PCI Configuration Registers
177 #define EHCI_PCI_CLASSC 0x09
178 #define EHCI_PCI_MEMORY_BASE 0x10
181 // Memory Offset Registers
183 #define EHCI_MEMORY_CAPLENGTH 0x0
184 #define EHCI_MEMORY_CONFIGFLAG 0x40
187 // USB Base Class Code,Sub-Class Code and Programming Interface
189 #define PCI_CLASSC_PI_EHCI 0x20
191 #define SETUP_PACKET_ID 0x2D
192 #define INPUT_PACKET_ID 0x69
193 #define OUTPUT_PACKET_ID 0xE1
194 #define ERROR_PACKET_ID 0x55
196 #define bit(a) (1 << (a))
198 #define GET_0B_TO_31B(Addr) (((UINTN) Addr) & (0xffffffff))
199 #define GET_32B_TO_63B(Addr) ((UINTN)RShiftU64((UINTN) Addr, 32) & (0xffffffff))
203 // Ehci Data and Ctrl Structures
214 UINT32 NextQtdTerminate
: 1;
216 UINT32 NextQtdPointer
: 27;
218 UINT32 AltNextQtdTerminate
: 1;
220 UINT32 AltNextQtdPointer
: 27;
224 UINT32 ErrorCount
: 2;
225 UINT32 CurrentPage
: 3;
226 UINT32 InterruptOnComplete
: 1;
227 UINT32 TotalBytes
: 15;
228 UINT32 DataToggle
: 1;
230 UINT32 CurrentOffset
: 12;
231 UINT32 BufferPointer0
: 20;
234 UINT32 BufferPointer1
: 20;
237 UINT32 BufferPointer2
: 20;
240 UINT32 BufferPointer3
: 20;
243 UINT32 BufferPointer4
: 20;
245 UINT32 ExtBufferPointer0
;
246 UINT32 ExtBufferPointer1
;
247 UINT32 ExtBufferPointer2
;
248 UINT32 ExtBufferPointer3
;
249 UINT32 ExtBufferPointer4
;
253 UINT32 QhTerminate
: 1;
254 UINT32 SelectType
: 2;
256 UINT32 QhHorizontalPointer
: 27;
258 UINT32 DeviceAddr
: 7;
260 UINT32 EndpointNum
: 4;
261 UINT32 EndpointSpeed
: 2;
262 UINT32 DataToggleControl
: 1;
263 UINT32 HeadReclamationFlag
: 1;
264 UINT32 MaxPacketLen
: 11;
265 UINT32 ControlEndpointFlag
: 1;
266 UINT32 NakCountReload
: 4;
268 UINT32 InerruptScheduleMask
: 8;
269 UINT32 SplitComletionMask
: 8;
272 UINT32 Multiplier
: 2;
275 UINT32 CurrentQtdPointer
: 27;
277 UINT32 NextQtdTerminate
: 1;
279 UINT32 NextQtdPointer
: 27;
281 UINT32 AltNextQtdTerminate
: 1;
283 UINT32 AltNextQtdPointer
: 27;
287 UINT32 ErrorCount
: 2;
288 UINT32 CurrentPage
: 3;
289 UINT32 InterruptOnComplete
: 1;
290 UINT32 TotalBytes
: 15;
291 UINT32 DataToggle
: 1;
293 UINT32 CurrentOffset
: 12;
294 UINT32 BufferPointer0
: 20;
296 UINT32 CompleteSplitMask
: 8;
298 UINT32 BufferPointer1
: 20;
301 UINT32 SplitBytes
: 7;
302 UINT32 BufferPointer2
: 20;
305 UINT32 BufferPointer3
: 20;
308 UINT32 BufferPointer4
: 20;
310 UINT32 ExtBufferPointer0
;
311 UINT32 ExtBufferPointer1
;
312 UINT32 ExtBufferPointer2
;
313 UINT32 ExtBufferPointer3
;
314 UINT32 ExtBufferPointer4
;
318 UINT32 LinkTerminate
: 1;
319 UINT32 SelectType
: 2;
321 UINT32 LinkPointer
: 27;
326 typedef struct _EHCI_QTD_ENTITY EHCI_QTD_ENTITY
;
327 typedef struct _EHCI_QH_ENTITY EHCI_QH_ENTITY
;
328 typedef struct _EHCI_ASYNC_REQUEST EHCI_ASYNC_REQUEST
;
330 struct _EHCI_QTD_ENTITY
{
333 UINT32 StaticTotalBytes
;
334 UINT32 StaticCurrentOffset
;
335 EHCI_QTD_ENTITY
*Prev
;
336 EHCI_QTD_ENTITY
*Next
;
337 EHCI_QTD_ENTITY
*AltNext
;
338 EHCI_QH_ENTITY
*SelfQh
;
341 struct _EHCI_QH_ENTITY
{
343 EHCI_QH_ENTITY
*Next
;
344 EHCI_QH_ENTITY
*Prev
;
345 EHCI_QTD_ENTITY
*FirstQtdPtr
;
346 EHCI_QTD_ENTITY
*LastQtdPtr
;
347 EHCI_QTD_ENTITY
*AltQtdPtr
;
352 #define GET_QH_ENTITY_ADDR(a) ((EHCI_QH_ENTITY *) a)
353 #define GET_QTD_ENTITY_ADDR(a) ((EHCI_QTD_ENTITY *) a)
357 // Ehci Managment Structures
359 #define USB2_HC_DEV_FROM_THIS(a) CR (a, USB2_HC_DEV, Usb2Hc, USB2_HC_DEV_SIGNATURE)
361 #define USB2_HC_DEV_SIGNATURE EFI_SIGNATURE_32 ('e', 'h', 'c', 'i')
363 struct _EHCI_ASYNC_REQUEST
{
365 EFI_ASYNC_USB_TRANSFER_CALLBACK CallBackFunc
;
367 EHCI_ASYNC_REQUEST
*Prev
;
368 EHCI_ASYNC_REQUEST
*Next
;
369 EHCI_QH_ENTITY
*QhPtr
;
372 typedef struct _MEMORY_MANAGE_HEADER
{
374 UINTN BitArraySizeInBytes
;
375 UINT8
*MemoryBlockPtr
;
376 UINTN MemoryBlockSizeInBytes
;
378 struct _MEMORY_MANAGE_HEADER
*Next
;
379 } MEMORY_MANAGE_HEADER
;
381 typedef struct _USB2_HC_DEV
{
383 EFI_PCI_IO_PROTOCOL
*PciIo
;
384 EFI_USB2_HC_PROTOCOL Usb2Hc
;
385 UINTN PeriodicFrameListLength
;
386 VOID
*PeriodicFrameListBuffer
;
387 VOID
*PeriodicFrameListMap
;
389 EHCI_ASYNC_REQUEST
*AsyncRequestList
;
390 EFI_EVENT AsyncRequestEvent
;
391 EFI_UNICODE_STRING_TABLE
*ControllerNameTable
;
392 MEMORY_MANAGE_HEADER
*MemoryHeader
;
393 UINT8 Is64BitCapable
;
394 UINT32 High32BitAddr
;
395 UINT32 UsbCapabilityLen
;
396 UINT16 DeviceSpeed
[16];
401 // Internal Functions Declaration
409 IN USB2_HC_DEV
*HcDev
,
410 OUT MEMORY_MANAGE_HEADER
**MemoryHeader
,
411 IN UINTN MemoryBlockSizeInPages
417 Use PciIo->AllocateBuffer to allocate common buffer for the memory block,
418 and use PciIo->Map to map the common buffer for Bus Master Read/Write.
423 MemoryHeader - MEMORY_MANAGE_HEADER to output
424 MemoryBlockSizeInPages - MemoryBlockSizeInPages
429 EFI_OUT_OF_RESOURCES Fail for no resources
430 EFI_UNSUPPORTED Unsupported currently
437 IN USB2_HC_DEV
*HcDev
,
438 IN MEMORY_MANAGE_HEADER
*MemoryHeader
449 MemoryHeader - MemoryHeader to be freed
454 EFI_INVALID_PARAMETER Parameter is error
460 InsertMemoryHeaderToList (
461 IN MEMORY_MANAGE_HEADER
*MemoryHeader
,
462 IN MEMORY_MANAGE_HEADER
*NewMemoryHeader
468 Insert Memory Header To List
472 MemoryHeader - MEMORY_MANAGE_HEADER
473 NewMemoryHeader - MEMORY_MANAGE_HEADER
483 AllocMemInMemoryBlock (
484 IN MEMORY_MANAGE_HEADER
*MemoryHeader
,
486 IN UINTN NumberOfMemoryUnit
492 Alloc Memory In MemoryBlock
496 MemoryHeader - MEMORY_MANAGE_HEADER
497 Pool - Place to store pointer to memory
498 NumberOfMemoryUnit - Number Of Memory Unit
503 EFI_NOT_FOUND Can't find the free memory
509 IsMemoryBlockEmptied (
510 IN MEMORY_MANAGE_HEADER
*MemoryHeaderPtr
516 Is Memory Block Emptied
520 MemoryHeaderPtr - MEMORY_MANAGE_HEADER
532 IN MEMORY_MANAGE_HEADER
*FirstMemoryHeader
,
533 IN MEMORY_MANAGE_HEADER
*NeedFreeMemoryHeader
543 FirstMemoryHeader - MEMORY_MANAGE_HEADER
544 NeedFreeMemoryHeader - MEMORY_MANAGE_HEADER
554 InitialMemoryManagement (
555 IN USB2_HC_DEV
*HcDev
561 Initialize Memory Management
570 EFI_DEVICE_ERROR Fail
576 DeinitialMemoryManagement (
577 IN USB2_HC_DEV
*HcDev
583 Deinitialize Memory Management
592 EFI_DEVICE_ERROR Fail
599 IN USB2_HC_DEV
*HcDev
,
612 Pool - Place to store pointer to the memory buffer
613 AllocSize - Alloc Size
618 EFI_DEVICE_ERROR Fail
625 IN USB2_HC_DEV
*HcDev
,
639 AllocSize - Pool size
652 ReadEhcCapabiltiyReg (
653 IN USB2_HC_DEV
*HcDev
,
654 IN UINT32 CapabiltiyRegAddr
,
661 Read Ehc Capabitlity register
666 CapabiltiyRegAddr - Ehc Capability register address
667 Data - A pointer to data read from register
672 EFI_DEVICE_ERROR Fail
678 ReadEhcOperationalReg (
679 IN USB2_HC_DEV
*HcDev
,
680 IN UINT32 OperationalRegAddr
,
687 Read Ehc Operation register
692 OperationalRegAddr - Ehc Operation register address
693 Data - A pointer to data read from register
698 EFI_DEVICE_ERROR Fail
704 WriteEhcOperationalReg (
705 IN USB2_HC_DEV
*HcDev
,
706 IN UINT32 OperationalRegAddr
,
713 Write Ehc Operation register
718 OperationalRegAddr - Ehc Operation register address
719 Data - 32bit write to register
724 EFI_DEVICE_ERROR Fail
731 IN USB2_HC_DEV
*HcDev
737 Set Ehc door bell bit
746 EFI_DEVICE_ERROR Fail
753 IN USB2_HC_DEV
*HcDev
,
760 Set the length of Frame List
765 Length - the required length of frame list
770 EFI_INVALID_PARAMETER Invalid parameter
771 EFI_DEVICE_ERROR Fail
777 IsFrameListProgrammable (
778 IN USB2_HC_DEV
*HcDev
784 Whether frame list is programmable
799 IsPeriodicScheduleEnabled (
800 IN USB2_HC_DEV
*HcDev
806 Whether periodic schedule is enabled
821 IsAsyncScheduleEnabled (
822 IN USB2_HC_DEV
*HcDev
828 Whether asynchronous schedule is enabled
844 IN USB2_HC_DEV
*HcDev
,
851 Whether port is enabled
867 IN USB2_HC_DEV
*HcDev
873 Whether Ehc is halted
889 IN USB2_HC_DEV
*HcDev
895 Whether Ehc is halted
911 IN USB2_HC_DEV
*HcDev
917 Whether Ehc is system error
926 FALSE No system error
933 IN EFI_USB2_HC_PROTOCOL
*This
,
940 Whether high speed device attached
956 IN USB2_HC_DEV
*HcDev
,
963 wait for Ehc reset or timeout
968 Timeout - timeout threshold
980 IN USB2_HC_DEV
*HcDev
,
987 wait for Ehc halt or timeout
992 Timeout - timeout threshold
1004 IN USB2_HC_DEV
*HcDev
,
1009 Routine Description:
1011 wait for Ehc not halt or timeout
1016 Timeout - timeout threshold
1027 WaitForEhcDoorbell (
1028 IN USB2_HC_DEV
*HcDev
,
1033 Routine Description:
1035 Wait for periodic schedule disable or timeout
1040 Timeout - timeout threshold
1051 WaitForAsyncScheduleEnable (
1052 IN USB2_HC_DEV
*HcDev
,
1057 Routine Description:
1059 Wait for Ehc asynchronous schedule enable or timeout
1064 Timeout - timeout threshold
1075 WaitForAsyncScheduleDisable (
1076 IN USB2_HC_DEV
*HcDev
,
1081 Routine Description:
1083 Wait for Ehc asynchronous schedule disable or timeout
1088 Timeout - timeout threshold
1099 WaitForPeriodicScheduleEnable (
1100 IN USB2_HC_DEV
*HcDev
,
1105 Routine Description:
1107 Wait for Ehc periodic schedule enable or timeout
1112 Timeout - timeout threshold
1123 WaitForPeriodicScheduleDisable (
1124 IN USB2_HC_DEV
*HcDev
,
1129 Routine Description:
1131 Wait for periodic schedule disable or timeout
1136 Timeout - timeout threshold
1148 IN USB2_HC_DEV
*HcDev
1152 Routine Description:
1154 Get the length of capability register
1163 EFI_DEVICE_ERROR Fail
1169 SetFrameListBaseAddr (
1170 IN USB2_HC_DEV
*HcDev
,
1171 IN UINT32 FrameBuffer
1175 Routine Description:
1177 Set base address of frame list first entry
1182 FrameBuffer - base address of first entry of frame list
1187 EFI_DEVICE_ERROR Fail
1194 IN USB2_HC_DEV
*HcDev
,
1195 IN EHCI_QH_ENTITY
*QhPtr
1199 Routine Description:
1201 Set address of first Async schedule Qh
1206 QhPtr - A pointer to first Qh in the Async schedule
1211 EFI_DEVICE_ERROR Fail
1217 SetCtrlDataStructSeg (
1218 IN USB2_HC_DEV
*HcDev
1222 Routine Description:
1224 Set address of first Async schedule Qh
1229 QhPtr - A pointer to first Qh in the Async schedule
1234 EFI_DEVICE_ERROR Fail
1241 IN USB2_HC_DEV
*HcDev
1245 Routine Description:
1247 Set Ehc port routing bit
1256 EFI_DEVICE_ERROR Fail
1262 EnablePeriodicSchedule (
1263 IN USB2_HC_DEV
*HcDev
1267 Routine Description:
1269 Enable periodic schedule
1278 EFI_DEVICE_ERROR Fail
1284 DisablePeriodicSchedule (
1285 IN USB2_HC_DEV
*HcDev
1289 Routine Description:
1291 Disable periodic schedule
1300 EFI_DEVICE_ERROR Fail
1306 EnableAsynchronousSchedule (
1307 IN USB2_HC_DEV
*HcDev
1311 Routine Description:
1313 Enable asynchrounous schedule
1322 EFI_DEVICE_ERROR Fail
1328 DisableAsynchronousSchedule (
1329 IN USB2_HC_DEV
*HcDev
1333 Routine Description:
1335 Disable asynchrounous schedule
1344 EFI_DEVICE_ERROR Fail
1350 StartScheduleExecution (
1351 IN USB2_HC_DEV
*HcDev
1355 Routine Description:
1357 Start Ehc schedule execution
1366 EFI_DEVICE_ERROR Fail
1373 IN USB2_HC_DEV
*HcDev
1377 Routine Description:
1388 EFI_DEVICE_ERROR Fail
1395 IN USB2_HC_DEV
*HcDev
1399 Routine Description:
1401 Clear Ehc all status bits
1410 EFI_DEVICE_ERROR Fail
1416 // EhciSched Functions
1419 InitialPeriodicFrameList (
1420 IN USB2_HC_DEV
*HcDev
,
1425 Routine Description:
1427 Initialize Periodic Schedule Frame List
1432 Length - Frame List Length
1437 EFI_DEVICE_ERROR Fail
1443 DeinitialPeriodicFrameList (
1444 IN USB2_HC_DEV
*HcDev
1448 Routine Description:
1450 Deinitialize Periodic Schedule Frame List
1464 CreatePollingTimer (
1465 IN USB2_HC_DEV
*HcDev
,
1466 IN EFI_EVENT_NOTIFY NotifyFunction
1470 Routine Description:
1472 Create Async Request Polling Timer
1477 NotifyFunction - Timer Notify Function
1482 EFI_DEVICE_ERROR Fail
1488 DestoryPollingTimer (
1489 IN USB2_HC_DEV
*HcDev
1493 Routine Description:
1495 Destory Async Request Polling Timer
1504 EFI_DEVICE_ERROR Fail
1511 IN USB2_HC_DEV
*HcDev
1515 Routine Description:
1517 Start Async Request Polling Timer
1526 EFI_DEVICE_ERROR Fail
1533 IN USB2_HC_DEV
*HcDev
1537 Routine Description:
1539 Stop Async Request Polling Timer
1548 EFI_DEVICE_ERROR Fail
1555 IN USB2_HC_DEV
*HcDev
,
1556 IN UINT8 DeviceAddr
,
1558 IN UINT8 DeviceSpeed
,
1559 IN UINTN MaxPacketLen
,
1560 OUT EHCI_QH_ENTITY
**QhPtrPtr
1564 Routine Description:
1566 Create Qh Structure and Pre-Initialize
1571 DeviceAddr - Address of Device
1572 Endpoint - Endpoint Number
1573 DeviceSpeed - Device Speed
1574 MaxPacketLen - Max Length of one Packet
1575 QhPtrPtr - A pointer of pointer to Qh for return
1580 EFI_DEVICE_ERROR Fail
1587 IN USB2_HC_DEV
*HcDev
,
1588 IN UINT8 DeviceAddr
,
1589 IN UINT8 DeviceSpeed
,
1590 IN UINTN MaxPacketLen
,
1591 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR
*Translator
,
1592 OUT EHCI_QH_ENTITY
**QhPtrPtr
1596 Routine Description:
1598 Create Qh for Control Transfer
1603 DeviceAddr - Address of Device
1604 DeviceSpeed - Device Speed
1605 MaxPacketLen - Max Length of one Packet
1606 Translator - Translator Transaction for SplitX
1607 QhPtrPtr - A pointer of pointer to Qh for return
1612 EFI_DEVICE_ERROR Fail
1619 IN USB2_HC_DEV
*HcDev
,
1620 IN UINT8 DeviceAddr
,
1621 IN UINT8 EndPointAddr
,
1622 IN UINT8 DeviceSpeed
,
1623 IN UINT8 DataToggle
,
1624 IN UINTN MaxPacketLen
,
1625 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR
*Translator
,
1626 OUT EHCI_QH_ENTITY
**QhPtrPtr
1630 Routine Description:
1632 Create Qh for Bulk Transfer
1637 DeviceAddr - Address of Device
1638 EndPointAddr - Address of Endpoint
1639 DeviceSpeed - Device Speed
1640 MaxPacketLen - Max Length of one Packet
1641 Translator - Translator Transaction for SplitX
1642 QhPtrPtr - A pointer of pointer to Qh for return
1647 EFI_DEVICE_ERROR Fail
1654 IN USB2_HC_DEV
*HcDev
,
1655 IN UINT8 DeviceAddr
,
1656 IN UINT8 EndPointAddr
,
1657 IN UINT8 DeviceSpeed
,
1658 IN UINT8 DataToggle
,
1659 IN UINTN MaxPacketLen
,
1661 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR
*Translator
,
1662 OUT EHCI_QH_ENTITY
**QhPtrPtr
1666 Routine Description:
1668 Create Qh for Control Transfer
1673 DeviceAddr - Address of Device
1674 EndPointAddr - Address of Endpoint
1675 DeviceSpeed - Device Speed
1676 MaxPacketLen - Max Length of one Packet
1677 Interval - value of interval
1678 Translator - Translator Transaction for SplitX
1679 QhPtrPtr - A pointer of pointer to Qh for return
1684 EFI_DEVICE_ERROR Fail
1691 IN USB2_HC_DEV
*HcDev
,
1692 IN EHCI_QH_ENTITY
*QhPtr
1696 Routine Description:
1698 Destory Qh Structure
1703 QhPtr - A pointer to Qh
1714 IN USB2_HC_DEV
*HcDev
,
1720 OUT EHCI_QTD_ENTITY
**QtdPtrPtr
1724 Routine Description:
1726 Create Qtd Structure and Pre-Initialize it
1731 DataPtr - A pointer to user data buffer to transfer
1732 DataLen - Length of user data to transfer
1733 PktId - Packet Identification of this Qtd
1734 Toggle - Data Toggle of this Qtd
1735 QtdStatus - Default value of status of this Qtd
1736 QtdPtrPtr - A pointer of pointer to Qtd for return
1741 EFI_OUT_OF_RESOURCES Cannot allocate resources
1748 IN USB2_HC_DEV
*HcDev
,
1749 IN UINT8
*DevReqPtr
,
1750 OUT EHCI_QTD_ENTITY
**QtdPtrPtr
1754 Routine Description:
1756 Create Qtd Structure for Setup
1761 DevReqPtr - A pointer to Device Request Data
1762 QtdPtrPtr - A pointer of pointer to Qtd for return
1767 EFI_OUT_OF_RESOURCES Cannot allocate resources
1774 IN USB2_HC_DEV
*HcDev
,
1779 OUT EHCI_QTD_ENTITY
**QtdPtrPtr
1783 Routine Description:
1785 Create Qtd Structure for data
1790 DataPtr - A pointer to user data buffer to transfer
1791 DataLen - Length of user data to transfer
1792 PktId - Packet Identification of this Qtd
1793 Toggle - Data Toggle of this Qtd
1794 QtdPtrPtr - A pointer of pointer to Qtd for return
1799 EFI_OUT_OF_RESOURCES Cannot allocate resources
1806 IN USB2_HC_DEV
*HcDev
,
1808 OUT EHCI_QTD_ENTITY
**QtdPtrPtr
1812 Routine Description:
1814 Create Qtd Structure for status
1819 PktId - Packet Identification of this Qtd
1820 QtdPtrPtr - A pointer of pointer to Qtd for return
1825 EFI_OUT_OF_RESOURCES Cannot allocate resources
1832 IN USB2_HC_DEV
*HcDev
,
1834 OUT EHCI_QTD_ENTITY
**QtdPtrPtr
1838 Routine Description:
1840 Create Qtd Structure for Alternative
1845 PktId - Packet Identification of this Qtd
1846 QtdPtrPtr - A pointer of pointer to Qtd for return
1851 EFI_OUT_OF_RESOURCES Cannot allocate resources
1858 IN USB2_HC_DEV
*HcDev
,
1860 IN UINT8
*RequestCursor
,
1861 IN UINT8
*DataCursor
,
1863 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR
*Translator
,
1864 OUT EHCI_QTD_ENTITY
**ControlQtdsHead
1868 Routine Description:
1870 Create Qtds list for Control Transfer
1875 DataPktId - Packet Identification of Data Qtds
1876 RequestCursor - A pointer to request structure buffer to transfer
1877 DataCursor - A pointer to user data buffer to transfer
1878 DataLen - Length of user data to transfer
1879 ControlQtdsHead - A pointer of pointer to first Qtd for control tranfer for return
1884 EFI_DEVICE_ERROR Fail
1890 CreateBulkOrInterruptQtds (
1891 IN USB2_HC_DEV
*HcDev
,
1893 IN UINT8
*DataCursor
,
1895 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR
*Translator
,
1896 OUT EHCI_QTD_ENTITY
**QtdsHead
1900 Routine Description:
1902 Create Qtds list for Bulk or Interrupt Transfer
1907 PktId - Packet Identification of Qtds
1908 DataCursor - A pointer to user data buffer to transfer
1909 DataLen - Length of user data to transfer
1910 DataToggle - Data Toggle to start
1911 Translator - Translator Transaction for SplitX
1912 QtdsHead - A pointer of pointer to first Qtd for control tranfer for return
1917 EFI_DEVICE_ERROR Fail
1924 IN USB2_HC_DEV
*HcDev
,
1925 IN EHCI_QTD_ENTITY
*FirstQtdPtr
1929 Routine Description:
1931 Destory all Qtds in the list
1936 FirstQtdPtr - A pointer to first Qtd in the list
1947 IN EHCI_QTD_ENTITY
*PreQtdPtr
,
1948 IN EHCI_QTD_ENTITY
*QtdPtr
1952 Routine Description:
1958 PreQtdPtr - A pointer to pre Qtd
1959 QtdPtr - A pointer to next Qtd
1970 IN EHCI_QTD_ENTITY
*FirstQtdPtr
,
1971 IN EHCI_QTD_ENTITY
*AltQtdPtr
1975 Routine Description:
1977 Link AlterQtds together
1981 FirstQtdPtr - A pointer to first Qtd in the list
1982 AltQtdPtr - A pointer to alternative Qtd
1992 IN EHCI_QH_ENTITY
*QhPtr
,
1993 IN EHCI_QTD_ENTITY
*QtdEntryPtr
1997 Routine Description:
1999 Link Qtds list to Qh
2003 QhPtr - A pointer to Qh
2004 QtdPtr - A pointer to first Qtd in the list
2015 IN USB2_HC_DEV
*HcDev
,
2016 IN EHCI_QH_ENTITY
*QhPtr
2020 Routine Description:
2022 Link Qh to Async Schedule List
2027 QhPtr - A pointer to Qh
2032 EFI_DEVICE_ERROR Fail
2038 UnlinkQhFromAsyncList (
2039 IN USB2_HC_DEV
*HcDev
,
2040 IN EHCI_QH_ENTITY
*QhPtr
2044 Routine Description:
2046 Unlink Qh from Async Schedule List
2051 QhPtr - A pointer to Qh
2056 EFI_DEVICE_ERROR Fail
2062 LinkQhToPeriodicList (
2063 IN USB2_HC_DEV
*HcDev
,
2064 IN EHCI_QH_ENTITY
*QhPtr
2068 Routine Description:
2070 Link Qh to Periodic Schedule List
2075 QhPtr - A pointer to Qh
2085 UnlinkQhFromPeriodicList (
2086 IN USB2_HC_DEV
*HcDev
,
2087 IN EHCI_QH_ENTITY
*QhPtr
,
2092 Routine Description:
2094 Unlink Qh from Periodic Schedule List
2099 QhPtr - A pointer to Qh
2100 Interval - Interval of this periodic transfer
2110 LinkToAsyncReqeust (
2111 IN USB2_HC_DEV
*HcDev
,
2112 IN EHCI_ASYNC_REQUEST
*AsyncRequestPtr
2116 Routine Description:
2118 Llink AsyncRequest Entry to Async Request List
2123 AsyncRequestPtr - A pointer to Async Request Entry
2133 UnlinkFromAsyncReqeust (
2134 IN USB2_HC_DEV
*HcDev
,
2135 IN EHCI_ASYNC_REQUEST
*AsyncRequestPtr
2139 Routine Description:
2141 Unlink AsyncRequest Entry from Async Request List
2146 AsyncRequestPtr - A pointer to Async Request Entry
2157 IN EHCI_QTD_ENTITY
*FirstQtdPtr
2161 Routine Description:
2163 Number of Qtds in the list
2167 FirstQtdPtr - A pointer to first Qtd in the list
2171 Number of Qtds in the list
2177 GetNumberOfTransaction (
2178 IN UINTN SizeOfData
,
2179 IN UINTN SizeOfTransaction
2183 Routine Description:
2185 Number of Transactions in one Qtd
2189 SizeOfData - Size of one Qtd
2190 SizeOfTransaction - Size of one Transaction
2194 Number of Transactions in this Qtd
2201 IN UINT8
*BufferCursor
2205 Routine Description:
2211 BufferCursor - BufferCursor of the Qtd
2221 GetApproxiOfInterval (
2226 Routine Description:
2228 Get the approximate value in the 2 index sequence
2232 Interval - the value of interval
2236 approximate value of interval in the 2 index sequence
2243 IN EHCI_QTD_HW
*HwQtdPtr
2247 Routine Description:
2249 Get Qtd next pointer field
2253 HwQtdPtr - A pointer to hardware Qtd structure
2257 A pointer to next hardware Qtd structure
2264 IN EHCI_QTD_HW
*HwQtdPtr
2268 Routine Description:
2270 Whether Qtd status is active or not
2274 HwQtdPtr - A pointer to hardware Qtd structure
2286 IN EHCI_QTD_HW
*HwQtdPtr
2290 Routine Description:
2292 Whether Qtd status is halted or not
2296 HwQtdPtr - A pointer to hardware Qtd structure
2307 IsQtdStatusBufferError (
2308 IN EHCI_QTD_HW
*HwQtdPtr
2312 Routine Description:
2314 Whether Qtd status is buffer error or not
2318 HwQtdPtr - A pointer to hardware Qtd structure
2323 FALSE No buffer error
2329 IsQtdStatusBabbleError (
2330 IN EHCI_QTD_HW
*HwQtdPtr
2334 Routine Description:
2336 Whether Qtd status is babble error or not
2340 HwQtdPtr - A pointer to hardware Qtd structure
2345 FALSE No babble error
2351 IsQtdStatusTransactionError (
2352 IN EHCI_QTD_HW
*HwQtdPtr
2356 Routine Description:
2358 Whether Qtd status is transaction error or not
2362 HwQtdPtr - A pointer to hardware Qtd structure
2366 TRUE Transaction error
2367 FALSE No transaction error
2374 IN UINT8 EndPointAddress
2378 Routine Description:
2380 Whether is a DataIn direction transfer
2384 EndPointAddress - address of the endpoint
2396 IN USB2_HC_DEV
*HcDev
,
2397 IN EFI_USB_DATA_DIRECTION TransferDirection
,
2399 IN OUT UINTN
*DataLength
,
2401 OUT UINT8
**DataCursor
,
2406 Routine Description:
2408 Map address of user data buffer
2413 TransferDirection - direction of transfer
2414 Data - A pointer to user data buffer
2415 DataLength - length of user data
2416 PktId - Packte Identificaion
2417 DataCursor - mapped address to return
2418 DataMap - identificaion of this mapping to return
2423 EFI_DEVICE_ERROR Fail
2430 IN USB2_HC_DEV
*HcDev
,
2431 IN OUT VOID
*Request
,
2432 OUT UINT8
**RequestCursor
,
2433 OUT VOID
**RequestMap
2437 Routine Description:
2439 Map address of request structure buffer
2444 Request - A pointer to request structure
2445 RequestCursor - Mapped address of request structure to return
2446 RequestMap - Identificaion of this mapping to return
2451 EFI_DEVICE_ERROR Fail
2457 SetQtdBufferPointer (
2458 IN EHCI_QTD_HW
*QtdHwPtr
,
2464 Routine Description:
2466 Set data buffer pointers in Qtd
2470 QtdHwPtr - A pointer to Qtd hardware structure
2471 DataPtr - A pointer to user data buffer
2472 DataLen - Length of the user data buffer
2482 GetQtdAlternateNextPointer (
2483 IN EHCI_QTD_HW
*HwQtdPtr
2487 Routine Description:
2489 Get Qtd alternate next pointer field
2493 HwQtdPtr - A pointer to hardware Qtd structure
2497 A pointer to hardware alternate Qtd
2504 IN EHCI_QH_ENTITY
*QhPtr
2508 Routine Description:
2510 Zero out the fields in Qh structure
2514 QhPtr - A pointer to Qh structure
2524 UpdateAsyncRequestTransfer (
2525 IN EHCI_ASYNC_REQUEST
*AsyncRequestPtr
,
2526 IN UINT32 TransferResult
,
2531 Routine Description:
2533 Update asynchronous request transfer
2537 AsyncRequestPtr - A pointer to async request
2538 TransferResult - transfer result
2539 ErrQtdPos - postion of error Qtd
2550 DeleteAsyncRequestTransfer (
2551 IN USB2_HC_DEV
*HcDev
,
2552 IN UINT8 DeviceAddress
,
2553 IN UINT8 EndPointAddress
,
2554 OUT UINT8
*DataToggle
2558 Routine Description:
2560 Delete all asynchronous request transfer
2565 DeviceAddress - address of usb device
2566 EndPointAddress - address of endpoint
2567 DataToggle - stored data toggle
2572 EFI_DEVICE_ERROR Fail
2578 CleanUpAllAsyncRequestTransfer (
2579 IN USB2_HC_DEV
*HcDev
2583 Routine Description:
2585 Clean up all asynchronous request transfer
2599 IN USB2_HC_DEV
*HcDev
,
2600 IN BOOLEAN IsControl
,
2601 IN EHCI_QH_ENTITY
*QhPtr
,
2602 IN OUT UINTN
*ActualLen
,
2603 OUT UINT8
*DataToggle
,
2605 OUT UINT32
*TransferResult
2609 Routine Description:
2611 Execute Bulk or SyncInterrupt Transfer
2616 IsControl - Is control transfer or not
2617 QhPtr - A pointer to Qh
2618 ActualLen - Actual transfered Len
2619 DataToggle - Data Toggle
2620 TimeOut - TimeOut threshold
2621 TransferResult - Transfer result
2626 EFI_DEVICE_ERROR Error
2632 CheckQtdsTransferResult (
2633 IN BOOLEAN IsControl
,
2634 IN EHCI_QH_ENTITY
*QhPtr
,
2636 OUT UINTN
*ErrQtdPos
,
2637 OUT UINTN
*ActualLen
2641 Routine Description:
2643 Check transfer result of Qtds
2647 IsControl - Is control transfer or not
2648 QhPtr - A pointer to Qh
2649 Result - Transfer result
2650 ErrQtdPos - Error TD Position
2651 ActualLen - Actual Transfer Size
2662 AsyncRequestMoniter (
2668 Routine Description:
2670 Interrupt transfer periodic check handler
2674 Event - Interrupt event
2675 Context - Pointer to USB2_HC_DEV
2680 EFI_DEVICE_ERROR Fail
2686 ClearLegacySupport (
2687 IN USB2_HC_DEV
*HcDev
2692 IN USB2_HC_DEV
*HcDev
2696 DumpEHCIPortsStatus (
2697 IN USB2_HC_DEV
*HcDev