3 Copyright (c) 2007, 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.
18 The definition for UHCI register operation routines.
25 #ifndef _EFI_UHCI_QUEUE_H_
26 #define _EFI_UHCI_QUEUE_H_
29 // Macroes used to set various links in UHCI's driver.
30 // In this UHCI driver, QH's horizontal link always pointers to other QH,
31 // and its vertical link always pointers to TD. TD's next pointer always
32 // pointers to other sibling TD. Frame link always pointers to QH because
33 // ISO transfer isn't supported.
35 // We should use UINT32 to access these pointers to void race conditions
38 #define QH_HLINK(Pointer, Terminate) \
39 (((UINT32) ((UINTN) (Pointer)) & 0xFFFFFFF0) | 0x02 | ((Terminate) ? 0x01 : 0))
41 #define QH_VLINK(Pointer, Terminate) \
42 (((UINT32) ((UINTN) (Pointer)) & 0xFFFFFFF0) | ((Terminate) ? 0x01 : 0))
44 #define TD_LINK(Pointer, VertFirst, Terminate) \
45 (((UINT32) ((UINTN) (Pointer)) & 0xFFFFFFF0) | \
46 ((VertFirst) ? 0x04 : 0) | ((Terminate) ? 0x01 : 0))
48 #define LINK_TERMINATED(Link) (((Link) & 0x01) != 0)
50 #define UHCI_ADDR(QhOrTd) ((VOID *) (UINTN) ((QhOrTd) & 0xFFFFFFF0))
54 // Both links in QH has this internal structure:
55 // Next pointer: 28, Reserved: 2, NextIsQh: 1, Terminate: 1
56 // This is the same as frame list entry.
64 // Next link in TD has this internal structure:
65 // Next pointer: 28, Reserved: 1, Vertical First: 1, NextIsQh: 1, Terminate: 1
69 UINT32 ActualLen
: 11;
75 UINT32 ErrorCount
: 2;
76 UINT32 ShortPacket
: 1;
79 UINT32 DeviceAddr
: 7;
81 UINT32 DataToggle
: 1;
83 UINT32 MaxPacketLen
: 11;
88 typedef struct _UHCI_TD_SW UHCI_TD_SW
;
89 typedef struct _UHCI_QH_SW UHCI_QH_SW
;
109 @param Qh The queue head for the TD to link to
110 @param Td The TD to link
124 Unlink TD from the QH
126 @param Qh The queue head to unlink from
127 @param Td The TD to unlink
141 Map address of request structure buffer
143 @param Uhc The UHCI device
144 @param Request The user request buffer
145 @param MappedAddr Mapped address of request
146 @param Map Identificaion of this mapping to return
148 @return EFI_SUCCESS : Success
149 @return EFI_DEVICE_ERROR : Fail to map the user request
155 IN OUT VOID
*Request
,
156 OUT UINT8
**MappedAddr
,
163 Map address of user data buffer
165 @param Uhc The UHCI device
166 @param Direction direction of the data transfer
167 @param Data The user data buffer
168 @param Len Length of the user data
169 @param PktId Packet identificaion
170 @param MappedAddr mapped address to return
171 @param Map identificaion of this mapping to return
173 @return EFI_SUCCESS : Success
174 @return EFI_DEVICE_ERROR : Fail to map the user data
180 IN EFI_USB_DATA_DIRECTION Direction
,
184 OUT UINT8
**MappedAddr
,
193 @param Uhc The UHCI device
194 @param FirstTd TD link list head
202 IN UHCI_TD_SW
*FirstTd
208 Create an initialize a new queue head
210 @param Uhc The UHCI device
211 @param Interval The polling interval for the queue
213 @return The newly created queue header
225 Create Tds list for Control Transfer
227 @param Uhc The UHCI device
228 @param DeviceAddr The device address
229 @param DataPktId Packet Identification of Data Tds
230 @param Request A pointer to request structure buffer to transfer
231 @param Data A pointer to user data buffer to transfer
232 @param DataLen Length of user data to transfer
233 @param MaxPacket Maximum packet size for control transfer
234 @param IsLow Full speed or low speed
236 @return The Td list head for the control transfer
254 Create Tds list for Bulk/Interrupt Transfer
256 @param Uhc USB_HC_DEV
257 @param DevAddr Address of Device
258 @param EndPoint Endpoint Number
259 @param PktId Packet Identification of Data Tds
260 @param Data A pointer to user data buffer to transfer
261 @param DataLen Length of user data to transfer
262 @param DataToggle Data Toggle Pointer
263 @param MaxPacket Maximum packet size for Bulk/Interrupt transfer
264 @param IsLow Is Low Speed Device
266 @return The Tds list head for the bulk transfer
270 UhciCreateBulkOrIntTds (
277 IN OUT UINT8
*DataToggle
,