]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Bus/Pci/UhciDxe/UhciQueue.h
Update some module INF files in MdeModulePkg to "UEFI_DRIVER"
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / UhciDxe / UhciQueue.h
1 /** @file
2
3 The definition for UHCI register operation routines.
4
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
10
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.
13
14 **/
15
16 #ifndef _EFI_UHCI_QUEUE_H_
17 #define _EFI_UHCI_QUEUE_H_
18
19 //
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.
25 //
26 // We should use UINT32 to access these pointers to void race conditions
27 // with hardware.
28 //
29 #define QH_HLINK(Pointer, Terminate) \
30 (((UINT32) ((UINTN) (Pointer)) & 0xFFFFFFF0) | 0x02 | ((Terminate) ? 0x01 : 0))
31
32 #define QH_VLINK(Pointer, Terminate) \
33 (((UINT32) ((UINTN) (Pointer)) & 0xFFFFFFF0) | ((Terminate) ? 0x01 : 0))
34
35 #define TD_LINK(Pointer, VertFirst, Terminate) \
36 (((UINT32) ((UINTN) (Pointer)) & 0xFFFFFFF0) | \
37 ((VertFirst) ? 0x04 : 0) | ((Terminate) ? 0x01 : 0))
38
39 #define LINK_TERMINATED(Link) (((Link) & 0x01) != 0)
40
41 #define UHCI_ADDR(QhOrTd) ((VOID *) (UINTN) ((QhOrTd) & 0xFFFFFFF0))
42
43 #pragma pack(1)
44 //
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.
48 //
49 typedef struct {
50 UINT32 HorizonLink;
51 UINT32 VerticalLink;
52 } UHCI_QH_HW;
53
54 //
55 // Next link in TD has this internal structure:
56 // Next pointer: 28, Reserved: 1, Vertical First: 1, NextIsQh: 1, Terminate: 1
57 //
58 typedef struct {
59 UINT32 NextLink;
60 UINT32 ActualLen : 11;
61 UINT32 Reserved1 : 5;
62 UINT32 Status : 8;
63 UINT32 IntOnCpl : 1;
64 UINT32 IsIsoch : 1;
65 UINT32 LowSpeed : 1;
66 UINT32 ErrorCount : 2;
67 UINT32 ShortPacket : 1;
68 UINT32 Reserved2 : 2;
69 UINT32 PidCode : 8;
70 UINT32 DeviceAddr : 7;
71 UINT32 EndPoint : 4;
72 UINT32 DataToggle : 1;
73 UINT32 Reserved3 : 1;
74 UINT32 MaxPacketLen: 11;
75 UINT32 DataBuffer;
76 } UHCI_TD_HW;
77 #pragma pack()
78
79 typedef struct _UHCI_TD_SW UHCI_TD_SW;
80 typedef struct _UHCI_QH_SW UHCI_QH_SW;
81
82 struct _UHCI_QH_SW {
83 UHCI_QH_HW QhHw;
84 UHCI_QH_SW *NextQh;
85 UHCI_TD_SW *TDs;
86 UINTN Interval;
87 };
88
89 struct _UHCI_TD_SW {
90 UHCI_TD_HW TdHw;
91 UHCI_TD_SW *NextTd;
92 UINT8 *Data;
93 UINT16 DataLen;
94 };
95
96
97 /**
98 Link the TD To QH.
99
100 @param Qh The queue head for the TD to link to.
101 @param Td The TD to link.
102
103 @return None.
104
105 **/
106 VOID
107 UhciLinkTdToQh (
108 IN UHCI_QH_SW *Qh,
109 IN UHCI_TD_SW *Td
110 )
111 ;
112
113
114 /**
115 Unlink TD from the QH.
116
117 @param Qh The queue head to unlink from.
118 @param Td The TD to unlink.
119
120 @return None.
121
122 **/
123 VOID
124 UhciUnlinkTdFromQh (
125 IN UHCI_QH_SW *Qh,
126 IN UHCI_TD_SW *Td
127 )
128 ;
129
130
131 /**
132 Map address of request structure buffer.
133
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.
138
139 @return EFI_SUCCESS Success.
140 @return EFI_DEVICE_ERROR Fail to map the user request.
141
142 **/
143 EFI_STATUS
144 UhciMapUserRequest (
145 IN USB_HC_DEV *Uhc,
146 IN OUT VOID *Request,
147 OUT UINT8 **MappedAddr,
148 OUT VOID **Map
149 )
150 ;
151
152
153 /**
154 Map address of user data buffer.
155
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.
163
164 @return EFI_SUCCESS Success.
165 @return EFI_DEVICE_ERROR Fail to map the user data.
166
167 **/
168 EFI_STATUS
169 UhciMapUserData (
170 IN USB_HC_DEV *Uhc,
171 IN EFI_USB_DATA_DIRECTION Direction,
172 IN VOID *Data,
173 IN OUT UINTN *Len,
174 OUT UINT8 *PktId,
175 OUT UINT8 **MappedAddr,
176 OUT VOID **Map
177 )
178 ;
179
180
181 /**
182 Delete a list of TDs.
183
184 @param Uhc The UHCI device.
185 @param FirstTd TD link list head.
186
187 @return None.
188
189 **/
190 VOID
191 UhciDestoryTds (
192 IN USB_HC_DEV *Uhc,
193 IN UHCI_TD_SW *FirstTd
194 )
195 ;
196
197
198 /**
199 Create an initialize a new queue head.
200
201 @param Uhc The UHCI device.
202 @param Interval The polling interval for the queue.
203
204 @return The newly created queue header.
205
206 **/
207 UHCI_QH_SW *
208 UhciCreateQh (
209 IN USB_HC_DEV *Uhc,
210 IN UINTN Interval
211 )
212 ;
213
214
215 /**
216 Create Tds list for Control Transfer.
217
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.
226
227 @return The Td list head for the control transfer.
228
229 **/
230 UHCI_TD_SW *
231 UhciCreateCtrlTds (
232 IN USB_HC_DEV *Uhc,
233 IN UINT8 DeviceAddr,
234 IN UINT8 DataPktId,
235 IN UINT8 *Request,
236 IN UINT8 *Data,
237 IN UINTN DataLen,
238 IN UINT8 MaxPacket,
239 IN BOOLEAN IsLow
240 )
241 ;
242
243
244 /**
245 Create Tds list for Bulk/Interrupt Transfer.
246
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.
256
257 @return The Tds list head for the bulk transfer.
258
259 **/
260 UHCI_TD_SW *
261 UhciCreateBulkOrIntTds (
262 IN USB_HC_DEV *Uhc,
263 IN UINT8 DevAddr,
264 IN UINT8 EndPoint,
265 IN UINT8 PktId,
266 IN UINT8 *Data,
267 IN UINTN DataLen,
268 IN OUT UINT8 *DataToggle,
269 IN UINT8 MaxPacket,
270 IN BOOLEAN IsLow
271 )
272 ;
273
274 #endif