3 The definition for UHCI register operation routines.
5 Copyright (c) 2007, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #ifndef _EFI_UHCI_QUEUE_H_
17 #define _EFI_UHCI_QUEUE_H_
20 // Macroes used to set various links in UHCI's driver.
21 // In this UHCI driver, QH's horizontal link always pointers to other QH,
22 // and its vertical link always pointers to TD. TD's next pointer always
23 // pointers to other sibling TD. Frame link always pointers to QH because
24 // ISO transfer isn't supported.
26 // We should use UINT32 to access these pointers to void race conditions
29 #define QH_HLINK(Pointer, Terminate) \
30 (((UINT32) ((UINTN) (Pointer)) & 0xFFFFFFF0) | 0x02 | ((Terminate) ? 0x01 : 0))
32 #define QH_VLINK(Pointer, Terminate) \
33 (((UINT32) ((UINTN) (Pointer)) & 0xFFFFFFF0) | ((Terminate) ? 0x01 : 0))
35 #define TD_LINK(Pointer, VertFirst, Terminate) \
36 (((UINT32) ((UINTN) (Pointer)) & 0xFFFFFFF0) | \
37 ((VertFirst) ? 0x04 : 0) | ((Terminate) ? 0x01 : 0))
39 #define LINK_TERMINATED(Link) (((Link) & 0x01) != 0)
41 #define UHCI_ADDR(QhOrTd) ((VOID *) (UINTN) ((QhOrTd) & 0xFFFFFFF0))
45 // Both links in QH has this internal structure:
46 // Next pointer: 28, Reserved: 2, NextIsQh: 1, Terminate: 1
47 // This is the same as frame list entry.
55 // Next link in TD has this internal structure:
56 // Next pointer: 28, Reserved: 1, Vertical First: 1, NextIsQh: 1, Terminate: 1
60 UINT32 ActualLen
: 11;
66 UINT32 ErrorCount
: 2;
67 UINT32 ShortPacket
: 1;
70 UINT32 DeviceAddr
: 7;
72 UINT32 DataToggle
: 1;
74 UINT32 MaxPacketLen
: 11;
79 typedef struct _UHCI_TD_SW UHCI_TD_SW
;
80 typedef struct _UHCI_QH_SW UHCI_QH_SW
;
100 @param Qh The queue head for the TD to link to.
101 @param Td The TD to link.
115 Unlink TD from the QH.
117 @param Qh The queue head to unlink from.
118 @param Td The TD to unlink.
132 Map address of request structure buffer.
134 @param Uhc The UHCI device.
135 @param Request The user request buffer.
136 @param MappedAddr Mapped address of request.
137 @param Map Identificaion of this mapping to return.
139 @return EFI_SUCCESS Success.
140 @return EFI_DEVICE_ERROR Fail to map the user request.
146 IN OUT VOID
*Request
,
147 OUT UINT8
**MappedAddr
,
154 Map address of user data buffer.
156 @param Uhc The UHCI device.
157 @param Direction Direction of the data transfer.
158 @param Data The user data buffer.
159 @param Len Length of the user data.
160 @param PktId Packet identificaion.
161 @param MappedAddr Mapped address to return.
162 @param Map Identificaion of this mapping to return.
164 @return EFI_SUCCESS Success.
165 @return EFI_DEVICE_ERROR Fail to map the user data.
171 IN EFI_USB_DATA_DIRECTION Direction
,
175 OUT UINT8
**MappedAddr
,
182 Delete a list of TDs.
184 @param Uhc The UHCI device.
185 @param FirstTd TD link list head.
193 IN UHCI_TD_SW
*FirstTd
199 Create an initialize a new queue head.
201 @param Uhc The UHCI device.
202 @param Interval The polling interval for the queue.
204 @return The newly created queue header.
216 Create Tds list for Control Transfer.
218 @param Uhc The UHCI device.
219 @param DeviceAddr The device address.
220 @param DataPktId Packet Identification of Data Tds.
221 @param Request A pointer to request structure buffer to transfer.
222 @param Data A pointer to user data buffer to transfer.
223 @param DataLen Length of user data to transfer.
224 @param MaxPacket Maximum packet size for control transfer.
225 @param IsLow Full speed or low speed.
227 @return The Td list head for the control transfer.
245 Create Tds list for Bulk/Interrupt Transfer.
247 @param Uhc USB_HC_DEV.
248 @param DevAddr Address of Device.
249 @param EndPoint Endpoint Number.
250 @param PktId Packet Identification of Data Tds.
251 @param Data A pointer to user data buffer to transfer.
252 @param DataLen Length of user data to transfer.
253 @param DataToggle Data Toggle Pointer.
254 @param MaxPacket Maximum packet size for Bulk/Interrupt transfer.
255 @param IsLow Is Low Speed Device.
257 @return The Tds list head for the bulk transfer.
261 UhciCreateBulkOrIntTds (
268 IN OUT UINT8
*DataToggle
,