2 Private Header file for Usb Host Controller PEIM
4 Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions
8 of the BSD License which accompanies this distribution. The
9 full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #ifndef _EFI_EHCI_URB_H_
18 #define _EFI_EHCI_URB_H_
20 typedef struct _PEI_EHC_QTD PEI_EHC_QTD
;
21 typedef struct _PEI_EHC_QH PEI_EHC_QH
;
22 typedef struct _PEI_URB PEI_URB
;
24 #define EHC_CTRL_TRANSFER 0x01
25 #define EHC_BULK_TRANSFER 0x02
26 #define EHC_INT_TRANSFER_SYNC 0x04
27 #define EHC_INT_TRANSFER_ASYNC 0x08
29 #define EHC_QTD_SIG SIGNATURE_32 ('U', 'S', 'B', 'T')
30 #define EHC_QH_SIG SIGNATURE_32 ('U', 'S', 'B', 'H')
31 #define EHC_URB_SIG SIGNATURE_32 ('U', 'S', 'B', 'R')
34 // Hardware related bit definitions
36 #define EHC_TYPE_ITD 0x00
37 #define EHC_TYPE_QH 0x02
38 #define EHC_TYPE_SITD 0x04
39 #define EHC_TYPE_FSTN 0x06
41 #define QH_NAK_RELOAD 3
42 #define QH_HSHBW_MULTI 1
45 #define QTD_PID_OUTPUT 0x00
46 #define QTD_PID_INPUT 0x01
47 #define QTD_PID_SETUP 0x02
49 #define QTD_STAT_DO_OUT 0
50 #define QTD_STAT_DO_SS 0
51 #define QTD_STAT_DO_PING 0x01
52 #define QTD_STAT_DO_CS 0x02
53 #define QTD_STAT_TRANS_ERR 0x08
54 #define QTD_STAT_BABBLE_ERR 0x10
55 #define QTD_STAT_BUFF_ERR 0x20
56 #define QTD_STAT_HALTED 0x40
57 #define QTD_STAT_ACTIVE 0x80
58 #define QTD_STAT_ERR_MASK (QTD_STAT_TRANS_ERR | QTD_STAT_BABBLE_ERR | QTD_STAT_BUFF_ERR)
60 #define QTD_MAX_BUFFER 4
61 #define QTD_BUF_LEN 4096
62 #define QTD_BUF_MASK 0x0FFF
64 #define QH_MICROFRAME_0 0x01
65 #define QH_MICROFRAME_1 0x02
66 #define QH_MICROFRAME_2 0x04
67 #define QH_MICROFRAME_3 0x08
68 #define QH_MICROFRAME_4 0x10
69 #define QH_MICROFRAME_5 0x20
70 #define QH_MICROFRAME_6 0x40
71 #define QH_MICROFRAME_7 0x80
73 #define USB_ERR_SHORT_PACKET 0x200
76 // Fill in the hardware link point: pass in a EHC_QH/QH_HW
77 // pointer to QH_LINK; A EHC_QTD/QTD_HW pointer to QTD_LINK
79 #define QH_LINK(Addr, Type, Term) \
80 ((UINT32) ((EHC_LOW_32BIT (Addr) & 0xFFFFFFE0) | (Type) | ((Term) ? 1 : 0)))
82 #define QTD_LINK(Addr, Term) QH_LINK((Addr), 0, (Term))
85 // The defination of EHCI hardware used data structure for
86 // little endian architecture. The QTD and QH structures
87 // are required to be 32 bytes aligned. Don't add members
88 // to the head of the associated software strucuture.
100 UINT32 TotalBytes
: 15;
101 UINT32 DataToggle
: 1;
110 // Endpoint capabilities/Characteristics DWord 1 and DWord 2
112 UINT32 DeviceAddr
: 7;
117 UINT32 ReclaimHead
: 1;
118 UINT32 MaxPacketLen
: 11;
120 UINT32 NakReload
: 4;
126 UINT32 Multiplier
: 2;
129 // Transaction execution overlay area
140 UINT32 TotalBytes
: 15;
141 UINT32 DataToggle
: 1;
150 // Endpoint address and its capabilities
152 typedef struct _USB_ENDPOINT
{
154 UINT8 EpAddr
; // Endpoint address, no direction encoded in
155 EFI_USB_DATA_DIRECTION Direction
;
160 UINT8 Toggle
; // Data toggle, not used for control transfer
162 UINTN PollRate
; // Polling interval used by EHCI
166 // Software QTD strcture, this is used to manage all the
167 // QTD generated from a URB. Don't add fields before QtdHw.
169 struct _PEI_EHC_QTD
{
172 EFI_LIST_ENTRY QtdList
; // The list of QTDs to one end point
173 UINT8
*Data
; // Buffer of the original data
174 UINTN DataLen
; // Original amount of data in this QTD
180 // Software QH structure. All three different transaction types
181 // supported by UEFI USB, that is the control/bulk/interrupt
182 // transfers use the queue head and queue token strcuture.
184 // Interrupt QHs are linked to periodic frame list in the reversed
185 // 2^N tree. Each interrupt QH is linked to the list starting at
186 // frame 0. There is a dummy interrupt QH linked to each frame as
187 // a sentinental whose polling interval is 1. Synchronous interrupt
188 // transfer is linked after this dummy QH.
190 // For control/bulk transfer, only synchronous (in the sense of UEFI)
191 // transfer is supported. A dummy QH is linked to EHCI AsyncListAddr
192 // as the reclamation header. New transfer is inserted after this QH.
197 PEI_EHC_QH
*NextQh
; // The queue head pointed to by horizontal link
198 EFI_LIST_ENTRY Qtds
; // The list of QTDs to this queue head
203 // URB (Usb Request Block) contains information for all kinds of
208 EFI_LIST_ENTRY UrbList
;
211 // Transaction information
214 EFI_USB_DEVICE_REQUEST
*Request
; // Control transfer only
215 VOID
*RequestPhy
; // Address of the mapped request
219 VOID
*DataPhy
; // Address of the mapped user data
221 EFI_ASYNC_USB_TRANSFER_CALLBACK Callback
;
230 // Transaction result
233 UINTN Completed
; // completed data length
238 Delete a single asynchronous interrupt transfer for
239 the device and endpoint.
241 @param Ehc The EHCI device.
242 @param Data Current data not associated with a QTD.
243 @param DataLen The length of the data.
244 @param PktId Packet ID to use in the QTD.
245 @param Toggle Data toggle to use in the QTD.
246 @param MaxPacket Maximu packet length of the endpoint.
248 @retval the pointer to the created QTD or NULL if failed to create one.
253 IN PEI_USB2_HC_DEV
*Ehc
,
263 Allocate and initialize a EHCI queue head.
265 @param Ehci The EHCI device.
266 @param Ep The endpoint to create queue head for.
268 @retval the pointer to the created queue head or NULL if failed to create one.
273 IN PEI_USB2_HC_DEV
*Ehci
,
279 Free an allocated URB. It is possible for it to be partially inited.
281 @param Ehc The EHCI device.
282 @param Urb The URB to free.
287 IN PEI_USB2_HC_DEV
*Ehc
,
293 Create a new URB and its associated QTD.
295 @param Ehc The EHCI device.
296 @param DevAddr The device address.
297 @param EpAddr Endpoint addrress & its direction.
298 @param DevSpeed The device speed.
299 @param Toggle Initial data toggle to use.
300 @param MaxPacket The max packet length of the endpoint.
301 @param Hub The transaction translator to use.
302 @param Type The transaction type.
303 @param Request The standard USB request for control transfer.
304 @param Data The user data to transfer.
305 @param DataLen The length of data buffer.
306 @param Callback The function to call when data is transferred.
307 @param Context The context to the callback.
308 @param Interval The interval for interrupt transfer.
310 @retval the pointer to the created URB or NULL.
315 IN PEI_USB2_HC_DEV
*Ehc
,
321 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR
*Hub
,
323 IN EFI_USB_DEVICE_REQUEST
*Request
,
326 IN EFI_ASYNC_USB_TRANSFER_CALLBACK Callback
,