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>
30 extern UINTN gEHCDebugLevel
;
31 extern UINTN gEHCErrorLevel
;
33 #define STALL_1_MACRO_SECOND 1
34 #define STALL_1_MILLI_SECOND 1000 * STALL_1_MACRO_SECOND
35 #define STALL_1_SECOND 1000 * STALL_1_MILLI_SECOND
37 #define SETUP_PACKET_PID_CODE 0x02
38 #define INPUT_PACKET_PID_CODE 0x01
39 #define OUTPUT_PACKET_PID_CODE 0x0
41 #define ITD_SELECT_TYPE 0x0
42 #define QH_SELECT_TYPE 0x01
43 #define SITD_SELECT_TYPE 0x02
44 #define FSTN_SELECT_TYPE 0x03
46 #define EHCI_SET_PORT_RESET_RECOVERY_TIME 50 * STALL_1_MILLI_SECOND
47 #define EHCI_CLEAR_PORT_RESET_RECOVERY_TIME STALL_1_MILLI_SECOND
48 #define EHCI_GENERIC_TIMEOUT 50 * STALL_1_MILLI_SECOND
49 #define EHCI_GENERIC_RECOVERY_TIME 50 * STALL_1_MACRO_SECOND
50 #define EHCI_SYNC_REQUEST_POLLING_TIME 50 * STALL_1_MACRO_SECOND
51 #define EHCI_ASYNC_REQUEST_POLLING_TIME 50 * STALL_1_MILLI_SECOND
53 #define USB_BAR_INDEX 0 /* how many bytes away from USB_BASE to 0x10 */
55 #define NORMAL_MEMORY_BLOCK_UNIT_IN_PAGES 1
57 #define EHCI_MIN_PACKET_SIZE 8
58 #define EHCI_MAX_PACKET_SIZE 1024
59 #define EHCI_MAX_FRAME_LIST_LENGTH 1024
60 #define EHCI_BLOCK_SIZE_WITH_TT 64
61 #define EHCI_BLOCK_SIZE 512
62 #define EHCI_MAX_QTD_CAPACITY (EFI_PAGE_SIZE * 5)
64 #define NAK_COUNT_RELOAD 3
65 #define QTD_ERROR_COUNTER 1
66 #define HIGH_BANDWIDTH_PIPE_MULTIPLIER 1
68 #define QTD_STATUS_ACTIVE 0x80
69 #define QTD_STATUS_HALTED 0x40
70 #define QTD_STATUS_BUFFER_ERR 0x20
71 #define QTD_STATUS_BABBLE_ERR 0x10
72 #define QTD_STATUS_TRANSACTION_ERR 0x08
73 #define QTD_STATUS_DO_STOP_SPLIT 0x02
74 #define QTD_STATUS_DO_START_SPLIT 0
75 #define QTD_STATUS_DO_PING 0x01
76 #define QTD_STATUS_DO_OUT 0
81 #define MICRO_FRAME_0_CHANNEL 0x01
82 #define MICRO_FRAME_1_CHANNEL 0x02
83 #define MICRO_FRAME_2_CHANNEL 0x04
84 #define MICRO_FRAME_3_CHANNEL 0x08
85 #define MICRO_FRAME_4_CHANNEL 0x10
86 #define MICRO_FRAME_5_CHANNEL 0x20
87 #define MICRO_FRAME_6_CHANNEL 0x40
88 #define MICRO_FRAME_7_CHANNEL 0x80
90 #define CONTROL_TRANSFER 0x01
91 #define BULK_TRANSFER 0x02
92 #define SYNC_INTERRUPT_TRANSFER 0x04
93 #define ASYNC_INTERRUPT_TRANSFER 0x08
94 #define SYNC_ISOCHRONOUS_TRANSFER 0x10
95 #define ASYNC_ISOCHRONOUS_TRANSFER 0x20
99 // Enhanced Host Controller Registers definitions
101 extern UINT32 mUsbCapabilityLen
;
102 extern EFI_DRIVER_BINDING_PROTOCOL gEhciDriverBinding
;
103 extern EFI_COMPONENT_NAME_PROTOCOL gEhciComponentName
;
105 #define USBCMD 0x0 /* Command Register Offset 00-03h */
106 #define USBCMD_RS 0x01 /* Run / Stop */
107 #define USBCMD_HCRESET 0x02 /* Host controller reset */
108 #define USBCMD_FLS_512 0x04 /* 512 elements (2048bytes) in Frame List */
109 #define USBCMD_FLS_256 0x08 /* 256 elements (1024bytes) in Frame List */
110 #define USBCMD_PSE 0x10 /* Periodic schedule enable */
111 #define USBCMD_ASE 0x20 /* Asynchronous schedule enable */
112 #define USBCMD_IAAD 0x40 /* Interrupt on async advance doorbell */
114 #define USBSTS 0x04 /* Statue Register Offset 04-07h */
115 #define USBSTS_HSE 0x10 /* Host system error */
116 #define USBSTS_IAA 0x20 /* Interrupt on async advance */
117 #define USBSTS_HCH 0x1000 /* Host controller halted */
118 #define USBSTS_PSS 0x4000 /* Periodic schedule status */
119 #define USBSTS_ASS 0x8000 /* Asynchronous schedule status */
121 #define USBINTR 0x08 /* Command Register Offset 08-0bh */
123 #define FRINDEX 0x0c /* Frame Index Offset 0c-0fh */
125 #define CTRLDSSGMENT 0x10 /* 4G Segment Selector Offset 10-13h */
127 #define PERIODICLISTBASE 0x14 /* Frame List Base Address Offset 14-17h */
129 #define ASYNCLISTADDR 0x18 /* Next Asynchronous List Address Offset 18-1bh */
131 #define CONFIGFLAG 0x40 /* Configured Flag Register Offset 40-43h */
132 #define CONFIGFLAG_CF 0x01 /* Configure Flag */
134 #define PORTSC 0x44 /* Port Status/Control Offset 44-47h */
135 #define PORTSC_CCS 0x01 /* Current Connect Status*/
136 #define PORTSC_CSC 0x02 /* Connect Status Change */
137 #define PORTSC_PED 0x04 /* Port Enable / Disable */
138 #define PORTSC_PEDC 0x08 /* Port Enable / Disable Change */
139 #define PORTSC_OCA 0x10 /* Over current Active */
140 #define PORTSC_OCC 0x20 /* Over current Change */
141 #define PORTSC_FPR 0x40 /* Force Port Resume */
142 #define PORTSC_SUSP 0x80 /* Port Suspend State */
143 #define PORTSC_PR 0x100 /* Port Reset */
144 #define PORTSC_LS_KSTATE 0x400 /* Line Status K-state */
145 #define PORTSC_LS_JSTATE 0x800 /* Line Status J-state */
146 #define PORTSC_PP 0x1000 /* Port Power */
147 #define PORTSC_PO 0x2000 /* Port Owner */
149 #define CAPLENGTH 0 /* Capability Register Length 00h */
151 #define HCIVERSION 0x02 /* Interface Version Number 02-03h */
153 #define HCSPARAMS 0x04 /* Structural Parameters 04-07h */
154 #define HCSP_NPORTS 0x0f /* Number of physical downstream ports on host controller */
156 #define HCCPARAMS 0x08 /* Capability Parameters 08-0bh */
157 #define HCCP_64BIT 0x01 /* 64-bit Addressing Capability */
158 #define HCCP_PFLF 0x02 /* Programmable Frame List Flag */
159 #define HCCP_EECP 0xff00 /* EHCI Extemded Capabilities Pointer */
161 #define HCSPPORTROUTE 0x0c /* Companion Port Route Description 60b */
163 #define CLASSC 0x09 /* Class Code 09-0bh */
165 #define USBBASE 0x10 /* Base Address to Memory-mapped Host Controller Register Space 10-13h */
167 #define SBRN 0x60 /* Serial Bus Release Number 60h */
169 #define FLADJ 0x61 /* Frame Length Adjustment Register 61h */
171 #define PORTWAKECAP 0x62 /* Port wake capablilities register(OPIONAL) 61-62h */
174 // PCI Configuration Registers
176 #define EHCI_PCI_CLASSC 0x09
177 #define EHCI_PCI_MEMORY_BASE 0x10
180 // Memory Offset Registers
182 #define EHCI_MEMORY_CAPLENGTH 0x0
183 #define EHCI_MEMORY_CONFIGFLAG 0x40
186 // USB Base Class Code,Sub-Class Code and Programming Interface
188 #define PCI_CLASSC_PI_EHCI 0x20
190 #define SETUP_PACKET_ID 0x2D
191 #define INPUT_PACKET_ID 0x69
192 #define OUTPUT_PACKET_ID 0xE1
193 #define ERROR_PACKET_ID 0x55
195 #define bit(a) 1 << (a)
197 #define GET_0B_TO_31B(Addr) (((UINTN) Addr) & (0xffffffff))
198 #define GET_32B_TO_63B(Addr) ((((UINTN) Addr) >> 32) & (0xffffffff))
202 // Ehci Data and Ctrl Structures
213 UINT32 NextQtdTerminate
: 1;
215 UINT32 NextQtdPointer
: 27;
217 UINT32 AltNextQtdTerminate
: 1;
219 UINT32 AltNextQtdPointer
: 27;
223 UINT32 ErrorCount
: 2;
224 UINT32 CurrentPage
: 3;
225 UINT32 InterruptOnComplete
: 1;
226 UINT32 TotalBytes
: 15;
227 UINT32 DataToggle
: 1;
229 UINT32 CurrentOffset
: 12;
230 UINT32 BufferPointer0
: 20;
233 UINT32 BufferPointer1
: 20;
236 UINT32 BufferPointer2
: 20;
239 UINT32 BufferPointer3
: 20;
242 UINT32 BufferPointer4
: 20;
244 UINT32 ExtBufferPointer0
;
245 UINT32 ExtBufferPointer1
;
246 UINT32 ExtBufferPointer2
;
247 UINT32 ExtBufferPointer3
;
248 UINT32 ExtBufferPointer4
;
252 UINT32 QhTerminate
: 1;
253 UINT32 SelectType
: 2;
255 UINT32 QhHorizontalPointer
: 27;
257 UINT32 DeviceAddr
: 7;
259 UINT32 EndpointNum
: 4;
260 UINT32 EndpointSpeed
: 2;
261 UINT32 DataToggleControl
: 1;
262 UINT32 HeadReclamationFlag
: 1;
263 UINT32 MaxPacketLen
: 11;
264 UINT32 ControlEndpointFlag
: 1;
265 UINT32 NakCountReload
: 4;
267 UINT32 InerruptScheduleMask
: 8;
268 UINT32 SplitComletionMask
: 8;
271 UINT32 Multiplier
: 2;
274 UINT32 CurrentQtdPointer
: 27;
276 UINT32 NextQtdTerminate
: 1;
278 UINT32 NextQtdPointer
: 27;
280 UINT32 AltNextQtdTerminate
: 1;
282 UINT32 AltNextQtdPointer
: 27;
286 UINT32 ErrorCount
: 2;
287 UINT32 CurrentPage
: 3;
288 UINT32 InterruptOnComplete
: 1;
289 UINT32 TotalBytes
: 15;
290 UINT32 DataToggle
: 1;
292 UINT32 CurrentOffset
: 12;
293 UINT32 BufferPointer0
: 20;
295 UINT32 CompleteSplitMask
: 8;
297 UINT32 BufferPointer1
: 20;
300 UINT32 SplitBytes
: 7;
301 UINT32 BufferPointer2
: 20;
304 UINT32 BufferPointer3
: 20;
307 UINT32 BufferPointer4
: 20;
309 UINT32 ExtBufferPointer0
;
310 UINT32 ExtBufferPointer1
;
311 UINT32 ExtBufferPointer2
;
312 UINT32 ExtBufferPointer3
;
313 UINT32 ExtBufferPointer4
;
317 UINT32 LinkTerminate
: 1;
318 UINT32 SelectType
: 2;
320 UINT32 LinkPointer
: 27;
325 typedef struct _EHCI_QTD_ENTITY EHCI_QTD_ENTITY
;
326 typedef struct _EHCI_QH_ENTITY EHCI_QH_ENTITY
;
327 typedef struct _EHCI_ASYNC_REQUEST EHCI_ASYNC_REQUEST
;
329 typedef struct _EHCI_QTD_ENTITY
{
332 UINT32 StaticTotalBytes
;
333 UINT32 StaticCurrentOffset
;
334 EHCI_QTD_ENTITY
*Prev
;
335 EHCI_QTD_ENTITY
*Next
;
336 EHCI_QTD_ENTITY
*AltNext
;
337 EHCI_QH_ENTITY
*SelfQh
;
340 typedef struct _EHCI_QH_ENTITY
{
342 EHCI_QH_ENTITY
*Next
;
343 EHCI_QH_ENTITY
*Prev
;
344 EHCI_QTD_ENTITY
*FirstQtdPtr
;
345 EHCI_QTD_ENTITY
*LastQtdPtr
;
346 EHCI_QTD_ENTITY
*AltQtdPtr
;
351 #define GET_QH_ENTITY_ADDR(a) ((EHCI_QH_ENTITY *) a)
352 #define GET_QTD_ENTITY_ADDR(a) ((EHCI_QTD_ENTITY *) a)
356 // Ehci Managment Structures
358 #define USB2_HC_DEV_FROM_THIS(a) CR (a, USB2_HC_DEV, Usb2Hc, USB2_HC_DEV_SIGNATURE)
360 #define USB2_HC_DEV_SIGNATURE EFI_SIGNATURE_32 ('e', 'h', 'c', 'i')
362 typedef struct _LIST_HEAD
{
363 struct _LIST_HEAD
*pre
;
364 struct _LIST_HEAD
*next
;
367 typedef struct _EHCI_ASYNC_REQUEST
{
369 EFI_ASYNC_USB_TRANSFER_CALLBACK CallBackFunc
;
371 EHCI_ASYNC_REQUEST
*Prev
;
372 EHCI_ASYNC_REQUEST
*Next
;
373 EHCI_QH_ENTITY
*QhPtr
;
374 } EHCI_ASYNC_REQUEST
;
376 typedef struct _MEMORY_MANAGE_HEADER
{
378 UINTN BitArraySizeInBytes
;
379 UINT8
*MemoryBlockPtr
;
380 UINTN MemoryBlockSizeInBytes
;
382 struct _MEMORY_MANAGE_HEADER
*Next
;
383 } MEMORY_MANAGE_HEADER
;
385 typedef struct _USB2_HC_DEV
{
387 EFI_PCI_IO_PROTOCOL
*PciIo
;
388 EFI_USB2_HC_PROTOCOL Usb2Hc
;
389 UINTN PeriodicFrameListLength
;
390 VOID
*PeriodicFrameListBuffer
;
391 VOID
*PeriodicFrameListMap
;
393 EHCI_ASYNC_REQUEST
*AsyncRequestList
;
394 EFI_EVENT AsyncRequestEvent
;
395 EFI_UNICODE_STRING_TABLE
*ControllerNameTable
;
396 MEMORY_MANAGE_HEADER
*MemoryHeader
;
397 UINT8 Is64BitCapable
;
398 UINT32 High32BitAddr
;
403 // Internal Functions Declaration
411 IN USB2_HC_DEV
*HcDev
,
412 OUT MEMORY_MANAGE_HEADER
**MemoryHeader
,
413 IN UINTN MemoryBlockSizeInPages
419 Use PciIo->AllocateBuffer to allocate common buffer for the memory block,
420 and use PciIo->Map to map the common buffer for Bus Master Read/Write.
425 MemoryHeader - MEMORY_MANAGE_HEADER to output
426 MemoryBlockSizeInPages - MemoryBlockSizeInPages
431 EFI_OUT_OF_RESOURCES Fail for no resources
432 EFI_UNSUPPORTED Unsupported currently
439 IN USB2_HC_DEV
*HcDev
,
440 IN MEMORY_MANAGE_HEADER
*MemoryHeader
451 MemoryHeader - MemoryHeader to be freed
456 EFI_INVALID_PARAMETER Parameter is error
462 InsertMemoryHeaderToList (
463 IN MEMORY_MANAGE_HEADER
*MemoryHeader
,
464 IN MEMORY_MANAGE_HEADER
*NewMemoryHeader
470 Insert Memory Header To List
474 MemoryHeader - MEMORY_MANAGE_HEADER
475 NewMemoryHeader - MEMORY_MANAGE_HEADER
485 AllocMemInMemoryBlock (
486 IN MEMORY_MANAGE_HEADER
*MemoryHeader
,
488 IN UINTN NumberOfMemoryUnit
494 Alloc Memory In MemoryBlock
498 MemoryHeader - MEMORY_MANAGE_HEADER
499 Pool - Place to store pointer to memory
500 NumberOfMemoryUnit - Number Of Memory Unit
505 EFI_NOT_FOUND Can't find the free memory
511 IsMemoryBlockEmptied (
512 IN MEMORY_MANAGE_HEADER
*MemoryHeaderPtr
518 Is Memory Block Emptied
522 MemoryHeaderPtr - MEMORY_MANAGE_HEADER
534 IN MEMORY_MANAGE_HEADER
*FirstMemoryHeader
,
535 IN MEMORY_MANAGE_HEADER
*NeedFreeMemoryHeader
545 FirstMemoryHeader - MEMORY_MANAGE_HEADER
546 NeedFreeMemoryHeader - MEMORY_MANAGE_HEADER
556 InitialMemoryManagement (
557 IN USB2_HC_DEV
*HcDev
563 Initialize Memory Management
572 EFI_DEVICE_ERROR Fail
578 DeinitialMemoryManagement (
579 IN USB2_HC_DEV
*HcDev
585 Deinitialize Memory Management
594 EFI_DEVICE_ERROR Fail
601 IN USB2_HC_DEV
*HcDev
,
614 Pool - Place to store pointer to the memory buffer
615 AllocSize - Alloc Size
620 EFI_DEVICE_ERROR Fail
627 IN USB2_HC_DEV
*HcDev
,
641 AllocSize - Pool size
654 ReadEhcCapabiltiyReg (
655 IN USB2_HC_DEV
*HcDev
,
656 IN UINT32 CapabiltiyRegAddr
,
663 Read Ehc Capabitlity register
668 CapabiltiyRegAddr - Ehc Capability register address
669 Data - A pointer to data read from register
674 EFI_DEVICE_ERROR Fail
680 ReadEhcOperationalReg (
681 IN USB2_HC_DEV
*HcDev
,
682 IN UINT32 OperationalRegAddr
,
689 Read Ehc Operation register
694 OperationalRegAddr - Ehc Operation register address
695 Data - A pointer to data read from register
700 EFI_DEVICE_ERROR Fail
706 WriteEhcOperationalReg (
707 IN USB2_HC_DEV
*HcDev
,
708 IN UINT32 OperationalRegAddr
,
715 Write Ehc Operation register
720 OperationalRegAddr - Ehc Operation register address
721 Data - 32bit write to register
726 EFI_DEVICE_ERROR Fail
733 IN USB2_HC_DEV
*HcDev
739 Set Ehc door bell bit
748 EFI_DEVICE_ERROR Fail
755 IN USB2_HC_DEV
*HcDev
,
762 Set the length of Frame List
767 Length - the required length of frame list
772 EFI_INVALID_PARAMETER Invalid parameter
773 EFI_DEVICE_ERROR Fail
779 IsFrameListProgrammable (
780 IN USB2_HC_DEV
*HcDev
786 Whether frame list is programmable
801 IsPeriodicScheduleEnabled (
802 IN USB2_HC_DEV
*HcDev
808 Whether periodic schedule is enabled
823 IsAsyncScheduleEnabled (
824 IN USB2_HC_DEV
*HcDev
830 Whether asynchronous schedule is enabled
846 IN USB2_HC_DEV
*HcDev
,
853 Whether port is enabled
869 IN USB2_HC_DEV
*HcDev
875 Whether Ehc is halted
891 IN USB2_HC_DEV
*HcDev
897 Whether Ehc is halted
913 IN USB2_HC_DEV
*HcDev
919 Whether Ehc is system error
928 FALSE No system error
935 IN EFI_USB2_HC_PROTOCOL
*This
,
942 Whether high speed device attached
958 IN USB2_HC_DEV
*HcDev
,
965 wait for Ehc reset or timeout
970 Timeout - timeout threshold
982 IN USB2_HC_DEV
*HcDev
,
989 wait for Ehc halt or timeout
994 Timeout - timeout threshold
1006 IN USB2_HC_DEV
*HcDev
,
1011 Routine Description:
1013 wait for Ehc not halt or timeout
1018 Timeout - timeout threshold
1029 WaitForEhcDoorbell (
1030 IN USB2_HC_DEV
*HcDev
,
1035 Routine Description:
1037 Wait for periodic schedule disable or timeout
1042 Timeout - timeout threshold
1053 WaitForAsyncScheduleEnable (
1054 IN USB2_HC_DEV
*HcDev
,
1059 Routine Description:
1061 Wait for Ehc asynchronous schedule enable or timeout
1066 Timeout - timeout threshold
1077 WaitForAsyncScheduleDisable (
1078 IN USB2_HC_DEV
*HcDev
,
1083 Routine Description:
1085 Wait for Ehc asynchronous schedule disable or timeout
1090 Timeout - timeout threshold
1101 WaitForPeriodicScheduleEnable (
1102 IN USB2_HC_DEV
*HcDev
,
1107 Routine Description:
1109 Wait for Ehc periodic schedule enable or timeout
1114 Timeout - timeout threshold
1125 WaitForPeriodicScheduleDisable (
1126 IN USB2_HC_DEV
*HcDev
,
1131 Routine Description:
1133 Wait for periodic schedule disable or timeout
1138 Timeout - timeout threshold
1150 IN USB2_HC_DEV
*HcDev
1154 Routine Description:
1156 Get the length of capability register
1165 EFI_DEVICE_ERROR Fail
1171 SetFrameListBaseAddr (
1172 IN USB2_HC_DEV
*HcDev
,
1173 IN UINT32 FrameBuffer
1177 Routine Description:
1179 Set base address of frame list first entry
1184 FrameBuffer - base address of first entry of frame list
1189 EFI_DEVICE_ERROR Fail
1196 IN USB2_HC_DEV
*HcDev
,
1197 IN EHCI_QH_ENTITY
*QhPtr
1201 Routine Description:
1203 Set address of first Async schedule Qh
1208 QhPtr - A pointer to first Qh in the Async schedule
1213 EFI_DEVICE_ERROR Fail
1219 SetCtrlDataStructSeg (
1220 IN USB2_HC_DEV
*HcDev
1224 Routine Description:
1226 Set address of first Async schedule Qh
1231 QhPtr - A pointer to first Qh in the Async schedule
1236 EFI_DEVICE_ERROR Fail
1243 IN USB2_HC_DEV
*HcDev
1247 Routine Description:
1249 Set Ehc port routing bit
1258 EFI_DEVICE_ERROR Fail
1264 EnablePeriodicSchedule (
1265 IN USB2_HC_DEV
*HcDev
1269 Routine Description:
1271 Enable periodic schedule
1280 EFI_DEVICE_ERROR Fail
1286 DisablePeriodicSchedule (
1287 IN USB2_HC_DEV
*HcDev
1291 Routine Description:
1293 Disable periodic schedule
1302 EFI_DEVICE_ERROR Fail
1308 EnableAsynchronousSchedule (
1309 IN USB2_HC_DEV
*HcDev
1313 Routine Description:
1315 Enable asynchrounous schedule
1324 EFI_DEVICE_ERROR Fail
1330 DisableAsynchronousSchedule (
1331 IN USB2_HC_DEV
*HcDev
1335 Routine Description:
1337 Disable asynchrounous schedule
1346 EFI_DEVICE_ERROR Fail
1352 StartScheduleExecution (
1353 IN USB2_HC_DEV
*HcDev
1357 Routine Description:
1359 Start Ehc schedule execution
1368 EFI_DEVICE_ERROR Fail
1375 IN USB2_HC_DEV
*HcDev
1379 Routine Description:
1390 EFI_DEVICE_ERROR Fail
1397 IN USB2_HC_DEV
*HcDev
1401 Routine Description:
1403 Clear Ehc all status bits
1412 EFI_DEVICE_ERROR Fail
1418 // EhciSched Functions
1421 InitialPeriodicFrameList (
1422 IN USB2_HC_DEV
*HcDev
,
1427 Routine Description:
1429 Initialize Periodic Schedule Frame List
1434 Length - Frame List Length
1439 EFI_DEVICE_ERROR Fail
1445 DeinitialPeriodicFrameList (
1446 IN USB2_HC_DEV
*HcDev
1450 Routine Description:
1452 Deinitialize Periodic Schedule Frame List
1466 CreatePollingTimer (
1467 IN USB2_HC_DEV
*HcDev
,
1468 IN EFI_EVENT_NOTIFY NotifyFunction
1472 Routine Description:
1474 Create Async Request Polling Timer
1479 NotifyFunction - Timer Notify Function
1484 EFI_DEVICE_ERROR Fail
1490 DestoryPollingTimer (
1491 IN USB2_HC_DEV
*HcDev
1495 Routine Description:
1497 Destory Async Request Polling Timer
1506 EFI_DEVICE_ERROR Fail
1513 IN USB2_HC_DEV
*HcDev
1517 Routine Description:
1519 Start Async Request Polling Timer
1528 EFI_DEVICE_ERROR Fail
1535 IN USB2_HC_DEV
*HcDev
1539 Routine Description:
1541 Stop Async Request Polling Timer
1550 EFI_DEVICE_ERROR Fail
1557 IN USB2_HC_DEV
*HcDev
,
1558 IN UINT8 DeviceAddr
,
1560 IN UINT8 DeviceSpeed
,
1561 IN UINTN MaxPacketLen
,
1562 OUT EHCI_QH_ENTITY
**QhPtrPtr
1566 Routine Description:
1568 Create Qh Structure and Pre-Initialize
1573 DeviceAddr - Address of Device
1574 Endpoint - Endpoint Number
1575 DeviceSpeed - Device Speed
1576 MaxPacketLen - Max Length of one Packet
1577 QhPtrPtr - A pointer of pointer to Qh for return
1582 EFI_DEVICE_ERROR Fail
1589 IN USB2_HC_DEV
*HcDev
,
1590 IN UINT8 DeviceAddr
,
1591 IN UINT8 DeviceSpeed
,
1592 IN UINTN MaxPacketLen
,
1593 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR
*Translator
,
1594 OUT EHCI_QH_ENTITY
**QhPtrPtr
1598 Routine Description:
1600 Create Qh for Control Transfer
1605 DeviceAddr - Address of Device
1606 DeviceSpeed - Device Speed
1607 MaxPacketLen - Max Length of one Packet
1608 Translator - Translator Transaction for SplitX
1609 QhPtrPtr - A pointer of pointer to Qh for return
1614 EFI_DEVICE_ERROR Fail
1621 IN USB2_HC_DEV
*HcDev
,
1622 IN UINT8 DeviceAddr
,
1623 IN UINT8 EndPointAddr
,
1624 IN UINT8 DeviceSpeed
,
1625 IN UINT8 DataToggle
,
1626 IN UINTN MaxPacketLen
,
1627 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR
*Translator
,
1628 OUT EHCI_QH_ENTITY
**QhPtrPtr
1632 Routine Description:
1634 Create Qh for Bulk Transfer
1639 DeviceAddr - Address of Device
1640 EndPointAddr - Address of Endpoint
1641 DeviceSpeed - Device Speed
1642 MaxPacketLen - Max Length of one Packet
1643 Translator - Translator Transaction for SplitX
1644 QhPtrPtr - A pointer of pointer to Qh for return
1649 EFI_DEVICE_ERROR Fail
1656 IN USB2_HC_DEV
*HcDev
,
1657 IN UINT8 DeviceAddr
,
1658 IN UINT8 EndPointAddr
,
1659 IN UINT8 DeviceSpeed
,
1660 IN UINT8 DataToggle
,
1661 IN UINTN MaxPacketLen
,
1663 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR
*Translator
,
1664 OUT EHCI_QH_ENTITY
**QhPtrPtr
1668 Routine Description:
1670 Create Qh for Control Transfer
1675 DeviceAddr - Address of Device
1676 EndPointAddr - Address of Endpoint
1677 DeviceSpeed - Device Speed
1678 MaxPacketLen - Max Length of one Packet
1679 Interval - value of interval
1680 Translator - Translator Transaction for SplitX
1681 QhPtrPtr - A pointer of pointer to Qh for return
1686 EFI_DEVICE_ERROR Fail
1693 IN USB2_HC_DEV
*HcDev
,
1694 IN EHCI_QH_ENTITY
*QhPtr
1698 Routine Description:
1700 Destory Qh Structure
1705 QhPtr - A pointer to Qh
1716 IN USB2_HC_DEV
*HcDev
,
1722 OUT EHCI_QTD_ENTITY
**QtdPtrPtr
1726 Routine Description:
1728 Create Qtd Structure and Pre-Initialize it
1733 DataPtr - A pointer to user data buffer to transfer
1734 DataLen - Length of user data to transfer
1735 PktId - Packet Identification of this Qtd
1736 Toggle - Data Toggle of this Qtd
1737 QtdStatus - Default value of status of this Qtd
1738 QtdPtrPtr - A pointer of pointer to Qtd for return
1743 EFI_OUT_OF_RESOURCES Cannot allocate resources
1750 IN USB2_HC_DEV
*HcDev
,
1751 IN UINT8
*DevReqPtr
,
1752 OUT EHCI_QTD_ENTITY
**QtdPtrPtr
1756 Routine Description:
1758 Create Qtd Structure for Setup
1763 DevReqPtr - A pointer to Device Request Data
1764 QtdPtrPtr - A pointer of pointer to Qtd for return
1769 EFI_OUT_OF_RESOURCES Cannot allocate resources
1776 IN USB2_HC_DEV
*HcDev
,
1781 OUT EHCI_QTD_ENTITY
**QtdPtrPtr
1785 Routine Description:
1787 Create Qtd Structure for data
1792 DataPtr - A pointer to user data buffer to transfer
1793 DataLen - Length of user data to transfer
1794 PktId - Packet Identification of this Qtd
1795 Toggle - Data Toggle of this Qtd
1796 QtdPtrPtr - A pointer of pointer to Qtd for return
1801 EFI_OUT_OF_RESOURCES Cannot allocate resources
1808 IN USB2_HC_DEV
*HcDev
,
1810 OUT EHCI_QTD_ENTITY
**QtdPtrPtr
1814 Routine Description:
1816 Create Qtd Structure for status
1821 PktId - Packet Identification of this Qtd
1822 QtdPtrPtr - A pointer of pointer to Qtd for return
1827 EFI_OUT_OF_RESOURCES Cannot allocate resources
1834 IN USB2_HC_DEV
*HcDev
,
1836 OUT EHCI_QTD_ENTITY
**QtdPtrPtr
1840 Routine Description:
1842 Create Qtd Structure for Alternative
1847 PktId - Packet Identification of this Qtd
1848 QtdPtrPtr - A pointer of pointer to Qtd for return
1853 EFI_OUT_OF_RESOURCES Cannot allocate resources
1860 IN USB2_HC_DEV
*HcDev
,
1862 IN UINT8
*RequestCursor
,
1863 IN UINT8
*DataCursor
,
1865 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR
*Translator
,
1866 OUT EHCI_QTD_ENTITY
**ControlQtdsHead
1870 Routine Description:
1872 Create Qtds list for Control Transfer
1877 DataPktId - Packet Identification of Data Qtds
1878 RequestCursor - A pointer to request structure buffer to transfer
1879 DataCursor - A pointer to user data buffer to transfer
1880 DataLen - Length of user data to transfer
1881 ControlQtdsHead - A pointer of pointer to first Qtd for control tranfer for return
1886 EFI_DEVICE_ERROR Fail
1892 CreateBulkOrInterruptQtds (
1893 IN USB2_HC_DEV
*HcDev
,
1895 IN UINT8
*DataCursor
,
1897 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR
*Translator
,
1898 OUT EHCI_QTD_ENTITY
**QtdsHead
1902 Routine Description:
1904 Create Qtds list for Bulk or Interrupt Transfer
1909 PktId - Packet Identification of Qtds
1910 DataCursor - A pointer to user data buffer to transfer
1911 DataLen - Length of user data to transfer
1912 DataToggle - Data Toggle to start
1913 Translator - Translator Transaction for SplitX
1914 QtdsHead - A pointer of pointer to first Qtd for control tranfer for return
1919 EFI_DEVICE_ERROR Fail
1926 IN USB2_HC_DEV
*HcDev
,
1927 IN EHCI_QTD_ENTITY
*FirstQtdPtr
1931 Routine Description:
1933 Destory all Qtds in the list
1938 FirstQtdPtr - A pointer to first Qtd in the list
1949 IN EHCI_QTD_ENTITY
*PreQtdPtr
,
1950 IN EHCI_QTD_ENTITY
*QtdPtr
1954 Routine Description:
1960 PreQtdPtr - A pointer to pre Qtd
1961 QtdPtr - A pointer to next Qtd
1972 IN EHCI_QTD_ENTITY
*FirstQtdPtr
,
1973 IN EHCI_QTD_ENTITY
*AltQtdPtr
1977 Routine Description:
1979 Link AlterQtds together
1983 FirstQtdPtr - A pointer to first Qtd in the list
1984 AltQtdPtr - A pointer to alternative Qtd
1994 IN EHCI_QH_ENTITY
*QhPtr
,
1995 IN EHCI_QTD_ENTITY
*QtdEntryPtr
1999 Routine Description:
2001 Link Qtds list to Qh
2005 QhPtr - A pointer to Qh
2006 QtdPtr - A pointer to first Qtd in the list
2017 IN USB2_HC_DEV
*HcDev
,
2018 IN EHCI_QH_ENTITY
*QhPtr
2022 Routine Description:
2024 Link Qh to Async Schedule List
2029 QhPtr - A pointer to Qh
2034 EFI_DEVICE_ERROR Fail
2040 UnlinkQhFromAsyncList (
2041 IN USB2_HC_DEV
*HcDev
,
2042 IN EHCI_QH_ENTITY
*QhPtr
2046 Routine Description:
2048 Unlink Qh from Async Schedule List
2053 QhPtr - A pointer to Qh
2058 EFI_DEVICE_ERROR Fail
2064 LinkQhToPeriodicList (
2065 IN USB2_HC_DEV
*HcDev
,
2066 IN EHCI_QH_ENTITY
*QhPtr
2070 Routine Description:
2072 Link Qh to Periodic Schedule List
2077 QhPtr - A pointer to Qh
2087 UnlinkQhFromPeriodicList (
2088 IN USB2_HC_DEV
*HcDev
,
2089 IN EHCI_QH_ENTITY
*QhPtr
,
2094 Routine Description:
2096 Unlink Qh from Periodic Schedule List
2101 QhPtr - A pointer to Qh
2102 Interval - Interval of this periodic transfer
2112 LinkToAsyncReqeust (
2113 IN USB2_HC_DEV
*HcDev
,
2114 IN EHCI_ASYNC_REQUEST
*AsyncRequestPtr
2118 Routine Description:
2120 Llink AsyncRequest Entry to Async Request List
2125 AsyncRequestPtr - A pointer to Async Request Entry
2135 UnlinkFromAsyncReqeust (
2136 IN USB2_HC_DEV
*HcDev
,
2137 IN EHCI_ASYNC_REQUEST
*AsyncRequestPtr
2141 Routine Description:
2143 Unlink AsyncRequest Entry from Async Request List
2148 AsyncRequestPtr - A pointer to Async Request Entry
2159 IN EHCI_QTD_ENTITY
*FirstQtdPtr
2163 Routine Description:
2165 Number of Qtds in the list
2169 FirstQtdPtr - A pointer to first Qtd in the list
2173 Number of Qtds in the list
2179 GetNumberOfTransaction (
2180 IN UINTN SizeOfData
,
2181 IN UINTN SizeOfTransaction
2185 Routine Description:
2187 Number of Transactions in one Qtd
2191 SizeOfData - Size of one Qtd
2192 SizeOfTransaction - Size of one Transaction
2196 Number of Transactions in this Qtd
2203 IN UINT8
*BufferCursor
2207 Routine Description:
2213 BufferCursor - BufferCursor of the Qtd
2223 GetApproxiOfInterval (
2228 Routine Description:
2230 Get the approximate value in the 2 index sequence
2234 Interval - the value of interval
2238 approximate value of interval in the 2 index sequence
2245 IN EHCI_QTD_HW
*HwQtdPtr
2249 Routine Description:
2251 Get Qtd next pointer field
2255 HwQtdPtr - A pointer to hardware Qtd structure
2259 A pointer to next hardware Qtd structure
2266 IN EHCI_QTD_HW
*HwQtdPtr
2270 Routine Description:
2272 Whether Qtd status is active or not
2276 HwQtdPtr - A pointer to hardware Qtd structure
2288 IN EHCI_QTD_HW
*HwQtdPtr
2292 Routine Description:
2294 Whether Qtd status is halted or not
2298 HwQtdPtr - A pointer to hardware Qtd structure
2309 IsQtdStatusBufferError (
2310 IN EHCI_QTD_HW
*HwQtdPtr
2314 Routine Description:
2316 Whether Qtd status is buffer error or not
2320 HwQtdPtr - A pointer to hardware Qtd structure
2325 FALSE No buffer error
2331 IsQtdStatusBabbleError (
2332 IN EHCI_QTD_HW
*HwQtdPtr
2336 Routine Description:
2338 Whether Qtd status is babble error or not
2342 HwQtdPtr - A pointer to hardware Qtd structure
2347 FALSE No babble error
2353 IsQtdStatusTransactionError (
2354 IN EHCI_QTD_HW
*HwQtdPtr
2358 Routine Description:
2360 Whether Qtd status is transaction error or not
2364 HwQtdPtr - A pointer to hardware Qtd structure
2368 TRUE Transaction error
2369 FALSE No transaction error
2376 IN UINT8 EndPointAddress
2380 Routine Description:
2382 Whether is a DataIn direction transfer
2386 EndPointAddress - address of the endpoint
2398 IN USB2_HC_DEV
*HcDev
,
2399 IN EFI_USB_DATA_DIRECTION TransferDirection
,
2401 IN OUT UINTN
*DataLength
,
2403 OUT UINT8
**DataCursor
,
2408 Routine Description:
2410 Map address of user data buffer
2415 TransferDirection - direction of transfer
2416 Data - A pointer to user data buffer
2417 DataLength - length of user data
2418 PktId - Packte Identificaion
2419 DataCursor - mapped address to return
2420 DataMap - identificaion of this mapping to return
2425 EFI_DEVICE_ERROR Fail
2432 IN USB2_HC_DEV
*HcDev
,
2433 IN OUT VOID
*Request
,
2434 OUT UINT8
**RequestCursor
,
2435 OUT VOID
**RequestMap
2439 Routine Description:
2441 Map address of request structure buffer
2446 Request - A pointer to request structure
2447 RequestCursor - Mapped address of request structure to return
2448 RequestMap - Identificaion of this mapping to return
2453 EFI_DEVICE_ERROR Fail
2459 SetQtdBufferPointer (
2460 IN EHCI_QTD_HW
*QtdHwPtr
,
2466 Routine Description:
2468 Set data buffer pointers in Qtd
2472 QtdHwPtr - A pointer to Qtd hardware structure
2473 DataPtr - A pointer to user data buffer
2474 DataLen - Length of the user data buffer
2484 GetQtdAlternateNextPointer (
2485 IN EHCI_QTD_HW
*HwQtdPtr
2489 Routine Description:
2491 Get Qtd alternate next pointer field
2495 HwQtdPtr - A pointer to hardware Qtd structure
2499 A pointer to hardware alternate Qtd
2506 IN EHCI_QH_ENTITY
*QhPtr
2510 Routine Description:
2512 Zero out the fields in Qh structure
2516 QhPtr - A pointer to Qh structure
2526 UpdateAsyncRequestTransfer (
2527 IN EHCI_ASYNC_REQUEST
*AsyncRequestPtr
,
2528 IN UINT32 TransferResult
,
2533 Routine Description:
2535 Update asynchronous request transfer
2539 AsyncRequestPtr - A pointer to async request
2540 TransferResult - transfer result
2541 ErrQtdPos - postion of error Qtd
2552 DeleteAsyncRequestTransfer (
2553 IN USB2_HC_DEV
*HcDev
,
2554 IN UINT8 DeviceAddress
,
2555 IN UINT8 EndPointAddress
,
2556 OUT UINT8
*DataToggle
2560 Routine Description:
2562 Delete all asynchronous request transfer
2567 DeviceAddress - address of usb device
2568 EndPointAddress - address of endpoint
2569 DataToggle - stored data toggle
2574 EFI_DEVICE_ERROR Fail
2580 CleanUpAllAsyncRequestTransfer (
2581 IN USB2_HC_DEV
*HcDev
2585 Routine Description:
2587 Clean up all asynchronous request transfer
2601 IN USB2_HC_DEV
*HcDev
,
2602 IN BOOLEAN IsControl
,
2603 IN EHCI_QH_ENTITY
*QhPtr
,
2604 IN OUT UINTN
*ActualLen
,
2605 OUT UINT8
*DataToggle
,
2607 OUT UINT32
*TransferResult
2611 Routine Description:
2613 Execute Bulk or SyncInterrupt Transfer
2618 IsControl - Is control transfer or not
2619 QhPtr - A pointer to Qh
2620 ActualLen - Actual transfered Len
2621 DataToggle - Data Toggle
2622 TimeOut - TimeOut threshold
2623 TransferResult - Transfer result
2628 EFI_DEVICE_ERROR Error
2634 CheckQtdsTransferResult (
2635 IN BOOLEAN IsControl
,
2636 IN EHCI_QH_ENTITY
*QhPtr
,
2638 OUT UINTN
*ErrQtdPos
,
2639 OUT UINTN
*ActualLen
2643 Routine Description:
2645 Check transfer result of Qtds
2649 IsControl - Is control transfer or not
2650 QhPtr - A pointer to Qh
2651 Result - Transfer result
2652 ErrQtdPos - Error TD Position
2653 ActualLen - Actual Transfer Size
2664 AsyncRequestMoniter (
2670 Routine Description:
2672 Interrupt transfer periodic check handler
2676 Event - Interrupt event
2677 Context - Pointer to USB2_HC_DEV
2682 EFI_DEVICE_ERROR Fail