Import EhciDxe and UhciDxe into MdeModulePkg.
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / EhciDxe / Ehci.h
1 /** @file
2
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
8
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.
11
12 Module Name:
13
14 Ehci.h
15
16 Abstract:
17
18
19 Revision History
20
21 **/
22
23 #ifndef _EFI_EHCI_H_
24 #define _EFI_EHCI_H_
25
26 //
27 // The package level header files this module uses
28 //
29 #include <PiDxe.h>
30 //
31 // The protocols, PPI and GUID defintions for this module
32 //
33 #include <Protocol/Usb2HostController.h>
34 #include <Protocol/PciIo.h>
35 //
36 // The Library classes this module consumes
37 //
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>
45
46
47 #include <IndustryStandard/Pci22.h>
48
49 typedef struct _USB2_HC_DEV USB2_HC_DEV;
50
51 #include "UsbHcMem.h"
52 #include "EhciReg.h"
53 #include "EhciUrb.h"
54 #include "EhciSched.h"
55 #include "EhciDebug.h"
56
57 enum {
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,
62
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
68
69 EHC_TPL = TPL_NOTIFY,
70 };
71
72 //
73 //Iterate through the doule linked list. NOT delete safe
74 //
75 #define EFI_LIST_FOR_EACH(Entry, ListHead) \
76 for(Entry = (ListHead)->ForwardLink; Entry != (ListHead); Entry = Entry->ForwardLink)
77
78 //
79 //Iterate through the doule linked list. This is delete-safe.
80 //Don't touch NextEntry
81 //
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)
85
86 #define EFI_LIST_CONTAINER(Entry, Type, Field) _CR(Entry, Type, Field)
87
88
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)))
92
93 #define EHC_REG_BIT_IS_SET(Ehc, Offset, Bit) \
94 (EHC_BIT_IS_SET(EhcReadOpReg ((Ehc), (Offset)), (Bit)))
95
96 #define EHC_FROM_THIS(a) CR(a, USB2_HC_DEV, Usb2Hc, USB2_HC_DEV_SIGNATURE)
97
98 typedef struct _USB2_HC_DEV {
99 UINTN Signature;
100 EFI_USB2_HC_PROTOCOL Usb2Hc;
101
102 EFI_PCI_IO_PROTOCOL *PciIo;
103 USBHC_MEM_POOL *MemPool;
104
105 //
106 // Schedule data shared between asynchronous and periodic
107 // transfers:
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
112 // status stage.
113 //
114 EHC_QTD *ShortReadStop;
115 EFI_EVENT PollTimer;
116
117 //
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.
121 //
122 EHC_QH *ReclaimHead;
123
124 //
125 // Peroidic (interrupt) transfer schedule data:
126 //
127 VOID *PeriodFrame; // Mapped as common buffer
128 VOID *PeriodFrameHost;
129 VOID *PeriodFrameMap;
130
131 EHC_QH *PeriodOne;
132 LIST_ENTRY AsyncIntTransfers;
133
134 //
135 // EHCI configuration data
136 //
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;
141
142 //
143 // Misc
144 //
145 EFI_UNICODE_STRING_TABLE *ControllerNameTable;
146 } USB2_HC_DEV;
147
148
149 extern EFI_DRIVER_BINDING_PROTOCOL gEhciDriverBinding;
150 extern EFI_COMPONENT_NAME_PROTOCOL gEhciComponentName;
151
152 #endif