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.
29 #include <Protocol/Usb2HostController.h>
30 #include <Protocol/PciIo.h>
32 #include <Library/DebugLib.h>
33 #include <Library/BaseMemoryLib.h>
34 #include <Library/UefiDriverEntryPoint.h>
35 #include <Library/UefiBootServicesTableLib.h>
36 #include <Library/UefiLib.h>
37 #include <Library/BaseLib.h>
38 #include <Library/MemoryAllocationLib.h>
41 #include <IndustryStandard/Pci22.h>
43 typedef struct _USB2_HC_DEV USB2_HC_DEV
;
48 #include "EhciSched.h"
49 #include "EhciDebug.h"
52 USB2_HC_DEV_SIGNATURE
= EFI_SIGNATURE_32 ('e', 'h', 'c', 'i'),
53 EHC_STALL_1_MICROSECOND
= 1,
54 EHC_STALL_1_MILLISECOND
= 1000 * EHC_STALL_1_MICROSECOND
,
55 EHC_STALL_1_SECOND
= 1000 * EHC_STALL_1_MILLISECOND
,
57 EHC_SET_PORT_RESET_TIME
= 50 * EHC_STALL_1_MILLISECOND
,
58 EHC_CLEAR_PORT_RESET_TIME
= EHC_STALL_1_MILLISECOND
,
59 EHC_GENERIC_TIME
= 10 * EHC_STALL_1_MILLISECOND
,
60 EHC_SYNC_POLL_TIME
= 20 * EHC_STALL_1_MICROSECOND
,
61 EHC_ASYNC_POLL_TIME
= 50 * 10000UL, // The unit of time is 100us
67 //Iterate through the doule linked list. NOT delete safe
69 #define EFI_LIST_FOR_EACH(Entry, ListHead) \
70 for(Entry = (ListHead)->ForwardLink; Entry != (ListHead); Entry = Entry->ForwardLink)
73 //Iterate through the doule linked list. This is delete-safe.
74 //Don't touch NextEntry
76 #define EFI_LIST_FOR_EACH_SAFE(Entry, NextEntry, ListHead) \
77 for(Entry = (ListHead)->ForwardLink, NextEntry = Entry->ForwardLink;\
78 Entry != (ListHead); Entry = NextEntry, NextEntry = Entry->ForwardLink)
80 #define EFI_LIST_CONTAINER(Entry, Type, Field) _CR(Entry, Type, Field)
83 #define EHC_LOW_32BIT(Addr64) ((UINT32)(((UINTN)(Addr64)) & 0XFFFFFFFF))
84 #define EHC_HIGH_32BIT(Addr64) ((UINT32)(RShiftU64((UINTN)(Addr64), 32) & 0XFFFFFFFF))
85 #define EHC_BIT_IS_SET(Data, Bit) ((BOOLEAN)(((Data) & (Bit)) == (Bit)))
87 #define EHC_REG_BIT_IS_SET(Ehc, Offset, Bit) \
88 (EHC_BIT_IS_SET(EhcReadOpReg ((Ehc), (Offset)), (Bit)))
90 #define EHC_FROM_THIS(a) CR(a, USB2_HC_DEV, Usb2Hc, USB2_HC_DEV_SIGNATURE)
94 EFI_USB2_HC_PROTOCOL Usb2Hc
;
96 EFI_PCI_IO_PROTOCOL
*PciIo
;
97 USBHC_MEM_POOL
*MemPool
;
100 // Schedule data shared between asynchronous and periodic
102 // ShortReadStop, as its name indicates, is used to terminate
103 // the short read except the control transfer. EHCI follows
104 // the alternative next QTD point when a short read happens.
105 // For control transfer, even the short read happens, try the
108 EHC_QTD
*ShortReadStop
;
112 // Asynchronous(bulk and control) transfer schedule data:
113 // ReclaimHead is used as the head of the asynchronous transfer
114 // list. It acts as the reclamation header.
119 // Peroidic (interrupt) transfer schedule data:
121 VOID
*PeriodFrame
; // Mapped as common buffer
122 VOID
*PeriodFrameHost
;
123 VOID
*PeriodFrameMap
;
126 LIST_ENTRY AsyncIntTransfers
;
129 // EHCI configuration data
131 UINT32 HcStructParams
; // Cache of HC structure parameter, EHC_HCSPARAMS_OFFSET
132 UINT32 HcCapParams
; // Cache of HC capability parameter, HCCPARAMS
133 UINT32 CapLen
; // Capability length
134 UINT32 High32bitAddr
;
139 EFI_UNICODE_STRING_TABLE
*ControllerNameTable
;
143 extern EFI_DRIVER_BINDING_PROTOCOL gEhciDriverBinding
;
144 extern EFI_COMPONENT_NAME_PROTOCOL gEhciComponentName
;