]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Protocol/PciRootBridgeIo.h
Update the copyright notice format
[mirror_edk2.git] / MdePkg / Include / Protocol / PciRootBridgeIo.h
1 /** @file
2 PCI Root Bridge I/O protocol as defined in the UEFI 2.0 specification.
3
4 PCI Root Bridge I/O protocol is used by PCI Bus Driver to perform PCI Memory, PCI I/O,
5 and PCI Configuration cycles on a PCI Root Bridge. It also provides services to perform
6 defferent types of bus mastering DMA.
7
8 Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
9 This program and the accompanying materials
10 are licensed and made available under the terms and conditions of the BSD License
11 which accompanies this distribution. The full text of the license may be found at
12 http://opensource.org/licenses/bsd-license.php
13
14 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
15 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16
17 **/
18
19 #ifndef __PCI_ROOT_BRIDGE_IO_H__
20 #define __PCI_ROOT_BRIDGE_IO_H__
21
22 #define EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GUID \
23 { \
24 0x2f707ebb, 0x4a1a, 0x11d4, {0x9a, 0x38, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
25 }
26
27 typedef struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL;
28
29 ///
30 /// *******************************************************
31 /// EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH
32 /// *******************************************************
33 ///
34 typedef enum {
35 EfiPciWidthUint8,
36 EfiPciWidthUint16,
37 EfiPciWidthUint32,
38 EfiPciWidthUint64,
39 EfiPciWidthFifoUint8,
40 EfiPciWidthFifoUint16,
41 EfiPciWidthFifoUint32,
42 EfiPciWidthFifoUint64,
43 EfiPciWidthFillUint8,
44 EfiPciWidthFillUint16,
45 EfiPciWidthFillUint32,
46 EfiPciWidthFillUint64,
47 EfiPciWidthMaximum
48 } EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH;
49
50 ///
51 /// *******************************************************
52 /// EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION
53 /// *******************************************************
54 ///
55 typedef enum {
56 ///
57 /// A read operation from system memory by a bus master that is not capable of producing
58 /// PCI dual address cycles.
59 ///
60 EfiPciOperationBusMasterRead,
61 ///
62 /// A write operation from system memory by a bus master that is not capable of producing
63 /// PCI dual address cycles.
64 ///
65 EfiPciOperationBusMasterWrite,
66 ///
67 /// Provides both read and write access to system memory by both the processor and a bus
68 /// master that is not capable of producing PCI dual address cycles.
69 ///
70 EfiPciOperationBusMasterCommonBuffer,
71 ///
72 /// A read operation from system memory by a bus master that is capable of producing PCI
73 /// dual address cycles.
74 ///
75 EfiPciOperationBusMasterRead64,
76 ///
77 /// A write operation to system memory by a bus master that is capable of producing PCI
78 /// dual address cycles.
79 ///
80 EfiPciOperationBusMasterWrite64,
81 ///
82 /// Provides both read and write access to system memory by both the processor and a bus
83 /// master that is capable of producing PCI dual address cycles.
84 ///
85 EfiPciOperationBusMasterCommonBuffer64,
86 EfiPciOperationMaximum
87 } EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION;
88
89 #define EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO 0x0001
90 #define EFI_PCI_ATTRIBUTE_ISA_IO 0x0002
91 #define EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO 0x0004
92 #define EFI_PCI_ATTRIBUTE_VGA_MEMORY 0x0008
93 #define EFI_PCI_ATTRIBUTE_VGA_IO 0x0010
94 #define EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO 0x0020
95 #define EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO 0x0040
96 #define EFI_PCI_ATTRIBUTE_MEMORY_WRITE_COMBINE 0x0080
97 #define EFI_PCI_ATTRIBUTE_MEMORY_CACHED 0x0800
98 #define EFI_PCI_ATTRIBUTE_MEMORY_DISABLE 0x1000
99 #define EFI_PCI_ATTRIBUTE_DUAL_ADDRESS_CYCLE 0x8000
100
101 #define EFI_PCI_ATTRIBUTE_VALID_FOR_ALLOCATE_BUFFER (EFI_PCI_ATTRIBUTE_MEMORY_WRITE_COMBINE | EFI_PCI_ATTRIBUTE_MEMORY_CACHED | EFI_PCI_ATTRIBUTE_DUAL_ADDRESS_CYCLE)
102
103 #define EFI_PCI_ATTRIBUTE_INVALID_FOR_ALLOCATE_BUFFER (~EFI_PCI_ATTRIBUTE_VALID_FOR_ALLOCATE_BUFFER)
104
105 #define EFI_PCI_ADDRESS(bus, dev, func, reg) \
106 ((UINT64) ((((UINTN) bus) << 24) + (((UINTN) dev) << 16) + (((UINTN) func) << 8) + ((UINTN) reg)))
107
108 typedef struct {
109 UINT8 Register;
110 UINT8 Function;
111 UINT8 Device;
112 UINT8 Bus;
113 UINT32 ExtendedRegister;
114 } EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS;
115
116 /**
117 Reads from the I/O space of a PCI Root Bridge. Returns when either the polling exit criteria is
118 satisfied or after a defined duration.
119
120 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
121 @param Width Signifies the width of the memory or I/O operations.
122 @param Address The base address of the memory or I/O operations.
123 @param Mask Mask used for the polling criteria.
124 @param Value The comparison value used for the polling exit criteria.
125 @param Delay The number of 100 ns units to poll.
126 @param Result Pointer to the last value read from the memory location.
127
128 @retval EFI_SUCCESS The last data returned from the access matched the poll exit criteria.
129 @retval EFI_TIMEOUT Delay expired before a match occurred.
130 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
131 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
132
133 **/
134 typedef
135 EFI_STATUS
136 (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_POLL_IO_MEM)(
137 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
138 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
139 IN UINT64 Address,
140 IN UINT64 Mask,
141 IN UINT64 Value,
142 IN UINT64 Delay,
143 OUT UINT64 *Result
144 );
145
146 /**
147 Enables a PCI driver to access PCI controller registers in the PCI root bridge memory space.
148
149 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
150 @param Width Signifies the width of the memory operations.
151 @param Address The base address of the memory operations.
152 @param Count The number of memory operations to perform.
153 @param Buffer For read operations, the destination buffer to store the results. For write
154 operations, the source buffer to write data from.
155
156 @retval EFI_SUCCESS The data was read from or written to the PCI root bridge.
157 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
158 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
159
160 **/
161 typedef
162 EFI_STATUS
163 (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_IO_MEM)(
164 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
165 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
166 IN UINT64 Address,
167 IN UINTN Count,
168 IN OUT VOID *Buffer
169 );
170
171 typedef struct {
172 ///
173 /// Read PCI controller registers in the PCI root bridge memory space.
174 ///
175 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_IO_MEM Read;
176 ///
177 /// Write PCI controller registers in the PCI root bridge memory space.
178 ///
179 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_IO_MEM Write;
180 } EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS;
181
182 /**
183 Enables a PCI driver to copy one region of PCI root bridge memory space to another region of PCI
184 root bridge memory space.
185
186 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL instance.
187 @param Width Signifies the width of the memory operations.
188 @param DestAddress The destination address of the memory operation.
189 @param SrcAddress The source address of the memory operation.
190 @param Count The number of memory operations to perform.
191
192 @retval EFI_SUCCESS The data was copied from one memory region to another memory region.
193 @retval EFI_INVALID_PARAMETER Width is invalid for this PCI root bridge.
194 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
195
196 **/
197 typedef
198 EFI_STATUS
199 (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_COPY_MEM)(
200 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
201 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
202 IN UINT64 DestAddress,
203 IN UINT64 SrcAddress,
204 IN UINTN Count
205 );
206
207 /**
208 Provides the PCI controller-specific addresses required to access system memory from a
209 DMA bus master.
210
211 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
212 @param Operation Indicates if the bus master is going to read or write to system memory.
213 @param HostAddress The system memory address to map to the PCI controller.
214 @param NumberOfBytes On input the number of bytes to map. On output the number of bytes
215 that were mapped.
216 @param DeviceAddress The resulting map address for the bus master PCI controller to use to
217 access the hosts HostAddress.
218 @param Mapping A resulting value to pass to Unmap().
219
220 @retval EFI_SUCCESS The range was mapped for the returned NumberOfBytes.
221 @retval EFI_UNSUPPORTED The HostAddress cannot be mapped as a common buffer.
222 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
223 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
224 @retval EFI_DEVICE_ERROR The system hardware could not map the requested address.
225
226 **/
227 typedef
228 EFI_STATUS
229 (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_MAP)(
230 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
231 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION Operation,
232 IN VOID *HostAddress,
233 IN OUT UINTN *NumberOfBytes,
234 OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
235 OUT VOID **Mapping
236 );
237
238 /**
239 Completes the Map() operation and releases any corresponding resources.
240
241 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
242 @param Mapping The mapping value returned from Map().
243
244 @retval EFI_SUCCESS The range was unmapped.
245 @retval EFI_INVALID_PARAMETER Mapping is not a value that was returned by Map().
246 @retval EFI_DEVICE_ERROR The data was not committed to the target system memory.
247
248 **/
249 typedef
250 EFI_STATUS
251 (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_UNMAP)(
252 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
253 IN VOID *Mapping
254 );
255
256 /**
257 Allocates pages that are suitable for an EfiPciOperationBusMasterCommonBuffer or
258 EfiPciOperationBusMasterCommonBuffer64 mapping.
259
260 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
261 @param Type This parameter is not used and must be ignored.
262 @param MemoryType The type of memory to allocate, EfiBootServicesData or
263 EfiRuntimeServicesData.
264 @param Pages The number of pages to allocate.
265 @param HostAddress A pointer to store the base system memory address of the
266 allocated range.
267 @param Attributes The requested bit mask of attributes for the allocated range.
268
269 @retval EFI_SUCCESS The requested memory pages were allocated.
270 @retval EFI_UNSUPPORTED Attributes is unsupported. The only legal attribute bits are
271 MEMORY_WRITE_COMBINE and MEMORY_CACHED.
272 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
273 @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.
274
275 **/
276 typedef
277 EFI_STATUS
278 (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ALLOCATE_BUFFER)(
279 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
280 IN EFI_ALLOCATE_TYPE Type,
281 IN EFI_MEMORY_TYPE MemoryType,
282 IN UINTN Pages,
283 IN OUT VOID **HostAddress,
284 IN UINT64 Attributes
285 );
286
287 /**
288 Frees memory that was allocated with AllocateBuffer().
289
290 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
291 @param Pages The number of pages to free.
292 @param HostAddress The base system memory address of the allocated range.
293
294 @retval EFI_SUCCESS The requested memory pages were freed.
295 @retval EFI_INVALID_PARAMETER The memory range specified by HostAddress and Pages
296 was not allocated with AllocateBuffer().
297
298 **/
299 typedef
300 EFI_STATUS
301 (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FREE_BUFFER)(
302 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
303 IN UINTN Pages,
304 IN VOID *HostAddress
305 );
306
307 /**
308 Flushes all PCI posted write transactions from a PCI host bridge to system memory.
309
310 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
311
312 @retval EFI_SUCCESS The PCI posted write transactions were flushed from the PCI host
313 bridge to system memory.
314 @retval EFI_DEVICE_ERROR The PCI posted write transactions were not flushed from the PCI
315 host bridge due to a hardware error.
316
317 **/
318 typedef
319 EFI_STATUS
320 (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FLUSH)(
321 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This
322 );
323
324 /**
325 Gets the attributes that a PCI root bridge supports setting with SetAttributes(), and the
326 attributes that a PCI root bridge is currently using.
327
328 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
329 @param Supports A pointer to the mask of attributes that this PCI root bridge supports
330 setting with SetAttributes().
331 @param Attributes A pointer to the mask of attributes that this PCI root bridge is currently
332 using.
333
334 @retval EFI_SUCCESS If Supports is not NULL, then the attributes that the PCI root
335 bridge supports is returned in Supports. If Attributes is
336 not NULL, then the attributes that the PCI root bridge is currently
337 using is returned in Attributes.
338 @retval EFI_INVALID_PARAMETER Both Supports and Attributes are NULL.
339
340
341 **/
342 typedef
343 EFI_STATUS
344 (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GET_ATTRIBUTES)(
345 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
346 OUT UINT64 *Supports,
347 OUT UINT64 *Attributes
348 );
349
350 /**
351 Sets attributes for a resource range on a PCI root bridge.
352
353 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
354 @param Attributes The mask of attributes to set.
355 @param ResourceBase A pointer to the base address of the resource range to be modified by the
356 attributes specified by Attributes.
357 @param ResourceLength A pointer to the length of the resource range to be modified by the
358 attributes specified by Attributes.
359
360 @retval EFI_SUCCESS The set of attributes specified by Attributes for the resource
361 range specified by ResourceBase and ResourceLength
362 were set on the PCI root bridge, and the actual resource range is
363 returned in ResuourceBase and ResourceLength.
364 @retval EFI_UNSUPPORTED A bit is set in Attributes that is not supported by the PCI Root
365 Bridge.
366 @retval EFI_OUT_OF_RESOURCES There are not enough resources to set the attributes on the
367 resource range specified by BaseAddress and Length.
368 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
369
370 **/
371 typedef
372 EFI_STATUS
373 (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_SET_ATTRIBUTES)(
374 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
375 IN UINT64 Attributes,
376 IN OUT UINT64 *ResourceBase,
377 IN OUT UINT64 *ResourceLength
378 );
379
380 /**
381 Retrieves the current resource settings of this PCI root bridge in the form of a set of ACPI 2.0
382 resource descriptors.
383
384 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
385 @param Resources A pointer to the ACPI 2.0 resource descriptors that describe the current
386 configuration of this PCI root bridge.
387
388 @retval EFI_SUCCESS The current configuration of this PCI root bridge was returned in
389 Resources.
390 @retval EFI_UNSUPPORTED The current configuration of this PCI root bridge could not be
391 retrieved.
392
393 **/
394 typedef
395 EFI_STATUS
396 (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_CONFIGURATION)(
397 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
398 OUT VOID **Resources
399 );
400
401 ///
402 /// Provides the basic Memory, I/O, PCI configuration, and DMA interfaces that are
403 /// used to abstract accesses to PCI controllers behind a PCI Root Bridge Controller.
404 ///
405 struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL {
406 ///
407 /// The EFI_HANDLE of the PCI Host Bridge of which this PCI Root Bridge is a member.
408 ///
409 EFI_HANDLE ParentHandle;
410 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_POLL_IO_MEM PollMem;
411 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_POLL_IO_MEM PollIo;
412 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS Mem;
413 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS Io;
414 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS Pci;
415 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_COPY_MEM CopyMem;
416 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_MAP Map;
417 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_UNMAP Unmap;
418 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ALLOCATE_BUFFER AllocateBuffer;
419 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FREE_BUFFER FreeBuffer;
420 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FLUSH Flush;
421 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GET_ATTRIBUTES GetAttributes;
422 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_SET_ATTRIBUTES SetAttributes;
423 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_CONFIGURATION Configuration;
424
425 ///
426 /// The segment number that this PCI root bridge resides.
427 ///
428 UINT32 SegmentNumber;
429 };
430
431 extern EFI_GUID gEfiPciRootBridgeIoProtocolGuid;
432
433 #endif