iPXE
PciIo.h
Go to the documentation of this file.
00001 /** @file
00002   EFI PCI I/O Protocol provides the basic Memory, I/O, PCI configuration,
00003   and DMA interfaces that a driver uses to access its PCI controller.
00004 
00005   Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
00006   This program and the accompanying materials
00007   are licensed and made available under the terms and conditions of the BSD License
00008   which accompanies this distribution.  The full text of the license may be found at
00009   http://opensource.org/licenses/bsd-license.php
00010 
00011   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
00012   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
00013 
00014 **/
00015 
00016 #ifndef __PCI_IO_H__
00017 #define __PCI_IO_H__
00018 
00019 FILE_LICENCE ( BSD3 );
00020 
00021 ///
00022 /// Global ID for the PCI I/O Protocol
00023 ///
00024 #define EFI_PCI_IO_PROTOCOL_GUID \
00025   { \
00026     0x4cf5b200, 0x68b8, 0x4ca5, {0x9e, 0xec, 0xb2, 0x3e, 0x3f, 0x50, 0x2, 0x9a } \
00027   }
00028 
00029 typedef struct _EFI_PCI_IO_PROTOCOL  EFI_PCI_IO_PROTOCOL;
00030 
00031 ///
00032 /// *******************************************************
00033 /// EFI_PCI_IO_PROTOCOL_WIDTH
00034 /// *******************************************************
00035 ///
00036 typedef enum {
00037   EfiPciIoWidthUint8      = 0,
00038   EfiPciIoWidthUint16,
00039   EfiPciIoWidthUint32,
00040   EfiPciIoWidthUint64,
00041   EfiPciIoWidthFifoUint8,
00042   EfiPciIoWidthFifoUint16,
00043   EfiPciIoWidthFifoUint32,
00044   EfiPciIoWidthFifoUint64,
00045   EfiPciIoWidthFillUint8,
00046   EfiPciIoWidthFillUint16,
00047   EfiPciIoWidthFillUint32,
00048   EfiPciIoWidthFillUint64,
00049   EfiPciIoWidthMaximum
00050 } EFI_PCI_IO_PROTOCOL_WIDTH;
00051 
00052 //
00053 // Complete PCI address generater
00054 //
00055 #define EFI_PCI_IO_PASS_THROUGH_BAR               0xff    ///< Special BAR that passes a memory or I/O cycle through unchanged
00056 #define EFI_PCI_IO_ATTRIBUTE_MASK                 0x077f  ///< All the following I/O and Memory cycles
00057 #define EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO   0x0001  ///< I/O cycles 0x0000-0x00FF (10 bit decode)
00058 #define EFI_PCI_IO_ATTRIBUTE_ISA_IO               0x0002  ///< I/O cycles 0x0100-0x03FF or greater (10 bit decode)
00059 #define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO       0x0004  ///< I/O cycles 0x3C6, 0x3C8, 0x3C9 (10 bit decode)
00060 #define EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY           0x0008  ///< MEM cycles 0xA0000-0xBFFFF (24 bit decode)
00061 #define EFI_PCI_IO_ATTRIBUTE_VGA_IO               0x0010  ///< I/O cycles 0x3B0-0x3BB and 0x3C0-0x3DF (10 bit decode)
00062 #define EFI_PCI_IO_ATTRIBUTE_IDE_PRIMARY_IO       0x0020  ///< I/O cycles 0x1F0-0x1F7, 0x3F6, 0x3F7 (10 bit decode)
00063 #define EFI_PCI_IO_ATTRIBUTE_IDE_SECONDARY_IO     0x0040  ///< I/O cycles 0x170-0x177, 0x376, 0x377 (10 bit decode)
00064 #define EFI_PCI_IO_ATTRIBUTE_MEMORY_WRITE_COMBINE 0x0080  ///< Map a memory range so writes are combined
00065 #define EFI_PCI_IO_ATTRIBUTE_IO                   0x0100  ///< Enable the I/O decode bit in the PCI Config Header
00066 #define EFI_PCI_IO_ATTRIBUTE_MEMORY               0x0200  ///< Enable the Memory decode bit in the PCI Config Header
00067 #define EFI_PCI_IO_ATTRIBUTE_BUS_MASTER           0x0400  ///< Enable the DMA bit in the PCI Config Header
00068 #define EFI_PCI_IO_ATTRIBUTE_MEMORY_CACHED        0x0800  ///< Map a memory range so all r/w accesses are cached
00069 #define EFI_PCI_IO_ATTRIBUTE_MEMORY_DISABLE       0x1000  ///< Disable a memory range
00070 #define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_DEVICE      0x2000  ///< Clear for an add-in PCI Device
00071 #define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_ROM         0x4000  ///< Clear for a physical PCI Option ROM accessed through ROM BAR
00072 #define EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE   0x8000  ///< Clear for PCI controllers that can not genrate a DAC
00073 #define EFI_PCI_IO_ATTRIBUTE_ISA_IO_16            0x10000 ///< I/O cycles 0x0100-0x03FF or greater (16 bit decode)
00074 #define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO_16    0x20000 ///< I/O cycles 0x3C6, 0x3C8, 0x3C9 (16 bit decode)
00075 #define EFI_PCI_IO_ATTRIBUTE_VGA_IO_16            0x40000 ///< I/O cycles 0x3B0-0x3BB and 0x3C0-0x3DF (16 bit decode)
00076 
00077 #define EFI_PCI_DEVICE_ENABLE                     (EFI_PCI_IO_ATTRIBUTE_IO | EFI_PCI_IO_ATTRIBUTE_MEMORY | EFI_PCI_IO_ATTRIBUTE_BUS_MASTER)
00078 #define EFI_VGA_DEVICE_ENABLE                     (EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO | EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY | EFI_PCI_IO_ATTRIBUTE_VGA_IO | EFI_PCI_IO_ATTRIBUTE_IO)
00079 
00080 ///
00081 /// *******************************************************
00082 /// EFI_PCI_IO_PROTOCOL_OPERATION
00083 /// *******************************************************
00084 ///
00085 typedef enum {
00086   ///
00087   /// A read operation from system memory by a bus master.
00088   ///
00089   EfiPciIoOperationBusMasterRead,
00090   ///
00091   /// A write operation from system memory by a bus master.
00092   ///
00093   EfiPciIoOperationBusMasterWrite,
00094   ///
00095   /// Provides both read and write access to system memory by both the processor and a
00096   /// bus master. The buffer is coherent from both the processor's and the bus master's point of view.
00097   ///
00098   EfiPciIoOperationBusMasterCommonBuffer,
00099   EfiPciIoOperationMaximum
00100 } EFI_PCI_IO_PROTOCOL_OPERATION;
00101 
00102 ///
00103 /// *******************************************************
00104 /// EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION
00105 /// *******************************************************
00106 ///
00107 typedef enum {
00108   ///
00109   /// Retrieve the PCI controller's current attributes, and return them in Result.
00110   ///
00111   EfiPciIoAttributeOperationGet,
00112   ///
00113   /// Set the PCI controller's current attributes to Attributes.
00114   ///
00115   EfiPciIoAttributeOperationSet,
00116   ///
00117   /// Enable the attributes specified by the bits that are set in Attributes for this PCI controller.
00118   ///
00119   EfiPciIoAttributeOperationEnable,
00120   ///
00121   /// Disable the attributes specified by the bits that are set in Attributes for this PCI controller.
00122   ///
00123   EfiPciIoAttributeOperationDisable,
00124   ///
00125   /// Retrieve the PCI controller's supported attributes, and return them in Result.
00126   ///
00127   EfiPciIoAttributeOperationSupported,
00128   EfiPciIoAttributeOperationMaximum
00129 } EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION;
00130 
00131 /**
00132   Reads from the memory space of a PCI controller. Returns either when the polling exit criteria is
00133   satisfied or after a defined duration.
00134 
00135   @param  This                  A pointer to the EFI_PCI_IO_PROTOCOL instance.
00136   @param  Width                 Signifies the width of the memory or I/O operations.
00137   @param  BarIndex              The BAR index of the standard PCI Configuration header to use as the
00138                                 base address for the memory operation to perform.
00139   @param  Offset                The offset within the selected BAR to start the memory operation.
00140   @param  Mask                  Mask used for the polling criteria.
00141   @param  Value                 The comparison value used for the polling exit criteria.
00142   @param  Delay                 The number of 100 ns units to poll.
00143   @param  Result                Pointer to the last value read from the memory location.
00144 
00145   @retval EFI_SUCCESS           The last data returned from the access matched the poll exit criteria.
00146   @retval EFI_UNSUPPORTED       BarIndex not valid for this PCI controller.
00147   @retval EFI_UNSUPPORTED       Offset is not valid for the BarIndex of this PCI controller.
00148   @retval EFI_TIMEOUT           Delay expired before a match occurred.
00149   @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack of resources.
00150   @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
00151 
00152 **/
00153 typedef
00154 EFI_STATUS
00155 (EFIAPI *EFI_PCI_IO_PROTOCOL_POLL_IO_MEM)(
00156   IN EFI_PCI_IO_PROTOCOL           *This,
00157   IN  EFI_PCI_IO_PROTOCOL_WIDTH    Width,
00158   IN  UINT8                        BarIndex,
00159   IN  UINT64                       Offset,
00160   IN  UINT64                       Mask,
00161   IN  UINT64                       Value,
00162   IN  UINT64                       Delay,
00163   OUT UINT64                       *Result
00164   );
00165 
00166 /**
00167   Enable a PCI driver to access PCI controller registers in the PCI memory or I/O space.
00168 
00169   @param  This                  A pointer to the EFI_PCI_IO_PROTOCOL instance.
00170   @param  Width                 Signifies the width of the memory or I/O operations.
00171   @param  BarIndex              The BAR index of the standard PCI Configuration header to use as the
00172                                 base address for the memory or I/O operation to perform.
00173   @param  Offset                The offset within the selected BAR to start the memory or I/O operation.
00174   @param  Count                 The number of memory or I/O operations to perform.
00175   @param  Buffer                For read operations, the destination buffer to store the results. For write
00176                                 operations, the source buffer to write data from.
00177 
00178   @retval EFI_SUCCESS           The data was read from or written to the PCI controller.
00179   @retval EFI_UNSUPPORTED       BarIndex not valid for this PCI controller.
00180   @retval EFI_UNSUPPORTED       The address range specified by Offset, Width, and Count is not
00181                                 valid for the PCI BAR specified by BarIndex.
00182   @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack of resources.
00183   @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
00184 
00185 **/
00186 typedef
00187 EFI_STATUS
00188 (EFIAPI *EFI_PCI_IO_PROTOCOL_IO_MEM)(
00189   IN EFI_PCI_IO_PROTOCOL              *This,
00190   IN     EFI_PCI_IO_PROTOCOL_WIDTH    Width,
00191   IN     UINT8                        BarIndex,
00192   IN     UINT64                       Offset,
00193   IN     UINTN                        Count,
00194   IN OUT VOID                         *Buffer
00195   );
00196 
00197 typedef struct {
00198   ///
00199   /// Read PCI controller registers in the PCI memory or I/O space.
00200   ///
00201   EFI_PCI_IO_PROTOCOL_IO_MEM  Read;
00202   ///
00203   /// Write PCI controller registers in the PCI memory or I/O space.
00204   ///
00205   EFI_PCI_IO_PROTOCOL_IO_MEM  Write;
00206 } EFI_PCI_IO_PROTOCOL_ACCESS;
00207 
00208 /**
00209   Enable a PCI driver to access PCI controller registers in PCI configuration space.
00210 
00211   @param  This                  A pointer to the EFI_PCI_IO_PROTOCOL instance.
00212   @param  Width                 Signifies the width of the memory operations.
00213   @param  Offset                The offset within the PCI configuration space for the PCI controller.
00214   @param  Count                 The number of PCI configuration operations to perform.
00215   @param  Buffer                For read operations, the destination buffer to store the results. For write
00216                                 operations, the source buffer to write data from.
00217 
00218 
00219   @retval EFI_SUCCESS           The data was read from or written to the PCI controller.
00220   @retval EFI_UNSUPPORTED       The address range specified by Offset, Width, and Count is not
00221                                 valid for the PCI configuration header of the PCI controller.
00222   @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack of resources.
00223   @retval EFI_INVALID_PARAMETER Buffer is NULL or Width is invalid.
00224 
00225 **/
00226 typedef
00227 EFI_STATUS
00228 (EFIAPI *EFI_PCI_IO_PROTOCOL_CONFIG)(
00229   IN EFI_PCI_IO_PROTOCOL              *This,
00230   IN     EFI_PCI_IO_PROTOCOL_WIDTH    Width,
00231   IN     UINT32                       Offset,
00232   IN     UINTN                        Count,
00233   IN OUT VOID                         *Buffer
00234   );
00235 
00236 typedef struct {
00237   ///
00238   /// Read PCI controller registers in PCI configuration space.
00239   ///
00240   EFI_PCI_IO_PROTOCOL_CONFIG  Read;
00241   ///
00242   /// Write PCI controller registers in PCI configuration space.
00243   ///
00244   EFI_PCI_IO_PROTOCOL_CONFIG  Write;
00245 } EFI_PCI_IO_PROTOCOL_CONFIG_ACCESS;
00246 
00247 /**
00248   Enables a PCI driver to copy one region of PCI memory space to another region of PCI
00249   memory space.
00250 
00251   @param  This                  A pointer to the EFI_PCI_IO_PROTOCOL instance.
00252   @param  Width                 Signifies the width of the memory operations.
00253   @param  DestBarIndex          The BAR index in the standard PCI Configuration header to use as the
00254                                 base address for the memory operation to perform.
00255   @param  DestOffset            The destination offset within the BAR specified by DestBarIndex to
00256                                 start the memory writes for the copy operation.
00257   @param  SrcBarIndex           The BAR index in the standard PCI Configuration header to use as the
00258                                 base address for the memory operation to perform.
00259   @param  SrcOffset             The source offset within the BAR specified by SrcBarIndex to start
00260                                 the memory reads for the copy operation.
00261   @param  Count                 The number of memory operations to perform. Bytes moved is Width
00262                                 size * Count, starting at DestOffset and SrcOffset.
00263 
00264   @retval EFI_SUCCESS           The data was copied from one memory region to another memory region.
00265   @retval EFI_UNSUPPORTED       DestBarIndex not valid for this PCI controller.
00266   @retval EFI_UNSUPPORTED       SrcBarIndex not valid for this PCI controller.
00267   @retval EFI_UNSUPPORTED       The address range specified by DestOffset, Width, and Count
00268                                 is not valid for the PCI BAR specified by DestBarIndex.
00269   @retval EFI_UNSUPPORTED       The address range specified by SrcOffset, Width, and Count is
00270                                 not valid for the PCI BAR specified by SrcBarIndex.
00271   @retval EFI_INVALID_PARAMETER Width is invalid.
00272   @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack of resources.
00273 
00274 **/
00275 typedef
00276 EFI_STATUS
00277 (EFIAPI *EFI_PCI_IO_PROTOCOL_COPY_MEM)(
00278   IN EFI_PCI_IO_PROTOCOL              *This,
00279   IN     EFI_PCI_IO_PROTOCOL_WIDTH    Width,
00280   IN     UINT8                        DestBarIndex,
00281   IN     UINT64                       DestOffset,
00282   IN     UINT8                        SrcBarIndex,
00283   IN     UINT64                       SrcOffset,
00284   IN     UINTN                        Count
00285   );
00286 
00287 /**
00288   Provides the PCI controller-specific addresses needed to access system memory.
00289 
00290   @param  This                  A pointer to the EFI_PCI_IO_PROTOCOL instance.
00291   @param  Operation             Indicates if the bus master is going to read or write to system memory.
00292   @param  HostAddress           The system memory address to map to the PCI controller.
00293   @param  NumberOfBytes         On input the number of bytes to map. On output the number of bytes
00294                                 that were mapped.
00295   @param  DeviceAddress         The resulting map address for the bus master PCI controller to use to
00296                                 access the hosts HostAddress.
00297   @param  Mapping               A resulting value to pass to Unmap().
00298 
00299   @retval EFI_SUCCESS           The range was mapped for the returned NumberOfBytes.
00300   @retval EFI_UNSUPPORTED       The HostAddress cannot be mapped as a common buffer.
00301   @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
00302   @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack of resources.
00303   @retval EFI_DEVICE_ERROR      The system hardware could not map the requested address.
00304 
00305 **/
00306 typedef
00307 EFI_STATUS
00308 (EFIAPI *EFI_PCI_IO_PROTOCOL_MAP)(
00309   IN EFI_PCI_IO_PROTOCOL                *This,
00310   IN     EFI_PCI_IO_PROTOCOL_OPERATION  Operation,
00311   IN     VOID                           *HostAddress,
00312   IN OUT UINTN                          *NumberOfBytes,
00313   OUT    EFI_PHYSICAL_ADDRESS           *DeviceAddress,
00314   OUT    VOID                           **Mapping
00315   );
00316 
00317 /**
00318   Completes the Map() operation and releases any corresponding resources.
00319 
00320   @param  This                  A pointer to the EFI_PCI_IO_PROTOCOL instance.
00321   @param  Mapping               The mapping value returned from Map().
00322 
00323   @retval EFI_SUCCESS           The range was unmapped.
00324   @retval EFI_DEVICE_ERROR      The data was not committed to the target system memory.
00325 
00326 **/
00327 typedef
00328 EFI_STATUS
00329 (EFIAPI *EFI_PCI_IO_PROTOCOL_UNMAP)(
00330   IN EFI_PCI_IO_PROTOCOL           *This,
00331   IN  VOID                         *Mapping
00332   );
00333 
00334 /**
00335   Allocates pages that are suitable for an EfiPciIoOperationBusMasterCommonBuffer
00336   mapping.
00337 
00338   @param  This                  A pointer to the EFI_PCI_IO_PROTOCOL instance.
00339   @param  Type                  This parameter is not used and must be ignored.
00340   @param  MemoryType            The type of memory to allocate, EfiBootServicesData or
00341                                 EfiRuntimeServicesData.
00342   @param  Pages                 The number of pages to allocate.
00343   @param  HostAddress           A pointer to store the base system memory address of the
00344                                 allocated range.
00345   @param  Attributes            The requested bit mask of attributes for the allocated range.
00346 
00347   @retval EFI_SUCCESS           The requested memory pages were allocated.
00348   @retval EFI_UNSUPPORTED       Attributes is unsupported. The only legal attribute bits are
00349                                 MEMORY_WRITE_COMBINE and MEMORY_CACHED.
00350   @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
00351   @retval EFI_OUT_OF_RESOURCES  The memory pages could not be allocated.
00352 
00353 **/
00354 typedef
00355 EFI_STATUS
00356 (EFIAPI *EFI_PCI_IO_PROTOCOL_ALLOCATE_BUFFER)(
00357   IN EFI_PCI_IO_PROTOCOL           *This,
00358   IN  EFI_ALLOCATE_TYPE            Type,
00359   IN  EFI_MEMORY_TYPE              MemoryType,
00360   IN  UINTN                        Pages,
00361   OUT VOID                         **HostAddress,
00362   IN  UINT64                       Attributes
00363   );
00364 
00365 /**
00366   Frees memory that was allocated with AllocateBuffer().
00367 
00368   @param  This                  A pointer to the EFI_PCI_IO_PROTOCOL instance.
00369   @param  Pages                 The number of pages to free.
00370   @param  HostAddress           The base system memory address of the allocated range.
00371 
00372   @retval EFI_SUCCESS           The requested memory pages were freed.
00373   @retval EFI_INVALID_PARAMETER The memory range specified by HostAddress and Pages
00374                                 was not allocated with AllocateBuffer().
00375 
00376 **/
00377 typedef
00378 EFI_STATUS
00379 (EFIAPI *EFI_PCI_IO_PROTOCOL_FREE_BUFFER)(
00380   IN EFI_PCI_IO_PROTOCOL           *This,
00381   IN  UINTN                        Pages,
00382   IN  VOID                         *HostAddress
00383   );
00384 
00385 /**
00386   Flushes all PCI posted write transactions from a PCI host bridge to system memory.
00387 
00388   @param  This                  A pointer to the EFI_PCI_IO_PROTOCOL instance.
00389 
00390   @retval EFI_SUCCESS           The PCI posted write transactions were flushed from the PCI host
00391                                 bridge to system memory.
00392   @retval EFI_DEVICE_ERROR      The PCI posted write transactions were not flushed from the PCI
00393                                 host bridge due to a hardware error.
00394 
00395 **/
00396 typedef
00397 EFI_STATUS
00398 (EFIAPI *EFI_PCI_IO_PROTOCOL_FLUSH)(
00399   IN EFI_PCI_IO_PROTOCOL  *This
00400   );
00401 
00402 /**
00403   Retrieves this PCI controller's current PCI bus number, device number, and function number.
00404 
00405   @param  This                  A pointer to the EFI_PCI_IO_PROTOCOL instance.
00406   @param  SegmentNumber         The PCI controller's current PCI segment number.
00407   @param  BusNumber             The PCI controller's current PCI bus number.
00408   @param  DeviceNumber          The PCI controller's current PCI device number.
00409   @param  FunctionNumber        The PCI controller's current PCI function number.
00410 
00411   @retval EFI_SUCCESS           The PCI controller location was returned.
00412   @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
00413 
00414 **/
00415 typedef
00416 EFI_STATUS
00417 (EFIAPI *EFI_PCI_IO_PROTOCOL_GET_LOCATION)(
00418   IN EFI_PCI_IO_PROTOCOL          *This,
00419   OUT UINTN                       *SegmentNumber,
00420   OUT UINTN                       *BusNumber,
00421   OUT UINTN                       *DeviceNumber,
00422   OUT UINTN                       *FunctionNumber
00423   );
00424 
00425 /**
00426   Performs an operation on the attributes that this PCI controller supports. The operations include
00427   getting the set of supported attributes, retrieving the current attributes, setting the current
00428   attributes, enabling attributes, and disabling attributes.
00429 
00430   @param  This                  A pointer to the EFI_PCI_IO_PROTOCOL instance.
00431   @param  Operation             The operation to perform on the attributes for this PCI controller.
00432   @param  Attributes            The mask of attributes that are used for Set, Enable, and Disable
00433                                 operations.
00434   @param  Result                A pointer to the result mask of attributes that are returned for the Get
00435                                 and Supported operations.
00436 
00437   @retval EFI_SUCCESS           The operation on the PCI controller's attributes was completed.
00438   @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
00439   @retval EFI_UNSUPPORTED       one or more of the bits set in
00440                                 Attributes are not supported by this PCI controller or one of
00441                                 its parent bridges when Operation is Set, Enable or Disable.
00442 
00443 **/
00444 typedef
00445 EFI_STATUS
00446 (EFIAPI *EFI_PCI_IO_PROTOCOL_ATTRIBUTES)(
00447   IN EFI_PCI_IO_PROTOCOL                       *This,
00448   IN  EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION  Operation,
00449   IN  UINT64                                   Attributes,
00450   OUT UINT64                                   *Result OPTIONAL
00451   );
00452 
00453 /**
00454   Gets the attributes that this PCI controller supports setting on a BAR using
00455   SetBarAttributes(), and retrieves the list of resource descriptors for a BAR.
00456 
00457   @param  This                  A pointer to the EFI_PCI_IO_PROTOCOL instance.
00458   @param  BarIndex              The BAR index of the standard PCI Configuration header to use as the
00459                                 base address for resource range. The legal range for this field is 0..5.
00460   @param  Supports              A pointer to the mask of attributes that this PCI controller supports
00461                                 setting for this BAR with SetBarAttributes().
00462   @param  Resources             A pointer to the ACPI 2.0 resource descriptors that describe the current
00463                                 configuration of this BAR of the PCI controller.
00464 
00465   @retval EFI_SUCCESS           If Supports is not NULL, then the attributes that the PCI
00466                                 controller supports are returned in Supports. If Resources
00467                                 is not NULL, then the ACPI 2.0 resource descriptors that the PCI
00468                                 controller is currently using are returned in Resources.
00469   @retval EFI_INVALID_PARAMETER Both Supports and Attributes are NULL.
00470   @retval EFI_UNSUPPORTED       BarIndex not valid for this PCI controller.
00471   @retval EFI_OUT_OF_RESOURCES  There are not enough resources available to allocate
00472                                 Resources.
00473 
00474 **/
00475 typedef
00476 EFI_STATUS
00477 (EFIAPI *EFI_PCI_IO_PROTOCOL_GET_BAR_ATTRIBUTES)(
00478   IN EFI_PCI_IO_PROTOCOL             *This,
00479   IN  UINT8                          BarIndex,
00480   OUT UINT64                         *Supports, OPTIONAL
00481   OUT VOID                           **Resources OPTIONAL
00482   );
00483 
00484 /**
00485   Sets the attributes for a range of a BAR on a PCI controller.
00486 
00487   @param  This                  A pointer to the EFI_PCI_IO_PROTOCOL instance.
00488   @param  Attributes            The mask of attributes to set for the resource range specified by
00489                                 BarIndex, Offset, and Length.
00490   @param  BarIndex              The BAR index of the standard PCI Configuration header to use as the
00491                                 base address for resource range. The legal range for this field is 0..5.
00492   @param  Offset                A pointer to the BAR relative base address of the resource range to be
00493                                 modified by the attributes specified by Attributes.
00494   @param  Length                A pointer to the length of the resource range to be modified by the
00495                                 attributes specified by Attributes.
00496 
00497   @retval EFI_SUCCESS           The set of attributes specified by Attributes for the resource
00498                                 range specified by BarIndex, Offset, and Length were
00499                                 set on the PCI controller, and the actual resource range is returned
00500                                 in Offset and Length.
00501   @retval EFI_INVALID_PARAMETER Offset or Length is NULL.
00502   @retval EFI_UNSUPPORTED       BarIndex not valid for this PCI controller.
00503   @retval EFI_OUT_OF_RESOURCES  There are not enough resources to set the attributes on the
00504                                 resource range specified by BarIndex, Offset, and
00505                                 Length.
00506 
00507 **/
00508 typedef
00509 EFI_STATUS
00510 (EFIAPI *EFI_PCI_IO_PROTOCOL_SET_BAR_ATTRIBUTES)(
00511   IN EFI_PCI_IO_PROTOCOL              *This,
00512   IN     UINT64                       Attributes,
00513   IN     UINT8                        BarIndex,
00514   IN OUT UINT64                       *Offset,
00515   IN OUT UINT64                       *Length
00516   );
00517 
00518 ///
00519 /// The EFI_PCI_IO_PROTOCOL provides the basic Memory, I/O, PCI configuration,
00520 /// and DMA interfaces used to abstract accesses to PCI controllers.
00521 /// There is one EFI_PCI_IO_PROTOCOL instance for each PCI controller on a PCI bus.
00522 /// A device driver that wishes to manage a PCI controller in a system will have to
00523 /// retrieve the EFI_PCI_IO_PROTOCOL instance that is associated with the PCI controller.
00524 ///
00525 struct _EFI_PCI_IO_PROTOCOL {
00526   EFI_PCI_IO_PROTOCOL_POLL_IO_MEM         PollMem;
00527   EFI_PCI_IO_PROTOCOL_POLL_IO_MEM         PollIo;
00528   EFI_PCI_IO_PROTOCOL_ACCESS              Mem;
00529   EFI_PCI_IO_PROTOCOL_ACCESS              Io;
00530   EFI_PCI_IO_PROTOCOL_CONFIG_ACCESS       Pci;
00531   EFI_PCI_IO_PROTOCOL_COPY_MEM            CopyMem;
00532   EFI_PCI_IO_PROTOCOL_MAP                 Map;
00533   EFI_PCI_IO_PROTOCOL_UNMAP               Unmap;
00534   EFI_PCI_IO_PROTOCOL_ALLOCATE_BUFFER     AllocateBuffer;
00535   EFI_PCI_IO_PROTOCOL_FREE_BUFFER         FreeBuffer;
00536   EFI_PCI_IO_PROTOCOL_FLUSH               Flush;
00537   EFI_PCI_IO_PROTOCOL_GET_LOCATION        GetLocation;
00538   EFI_PCI_IO_PROTOCOL_ATTRIBUTES          Attributes;
00539   EFI_PCI_IO_PROTOCOL_GET_BAR_ATTRIBUTES  GetBarAttributes;
00540   EFI_PCI_IO_PROTOCOL_SET_BAR_ATTRIBUTES  SetBarAttributes;
00541 
00542   ///
00543   /// The size, in bytes, of the ROM image.
00544   ///
00545   UINT64                                  RomSize;
00546 
00547   ///
00548   /// A pointer to the in memory copy of the ROM image. The PCI Bus Driver is responsible
00549   /// for allocating memory for the ROM image, and copying the contents of the ROM to memory.
00550   /// The contents of this buffer are either from the PCI option ROM that can be accessed
00551   /// through the ROM BAR of the PCI controller, or it is from a platform-specific location.
00552   /// The Attributes() function can be used to determine from which of these two sources
00553   /// the RomImage buffer was initialized.
00554   ///
00555   VOID                                    *RomImage;
00556 };
00557 
00558 extern EFI_GUID gEfiPciIoProtocolGuid;
00559 
00560 #endif