2 PCI Root Bridge I/O protocol as defined in the UEFI 2.0 specification.
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
8 Copyright (c) 2006 - 2008, Intel Corporation
9 All rights reserved. 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
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.
19 #ifndef __PCI_ROOT_BRIDGE_IO_H__
20 #define __PCI_ROOT_BRIDGE_IO_H__
22 #define EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GUID \
24 0x2f707ebb, 0x4a1a, 0x11d4, {0x9a, 0x38, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
27 typedef struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
;
35 EfiPciWidthFifoUint16
,
36 EfiPciWidthFifoUint32
,
37 EfiPciWidthFifoUint64
,
39 EfiPciWidthFillUint16
,
40 EfiPciWidthFillUint32
,
41 EfiPciWidthFillUint64
,
43 } EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH
;
46 EfiPciOperationBusMasterRead
,
47 EfiPciOperationBusMasterWrite
,
48 EfiPciOperationBusMasterCommonBuffer
,
49 EfiPciOperationBusMasterRead64
,
50 EfiPciOperationBusMasterWrite64
,
51 EfiPciOperationBusMasterCommonBuffer64
,
52 EfiPciOperationMaximum
53 } EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION
;
55 #define EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO 0x0001
56 #define EFI_PCI_ATTRIBUTE_ISA_IO 0x0002
57 #define EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO 0x0004
58 #define EFI_PCI_ATTRIBUTE_VGA_MEMORY 0x0008
59 #define EFI_PCI_ATTRIBUTE_VGA_IO 0x0010
60 #define EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO 0x0020
61 #define EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO 0x0040
62 #define EFI_PCI_ATTRIBUTE_MEMORY_WRITE_COMBINE 0x0080
63 #define EFI_PCI_ATTRIBUTE_MEMORY_CACHED 0x0800
64 #define EFI_PCI_ATTRIBUTE_MEMORY_DISABLE 0x1000
65 #define EFI_PCI_ATTRIBUTE_DUAL_ADDRESS_CYCLE 0x8000
67 #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)
69 #define EFI_PCI_ATTRIBUTE_INVALID_FOR_ALLOCATE_BUFFER (~EFI_PCI_ATTRIBUTE_VALID_FOR_ALLOCATE_BUFFER)
71 #define EFI_PCI_ADDRESS(bus, dev, func, reg) \
72 ((UINT64) ((((UINTN) bus) << 24) + (((UINTN) dev) << 16) + (((UINTN) func) << 8) + ((UINTN) reg)))
79 UINT32 ExtendedRegister
;
80 } EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS
;
83 Reads from the I/O space of a PCI Root Bridge. Returns when either the polling exit criteria is
84 satisfied or after a defined duration.
86 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
87 @param Width Signifies the width of the memory or I/O operations.
88 @param Address The base address of the memory or I/O operations.
89 @param Mask Mask used for the polling criteria.
90 @param Value The comparison value used for the polling exit criteria.
91 @param Delay The number of 100 ns units to poll.
92 @param Result Pointer to the last value read from the memory location.
94 @retval EFI_SUCCESS The last data returned from the access matched the poll exit criteria.
95 @retval EFI_TIMEOUT Delay expired before a match occurred.
96 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
97 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
102 (EFIAPI
*EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_POLL_IO_MEM
)(
103 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*This
,
104 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width
,
113 Enables a PCI driver to access PCI controller registers in the PCI root bridge memory space.
115 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
116 @param Width Signifies the width of the memory operations.
117 @param Address The base address of the memory operations.
118 @param Count The number of memory operations to perform.
119 @param Buffer For read operations, the destination buffer to store the results. For write
120 operations, the source buffer to write data from.
122 @retval EFI_SUCCESS The data was read from or written to the PCI root bridge.
123 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
124 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
129 (EFIAPI
*EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_IO_MEM
)(
130 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*This
,
131 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width
,
138 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_IO_MEM Read
;
139 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_IO_MEM Write
;
140 } EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS
;
143 Enables a PCI driver to copy one region of PCI root bridge memory space to another region of PCI
144 root bridge memory space.
146 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL instance.
147 @param Width Signifies the width of the memory operations.
148 @param DestAddress The destination address of the memory operation.
149 @param SrcAddress The source address of the memory operation.
150 @param Count The number of memory operations to perform.
152 @retval EFI_SUCCESS The data was copied from one memory region to another memory region.
153 @retval EFI_INVALID_PARAMETER Width is invalid for this PCI root bridge.
154 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
159 (EFIAPI
*EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_COPY_MEM
)(
160 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*This
,
161 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width
,
162 IN UINT64 DestAddress
,
163 IN UINT64 SrcAddress
,
168 Provides the PCI controller-Cspecific addresses required to access system memory from a
171 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
172 @param Operation Indicates if the bus master is going to read or write to system memory.
173 @param HostAddress The system memory address to map to the PCI controller.
174 @param NumberOfBytes On input the number of bytes to map. On output the number of bytes
176 @param DeviceAddress The resulting map address for the bus master PCI controller to use to
177 access the hosts HostAddress.
178 @param Mapping A resulting value to pass to Unmap().
180 @retval EFI_SUCCESS The range was mapped for the returned NumberOfBytes.
181 @retval EFI_UNSUPPORTED The HostAddress cannot be mapped as a common buffer.
182 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
183 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
184 @retval EFI_DEVICE_ERROR The system hardware could not map the requested address.
189 (EFIAPI
*EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_MAP
)(
190 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*This
,
191 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION Operation
,
192 IN VOID
*HostAddress
,
193 IN OUT UINTN
*NumberOfBytes
,
194 OUT EFI_PHYSICAL_ADDRESS
*DeviceAddress
,
199 Completes the Map() operation and releases any corresponding resources.
201 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
202 @param Mapping The mapping value returned from Map().
204 @retval EFI_SUCCESS The range was unmapped.
205 @retval EFI_INVALID_PARAMETER Mapping is not a value that was returned by Map().
206 @retval EFI_DEVICE_ERROR The data was not committed to the target system memory.
211 (EFIAPI
*EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_UNMAP
)(
212 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*This
,
217 Allocates pages that are suitable for an EfiPciOperationBusMasterCommonBuffer or
218 EfiPciOperationBusMasterCommonBuffer64 mapping.
220 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
221 @param Type This parameter is not used and must be ignored.
222 @param MemoryType The type of memory to allocate, EfiBootServicesData or
223 EfiRuntimeServicesData.
224 @param Pages The number of pages to allocate.
225 @param HostAddress A pointer to store the base system memory address of the
227 @param Attributes The requested bit mask of attributes for the allocated range.
229 @retval EFI_SUCCESS The requested memory pages were allocated.
230 @retval EFI_UNSUPPORTED Attributes is unsupported. The only legal attribute bits are
231 MEMORY_WRITE_COMBINE and MEMORY_CACHED.
232 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
233 @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.
238 (EFIAPI
*EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ALLOCATE_BUFFER
)(
239 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*This
,
240 IN EFI_ALLOCATE_TYPE Type
,
241 IN EFI_MEMORY_TYPE MemoryType
,
243 IN OUT VOID
**HostAddress
,
248 Frees memory that was allocated with AllocateBuffer().
250 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
251 @param Pages The number of pages to free.
252 @param HostAddress The base system memory address of the allocated range.
254 @retval EFI_SUCCESS The requested memory pages were freed.
255 @retval EFI_INVALID_PARAMETER The memory range specified by HostAddress and Pages
256 was not allocated with AllocateBuffer().
261 (EFIAPI
*EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FREE_BUFFER
)(
262 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*This
,
268 Flushes all PCI posted write transactions from a PCI host bridge to system memory.
270 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
272 @retval EFI_SUCCESS The PCI posted write transactions were flushed from the PCI host
273 bridge to system memory.
274 @retval EFI_DEVICE_ERROR The PCI posted write transactions were not flushed from the PCI
275 host bridge due to a hardware error.
280 (EFIAPI
*EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FLUSH
)(
281 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*This
285 Gets the attributes that a PCI root bridge supports setting with SetAttributes(), and the
286 attributes that a PCI root bridge is currently using.
288 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
289 @param Supports A pointer to the mask of attributes that this PCI root bridge supports
290 setting with SetAttributes().
291 @param Attributes A pointer to the mask of attributes that this PCI root bridge is currently
294 @retval EFI_SUCCESS If Supports is not NULL, then the attributes that the PCI root
295 bridge supports is returned in Supports. If Attributes is
296 not NULL, then the attributes that the PCI root bridge is currently
297 using is returned in Attributes.
298 @retval EFI_INVALID_PARAMETER Both Supports and Attributes are NULL.
304 (EFIAPI
*EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GET_ATTRIBUTES
)(
305 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*This
,
306 OUT UINT64
*Supports
,
307 OUT UINT64
*Attributes
311 Sets attributes for a resource range on a PCI root bridge.
313 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
314 @param Attributes The mask of attributes to set.
315 @param ResourceBase A pointer to the base address of the resource range to be modified by the
316 attributes specified by Attributes.
317 @param ResourceLength A pointer to the length of the resource range to be modified by the
318 attributes specified by Attributes.
320 @retval EFI_SUCCESS The set of attributes specified by Attributes for the resource
321 range specified by ResourceBase and ResourceLength
322 were set on the PCI root bridge, and the actual resource range is
323 returned in ResuourceBase and ResourceLength.
324 @retval EFI_UNSUPPORTED A bit is set in Attributes that is not supported by the PCI Root
326 @retval EFI_OUT_OF_RESOURCES There are not enough resources to set the attributes on the
327 resource range specified by BaseAddress and Length.
328 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
333 (EFIAPI
*EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_SET_ATTRIBUTES
)(
334 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*This
,
335 IN UINT64 Attributes
,
336 IN OUT UINT64
*ResourceBase
,
337 IN OUT UINT64
*ResourceLength
341 Retrieves the current resource settings of this PCI root bridge in the form of a set of ACPI 2.0
342 resource descriptors.
344 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
345 @param Resources A pointer to the ACPI 2.0 resource descriptors that describe the current
346 configuration of this PCI root bridge.
348 @retval EFI_SUCCESS The current configuration of this PCI root bridge was returned in
350 @retval EFI_UNSUPPORTED The current configuration of this PCI root bridge could not be
356 (EFIAPI
*EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_CONFIGURATION
)(
357 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*This
,
362 /// Provides the basic Memory, I/O, PCI configuration, and DMA interfaces that are
363 /// used to abstract accesses to PCI controllers behind a PCI Root Bridge Controller.
365 struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
{
367 /// The EFI_HANDLE of the PCI Host Bridge of which this PCI Root Bridge is a member.
369 EFI_HANDLE ParentHandle
;
370 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_POLL_IO_MEM PollMem
;
371 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_POLL_IO_MEM PollIo
;
372 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS Mem
;
373 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS Io
;
374 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS Pci
;
375 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_COPY_MEM CopyMem
;
376 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_MAP Map
;
377 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_UNMAP Unmap
;
378 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ALLOCATE_BUFFER AllocateBuffer
;
379 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FREE_BUFFER FreeBuffer
;
380 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FLUSH Flush
;
381 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GET_ATTRIBUTES GetAttributes
;
382 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_SET_ATTRIBUTES SetAttributes
;
383 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_CONFIGURATION Configuration
;
386 /// The segment number that this PCI root bridge resides.
388 UINT32 SegmentNumber
;
391 extern EFI_GUID gEfiPciRootBridgeIoProtocolGuid
;