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 UINT32 mUsbCapabilityLen
;
104 extern EFI_DRIVER_BINDING_PROTOCOL gEhciDriverBinding
;
105 extern EFI_COMPONENT_NAME_PROTOCOL gEhciComponentName
;
107 #define USBCMD 0x0 /* Command Register Offset 00-03h */
108 #define USBCMD_RS 0x01 /* Run / Stop */
109 #define USBCMD_HCRESET 0x02 /* Host controller reset */
110 #define USBCMD_FLS_512 0x04 /* 512 elements (2048bytes) in Frame List */
111 #define USBCMD_FLS_256 0x08 /* 256 elements (1024bytes) in Frame List */
112 #define USBCMD_PSE 0x10 /* Periodic schedule enable */
113 #define USBCMD_ASE 0x20 /* Asynchronous schedule enable */
114 #define USBCMD_IAAD 0x40 /* Interrupt on async advance doorbell */
116 #define USBSTS 0x04 /* Statue Register Offset 04-07h */
117 #define USBSTS_HSE 0x10 /* Host system error */
118 #define USBSTS_IAA 0x20 /* Interrupt on async advance */
119 #define USBSTS_HCH 0x1000 /* Host controller halted */
120 #define USBSTS_PSS 0x4000 /* Periodic schedule status */
121 #define USBSTS_ASS 0x8000 /* Asynchronous schedule status */
123 #define USBINTR 0x08 /* Command Register Offset 08-0bh */
125 #define FRINDEX 0x0c /* Frame Index Offset 0c-0fh */
127 #define CTRLDSSGMENT 0x10 /* 4G Segment Selector Offset 10-13h */
129 #define PERIODICLISTBASE 0x14 /* Frame List Base Address Offset 14-17h */
131 #define ASYNCLISTADDR 0x18 /* Next Asynchronous List Address Offset 18-1bh */
133 #define CONFIGFLAG 0x40 /* Configured Flag Register Offset 40-43h */
134 #define CONFIGFLAG_CF 0x01 /* Configure Flag */
136 #define PORTSC 0x44 /* Port Status/Control Offset 44-47h */
137 #define PORTSC_CCS 0x01 /* Current Connect Status*/
138 #define PORTSC_CSC 0x02 /* Connect Status Change */
139 #define PORTSC_PED 0x04 /* Port Enable / Disable */
140 #define PORTSC_PEDC 0x08 /* Port Enable / Disable Change */
141 #define PORTSC_OCA 0x10 /* Over current Active */
142 #define PORTSC_OCC 0x20 /* Over current Change */
143 #define PORTSC_FPR 0x40 /* Force Port Resume */
144 #define PORTSC_SUSP 0x80 /* Port Suspend State */
145 #define PORTSC_PR 0x100 /* Port Reset */
146 #define PORTSC_LS_KSTATE 0x400 /* Line Status K-state */
147 #define PORTSC_LS_JSTATE 0x800 /* Line Status J-state */
148 #define PORTSC_PP 0x1000 /* Port Power */
149 #define PORTSC_PO 0x2000 /* Port Owner */
151 #define CAPLENGTH 0 /* Capability Register Length 00h */
153 #define HCIVERSION 0x02 /* Interface Version Number 02-03h */
155 #define HCSPARAMS 0x04 /* Structural Parameters 04-07h */
156 #define HCSP_NPORTS 0x0f /* Number of physical downstream ports on host controller */
158 #define HCCPARAMS 0x08 /* Capability Parameters 08-0bh */
159 #define HCCP_64BIT 0x01 /* 64-bit Addressing Capability */
160 #define HCCP_PFLF 0x02 /* Programmable Frame List Flag */
161 #define HCCP_EECP 0xff00 /* EHCI Extemded Capabilities Pointer */
163 #define HCSPPORTROUTE 0x0c /* Companion Port Route Description 60b */
165 #define CLASSC 0x09 /* Class Code 09-0bh */
167 #define USBBASE 0x10 /* Base Address to Memory-mapped Host Controller Register Space 10-13h */
169 #define SBRN 0x60 /* Serial Bus Release Number 60h */
171 #define FLADJ 0x61 /* Frame Length Adjustment Register 61h */
173 #define PORTWAKECAP 0x62 /* Port wake capablilities register(OPIONAL) 61-62h */
176 // PCI Configuration Registers
178 #define EHCI_PCI_CLASSC 0x09
179 #define EHCI_PCI_MEMORY_BASE 0x10
182 // Memory Offset Registers
184 #define EHCI_MEMORY_CAPLENGTH 0x0
185 #define EHCI_MEMORY_CONFIGFLAG 0x40
188 // USB Base Class Code,Sub-Class Code and Programming Interface
190 #define PCI_CLASSC_PI_EHCI 0x20
192 #define SETUP_PACKET_ID 0x2D
193 #define INPUT_PACKET_ID 0x69
194 #define OUTPUT_PACKET_ID 0xE1
195 #define ERROR_PACKET_ID 0x55
197 #define bit(a) 1 << (a)
199 #define GET_0B_TO_31B(Addr) (((UINTN) Addr) & (0xffffffff))
200 #define GET_32B_TO_63B(Addr) ((((UINTN) Addr) >> 32) & (0xffffffff))
204 // Ehci Data and Ctrl Structures
215 UINT32 NextQtdTerminate
: 1;
217 UINT32 NextQtdPointer
: 27;
219 UINT32 AltNextQtdTerminate
: 1;
221 UINT32 AltNextQtdPointer
: 27;
225 UINT32 ErrorCount
: 2;
226 UINT32 CurrentPage
: 3;
227 UINT32 InterruptOnComplete
: 1;
228 UINT32 TotalBytes
: 15;
229 UINT32 DataToggle
: 1;
231 UINT32 CurrentOffset
: 12;
232 UINT32 BufferPointer0
: 20;
235 UINT32 BufferPointer1
: 20;
238 UINT32 BufferPointer2
: 20;
241 UINT32 BufferPointer3
: 20;
244 UINT32 BufferPointer4
: 20;
246 UINT32 ExtBufferPointer0
;
247 UINT32 ExtBufferPointer1
;
248 UINT32 ExtBufferPointer2
;
249 UINT32 ExtBufferPointer3
;
250 UINT32 ExtBufferPointer4
;
254 UINT32 QhTerminate
: 1;
255 UINT32 SelectType
: 2;
257 UINT32 QhHorizontalPointer
: 27;
259 UINT32 DeviceAddr
: 7;
261 UINT32 EndpointNum
: 4;
262 UINT32 EndpointSpeed
: 2;
263 UINT32 DataToggleControl
: 1;
264 UINT32 HeadReclamationFlag
: 1;
265 UINT32 MaxPacketLen
: 11;
266 UINT32 ControlEndpointFlag
: 1;
267 UINT32 NakCountReload
: 4;
269 UINT32 InerruptScheduleMask
: 8;
270 UINT32 SplitComletionMask
: 8;
273 UINT32 Multiplier
: 2;
276 UINT32 CurrentQtdPointer
: 27;
278 UINT32 NextQtdTerminate
: 1;
280 UINT32 NextQtdPointer
: 27;
282 UINT32 AltNextQtdTerminate
: 1;
284 UINT32 AltNextQtdPointer
: 27;
288 UINT32 ErrorCount
: 2;
289 UINT32 CurrentPage
: 3;
290 UINT32 InterruptOnComplete
: 1;
291 UINT32 TotalBytes
: 15;
292 UINT32 DataToggle
: 1;
294 UINT32 CurrentOffset
: 12;
295 UINT32 BufferPointer0
: 20;
297 UINT32 CompleteSplitMask
: 8;
299 UINT32 BufferPointer1
: 20;
302 UINT32 SplitBytes
: 7;
303 UINT32 BufferPointer2
: 20;
306 UINT32 BufferPointer3
: 20;
309 UINT32 BufferPointer4
: 20;
311 UINT32 ExtBufferPointer0
;
312 UINT32 ExtBufferPointer1
;
313 UINT32 ExtBufferPointer2
;
314 UINT32 ExtBufferPointer3
;
315 UINT32 ExtBufferPointer4
;
319 UINT32 LinkTerminate
: 1;
320 UINT32 SelectType
: 2;
322 UINT32 LinkPointer
: 27;
327 typedef struct _EHCI_QTD_ENTITY EHCI_QTD_ENTITY
;
328 typedef struct _EHCI_QH_ENTITY EHCI_QH_ENTITY
;
329 typedef struct _EHCI_ASYNC_REQUEST EHCI_ASYNC_REQUEST
;
331 typedef struct _EHCI_QTD_ENTITY
{
334 UINT32 StaticTotalBytes
;
335 UINT32 StaticCurrentOffset
;
336 EHCI_QTD_ENTITY
*Prev
;
337 EHCI_QTD_ENTITY
*Next
;
338 EHCI_QTD_ENTITY
*AltNext
;
339 EHCI_QH_ENTITY
*SelfQh
;
342 typedef struct _EHCI_QH_ENTITY
{
344 EHCI_QH_ENTITY
*Next
;
345 EHCI_QH_ENTITY
*Prev
;
346 EHCI_QTD_ENTITY
*FirstQtdPtr
;
347 EHCI_QTD_ENTITY
*LastQtdPtr
;
348 EHCI_QTD_ENTITY
*AltQtdPtr
;
353 #define GET_QH_ENTITY_ADDR(a) ((EHCI_QH_ENTITY *) a)
354 #define GET_QTD_ENTITY_ADDR(a) ((EHCI_QTD_ENTITY *) a)
358 // Ehci Managment Structures
360 #define USB2_HC_DEV_FROM_THIS(a) CR (a, USB2_HC_DEV, Usb2Hc, USB2_HC_DEV_SIGNATURE)
362 #define USB2_HC_DEV_SIGNATURE EFI_SIGNATURE_32 ('e', 'h', 'c', 'i')
364 typedef struct _LIST_HEAD
{
365 struct _LIST_HEAD
*pre
;
366 struct _LIST_HEAD
*next
;
369 typedef struct _EHCI_ASYNC_REQUEST
{
371 EFI_ASYNC_USB_TRANSFER_CALLBACK CallBackFunc
;
373 EHCI_ASYNC_REQUEST
*Prev
;
374 EHCI_ASYNC_REQUEST
*Next
;
375 EHCI_QH_ENTITY
*QhPtr
;
376 } EHCI_ASYNC_REQUEST
;
378 typedef struct _MEMORY_MANAGE_HEADER
{
380 UINTN BitArraySizeInBytes
;
381 UINT8
*MemoryBlockPtr
;
382 UINTN MemoryBlockSizeInBytes
;
384 struct _MEMORY_MANAGE_HEADER
*Next
;
385 } MEMORY_MANAGE_HEADER
;
387 typedef struct _USB2_HC_DEV
{
389 EFI_PCI_IO_PROTOCOL
*PciIo
;
390 EFI_USB2_HC_PROTOCOL Usb2Hc
;
391 UINTN PeriodicFrameListLength
;
392 VOID
*PeriodicFrameListBuffer
;
393 VOID
*PeriodicFrameListMap
;
395 EHCI_ASYNC_REQUEST
*AsyncRequestList
;
396 EFI_EVENT AsyncRequestEvent
;
397 EFI_UNICODE_STRING_TABLE
*ControllerNameTable
;
398 MEMORY_MANAGE_HEADER
*MemoryHeader
;
399 UINT8 Is64BitCapable
;
400 UINT32 High32BitAddr
;
405 // Internal Functions Declaration
413 IN USB2_HC_DEV
*HcDev
,
414 OUT MEMORY_MANAGE_HEADER
**MemoryHeader
,
415 IN UINTN MemoryBlockSizeInPages
421 Use PciIo->AllocateBuffer to allocate common buffer for the memory block,
422 and use PciIo->Map to map the common buffer for Bus Master Read/Write.
427 MemoryHeader - MEMORY_MANAGE_HEADER to output
428 MemoryBlockSizeInPages - MemoryBlockSizeInPages
433 EFI_OUT_OF_RESOURCES Fail for no resources
434 EFI_UNSUPPORTED Unsupported currently
441 IN USB2_HC_DEV
*HcDev
,
442 IN MEMORY_MANAGE_HEADER
*MemoryHeader
453 MemoryHeader - MemoryHeader to be freed
458 EFI_INVALID_PARAMETER Parameter is error
464 InsertMemoryHeaderToList (
465 IN MEMORY_MANAGE_HEADER
*MemoryHeader
,
466 IN MEMORY_MANAGE_HEADER
*NewMemoryHeader
472 Insert Memory Header To List
476 MemoryHeader - MEMORY_MANAGE_HEADER
477 NewMemoryHeader - MEMORY_MANAGE_HEADER
487 AllocMemInMemoryBlock (
488 IN MEMORY_MANAGE_HEADER
*MemoryHeader
,
490 IN UINTN NumberOfMemoryUnit
496 Alloc Memory In MemoryBlock
500 MemoryHeader - MEMORY_MANAGE_HEADER
501 Pool - Place to store pointer to memory
502 NumberOfMemoryUnit - Number Of Memory Unit
507 EFI_NOT_FOUND Can't find the free memory
513 IsMemoryBlockEmptied (
514 IN MEMORY_MANAGE_HEADER
*MemoryHeaderPtr
520 Is Memory Block Emptied
524 MemoryHeaderPtr - MEMORY_MANAGE_HEADER
536 IN MEMORY_MANAGE_HEADER
*FirstMemoryHeader
,
537 IN MEMORY_MANAGE_HEADER
*NeedFreeMemoryHeader
547 FirstMemoryHeader - MEMORY_MANAGE_HEADER
548 NeedFreeMemoryHeader - MEMORY_MANAGE_HEADER
558 InitialMemoryManagement (
559 IN USB2_HC_DEV
*HcDev
565 Initialize Memory Management
574 EFI_DEVICE_ERROR Fail
580 DeinitialMemoryManagement (
581 IN USB2_HC_DEV
*HcDev
587 Deinitialize Memory Management
596 EFI_DEVICE_ERROR Fail
603 IN USB2_HC_DEV
*HcDev
,
616 Pool - Place to store pointer to the memory buffer
617 AllocSize - Alloc Size
622 EFI_DEVICE_ERROR Fail
629 IN USB2_HC_DEV
*HcDev
,
643 AllocSize - Pool size
656 ReadEhcCapabiltiyReg (
657 IN USB2_HC_DEV
*HcDev
,
658 IN UINT32 CapabiltiyRegAddr
,
665 Read Ehc Capabitlity register
670 CapabiltiyRegAddr - Ehc Capability register address
671 Data - A pointer to data read from register
676 EFI_DEVICE_ERROR Fail
682 ReadEhcOperationalReg (
683 IN USB2_HC_DEV
*HcDev
,
684 IN UINT32 OperationalRegAddr
,
691 Read Ehc Operation register
696 OperationalRegAddr - Ehc Operation register address
697 Data - A pointer to data read from register
702 EFI_DEVICE_ERROR Fail
708 WriteEhcOperationalReg (
709 IN USB2_HC_DEV
*HcDev
,
710 IN UINT32 OperationalRegAddr
,
717 Write Ehc Operation register
722 OperationalRegAddr - Ehc Operation register address
723 Data - 32bit write to register
728 EFI_DEVICE_ERROR Fail
735 IN USB2_HC_DEV
*HcDev
741 Set Ehc door bell bit
750 EFI_DEVICE_ERROR Fail
757 IN USB2_HC_DEV
*HcDev
,
764 Set the length of Frame List
769 Length - the required length of frame list
774 EFI_INVALID_PARAMETER Invalid parameter
775 EFI_DEVICE_ERROR Fail
781 IsFrameListProgrammable (
782 IN USB2_HC_DEV
*HcDev
788 Whether frame list is programmable
803 IsPeriodicScheduleEnabled (
804 IN USB2_HC_DEV
*HcDev
810 Whether periodic schedule is enabled
825 IsAsyncScheduleEnabled (
826 IN USB2_HC_DEV
*HcDev
832 Whether asynchronous schedule is enabled
848 IN USB2_HC_DEV
*HcDev
,
855 Whether port is enabled
871 IN USB2_HC_DEV
*HcDev
877 Whether Ehc is halted
893 IN USB2_HC_DEV
*HcDev
899 Whether Ehc is halted
915 IN USB2_HC_DEV
*HcDev
921 Whether Ehc is system error
930 FALSE No system error
937 IN EFI_USB2_HC_PROTOCOL
*This
,
944 Whether high speed device attached
960 IN USB2_HC_DEV
*HcDev
,
967 wait for Ehc reset or timeout
972 Timeout - timeout threshold
984 IN USB2_HC_DEV
*HcDev
,
991 wait for Ehc halt or timeout
996 Timeout - timeout threshold
1008 IN USB2_HC_DEV
*HcDev
,
1013 Routine Description:
1015 wait for Ehc not halt or timeout
1020 Timeout - timeout threshold
1031 WaitForEhcDoorbell (
1032 IN USB2_HC_DEV
*HcDev
,
1037 Routine Description:
1039 Wait for periodic schedule disable or timeout
1044 Timeout - timeout threshold
1055 WaitForAsyncScheduleEnable (
1056 IN USB2_HC_DEV
*HcDev
,
1061 Routine Description:
1063 Wait for Ehc asynchronous schedule enable or timeout
1068 Timeout - timeout threshold
1079 WaitForAsyncScheduleDisable (
1080 IN USB2_HC_DEV
*HcDev
,
1085 Routine Description:
1087 Wait for Ehc asynchronous schedule disable or timeout
1092 Timeout - timeout threshold
1103 WaitForPeriodicScheduleEnable (
1104 IN USB2_HC_DEV
*HcDev
,
1109 Routine Description:
1111 Wait for Ehc periodic schedule enable or timeout
1116 Timeout - timeout threshold
1127 WaitForPeriodicScheduleDisable (
1128 IN USB2_HC_DEV
*HcDev
,
1133 Routine Description:
1135 Wait for periodic schedule disable or timeout
1140 Timeout - timeout threshold
1152 IN USB2_HC_DEV
*HcDev
1156 Routine Description:
1158 Get the length of capability register
1167 EFI_DEVICE_ERROR Fail
1173 SetFrameListBaseAddr (
1174 IN USB2_HC_DEV
*HcDev
,
1175 IN UINT32 FrameBuffer
1179 Routine Description:
1181 Set base address of frame list first entry
1186 FrameBuffer - base address of first entry of frame list
1191 EFI_DEVICE_ERROR Fail
1198 IN USB2_HC_DEV
*HcDev
,
1199 IN EHCI_QH_ENTITY
*QhPtr
1203 Routine Description:
1205 Set address of first Async schedule Qh
1210 QhPtr - A pointer to first Qh in the Async schedule
1215 EFI_DEVICE_ERROR Fail
1221 SetCtrlDataStructSeg (
1222 IN USB2_HC_DEV
*HcDev
1226 Routine Description:
1228 Set address of first Async schedule Qh
1233 QhPtr - A pointer to first Qh in the Async schedule
1238 EFI_DEVICE_ERROR Fail
1245 IN USB2_HC_DEV
*HcDev
1249 Routine Description:
1251 Set Ehc port routing bit
1260 EFI_DEVICE_ERROR Fail
1266 EnablePeriodicSchedule (
1267 IN USB2_HC_DEV
*HcDev
1271 Routine Description:
1273 Enable periodic schedule
1282 EFI_DEVICE_ERROR Fail
1288 DisablePeriodicSchedule (
1289 IN USB2_HC_DEV
*HcDev
1293 Routine Description:
1295 Disable periodic schedule
1304 EFI_DEVICE_ERROR Fail
1310 EnableAsynchronousSchedule (
1311 IN USB2_HC_DEV
*HcDev
1315 Routine Description:
1317 Enable asynchrounous schedule
1326 EFI_DEVICE_ERROR Fail
1332 DisableAsynchronousSchedule (
1333 IN USB2_HC_DEV
*HcDev
1337 Routine Description:
1339 Disable asynchrounous schedule
1348 EFI_DEVICE_ERROR Fail
1354 StartScheduleExecution (
1355 IN USB2_HC_DEV
*HcDev
1359 Routine Description:
1361 Start Ehc schedule execution
1370 EFI_DEVICE_ERROR Fail
1377 IN USB2_HC_DEV
*HcDev
1381 Routine Description:
1392 EFI_DEVICE_ERROR Fail
1399 IN USB2_HC_DEV
*HcDev
1403 Routine Description:
1405 Clear Ehc all status bits
1414 EFI_DEVICE_ERROR Fail
1420 // EhciSched Functions
1423 InitialPeriodicFrameList (
1424 IN USB2_HC_DEV
*HcDev
,
1429 Routine Description:
1431 Initialize Periodic Schedule Frame List
1436 Length - Frame List Length
1441 EFI_DEVICE_ERROR Fail
1447 DeinitialPeriodicFrameList (
1448 IN USB2_HC_DEV
*HcDev
1452 Routine Description:
1454 Deinitialize Periodic Schedule Frame List
1468 CreatePollingTimer (
1469 IN USB2_HC_DEV
*HcDev
,
1470 IN EFI_EVENT_NOTIFY NotifyFunction
1474 Routine Description:
1476 Create Async Request Polling Timer
1481 NotifyFunction - Timer Notify Function
1486 EFI_DEVICE_ERROR Fail
1492 DestoryPollingTimer (
1493 IN USB2_HC_DEV
*HcDev
1497 Routine Description:
1499 Destory Async Request Polling Timer
1508 EFI_DEVICE_ERROR Fail
1515 IN USB2_HC_DEV
*HcDev
1519 Routine Description:
1521 Start Async Request Polling Timer
1530 EFI_DEVICE_ERROR Fail
1537 IN USB2_HC_DEV
*HcDev
1541 Routine Description:
1543 Stop Async Request Polling Timer
1552 EFI_DEVICE_ERROR Fail
1559 IN USB2_HC_DEV
*HcDev
,
1560 IN UINT8 DeviceAddr
,
1562 IN UINT8 DeviceSpeed
,
1563 IN UINTN MaxPacketLen
,
1564 OUT EHCI_QH_ENTITY
**QhPtrPtr
1568 Routine Description:
1570 Create Qh Structure and Pre-Initialize
1575 DeviceAddr - Address of Device
1576 Endpoint - Endpoint Number
1577 DeviceSpeed - Device Speed
1578 MaxPacketLen - Max Length of one Packet
1579 QhPtrPtr - A pointer of pointer to Qh for return
1584 EFI_DEVICE_ERROR Fail
1591 IN USB2_HC_DEV
*HcDev
,
1592 IN UINT8 DeviceAddr
,
1593 IN UINT8 DeviceSpeed
,
1594 IN UINTN MaxPacketLen
,
1595 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR
*Translator
,
1596 OUT EHCI_QH_ENTITY
**QhPtrPtr
1600 Routine Description:
1602 Create Qh for Control Transfer
1607 DeviceAddr - Address of Device
1608 DeviceSpeed - Device Speed
1609 MaxPacketLen - Max Length of one Packet
1610 Translator - Translator Transaction for SplitX
1611 QhPtrPtr - A pointer of pointer to Qh for return
1616 EFI_DEVICE_ERROR Fail
1623 IN USB2_HC_DEV
*HcDev
,
1624 IN UINT8 DeviceAddr
,
1625 IN UINT8 EndPointAddr
,
1626 IN UINT8 DeviceSpeed
,
1627 IN UINT8 DataToggle
,
1628 IN UINTN MaxPacketLen
,
1629 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR
*Translator
,
1630 OUT EHCI_QH_ENTITY
**QhPtrPtr
1634 Routine Description:
1636 Create Qh for Bulk Transfer
1641 DeviceAddr - Address of Device
1642 EndPointAddr - Address of Endpoint
1643 DeviceSpeed - Device Speed
1644 MaxPacketLen - Max Length of one Packet
1645 Translator - Translator Transaction for SplitX
1646 QhPtrPtr - A pointer of pointer to Qh for return
1651 EFI_DEVICE_ERROR Fail
1658 IN USB2_HC_DEV
*HcDev
,
1659 IN UINT8 DeviceAddr
,
1660 IN UINT8 EndPointAddr
,
1661 IN UINT8 DeviceSpeed
,
1662 IN UINT8 DataToggle
,
1663 IN UINTN MaxPacketLen
,
1665 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR
*Translator
,
1666 OUT EHCI_QH_ENTITY
**QhPtrPtr
1670 Routine Description:
1672 Create Qh for Control Transfer
1677 DeviceAddr - Address of Device
1678 EndPointAddr - Address of Endpoint
1679 DeviceSpeed - Device Speed
1680 MaxPacketLen - Max Length of one Packet
1681 Interval - value of interval
1682 Translator - Translator Transaction for SplitX
1683 QhPtrPtr - A pointer of pointer to Qh for return
1688 EFI_DEVICE_ERROR Fail
1695 IN USB2_HC_DEV
*HcDev
,
1696 IN EHCI_QH_ENTITY
*QhPtr
1700 Routine Description:
1702 Destory Qh Structure
1707 QhPtr - A pointer to Qh
1718 IN USB2_HC_DEV
*HcDev
,
1724 OUT EHCI_QTD_ENTITY
**QtdPtrPtr
1728 Routine Description:
1730 Create Qtd Structure and Pre-Initialize it
1735 DataPtr - A pointer to user data buffer to transfer
1736 DataLen - Length of user data to transfer
1737 PktId - Packet Identification of this Qtd
1738 Toggle - Data Toggle of this Qtd
1739 QtdStatus - Default value of status of this Qtd
1740 QtdPtrPtr - A pointer of pointer to Qtd for return
1745 EFI_OUT_OF_RESOURCES Cannot allocate resources
1752 IN USB2_HC_DEV
*HcDev
,
1753 IN UINT8
*DevReqPtr
,
1754 OUT EHCI_QTD_ENTITY
**QtdPtrPtr
1758 Routine Description:
1760 Create Qtd Structure for Setup
1765 DevReqPtr - A pointer to Device Request Data
1766 QtdPtrPtr - A pointer of pointer to Qtd for return
1771 EFI_OUT_OF_RESOURCES Cannot allocate resources
1778 IN USB2_HC_DEV
*HcDev
,
1783 OUT EHCI_QTD_ENTITY
**QtdPtrPtr
1787 Routine Description:
1789 Create Qtd Structure for data
1794 DataPtr - A pointer to user data buffer to transfer
1795 DataLen - Length of user data to transfer
1796 PktId - Packet Identification of this Qtd
1797 Toggle - Data Toggle of this Qtd
1798 QtdPtrPtr - A pointer of pointer to Qtd for return
1803 EFI_OUT_OF_RESOURCES Cannot allocate resources
1810 IN USB2_HC_DEV
*HcDev
,
1812 OUT EHCI_QTD_ENTITY
**QtdPtrPtr
1816 Routine Description:
1818 Create Qtd Structure for status
1823 PktId - Packet Identification of this Qtd
1824 QtdPtrPtr - A pointer of pointer to Qtd for return
1829 EFI_OUT_OF_RESOURCES Cannot allocate resources
1836 IN USB2_HC_DEV
*HcDev
,
1838 OUT EHCI_QTD_ENTITY
**QtdPtrPtr
1842 Routine Description:
1844 Create Qtd Structure for Alternative
1849 PktId - Packet Identification of this Qtd
1850 QtdPtrPtr - A pointer of pointer to Qtd for return
1855 EFI_OUT_OF_RESOURCES Cannot allocate resources
1862 IN USB2_HC_DEV
*HcDev
,
1864 IN UINT8
*RequestCursor
,
1865 IN UINT8
*DataCursor
,
1867 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR
*Translator
,
1868 OUT EHCI_QTD_ENTITY
**ControlQtdsHead
1872 Routine Description:
1874 Create Qtds list for Control Transfer
1879 DataPktId - Packet Identification of Data Qtds
1880 RequestCursor - A pointer to request structure buffer to transfer
1881 DataCursor - A pointer to user data buffer to transfer
1882 DataLen - Length of user data to transfer
1883 ControlQtdsHead - A pointer of pointer to first Qtd for control tranfer for return
1888 EFI_DEVICE_ERROR Fail
1894 CreateBulkOrInterruptQtds (
1895 IN USB2_HC_DEV
*HcDev
,
1897 IN UINT8
*DataCursor
,
1899 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR
*Translator
,
1900 OUT EHCI_QTD_ENTITY
**QtdsHead
1904 Routine Description:
1906 Create Qtds list for Bulk or Interrupt Transfer
1911 PktId - Packet Identification of Qtds
1912 DataCursor - A pointer to user data buffer to transfer
1913 DataLen - Length of user data to transfer
1914 DataToggle - Data Toggle to start
1915 Translator - Translator Transaction for SplitX
1916 QtdsHead - A pointer of pointer to first Qtd for control tranfer for return
1921 EFI_DEVICE_ERROR Fail
1928 IN USB2_HC_DEV
*HcDev
,
1929 IN EHCI_QTD_ENTITY
*FirstQtdPtr
1933 Routine Description:
1935 Destory all Qtds in the list
1940 FirstQtdPtr - A pointer to first Qtd in the list
1951 IN EHCI_QTD_ENTITY
*PreQtdPtr
,
1952 IN EHCI_QTD_ENTITY
*QtdPtr
1956 Routine Description:
1962 PreQtdPtr - A pointer to pre Qtd
1963 QtdPtr - A pointer to next Qtd
1974 IN EHCI_QTD_ENTITY
*FirstQtdPtr
,
1975 IN EHCI_QTD_ENTITY
*AltQtdPtr
1979 Routine Description:
1981 Link AlterQtds together
1985 FirstQtdPtr - A pointer to first Qtd in the list
1986 AltQtdPtr - A pointer to alternative Qtd
1996 IN EHCI_QH_ENTITY
*QhPtr
,
1997 IN EHCI_QTD_ENTITY
*QtdEntryPtr
2001 Routine Description:
2003 Link Qtds list to Qh
2007 QhPtr - A pointer to Qh
2008 QtdPtr - A pointer to first Qtd in the list
2019 IN USB2_HC_DEV
*HcDev
,
2020 IN EHCI_QH_ENTITY
*QhPtr
2024 Routine Description:
2026 Link Qh to Async Schedule List
2031 QhPtr - A pointer to Qh
2036 EFI_DEVICE_ERROR Fail
2042 UnlinkQhFromAsyncList (
2043 IN USB2_HC_DEV
*HcDev
,
2044 IN EHCI_QH_ENTITY
*QhPtr
2048 Routine Description:
2050 Unlink Qh from Async Schedule List
2055 QhPtr - A pointer to Qh
2060 EFI_DEVICE_ERROR Fail
2066 LinkQhToPeriodicList (
2067 IN USB2_HC_DEV
*HcDev
,
2068 IN EHCI_QH_ENTITY
*QhPtr
2072 Routine Description:
2074 Link Qh to Periodic Schedule List
2079 QhPtr - A pointer to Qh
2089 UnlinkQhFromPeriodicList (
2090 IN USB2_HC_DEV
*HcDev
,
2091 IN EHCI_QH_ENTITY
*QhPtr
,
2096 Routine Description:
2098 Unlink Qh from Periodic Schedule List
2103 QhPtr - A pointer to Qh
2104 Interval - Interval of this periodic transfer
2114 LinkToAsyncReqeust (
2115 IN USB2_HC_DEV
*HcDev
,
2116 IN EHCI_ASYNC_REQUEST
*AsyncRequestPtr
2120 Routine Description:
2122 Llink AsyncRequest Entry to Async Request List
2127 AsyncRequestPtr - A pointer to Async Request Entry
2137 UnlinkFromAsyncReqeust (
2138 IN USB2_HC_DEV
*HcDev
,
2139 IN EHCI_ASYNC_REQUEST
*AsyncRequestPtr
2143 Routine Description:
2145 Unlink AsyncRequest Entry from Async Request List
2150 AsyncRequestPtr - A pointer to Async Request Entry
2161 IN EHCI_QTD_ENTITY
*FirstQtdPtr
2165 Routine Description:
2167 Number of Qtds in the list
2171 FirstQtdPtr - A pointer to first Qtd in the list
2175 Number of Qtds in the list
2181 GetNumberOfTransaction (
2182 IN UINTN SizeOfData
,
2183 IN UINTN SizeOfTransaction
2187 Routine Description:
2189 Number of Transactions in one Qtd
2193 SizeOfData - Size of one Qtd
2194 SizeOfTransaction - Size of one Transaction
2198 Number of Transactions in this Qtd
2205 IN UINT8
*BufferCursor
2209 Routine Description:
2215 BufferCursor - BufferCursor of the Qtd
2225 GetApproxiOfInterval (
2230 Routine Description:
2232 Get the approximate value in the 2 index sequence
2236 Interval - the value of interval
2240 approximate value of interval in the 2 index sequence
2247 IN EHCI_QTD_HW
*HwQtdPtr
2251 Routine Description:
2253 Get Qtd next pointer field
2257 HwQtdPtr - A pointer to hardware Qtd structure
2261 A pointer to next hardware Qtd structure
2268 IN EHCI_QTD_HW
*HwQtdPtr
2272 Routine Description:
2274 Whether Qtd status is active or not
2278 HwQtdPtr - A pointer to hardware Qtd structure
2290 IN EHCI_QTD_HW
*HwQtdPtr
2294 Routine Description:
2296 Whether Qtd status is halted or not
2300 HwQtdPtr - A pointer to hardware Qtd structure
2311 IsQtdStatusBufferError (
2312 IN EHCI_QTD_HW
*HwQtdPtr
2316 Routine Description:
2318 Whether Qtd status is buffer error or not
2322 HwQtdPtr - A pointer to hardware Qtd structure
2327 FALSE No buffer error
2333 IsQtdStatusBabbleError (
2334 IN EHCI_QTD_HW
*HwQtdPtr
2338 Routine Description:
2340 Whether Qtd status is babble error or not
2344 HwQtdPtr - A pointer to hardware Qtd structure
2349 FALSE No babble error
2355 IsQtdStatusTransactionError (
2356 IN EHCI_QTD_HW
*HwQtdPtr
2360 Routine Description:
2362 Whether Qtd status is transaction error or not
2366 HwQtdPtr - A pointer to hardware Qtd structure
2370 TRUE Transaction error
2371 FALSE No transaction error
2378 IN UINT8 EndPointAddress
2382 Routine Description:
2384 Whether is a DataIn direction transfer
2388 EndPointAddress - address of the endpoint
2400 IN USB2_HC_DEV
*HcDev
,
2401 IN EFI_USB_DATA_DIRECTION TransferDirection
,
2403 IN OUT UINTN
*DataLength
,
2405 OUT UINT8
**DataCursor
,
2410 Routine Description:
2412 Map address of user data buffer
2417 TransferDirection - direction of transfer
2418 Data - A pointer to user data buffer
2419 DataLength - length of user data
2420 PktId - Packte Identificaion
2421 DataCursor - mapped address to return
2422 DataMap - identificaion of this mapping to return
2427 EFI_DEVICE_ERROR Fail
2434 IN USB2_HC_DEV
*HcDev
,
2435 IN OUT VOID
*Request
,
2436 OUT UINT8
**RequestCursor
,
2437 OUT VOID
**RequestMap
2441 Routine Description:
2443 Map address of request structure buffer
2448 Request - A pointer to request structure
2449 RequestCursor - Mapped address of request structure to return
2450 RequestMap - Identificaion of this mapping to return
2455 EFI_DEVICE_ERROR Fail
2461 SetQtdBufferPointer (
2462 IN EHCI_QTD_HW
*QtdHwPtr
,
2468 Routine Description:
2470 Set data buffer pointers in Qtd
2474 QtdHwPtr - A pointer to Qtd hardware structure
2475 DataPtr - A pointer to user data buffer
2476 DataLen - Length of the user data buffer
2486 GetQtdAlternateNextPointer (
2487 IN EHCI_QTD_HW
*HwQtdPtr
2491 Routine Description:
2493 Get Qtd alternate next pointer field
2497 HwQtdPtr - A pointer to hardware Qtd structure
2501 A pointer to hardware alternate Qtd
2508 IN EHCI_QH_ENTITY
*QhPtr
2512 Routine Description:
2514 Zero out the fields in Qh structure
2518 QhPtr - A pointer to Qh structure
2528 UpdateAsyncRequestTransfer (
2529 IN EHCI_ASYNC_REQUEST
*AsyncRequestPtr
,
2530 IN UINT32 TransferResult
,
2535 Routine Description:
2537 Update asynchronous request transfer
2541 AsyncRequestPtr - A pointer to async request
2542 TransferResult - transfer result
2543 ErrQtdPos - postion of error Qtd
2554 DeleteAsyncRequestTransfer (
2555 IN USB2_HC_DEV
*HcDev
,
2556 IN UINT8 DeviceAddress
,
2557 IN UINT8 EndPointAddress
,
2558 OUT UINT8
*DataToggle
2562 Routine Description:
2564 Delete all asynchronous request transfer
2569 DeviceAddress - address of usb device
2570 EndPointAddress - address of endpoint
2571 DataToggle - stored data toggle
2576 EFI_DEVICE_ERROR Fail
2582 CleanUpAllAsyncRequestTransfer (
2583 IN USB2_HC_DEV
*HcDev
2587 Routine Description:
2589 Clean up all asynchronous request transfer
2603 IN USB2_HC_DEV
*HcDev
,
2604 IN BOOLEAN IsControl
,
2605 IN EHCI_QH_ENTITY
*QhPtr
,
2606 IN OUT UINTN
*ActualLen
,
2607 OUT UINT8
*DataToggle
,
2609 OUT UINT32
*TransferResult
2613 Routine Description:
2615 Execute Bulk or SyncInterrupt Transfer
2620 IsControl - Is control transfer or not
2621 QhPtr - A pointer to Qh
2622 ActualLen - Actual transfered Len
2623 DataToggle - Data Toggle
2624 TimeOut - TimeOut threshold
2625 TransferResult - Transfer result
2630 EFI_DEVICE_ERROR Error
2636 CheckQtdsTransferResult (
2637 IN BOOLEAN IsControl
,
2638 IN EHCI_QH_ENTITY
*QhPtr
,
2640 OUT UINTN
*ErrQtdPos
,
2641 OUT UINTN
*ActualLen
2645 Routine Description:
2647 Check transfer result of Qtds
2651 IsControl - Is control transfer or not
2652 QhPtr - A pointer to Qh
2653 Result - Transfer result
2654 ErrQtdPos - Error TD Position
2655 ActualLen - Actual Transfer Size
2666 AsyncRequestMoniter (
2672 Routine Description:
2674 Interrupt transfer periodic check handler
2678 Event - Interrupt event
2679 Context - Pointer to USB2_HC_DEV
2684 EFI_DEVICE_ERROR Fail