]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Bus/Pci/EhciDxe/Ehci.h
Clean up to update the reference of the these macros:
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / EhciDxe / Ehci.h
1 /** @file
2
3 Provides some data struct used by EHCI controller driver.
4
5 Copyright (c) 2006 - 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_EHCI_H_
17 #define _EFI_EHCI_H_
18
19
20 #include <Uefi.h>
21
22 #include <Protocol/Usb2HostController.h>
23 #include <Protocol/PciIo.h>
24
25 #include <Library/DebugLib.h>
26 #include <Library/BaseMemoryLib.h>
27 #include <Library/UefiDriverEntryPoint.h>
28 #include <Library/UefiBootServicesTableLib.h>
29 #include <Library/UefiLib.h>
30 #include <Library/BaseLib.h>
31 #include <Library/MemoryAllocationLib.h>
32 #include <Library/PcdLib.h>
33
34 #include <IndustryStandard/Pci22.h>
35
36 typedef struct _USB2_HC_DEV USB2_HC_DEV;
37
38 #include "UsbHcMem.h"
39 #include "EhciReg.h"
40 #include "EhciUrb.h"
41 #include "EhciSched.h"
42 #include "EhciDebug.h"
43 #include "ComponentName.h"
44
45 typedef enum {
46 EHC_1_MICROSECOND = 1,
47 EHC_1_MILLISECOND = 1000 * EHC_1_MICROSECOND,
48 EHC_1_SECOND = 1000 * EHC_1_MILLISECOND,
49
50 //
51 // EHCI register operation timeout, set by experience
52 //
53 EHC_RESET_TIMEOUT = 1 * EHC_1_SECOND,
54 EHC_GENERIC_TIMEOUT = 10 * EHC_1_MILLISECOND,
55
56 //
57 // Wait for roothub port power stable, refers to Spec[EHCI1.0-2.3.9]
58 //
59 EHC_ROOT_PORT_RECOVERY_STALL = 20 * EHC_1_MILLISECOND,
60
61 //
62 // Sync and Async transfer polling interval, set by experience,
63 // and the unit of Async is 100us, means 50ms as interval.
64 //
65 EHC_SYNC_POLL_INTERVAL = 20 * EHC_1_MICROSECOND,
66 EHC_ASYNC_POLL_INTERVAL = 50 * 10000U
67 } EHC_TIMEOUT_EXPERIENCE_VALUE;
68
69
70 //
71 // EHC raises TPL to TPL_NOTIFY to serialize all its operations
72 // to protect shared data structures.
73 //
74 #define EHC_TPL TPL_NOTIFY
75
76 #define USB2_HC_DEV_SIGNATURE SIGNATURE_32 ('e', 'h', 'c', 'i')
77
78 //
79 //Iterate through the doule linked list. NOT delete safe
80 //
81 #define EFI_LIST_FOR_EACH(Entry, ListHead) \
82 for(Entry = (ListHead)->ForwardLink; Entry != (ListHead); Entry = Entry->ForwardLink)
83
84 //
85 //Iterate through the doule linked list. This is delete-safe.
86 //Don't touch NextEntry
87 //
88 #define EFI_LIST_FOR_EACH_SAFE(Entry, NextEntry, ListHead) \
89 for(Entry = (ListHead)->ForwardLink, NextEntry = Entry->ForwardLink;\
90 Entry != (ListHead); Entry = NextEntry, NextEntry = Entry->ForwardLink)
91
92 #define EFI_LIST_CONTAINER(Entry, Type, Field) BASE_CR(Entry, Type, Field)
93
94
95 #define EHC_LOW_32BIT(Addr64) ((UINT32)(((UINTN)(Addr64)) & 0XFFFFFFFF))
96 #define EHC_HIGH_32BIT(Addr64) ((UINT32)(RShiftU64((UINTN)(Addr64), 32) & 0XFFFFFFFF))
97 #define EHC_BIT_IS_SET(Data, Bit) ((BOOLEAN)(((Data) & (Bit)) == (Bit)))
98
99 #define EHC_REG_BIT_IS_SET(Ehc, Offset, Bit) \
100 (EHC_BIT_IS_SET(EhcReadOpReg ((Ehc), (Offset)), (Bit)))
101
102 #define EHC_FROM_THIS(a) CR(a, USB2_HC_DEV, Usb2Hc, USB2_HC_DEV_SIGNATURE)
103
104 struct _USB2_HC_DEV {
105 UINTN Signature;
106 EFI_USB2_HC_PROTOCOL Usb2Hc;
107
108 EFI_PCI_IO_PROTOCOL *PciIo;
109 UINT64 OriginalPciAttributes;
110 USBHC_MEM_POOL *MemPool;
111
112 //
113 // Schedule data shared between asynchronous and periodic
114 // transfers:
115 // ShortReadStop, as its name indicates, is used to terminate
116 // the short read except the control transfer. EHCI follows
117 // the alternative next QTD point when a short read happens.
118 // For control transfer, even the short read happens, try the
119 // status stage.
120 //
121 EHC_QTD *ShortReadStop;
122 EFI_EVENT PollTimer;
123
124 //
125 // Asynchronous(bulk and control) transfer schedule data:
126 // ReclaimHead is used as the head of the asynchronous transfer
127 // list. It acts as the reclamation header.
128 //
129 EHC_QH *ReclaimHead;
130
131 //
132 // Peroidic (interrupt) transfer schedule data:
133 //
134 VOID *PeriodFrame; // Mapped as common buffer
135 VOID *PeriodFrameHost;
136 VOID *PeriodFrameMap;
137
138 EHC_QH *PeriodOne;
139 LIST_ENTRY AsyncIntTransfers;
140
141 //
142 // EHCI configuration data
143 //
144 UINT32 HcStructParams; // Cache of HC structure parameter, EHC_HCSPARAMS_OFFSET
145 UINT32 HcCapParams; // Cache of HC capability parameter, HCCPARAMS
146 UINT32 CapLen; // Capability length
147 UINT32 High32bitAddr;
148
149 //
150 // Misc
151 //
152 EFI_UNICODE_STRING_TABLE *ControllerNameTable;
153 };
154
155
156 extern EFI_DRIVER_BINDING_PROTOCOL gEhciDriverBinding;
157 extern EFI_COMPONENT_NAME_PROTOCOL gEhciComponentName;
158 extern EFI_COMPONENT_NAME2_PROTOCOL gEhciComponentName2;
159
160 /**
161 Test to see if this driver supports ControllerHandle. Any
162 ControllerHandle that has Usb2HcProtocol installed will
163 be supported.
164
165 @param This Protocol instance pointer.
166 @param Controller Handle of device to test.
167 @param RemainingDevicePath Not used.
168
169 @return EFI_SUCCESS This driver supports this device.
170 @return EFI_UNSUPPORTED This driver does not support this device.
171
172 **/
173 EFI_STATUS
174 EFIAPI
175 EhcDriverBindingSupported (
176 IN EFI_DRIVER_BINDING_PROTOCOL *This,
177 IN EFI_HANDLE Controller,
178 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
179 );
180
181 /**
182 Starting the Usb EHCI Driver.
183
184 @param This Protocol instance pointer.
185 @param Controller Handle of device to test.
186 @param RemainingDevicePath Not used.
187
188 @return EFI_SUCCESS supports this device.
189 @return EFI_UNSUPPORTED do not support this device.
190 @return EFI_DEVICE_ERROR cannot be started due to device Error.
191 @return EFI_OUT_OF_RESOURCES cannot allocate resources.
192
193 **/
194 EFI_STATUS
195 EFIAPI
196 EhcDriverBindingStart (
197 IN EFI_DRIVER_BINDING_PROTOCOL *This,
198 IN EFI_HANDLE Controller,
199 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
200 );
201
202 /**
203 Stop this driver on ControllerHandle. Support stoping any child handles
204 created by this driver.
205
206 @param This Protocol instance pointer.
207 @param Controller Handle of device to stop driver on.
208 @param NumberOfChildren Number of Children in the ChildHandleBuffer.
209 @param ChildHandleBuffer List of handles for the children we need to stop.
210
211 @return EFI_SUCCESS Success.
212 @return EFI_DEVICE_ERROR Fail.
213
214 **/
215 EFI_STATUS
216 EFIAPI
217 EhcDriverBindingStop (
218 IN EFI_DRIVER_BINDING_PROTOCOL *This,
219 IN EFI_HANDLE Controller,
220 IN UINTN NumberOfChildren,
221 IN EFI_HANDLE *ChildHandleBuffer
222 );
223
224 #endif
225