]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Pci/EhciDxe/Ehci.h
Fixed potential issues to release resources when error occurs.
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / EhciDxe / Ehci.h
CommitLineData
913cb9dc 1/** @file\r
2\r
3Copyright (c) 2006 - 2007, Intel Corporation\r
4All rights reserved. This program and the accompanying materials\r
5are licensed and made available under the terms and conditions of the BSD License\r
6which accompanies this distribution. The full text of the license may be found at\r
7http://opensource.org/licenses/bsd-license.php\r
8\r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
11\r
12Module Name:\r
13\r
14 Ehci.h\r
15\r
16Abstract:\r
17\r
18\r
19Revision History\r
20\r
21**/\r
22\r
23#ifndef _EFI_EHCI_H_\r
24#define _EFI_EHCI_H_\r
25\r
ed7748fe 26\r
913cb9dc 27#include <PiDxe.h>\r
ed7748fe 28\r
913cb9dc 29#include <Protocol/Usb2HostController.h>\r
30#include <Protocol/PciIo.h>\r
ed7748fe 31\r
913cb9dc 32#include <Library/DebugLib.h>\r
33#include <Library/BaseMemoryLib.h>\r
34#include <Library/UefiDriverEntryPoint.h>\r
35#include <Library/UefiBootServicesTableLib.h>\r
36#include <Library/UefiLib.h>\r
37#include <Library/BaseLib.h>\r
38#include <Library/MemoryAllocationLib.h>\r
39\r
40\r
41#include <IndustryStandard/Pci22.h>\r
42\r
43typedef struct _USB2_HC_DEV USB2_HC_DEV;\r
44\r
45#include "UsbHcMem.h"\r
46#include "EhciReg.h"\r
47#include "EhciUrb.h"\r
48#include "EhciSched.h"\r
49#include "EhciDebug.h"\r
50\r
51enum {\r
41e8ff27 52 EHC_1_MICROSECOND = 1,\r
53 EHC_1_MILLISECOND = 1000 * EHC_1_MICROSECOND,\r
54 EHC_1_SECOND = 1000 * EHC_1_MILLISECOND,\r
55\r
56 //\r
57 // EHCI register operation timeout, set by experience\r
58 //\r
59 EHC_RESET_TIMEOUT = 1 * EHC_1_SECOND,\r
60 EHC_GENERIC_TIMEOUT = 10 * EHC_1_MILLISECOND,\r
61\r
62 //\r
63 // Wait for roothub port power stable, refers to Spec[EHCI1.0-2.3.9]\r
64 //\r
65 EHC_ROOT_PORT_RECOVERY_STALL = 20 * EHC_1_MILLISECOND,\r
66\r
67 //\r
68246fa8 68 // Sync and Async transfer polling interval, set by experience,\r
41e8ff27 69 // and the unit of Async is 100us, means 50ms as interval.\r
70 //\r
71 EHC_SYNC_POLL_INTERVAL = 20 * EHC_1_MICROSECOND,\r
68246fa8 72 EHC_ASYNC_POLL_INTERVAL = 50 * 10000U,\r
41e8ff27 73\r
74 //\r
75 // EHC raises TPL to TPL_NOTIFY to serialize all its operations\r
76 // to protect shared data structures.\r
77 //\r
78 EHC_TPL = TPL_NOTIFY,\r
79\r
23c326c2 80 USB2_HC_DEV_SIGNATURE = EFI_SIGNATURE_32 ('e', 'h', 'c', 'i')\r
913cb9dc 81};\r
82\r
83//\r
84//Iterate through the doule linked list. NOT delete safe\r
85//\r
86#define EFI_LIST_FOR_EACH(Entry, ListHead) \\r
87 for(Entry = (ListHead)->ForwardLink; Entry != (ListHead); Entry = Entry->ForwardLink)\r
88\r
89//\r
90//Iterate through the doule linked list. This is delete-safe.\r
91//Don't touch NextEntry\r
92//\r
93#define EFI_LIST_FOR_EACH_SAFE(Entry, NextEntry, ListHead) \\r
94 for(Entry = (ListHead)->ForwardLink, NextEntry = Entry->ForwardLink;\\r
95 Entry != (ListHead); Entry = NextEntry, NextEntry = Entry->ForwardLink)\r
96\r
97#define EFI_LIST_CONTAINER(Entry, Type, Field) _CR(Entry, Type, Field)\r
98\r
99\r
100#define EHC_LOW_32BIT(Addr64) ((UINT32)(((UINTN)(Addr64)) & 0XFFFFFFFF))\r
101#define EHC_HIGH_32BIT(Addr64) ((UINT32)(RShiftU64((UINTN)(Addr64), 32) & 0XFFFFFFFF))\r
102#define EHC_BIT_IS_SET(Data, Bit) ((BOOLEAN)(((Data) & (Bit)) == (Bit)))\r
103\r
104#define EHC_REG_BIT_IS_SET(Ehc, Offset, Bit) \\r
105 (EHC_BIT_IS_SET(EhcReadOpReg ((Ehc), (Offset)), (Bit)))\r
106\r
107#define EHC_FROM_THIS(a) CR(a, USB2_HC_DEV, Usb2Hc, USB2_HC_DEV_SIGNATURE)\r
108\r
c52fa98c 109struct _USB2_HC_DEV {\r
913cb9dc 110 UINTN Signature;\r
111 EFI_USB2_HC_PROTOCOL Usb2Hc;\r
112\r
113 EFI_PCI_IO_PROTOCOL *PciIo;\r
68246fa8 114 UINT64 OriginalPciAttributes;\r
913cb9dc 115 USBHC_MEM_POOL *MemPool;\r
116\r
117 //\r
118 // Schedule data shared between asynchronous and periodic\r
119 // transfers:\r
120 // ShortReadStop, as its name indicates, is used to terminate\r
121 // the short read except the control transfer. EHCI follows\r
122 // the alternative next QTD point when a short read happens.\r
123 // For control transfer, even the short read happens, try the\r
124 // status stage.\r
125 //\r
126 EHC_QTD *ShortReadStop;\r
127 EFI_EVENT PollTimer;\r
128\r
129 //\r
130 // Asynchronous(bulk and control) transfer schedule data:\r
131 // ReclaimHead is used as the head of the asynchronous transfer\r
132 // list. It acts as the reclamation header.\r
133 //\r
134 EHC_QH *ReclaimHead;\r
135\r
136 //\r
137 // Peroidic (interrupt) transfer schedule data:\r
138 //\r
139 VOID *PeriodFrame; // Mapped as common buffer\r
140 VOID *PeriodFrameHost;\r
141 VOID *PeriodFrameMap;\r
142\r
143 EHC_QH *PeriodOne;\r
144 LIST_ENTRY AsyncIntTransfers;\r
145\r
146 //\r
147 // EHCI configuration data\r
148 //\r
149 UINT32 HcStructParams; // Cache of HC structure parameter, EHC_HCSPARAMS_OFFSET\r
150 UINT32 HcCapParams; // Cache of HC capability parameter, HCCPARAMS\r
151 UINT32 CapLen; // Capability length\r
152 UINT32 High32bitAddr;\r
153\r
154 //\r
155 // Misc\r
156 //\r
157 EFI_UNICODE_STRING_TABLE *ControllerNameTable;\r
c52fa98c 158};\r
913cb9dc 159\r
160\r
f527bce3 161extern EFI_DRIVER_BINDING_PROTOCOL gEhciDriverBinding;\r
162extern EFI_COMPONENT_NAME_PROTOCOL gEhciComponentName;\r
163extern EFI_COMPONENT_NAME2_PROTOCOL gEhciComponentName2;\r
913cb9dc 164\r
165#endif\r