SecurityPkg: Tcg2Dxe: Report correct FinalEventLog size
[mirror_edk2.git] / Omap35xxPkg / PciEmulation / PciEmulation.h
1 /** @file
2
3 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
4
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #ifndef _PCI_ROOT_BRIDGE_H_
16 #define _PCI_ROOT_BRIDGE_H_
17
18 #include <PiDxe.h>
19
20 #include <TPS65950.h>
21
22 #include <Library/BaseLib.h>
23 #include <Library/BaseMemoryLib.h>
24 #include <Library/DebugLib.h>
25 #include <Library/DxeServicesTableLib.h>
26 #include <Library/IoLib.h>
27 #include <Library/MemoryAllocationLib.h>
28 #include <Library/PciLib.h>
29 #include <Library/UefiLib.h>
30 #include <Library/UefiBootServicesTableLib.h>
31 #include <Library/OmapDmaLib.h>
32 #include <Library/DmaLib.h>
33
34 #include <Protocol/EmbeddedExternalDevice.h>
35 #include <Protocol/DevicePath.h>
36 #include <Protocol/PciIo.h>
37 #include <Protocol/PciRootBridgeIo.h>
38 #include <Protocol/PciHostBridgeResourceAllocation.h>
39
40 #include <IndustryStandard/Pci22.h>
41 #include <IndustryStandard/Acpi.h>
42
43 #include <Omap3530/Omap3530.h>
44
45
46
47 #define EFI_RESOURCE_NONEXISTENT 0xFFFFFFFFFFFFFFFFULL
48 #define EFI_RESOURCE_LESS 0xFFFFFFFFFFFFFFFEULL
49 #define EFI_RESOURCE_SATISFIED 0x0000000000000000ULL
50
51
52 typedef struct {
53 ACPI_HID_DEVICE_PATH AcpiDevicePath;
54 EFI_DEVICE_PATH_PROTOCOL EndDevicePath;
55 } EFI_PCI_ROOT_BRIDGE_DEVICE_PATH;
56
57
58 #define ACPI_CONFIG_IO 0
59 #define ACPI_CONFIG_MMIO 1
60 #define ACPI_CONFIG_BUS 2
61
62 typedef struct {
63 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR Desc[3];
64 EFI_ACPI_END_TAG_DESCRIPTOR EndDesc;
65 } ACPI_CONFIG_INFO;
66
67
68 #define PCI_ROOT_BRIDGE_SIGNATURE SIGNATURE_32 ('P', 'c', 'i', 'F')
69
70 typedef struct {
71 UINT32 Signature;
72 EFI_HANDLE Handle;
73 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL Io;
74 EFI_PCI_ROOT_BRIDGE_DEVICE_PATH DevicePath;
75
76 UINT8 StartBus;
77 UINT8 EndBus;
78 UINT16 Type;
79 UINT32 MemoryStart;
80 UINT32 MemorySize;
81 UINTN IoOffset;
82 UINT32 IoStart;
83 UINT32 IoSize;
84 UINT64 PciAttributes;
85
86 ACPI_CONFIG_INFO *Config;
87
88 } PCI_ROOT_BRIDGE;
89
90
91 #define INSTANCE_FROM_PCI_ROOT_BRIDGE_IO_THIS(a) CR (a, PCI_ROOT_BRIDGE, Io, PCI_ROOT_BRIDGE_SIGNATURE)
92
93
94 typedef union {
95 UINT8 volatile *buf;
96 UINT8 volatile *ui8;
97 UINT16 volatile *ui16;
98 UINT32 volatile *ui32;
99 UINT64 volatile *ui64;
100 UINTN volatile ui;
101 } PTR;
102
103
104
105 EFI_STATUS
106 EFIAPI
107 PciRootBridgeIoPollMem (
108 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
109 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
110 IN UINT64 Address,
111 IN UINT64 Mask,
112 IN UINT64 Value,
113 IN UINT64 Delay,
114 OUT UINT64 *Result
115 );
116
117 EFI_STATUS
118 EFIAPI
119 PciRootBridgeIoPollIo (
120 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
121 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
122 IN UINT64 Address,
123 IN UINT64 Mask,
124 IN UINT64 Value,
125 IN UINT64 Delay,
126 OUT UINT64 *Result
127 );
128
129 EFI_STATUS
130 EFIAPI
131 PciRootBridgeIoMemRead (
132 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
133 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
134 IN UINT64 Address,
135 IN UINTN Count,
136 IN OUT VOID *Buffer
137 );
138
139 EFI_STATUS
140 EFIAPI
141 PciRootBridgeIoMemWrite (
142 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
143 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
144 IN UINT64 Address,
145 IN UINTN Count,
146 IN OUT VOID *Buffer
147 );
148
149 EFI_STATUS
150 EFIAPI
151 PciRootBridgeIoIoRead (
152 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
153 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
154 IN UINT64 UserAddress,
155 IN UINTN Count,
156 IN OUT VOID *UserBuffer
157 );
158
159 EFI_STATUS
160 EFIAPI
161 PciRootBridgeIoIoWrite (
162 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
163 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
164 IN UINT64 UserAddress,
165 IN UINTN Count,
166 IN OUT VOID *UserBuffer
167 );
168
169 EFI_STATUS
170 EFIAPI
171 PciRootBridgeIoCopyMem (
172 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
173 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
174 IN UINT64 DestAddress,
175 IN UINT64 SrcAddress,
176 IN UINTN Count
177 );
178
179 EFI_STATUS
180 EFIAPI
181 PciRootBridgeIoPciRead (
182 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
183 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
184 IN UINT64 Address,
185 IN UINTN Count,
186 IN OUT VOID *Buffer
187 );
188
189 EFI_STATUS
190 EFIAPI
191 PciRootBridgeIoPciWrite (
192 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
193 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
194 IN UINT64 Address,
195 IN UINTN Count,
196 IN OUT VOID *Buffer
197 );
198
199 EFI_STATUS
200 EFIAPI
201 PciRootBridgeIoMap (
202 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
203 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION Operation,
204 IN VOID *HostAddress,
205 IN OUT UINTN *NumberOfBytes,
206 OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
207 OUT VOID **Mapping
208 );
209
210 EFI_STATUS
211 EFIAPI
212 PciRootBridgeIoUnmap (
213 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
214 IN VOID *Mapping
215 );
216
217 EFI_STATUS
218 EFIAPI
219 PciRootBridgeIoAllocateBuffer (
220 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
221 IN EFI_ALLOCATE_TYPE Type,
222 IN EFI_MEMORY_TYPE MemoryType,
223 IN UINTN Pages,
224 OUT VOID **HostAddress,
225 IN UINT64 Attributes
226 );
227
228 EFI_STATUS
229 EFIAPI
230 PciRootBridgeIoFreeBuffer (
231 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
232 IN UINTN Pages,
233 OUT VOID *HostAddress
234 );
235
236 EFI_STATUS
237 EFIAPI
238 PciRootBridgeIoFlush (
239 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This
240 );
241
242 EFI_STATUS
243 EFIAPI
244 PciRootBridgeIoGetAttributes (
245 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
246 OUT UINT64 *Supported,
247 OUT UINT64 *Attributes
248 );
249
250 EFI_STATUS
251 EFIAPI
252 PciRootBridgeIoSetAttributes (
253 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
254 IN UINT64 Attributes,
255 IN OUT UINT64 *ResourceBase,
256 IN OUT UINT64 *ResourceLength
257 );
258
259 EFI_STATUS
260 EFIAPI
261 PciRootBridgeIoConfiguration (
262 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
263 OUT VOID **Resources
264 );
265
266 //
267 // Private Function Prototypes
268 //
269 EFI_STATUS
270 EFIAPI
271 PciRootBridgeIoMemRW (
272 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
273 IN UINTN Count,
274 IN BOOLEAN InStrideFlag,
275 IN PTR In,
276 IN BOOLEAN OutStrideFlag,
277 OUT PTR Out
278 );
279
280 BOOLEAN
281 PciIoMemAddressValid (
282 IN EFI_PCI_IO_PROTOCOL *This,
283 IN UINT64 Address
284 );
285
286 EFI_STATUS
287 EmulatePciIoForEhci (
288 INTN MvPciIfMaxIf
289 );
290
291 #endif
292