2398b15667fb4b52e0fbfa4e9e53fd00b40477f7
[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 #include <PiDxe.h>
28
29 #include <Protocol/Usb2HostController.h>
30 #include <Protocol/PciIo.h>
31
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>
39
40
41 #include <IndustryStandard/Pci22.h>
42
43 typedef struct _USB2_HC_DEV USB2_HC_DEV;
44
45 #include "UsbHcMem.h"
46 #include "EhciReg.h"
47 #include "EhciUrb.h"
48 #include "EhciSched.h"
49 #include "EhciDebug.h"
50
51 enum {
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,
56
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
62
63 EHC_TPL = TPL_NOTIFY
64 };
65
66 //
67 //Iterate through the doule linked list. NOT delete safe
68 //
69 #define EFI_LIST_FOR_EACH(Entry, ListHead) \
70 for(Entry = (ListHead)->ForwardLink; Entry != (ListHead); Entry = Entry->ForwardLink)
71
72 //
73 //Iterate through the doule linked list. This is delete-safe.
74 //Don't touch NextEntry
75 //
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)
79
80 #define EFI_LIST_CONTAINER(Entry, Type, Field) _CR(Entry, Type, Field)
81
82
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)))
86
87 #define EHC_REG_BIT_IS_SET(Ehc, Offset, Bit) \
88 (EHC_BIT_IS_SET(EhcReadOpReg ((Ehc), (Offset)), (Bit)))
89
90 #define EHC_FROM_THIS(a) CR(a, USB2_HC_DEV, Usb2Hc, USB2_HC_DEV_SIGNATURE)
91
92 struct _USB2_HC_DEV {
93 UINTN Signature;
94 EFI_USB2_HC_PROTOCOL Usb2Hc;
95
96 EFI_PCI_IO_PROTOCOL *PciIo;
97 USBHC_MEM_POOL *MemPool;
98
99 //
100 // Schedule data shared between asynchronous and periodic
101 // transfers:
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
106 // status stage.
107 //
108 EHC_QTD *ShortReadStop;
109 EFI_EVENT PollTimer;
110
111 //
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.
115 //
116 EHC_QH *ReclaimHead;
117
118 //
119 // Peroidic (interrupt) transfer schedule data:
120 //
121 VOID *PeriodFrame; // Mapped as common buffer
122 VOID *PeriodFrameHost;
123 VOID *PeriodFrameMap;
124
125 EHC_QH *PeriodOne;
126 LIST_ENTRY AsyncIntTransfers;
127
128 //
129 // EHCI configuration data
130 //
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;
135
136 //
137 // Misc
138 //
139 EFI_UNICODE_STRING_TABLE *ControllerNameTable;
140 };
141
142
143 extern EFI_DRIVER_BINDING_PROTOCOL gEhciDriverBinding;
144 extern EFI_COMPONENT_NAME_PROTOCOL gEhciComponentName;
145
146 #endif