3 The definition for UHCI register operation routines.
5 Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #ifndef _EFI_UHCI_QUEUE_H_
11 #define _EFI_UHCI_QUEUE_H_
14 // Macroes used to set various links in UHCI's driver.
15 // In this UHCI driver, QH's horizontal link always pointers to other QH,
16 // and its vertical link always pointers to TD. TD's next pointer always
17 // pointers to other sibling TD. Frame link always pointers to QH because
18 // ISO transfer isn't supported.
20 // We should use UINT32 to access these pointers to void race conditions
23 #define QH_HLINK(Pointer, Terminate) \
24 (((UINT32) ((UINTN) (Pointer)) & 0xFFFFFFF0) | 0x02 | ((Terminate) ? 0x01 : 0))
26 #define QH_VLINK(Pointer, Terminate) \
27 (((UINT32) ((UINTN) (Pointer)) & 0xFFFFFFF0) | ((Terminate) ? 0x01 : 0))
29 #define TD_LINK(Pointer, VertFirst, Terminate) \
30 (((UINT32) ((UINTN) (Pointer)) & 0xFFFFFFF0) | \
31 ((VertFirst) ? 0x04 : 0) | ((Terminate) ? 0x01 : 0))
33 #define LINK_TERMINATED(Link) (((Link) & 0x01) != 0)
35 #define UHCI_ADDR(QhOrTd) ((VOID *) (UINTN) ((QhOrTd) & 0xFFFFFFF0))
39 // Both links in QH has this internal structure:
40 // Next pointer: 28, Reserved: 2, NextIsQh: 1, Terminate: 1
41 // This is the same as frame list entry.
49 // Next link in TD has this internal structure:
50 // Next pointer: 28, Reserved: 1, Vertical First: 1, NextIsQh: 1, Terminate: 1
54 UINT32 ActualLen
: 11;
60 UINT32 ErrorCount
: 2;
61 UINT32 ShortPacket
: 1;
64 UINT32 DeviceAddr
: 7;
66 UINT32 DataToggle
: 1;
68 UINT32 MaxPacketLen
: 11;
73 typedef struct _UHCI_TD_SW UHCI_TD_SW
;
74 typedef struct _UHCI_QH_SW UHCI_QH_SW
;
93 @param Uhc The UHCI device.
94 @param Qh The queue head for the TD to link to.
95 @param Td The TD to link.
106 Unlink TD from the QH.
108 @param Qh The queue head to unlink from.
109 @param Td The TD to unlink.
121 Map address of request structure buffer.
123 @param Uhc The UHCI device.
124 @param Request The user request buffer.
125 @param MappedAddr Mapped address of request.
126 @param Map Identificaion of this mapping to return.
128 @return EFI_SUCCESS Success.
129 @return EFI_DEVICE_ERROR Fail to map the user request.
135 IN OUT VOID
*Request
,
136 OUT UINT8
**MappedAddr
,
141 Map address of user data buffer.
143 @param Uhc The UHCI device.
144 @param Direction Direction of the data transfer.
145 @param Data The user data buffer.
146 @param Len Length of the user data.
147 @param PktId Packet identificaion.
148 @param MappedAddr Mapped address to return.
149 @param Map Identificaion of this mapping to return.
151 @return EFI_SUCCESS Success.
152 @return EFI_DEVICE_ERROR Fail to map the user data.
158 IN EFI_USB_DATA_DIRECTION Direction
,
162 OUT UINT8
**MappedAddr
,
167 Delete a list of TDs.
169 @param Uhc The UHCI device.
170 @param FirstTd TD link list head.
178 IN UHCI_TD_SW
*FirstTd
182 Create an initialize a new queue head.
184 @param Uhc The UHCI device.
185 @param Interval The polling interval for the queue.
187 @return The newly created queue header.
197 Create Tds list for Control Transfer.
199 @param Uhc The UHCI device.
200 @param DeviceAddr The device address.
201 @param DataPktId Packet Identification of Data Tds.
202 @param Request A pointer to cpu memory address of request structure buffer to transfer.
203 @param RequestPhy A pointer to pci memory address of request structure buffer to transfer.
204 @param Data A pointer to cpu memory address of user data buffer to transfer.
205 @param DataPhy A pointer to pci memory address of user data buffer to transfer.
206 @param DataLen Length of user data to transfer.
207 @param MaxPacket Maximum packet size for control transfer.
208 @param IsLow Full speed or low speed.
210 @return The Td list head for the control transfer.
219 IN UINT8
*RequestPhy
,
228 Create Tds list for Bulk/Interrupt Transfer.
230 @param Uhc USB_HC_DEV.
231 @param DevAddr Address of Device.
232 @param EndPoint Endpoint Number.
233 @param PktId Packet Identification of Data Tds.
234 @param Data A pointer to cpu memory address of user data buffer to transfer.
235 @param DataPhy A pointer to pci memory address of user data buffer to transfer.
236 @param DataLen Length of user data to transfer.
237 @param DataToggle Data Toggle Pointer.
238 @param MaxPacket Maximum packet size for Bulk/Interrupt transfer.
239 @param IsLow Is Low Speed Device.
241 @return The Tds list head for the bulk transfer.
245 UhciCreateBulkOrIntTds (
253 IN OUT UINT8
*DataToggle
,