PciRootBridgeIo.h

Go to the documentation of this file.
00001 /** @file
00002   PCI Root Bridge I/O protocol as defined in the UEFI 2.0 specification.
00003 
00004   PCI Root Bridge I/O protocol is used by PCI Bus Driver to perform PCI Memory, PCI I/O,
00005   and PCI Configuration cycles on a PCI Root Bridge. It also provides services to perform
00006   defferent types of bus mastering DMA
00007 
00008   Copyright (c) 2006 - 2008, Intel Corporation
00009   All rights reserved. This program and the accompanying materials
00010   are licensed and made available under the terms and conditions of the BSD License
00011   which accompanies this distribution.  The full text of the license may be found at
00012   http://opensource.org/licenses/bsd-license.php
00013 
00014   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
00015   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
00016 
00017 **/
00018 
00019 #ifndef __PCI_ROOT_BRIDGE_IO_H__
00020 #define __PCI_ROOT_BRIDGE_IO_H__
00021 
00022 #define EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GUID \
00023   { \
00024     0x2f707ebb, 0x4a1a, 0x11d4, {0x9a, 0x38, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
00025   }
00026 
00027 typedef struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL;
00028 
00029 typedef enum {
00030   EfiPciWidthUint8,
00031   EfiPciWidthUint16,
00032   EfiPciWidthUint32,
00033   EfiPciWidthUint64,
00034   EfiPciWidthFifoUint8,
00035   EfiPciWidthFifoUint16,
00036   EfiPciWidthFifoUint32,
00037   EfiPciWidthFifoUint64,
00038   EfiPciWidthFillUint8,
00039   EfiPciWidthFillUint16,
00040   EfiPciWidthFillUint32,
00041   EfiPciWidthFillUint64,
00042   EfiPciWidthMaximum
00043 } EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH;
00044 
00045 typedef enum {
00046   EfiPciOperationBusMasterRead,
00047   EfiPciOperationBusMasterWrite,
00048   EfiPciOperationBusMasterCommonBuffer,
00049   EfiPciOperationBusMasterRead64,
00050   EfiPciOperationBusMasterWrite64,
00051   EfiPciOperationBusMasterCommonBuffer64,
00052   EfiPciOperationMaximum
00053 } EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION;
00054 
00055 #define EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO          0x0001
00056 #define EFI_PCI_ATTRIBUTE_ISA_IO                      0x0002
00057 #define EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO              0x0004
00058 #define EFI_PCI_ATTRIBUTE_VGA_MEMORY                  0x0008
00059 #define EFI_PCI_ATTRIBUTE_VGA_IO                      0x0010
00060 #define EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO              0x0020
00061 #define EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO            0x0040
00062 #define EFI_PCI_ATTRIBUTE_MEMORY_WRITE_COMBINE        0x0080
00063 #define EFI_PCI_ATTRIBUTE_MEMORY_CACHED               0x0800
00064 #define EFI_PCI_ATTRIBUTE_MEMORY_DISABLE              0x1000
00065 #define EFI_PCI_ATTRIBUTE_DUAL_ADDRESS_CYCLE          0x8000
00066 
00067 #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)
00068 
00069 #define EFI_PCI_ATTRIBUTE_INVALID_FOR_ALLOCATE_BUFFER (~EFI_PCI_ATTRIBUTE_VALID_FOR_ALLOCATE_BUFFER)
00070 
00071 #define EFI_PCI_ADDRESS(bus, dev, func, reg) \
00072     ((UINT64) ((((UINTN) bus) << 24) + (((UINTN) dev) << 16) + (((UINTN) func) << 8) + ((UINTN) reg)))
00073 
00074 typedef struct {
00075   UINT8   Register;
00076   UINT8   Function;
00077   UINT8   Device;
00078   UINT8   Bus;
00079   UINT32  ExtendedRegister;
00080 } EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS;
00081 
00082 /**
00083   Reads from the I/O space of a PCI Root Bridge. Returns when either the polling exit criteria is
00084   satisfied or after a defined duration.
00085 
00086   @param  This                  A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
00087   @param  Width                 Signifies the width of the memory or I/O operations.
00088   @param  Address               The base address of the memory or I/O operations.
00089   @param  Mask                  Mask used for the polling criteria.
00090   @param  Value                 The comparison value used for the polling exit criteria.
00091   @param  Delay                 The number of 100 ns units to poll.
00092   @param  Result                Pointer to the last value read from the memory location.
00093 
00094   @retval EFI_SUCCESS           The last data returned from the access matched the poll exit criteria.
00095   @retval EFI_TIMEOUT           Delay expired before a match occurred.
00096   @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack of resources.
00097   @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
00098 
00099 **/
00100 typedef
00101 EFI_STATUS
00102 (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_POLL_IO_MEM)(
00103   IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL           *This,
00104   IN  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH    Width,
00105   IN  UINT64                                   Address,
00106   IN  UINT64                                   Mask,
00107   IN  UINT64                                   Value,
00108   IN  UINT64                                   Delay,
00109   OUT UINT64                                   *Result
00110   );
00111 
00112 /**
00113   Enables a PCI driver to access PCI controller registers in the PCI root bridge memory space.
00114 
00115   @param  This                  A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
00116   @param  Width                 Signifies the width of the memory operations.
00117   @param  Address               The base address of the memory operations.
00118   @param  Count                 The number of memory operations to perform.
00119   @param  Buffer                For read operations, the destination buffer to store the results. For write
00120                                 operations, the source buffer to write data from.
00121 
00122   @retval EFI_SUCCESS           The data was read from or written to the PCI root bridge.
00123   @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack of resources.
00124   @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
00125 
00126 **/
00127 typedef
00128 EFI_STATUS
00129 (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_IO_MEM)(
00130   IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL              *This,
00131   IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH    Width,
00132   IN     UINT64                                   Address,
00133   IN     UINTN                                    Count,
00134   IN OUT VOID                                     *Buffer
00135   );
00136 
00137 typedef struct {
00138   EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_IO_MEM  Read;
00139   EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_IO_MEM  Write;
00140 } EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS;
00141 
00142 /**
00143   Enables a PCI driver to copy one region of PCI root bridge memory space to another region of PCI
00144   root bridge memory space.
00145 
00146   @param  This                  A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL instance.
00147   @param  Width                 Signifies the width of the memory operations.
00148   @param  DestAddress           The destination address of the memory operation.
00149   @param  SrcAddress            The source address of the memory operation.
00150   @param  Count                 The number of memory operations to perform.
00151 
00152   @retval EFI_SUCCESS           The data was copied from one memory region to another memory region.
00153   @retval EFI_INVALID_PARAMETER Width is invalid for this PCI root bridge.
00154   @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack of resources.
00155 
00156 **/
00157 typedef
00158 EFI_STATUS
00159 (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_COPY_MEM)(
00160   IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL              *This,
00161   IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH    Width,
00162   IN     UINT64                                   DestAddress,
00163   IN     UINT64                                   SrcAddress,
00164   IN     UINTN                                    Count
00165   );
00166 
00167 /**
00168   Provides the PCI controller-Cspecific addresses required to access system memory from a
00169   DMA bus master.
00170 
00171   @param  This                  A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
00172   @param  Operation             Indicates if the bus master is going to read or write to system memory.
00173   @param  HostAddress           The system memory address to map to the PCI controller.
00174   @param  NumberOfBytes         On input the number of bytes to map. On output the number of bytes
00175                                 that were mapped.
00176   @param  DeviceAddress         The resulting map address for the bus master PCI controller to use to
00177                                 access the hosts HostAddress.
00178   @param  Mapping               A resulting value to pass to Unmap().
00179 
00180   @retval EFI_SUCCESS           The range was mapped for the returned NumberOfBytes.
00181   @retval EFI_UNSUPPORTED       The HostAddress cannot be mapped as a common buffer.
00182   @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
00183   @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack of resources.
00184   @retval EFI_DEVICE_ERROR      The system hardware could not map the requested address.
00185 
00186 **/
00187 typedef
00188 EFI_STATUS
00189 (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_MAP)(
00190   IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL                *This,
00191   IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION  Operation,
00192   IN     VOID                                       *HostAddress,
00193   IN OUT UINTN                                      *NumberOfBytes,
00194   OUT    EFI_PHYSICAL_ADDRESS                       *DeviceAddress,
00195   OUT    VOID                                       **Mapping
00196   );
00197 
00198 /**
00199   Completes the Map() operation and releases any corresponding resources.
00200 
00201   @param  This                  A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
00202   @param  Mapping               The mapping value returned from Map().
00203 
00204   @retval EFI_SUCCESS           The range was unmapped.
00205   @retval EFI_INVALID_PARAMETER Mapping is not a value that was returned by Map().
00206   @retval EFI_DEVICE_ERROR      The data was not committed to the target system memory.
00207 
00208 **/
00209 typedef
00210 EFI_STATUS
00211 (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_UNMAP)(
00212   IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL           *This,
00213   IN  VOID                                     *Mapping
00214   );
00215 
00216 /**
00217   Allocates pages that are suitable for an EfiPciOperationBusMasterCommonBuffer or
00218   EfiPciOperationBusMasterCommonBuffer64 mapping.
00219 
00220   @param  This                  A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
00221   @param  Type                  This parameter is not used and must be ignored.
00222   @param  MemoryType            The type of memory to allocate, EfiBootServicesData or
00223                                 EfiRuntimeServicesData.
00224   @param  Pages                 The number of pages to allocate.
00225   @param  HostAddress           A pointer to store the base system memory address of the
00226                                 allocated range.
00227   @param  Attributes            The requested bit mask of attributes for the allocated range.
00228 
00229   @retval EFI_SUCCESS           The requested memory pages were allocated.
00230   @retval EFI_UNSUPPORTED       Attributes is unsupported. The only legal attribute bits are
00231                                 MEMORY_WRITE_COMBINE and MEMORY_CACHED.
00232   @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
00233   @retval EFI_OUT_OF_RESOURCES  The memory pages could not be allocated.
00234 
00235 **/
00236 typedef
00237 EFI_STATUS
00238 (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ALLOCATE_BUFFER)(
00239   IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL              *This,
00240   IN     EFI_ALLOCATE_TYPE                        Type,
00241   IN     EFI_MEMORY_TYPE                          MemoryType,
00242   IN     UINTN                                    Pages,
00243   IN OUT VOID                                     **HostAddress,
00244   IN     UINT64                                   Attributes
00245   );
00246 
00247 /**
00248   Frees memory that was allocated with AllocateBuffer().
00249 
00250   @param  This                  A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
00251   @param  Pages                 The number of pages to free.
00252   @param  HostAddress           The base system memory address of the allocated range.
00253 
00254   @retval EFI_SUCCESS           The requested memory pages were freed.
00255   @retval EFI_INVALID_PARAMETER The memory range specified by HostAddress and Pages
00256                                 was not allocated with AllocateBuffer().
00257 
00258 **/
00259 typedef
00260 EFI_STATUS
00261 (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FREE_BUFFER)(
00262   IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL           *This,
00263   IN  UINTN                                    Pages,
00264   IN  VOID                                     *HostAddress
00265   );
00266 
00267 /**
00268   Flushes all PCI posted write transactions from a PCI host bridge to system memory.
00269 
00270   @param  This                  A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
00271 
00272   @retval EFI_SUCCESS           The PCI posted write transactions were flushed from the PCI host
00273                                 bridge to system memory.
00274   @retval EFI_DEVICE_ERROR      The PCI posted write transactions were not flushed from the PCI
00275                                 host bridge due to a hardware error.
00276 
00277 **/
00278 typedef
00279 EFI_STATUS
00280 (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FLUSH)(
00281   IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *This
00282   );
00283 
00284 /**
00285   Gets the attributes that a PCI root bridge supports setting with SetAttributes(), and the
00286   attributes that a PCI root bridge is currently using.
00287 
00288   @param  This                  A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
00289   @param  Supports              A pointer to the mask of attributes that this PCI root bridge supports
00290                                 setting with SetAttributes().
00291   @param  Attributes            A pointer to the mask of attributes that this PCI root bridge is currently
00292                                 using.
00293 
00294   @retval EFI_SUCCESS           If Supports is not NULL, then the attributes that the PCI root
00295                                 bridge supports is returned in Supports. If Attributes is
00296                                 not NULL, then the attributes that the PCI root bridge is currently
00297                                 using is returned in Attributes.
00298   @retval EFI_INVALID_PARAMETER Both Supports and Attributes are NULL.
00299 
00300 
00301 **/
00302 typedef
00303 EFI_STATUS
00304 (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GET_ATTRIBUTES)(
00305   IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL           *This,
00306   OUT UINT64                                   *Supports,
00307   OUT UINT64                                   *Attributes
00308   );
00309 
00310 /**
00311   Sets attributes for a resource range on a PCI root bridge.
00312 
00313   @param  This                  A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
00314   @param  Attributes            The mask of attributes to set.
00315   @param  ResourceBase          A pointer to the base address of the resource range to be modified by the
00316                                 attributes specified by Attributes.
00317   @param  ResourceLength        A pointer to the length of the resource range to be modified by the
00318                                 attributes specified by Attributes.
00319 
00320   @retval EFI_SUCCESS           The set of attributes specified by Attributes for the resource
00321                                 range specified by ResourceBase and ResourceLength
00322                                 were set on the PCI root bridge, and the actual resource range is
00323                                 returned in ResuourceBase and ResourceLength.
00324   @retval EFI_UNSUPPORTED       A bit is set in Attributes that is not supported by the PCI Root
00325                                 Bridge.
00326   @retval EFI_OUT_OF_RESOURCES  There are not enough resources to set the attributes on the
00327                                 resource range specified by BaseAddress and Length.
00328   @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
00329 
00330 **/
00331 typedef
00332 EFI_STATUS
00333 (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_SET_ATTRIBUTES)(
00334   IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL              *This,
00335   IN     UINT64                                   Attributes,
00336   IN OUT UINT64                                   *ResourceBase,
00337   IN OUT UINT64                                   *ResourceLength
00338   );
00339 
00340 /**
00341   Retrieves the current resource settings of this PCI root bridge in the form of a set of ACPI 2.0
00342   resource descriptors.
00343 
00344   @param  This                  A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
00345   @param  Resources             A pointer to the ACPI 2.0 resource descriptors that describe the current
00346                                 configuration of this PCI root bridge.
00347 
00348   @retval EFI_SUCCESS           The current configuration of this PCI root bridge was returned in
00349                                 Resources.
00350   @retval EFI_UNSUPPORTED       The current configuration of this PCI root bridge could not be
00351                                 retrieved.
00352 
00353 **/
00354 typedef
00355 EFI_STATUS
00356 (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_CONFIGURATION)(
00357   IN  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL          *This,
00358   OUT VOID                                     **Resources
00359   );
00360 
00361 ///
00362 /// Provides the basic Memory, I/O, PCI configuration, and DMA interfaces that are
00363 /// used to abstract accesses to PCI controllers behind a PCI Root Bridge Controller.
00364 ///
00365 struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL {
00366   ///
00367   /// The EFI_HANDLE of the PCI Host Bridge of which this PCI Root Bridge is a member.
00368   ///
00369   EFI_HANDLE                                      ParentHandle;
00370   EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_POLL_IO_MEM     PollMem;
00371   EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_POLL_IO_MEM     PollIo;
00372   EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS          Mem;
00373   EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS          Io;
00374   EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS          Pci;
00375   EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_COPY_MEM        CopyMem;
00376   EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_MAP             Map;
00377   EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_UNMAP           Unmap;
00378   EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ALLOCATE_BUFFER AllocateBuffer;
00379   EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FREE_BUFFER     FreeBuffer;
00380   EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FLUSH           Flush;
00381   EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GET_ATTRIBUTES  GetAttributes;
00382   EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_SET_ATTRIBUTES  SetAttributes;
00383   EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_CONFIGURATION   Configuration;
00384 
00385   ///
00386   /// The segment number that this PCI root bridge resides.
00387   ///
00388   UINT32                                          SegmentNumber;
00389 };
00390 
00391 extern EFI_GUID gEfiPciRootBridgeIoProtocolGuid;
00392 
00393 #endif

Generated on Tue Apr 6 20:01:07 2010 for gPXE by  doxygen 1.5.7.1