3 Copyright (c) 2006 - 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.
27 // The package level header files this module uses
31 // The protocols, PPI and GUID defintions for this module
33 #include <Protocol/Usb2HostController.h>
34 #include <Protocol/PciIo.h>
36 // The Library classes this module consumes
38 #include <Library/DebugLib.h>
39 #include <Library/BaseMemoryLib.h>
40 #include <Library/UefiDriverEntryPoint.h>
41 #include <Library/UefiBootServicesTableLib.h>
42 #include <Library/UefiLib.h>
43 #include <Library/BaseLib.h>
44 #include <Library/MemoryAllocationLib.h>
47 #include <IndustryStandard/Pci22.h>
49 typedef struct _USB2_HC_DEV USB2_HC_DEV
;
54 #include "EhciSched.h"
55 #include "EhciDebug.h"
58 USB2_HC_DEV_SIGNATURE
= EFI_SIGNATURE_32 ('e', 'h', 'c', 'i'),
59 EHC_STALL_1_MICROSECOND
= 1,
60 EHC_STALL_1_MILLISECOND
= 1000 * EHC_STALL_1_MICROSECOND
,
61 EHC_STALL_1_SECOND
= 1000 * EHC_STALL_1_MILLISECOND
,
63 EHC_SET_PORT_RESET_TIME
= 50 * EHC_STALL_1_MILLISECOND
,
64 EHC_CLEAR_PORT_RESET_TIME
= EHC_STALL_1_MILLISECOND
,
65 EHC_GENERIC_TIME
= 10 * EHC_STALL_1_MILLISECOND
,
66 EHC_SYNC_POLL_TIME
= 20 * EHC_STALL_1_MICROSECOND
,
67 EHC_ASYNC_POLL_TIME
= 50 * 10000UL, // The unit of time is 100us
73 //Iterate through the doule linked list. NOT delete safe
75 #define EFI_LIST_FOR_EACH(Entry, ListHead) \
76 for(Entry = (ListHead)->ForwardLink; Entry != (ListHead); Entry = Entry->ForwardLink)
79 //Iterate through the doule linked list. This is delete-safe.
80 //Don't touch NextEntry
82 #define EFI_LIST_FOR_EACH_SAFE(Entry, NextEntry, ListHead) \
83 for(Entry = (ListHead)->ForwardLink, NextEntry = Entry->ForwardLink;\
84 Entry != (ListHead); Entry = NextEntry, NextEntry = Entry->ForwardLink)
86 #define EFI_LIST_CONTAINER(Entry, Type, Field) _CR(Entry, Type, Field)
89 #define EHC_LOW_32BIT(Addr64) ((UINT32)(((UINTN)(Addr64)) & 0XFFFFFFFF))
90 #define EHC_HIGH_32BIT(Addr64) ((UINT32)(RShiftU64((UINTN)(Addr64), 32) & 0XFFFFFFFF))
91 #define EHC_BIT_IS_SET(Data, Bit) ((BOOLEAN)(((Data) & (Bit)) == (Bit)))
93 #define EHC_REG_BIT_IS_SET(Ehc, Offset, Bit) \
94 (EHC_BIT_IS_SET(EhcReadOpReg ((Ehc), (Offset)), (Bit)))
96 #define EHC_FROM_THIS(a) CR(a, USB2_HC_DEV, Usb2Hc, USB2_HC_DEV_SIGNATURE)
100 EFI_USB2_HC_PROTOCOL Usb2Hc
;
102 EFI_PCI_IO_PROTOCOL
*PciIo
;
103 USBHC_MEM_POOL
*MemPool
;
106 // Schedule data shared between asynchronous and periodic
108 // ShortReadStop, as its name indicates, is used to terminate
109 // the short read except the control transfer. EHCI follows
110 // the alternative next QTD point when a short read happens.
111 // For control transfer, even the short read happens, try the
114 EHC_QTD
*ShortReadStop
;
118 // Asynchronous(bulk and control) transfer schedule data:
119 // ReclaimHead is used as the head of the asynchronous transfer
120 // list. It acts as the reclamation header.
125 // Peroidic (interrupt) transfer schedule data:
127 VOID
*PeriodFrame
; // Mapped as common buffer
128 VOID
*PeriodFrameHost
;
129 VOID
*PeriodFrameMap
;
132 LIST_ENTRY AsyncIntTransfers
;
135 // EHCI configuration data
137 UINT32 HcStructParams
; // Cache of HC structure parameter, EHC_HCSPARAMS_OFFSET
138 UINT32 HcCapParams
; // Cache of HC capability parameter, HCCPARAMS
139 UINT32 CapLen
; // Capability length
140 UINT32 High32bitAddr
;
145 EFI_UNICODE_STRING_TABLE
*ControllerNameTable
;
149 extern EFI_DRIVER_BINDING_PROTOCOL gEhciDriverBinding
;
150 extern EFI_COMPONENT_NAME_PROTOCOL gEhciComponentName
;