Import EhciDxe and UhciDxe into MdeModulePkg.
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / UhciDxe / Uhci.h
1 /** @file
2
3 Copyright (c) 2004 - 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 Uhci.h
15
16 Abstract:
17
18 The definition for UHCI driver model and HC protocol routines.
19
20 Revision History
21
22
23 **/
24
25 #ifndef _UHCI_H
26 #define _UHCI_H
27
28 //
29 // The package level header files this module uses
30 //
31 #include <PiDxe.h>
32 //
33 // The protocols, PPI and GUID defintions for this module
34 //
35 #include <Protocol/Usb2HostController.h>
36 #include <Protocol/UsbHostController.h>
37 #include <Protocol/PciIo.h>
38 //
39 // The Library classes this module consumes
40 //
41 #include <Library/DebugLib.h>
42 #include <Library/BaseMemoryLib.h>
43 #include <Library/UefiDriverEntryPoint.h>
44 #include <Library/UefiBootServicesTableLib.h>
45 #include <Library/UefiLib.h>
46 #include <Library/BaseLib.h>
47 #include <Library/MemoryAllocationLib.h>
48
49 #include <IndustryStandard/Pci22.h>
50
51 typedef struct _USB_HC_DEV USB_HC_DEV;
52
53 #include "UsbHcMem.h"
54 #include "UhciQueue.h"
55 #include "UhciReg.h"
56 #include "UhciSched.h"
57 #include "UhciDebug.h"
58
59 enum {
60 //
61 // Stall times
62 //
63 STALL_1_MS = 1000,
64 STALL_1_SECOND = 1000 *STALL_1_MS,
65
66 UHC_SYN_POLL = 50,
67 FORCE_GLOBAL_RESUME_TIME = 20 *STALL_1_MS,
68 ROOT_PORT_REST_TIME = 50 *STALL_1_MS,
69 PORT_RESET_RECOVERY_TIME = 10 *STALL_1_MS,
70 INTERRUPT_POLLING_TIME = 50 * 10000UL,
71
72 //
73 // UHC raises TPL to TPL_NOTIFY to serialize all its operations
74 // to protect shared data structures.
75 //
76 UHCI_TPL = TPL_NOTIFY,
77
78 USB_HC_DEV_SIGNATURE = EFI_SIGNATURE_32 ('u', 'h', 'c', 'i'),
79 };
80
81 #pragma pack(1)
82 typedef struct {
83 UINT8 PI;
84 UINT8 SubClassCode;
85 UINT8 BaseCode;
86 } USB_CLASSC;
87 #pragma pack()
88
89 #define UHC_FROM_USB_HC_PROTO(This) CR(This, USB_HC_DEV, UsbHc, USB_HC_DEV_SIGNATURE)
90 #define UHC_FROM_USB2_HC_PROTO(This) CR(This, USB_HC_DEV, Usb2Hc, USB_HC_DEV_SIGNATURE)
91
92 //
93 // USB_HC_DEV support the UHCI hardware controller. It schedules
94 // the asynchronous interrupt transfer with the same method as
95 // EHCI: a reversed tree structure. For synchronous interrupt,
96 // control and bulk transfer, it uses three static queue head to
97 // schedule them. SyncIntQh is for interrupt transfer. LsCtrlQh is
98 // for LOW speed control transfer, and FsCtrlBulkQh is for FULL
99 // speed control or bulk transfer. This is because FULL speed contrl
100 // or bulk transfer can reclaim the unused bandwidth. Some USB
101 // device requires this bandwidth reclamation capability.
102 //
103 typedef struct _USB_HC_DEV {
104 UINT32 Signature;
105 EFI_USB_HC_PROTOCOL UsbHc;
106 EFI_USB2_HC_PROTOCOL Usb2Hc;
107 EFI_PCI_IO_PROTOCOL *PciIo;
108
109 //
110 // Schedule data structures
111 //
112 UINT32 *FrameBase;
113 UHCI_QH_SW *SyncIntQh;
114 UHCI_QH_SW *CtrlQh;
115 UHCI_QH_SW *BulkQh;
116
117 //
118 // Structures to maintain asynchronus interrupt transfers.
119 // When asynchronous interrutp transfer is unlinked from
120 // the frame list, the hardware may still hold a pointer
121 // to it. To synchronize with hardware, its resoureces are
122 // released in two steps using Recycle and RecycleWait.
123 // Check the asynchronous interrupt management routines.
124 //
125 LIST_ENTRY AsyncIntList;
126 EFI_EVENT AsyncIntMonitor;
127 UHCI_ASYNC_REQUEST *Recycle;
128 UHCI_ASYNC_REQUEST *RecycleWait;
129
130
131 UINTN RootPorts;
132 USBHC_MEM_POOL *MemPool;
133 EFI_UNICODE_STRING_TABLE *CtrlNameTable;
134 VOID *FrameMapping;
135 } USB_HC_DEV;
136
137 extern EFI_DRIVER_BINDING_PROTOCOL gUhciDriverBinding;
138 extern EFI_COMPONENT_NAME_PROTOCOL gUhciComponentName;
139
140 #endif