1ca987d46SWarner Losh /** @file 2ca987d46SWarner Losh EFI PCI I/O Protocol provides the basic Memory, I/O, PCI configuration, 3ca987d46SWarner Losh and DMA interfaces that a driver uses to access its PCI controller. 4ca987d46SWarner Losh 5ca987d46SWarner Losh Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR> 6ca987d46SWarner Losh This program and the accompanying materials 7ca987d46SWarner Losh are licensed and made available under the terms and conditions of the BSD License 8ca987d46SWarner Losh which accompanies this distribution. The full text of the license may be found at 9ca987d46SWarner Losh http://opensource.org/licenses/bsd-license.php 10ca987d46SWarner Losh 11ca987d46SWarner Losh THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 12ca987d46SWarner Losh WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 13ca987d46SWarner Losh 14ca987d46SWarner Losh **/ 15ca987d46SWarner Losh 16ca987d46SWarner Losh #ifndef __PCI_IO_H__ 17ca987d46SWarner Losh #define __PCI_IO_H__ 18ca987d46SWarner Losh 1965641822SToomas Soome #define EFI_PCI_ROOT_IO_GUID \ 2065641822SToomas Soome { 0x2F707EBB, 0x4A1A, 0x11d4, { 0x9A, 0x38, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }} 2165641822SToomas Soome 22ca987d46SWarner Losh /// 23ca987d46SWarner Losh /// Global ID for the PCI I/O Protocol 24ca987d46SWarner Losh /// 25ca987d46SWarner Losh #define EFI_PCI_IO_PROTOCOL_GUID \ 26ca987d46SWarner Losh { 0x4cf5b200, 0x68b8, 0x4ca5, {0x9e, 0xec, 0xb2, 0x3e, 0x3f, 0x50, 0x2, 0x9a} } 27ca987d46SWarner Losh 28ca987d46SWarner Losh typedef struct _EFI_PCI_IO_PROTOCOL EFI_PCI_IO_PROTOCOL; 29ca987d46SWarner Losh 30ca987d46SWarner Losh /// 31ca987d46SWarner Losh /// ******************************************************* 32ca987d46SWarner Losh /// EFI_PCI_IO_PROTOCOL_WIDTH 33ca987d46SWarner Losh /// ******************************************************* 34ca987d46SWarner Losh /// 35ca987d46SWarner Losh typedef enum { 36ca987d46SWarner Losh EfiPciIoWidthUint8 = 0, 37ca987d46SWarner Losh EfiPciIoWidthUint16, 38ca987d46SWarner Losh EfiPciIoWidthUint32, 39ca987d46SWarner Losh EfiPciIoWidthUint64, 40ca987d46SWarner Losh EfiPciIoWidthFifoUint8, 41ca987d46SWarner Losh EfiPciIoWidthFifoUint16, 42ca987d46SWarner Losh EfiPciIoWidthFifoUint32, 43ca987d46SWarner Losh EfiPciIoWidthFifoUint64, 44ca987d46SWarner Losh EfiPciIoWidthFillUint8, 45ca987d46SWarner Losh EfiPciIoWidthFillUint16, 46ca987d46SWarner Losh EfiPciIoWidthFillUint32, 47ca987d46SWarner Losh EfiPciIoWidthFillUint64, 48ca987d46SWarner Losh EfiPciIoWidthMaximum 49ca987d46SWarner Losh } EFI_PCI_IO_PROTOCOL_WIDTH; 50ca987d46SWarner Losh 51ca987d46SWarner Losh // 52ca987d46SWarner Losh // Complete PCI address generater 53ca987d46SWarner Losh // 54ca987d46SWarner Losh #define EFI_PCI_IO_PASS_THROUGH_BAR 0xff ///< Special BAR that passes a memory or I/O cycle through unchanged 55ca987d46SWarner Losh #define EFI_PCI_IO_ATTRIBUTE_MASK 0x077f ///< All the following I/O and Memory cycles 56ca987d46SWarner Losh #define EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO 0x0001 ///< I/O cycles 0x0000-0x00FF (10 bit decode) 57ca987d46SWarner Losh #define EFI_PCI_IO_ATTRIBUTE_ISA_IO 0x0002 ///< I/O cycles 0x0100-0x03FF or greater (10 bit decode) 58ca987d46SWarner Losh #define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO 0x0004 ///< I/O cycles 0x3C6, 0x3C8, 0x3C9 (10 bit decode) 59ca987d46SWarner Losh #define EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY 0x0008 ///< MEM cycles 0xA0000-0xBFFFF (24 bit decode) 60ca987d46SWarner Losh #define EFI_PCI_IO_ATTRIBUTE_VGA_IO 0x0010 ///< I/O cycles 0x3B0-0x3BB and 0x3C0-0x3DF (10 bit decode) 61ca987d46SWarner Losh #define EFI_PCI_IO_ATTRIBUTE_IDE_PRIMARY_IO 0x0020 ///< I/O cycles 0x1F0-0x1F7, 0x3F6, 0x3F7 (10 bit decode) 62ca987d46SWarner Losh #define EFI_PCI_IO_ATTRIBUTE_IDE_SECONDARY_IO 0x0040 ///< I/O cycles 0x170-0x177, 0x376, 0x377 (10 bit decode) 63ca987d46SWarner Losh #define EFI_PCI_IO_ATTRIBUTE_MEMORY_WRITE_COMBINE 0x0080 ///< Map a memory range so writes are combined 64ca987d46SWarner Losh #define EFI_PCI_IO_ATTRIBUTE_IO 0x0100 ///< Enable the I/O decode bit in the PCI Config Header 65ca987d46SWarner Losh #define EFI_PCI_IO_ATTRIBUTE_MEMORY 0x0200 ///< Enable the Memory decode bit in the PCI Config Header 66ca987d46SWarner Losh #define EFI_PCI_IO_ATTRIBUTE_BUS_MASTER 0x0400 ///< Enable the DMA bit in the PCI Config Header 67ca987d46SWarner Losh #define EFI_PCI_IO_ATTRIBUTE_MEMORY_CACHED 0x0800 ///< Map a memory range so all r/w accesses are cached 68ca987d46SWarner Losh #define EFI_PCI_IO_ATTRIBUTE_MEMORY_DISABLE 0x1000 ///< Disable a memory range 69ca987d46SWarner Losh #define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_DEVICE 0x2000 ///< Clear for an add-in PCI Device 70ca987d46SWarner Losh #define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_ROM 0x4000 ///< Clear for a physical PCI Option ROM accessed through ROM BAR 71ca987d46SWarner Losh #define EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE 0x8000 ///< Clear for PCI controllers that can not genrate a DAC 72ca987d46SWarner Losh #define EFI_PCI_IO_ATTRIBUTE_ISA_IO_16 0x10000 ///< I/O cycles 0x0100-0x03FF or greater (16 bit decode) 73ca987d46SWarner Losh #define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO_16 0x20000 ///< I/O cycles 0x3C6, 0x3C8, 0x3C9 (16 bit decode) 74ca987d46SWarner Losh #define EFI_PCI_IO_ATTRIBUTE_VGA_IO_16 0x40000 ///< I/O cycles 0x3B0-0x3BB and 0x3C0-0x3DF (16 bit decode) 75ca987d46SWarner Losh 76ca987d46SWarner Losh #define EFI_PCI_DEVICE_ENABLE (EFI_PCI_IO_ATTRIBUTE_IO | EFI_PCI_IO_ATTRIBUTE_MEMORY | EFI_PCI_IO_ATTRIBUTE_BUS_MASTER) 77ca987d46SWarner Losh #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) 78ca987d46SWarner Losh 79ca987d46SWarner Losh /// 80ca987d46SWarner Losh /// ******************************************************* 81ca987d46SWarner Losh /// EFI_PCI_IO_PROTOCOL_OPERATION 82ca987d46SWarner Losh /// ******************************************************* 83ca987d46SWarner Losh /// 84ca987d46SWarner Losh typedef enum { 85ca987d46SWarner Losh /// 86ca987d46SWarner Losh /// A read operation from system memory by a bus master. 87ca987d46SWarner Losh /// 88ca987d46SWarner Losh EfiPciIoOperationBusMasterRead, 89ca987d46SWarner Losh /// 90ca987d46SWarner Losh /// A write operation from system memory by a bus master. 91ca987d46SWarner Losh /// 92ca987d46SWarner Losh EfiPciIoOperationBusMasterWrite, 93ca987d46SWarner Losh /// 94ca987d46SWarner Losh /// Provides both read and write access to system memory by both the processor and a 95ca987d46SWarner Losh /// bus master. The buffer is coherent from both the processor's and the bus master's point of view. 96ca987d46SWarner Losh /// 97ca987d46SWarner Losh EfiPciIoOperationBusMasterCommonBuffer, 98ca987d46SWarner Losh EfiPciIoOperationMaximum 99ca987d46SWarner Losh } EFI_PCI_IO_PROTOCOL_OPERATION; 100ca987d46SWarner Losh 101ca987d46SWarner Losh /// 102ca987d46SWarner Losh /// ******************************************************* 103ca987d46SWarner Losh /// EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION 104ca987d46SWarner Losh /// ******************************************************* 105ca987d46SWarner Losh /// 106ca987d46SWarner Losh typedef enum { 107ca987d46SWarner Losh /// 108ca987d46SWarner Losh /// Retrieve the PCI controller's current attributes, and return them in Result. 109ca987d46SWarner Losh /// 110ca987d46SWarner Losh EfiPciIoAttributeOperationGet, 111ca987d46SWarner Losh /// 112ca987d46SWarner Losh /// Set the PCI controller's current attributes to Attributes. 113ca987d46SWarner Losh /// 114ca987d46SWarner Losh EfiPciIoAttributeOperationSet, 115ca987d46SWarner Losh /// 116ca987d46SWarner Losh /// Enable the attributes specified by the bits that are set in Attributes for this PCI controller. 117ca987d46SWarner Losh /// 118ca987d46SWarner Losh EfiPciIoAttributeOperationEnable, 119ca987d46SWarner Losh /// 120ca987d46SWarner Losh /// Disable the attributes specified by the bits that are set in Attributes for this PCI controller. 121ca987d46SWarner Losh /// 122ca987d46SWarner Losh EfiPciIoAttributeOperationDisable, 123ca987d46SWarner Losh /// 124ca987d46SWarner Losh /// Retrieve the PCI controller's supported attributes, and return them in Result. 125ca987d46SWarner Losh /// 126ca987d46SWarner Losh EfiPciIoAttributeOperationSupported, 127ca987d46SWarner Losh EfiPciIoAttributeOperationMaximum 128ca987d46SWarner Losh } EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION; 129ca987d46SWarner Losh 130ca987d46SWarner Losh /** 131ca987d46SWarner Losh Reads from the memory space of a PCI controller. Returns either when the polling exit criteria is 132ca987d46SWarner Losh satisfied or after a defined duration. 133ca987d46SWarner Losh 134ca987d46SWarner Losh @param This A pointer to the EFI_PCI_IO_PROTOCOL instance. 135ca987d46SWarner Losh @param Width Signifies the width of the memory or I/O operations. 136ca987d46SWarner Losh @param BarIndex The BAR index of the standard PCI Configuration header to use as the 137ca987d46SWarner Losh base address for the memory operation to perform. 138ca987d46SWarner Losh @param Offset The offset within the selected BAR to start the memory operation. 139ca987d46SWarner Losh @param Mask Mask used for the polling criteria. 140ca987d46SWarner Losh @param Value The comparison value used for the polling exit criteria. 141ca987d46SWarner Losh @param Delay The number of 100 ns units to poll. 142ca987d46SWarner Losh @param Result Pointer to the last value read from the memory location. 143ca987d46SWarner Losh 144ca987d46SWarner Losh @retval EFI_SUCCESS The last data returned from the access matched the poll exit criteria. 145ca987d46SWarner Losh @retval EFI_UNSUPPORTED BarIndex not valid for this PCI controller. 146ca987d46SWarner Losh @retval EFI_UNSUPPORTED Offset is not valid for the BarIndex of this PCI controller. 147ca987d46SWarner Losh @retval EFI_TIMEOUT Delay expired before a match occurred. 148ca987d46SWarner Losh @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. 149ca987d46SWarner Losh @retval EFI_INVALID_PARAMETER One or more parameters are invalid. 150ca987d46SWarner Losh 151ca987d46SWarner Losh **/ 152ca987d46SWarner Losh typedef 153ca987d46SWarner Losh EFI_STATUS 154ca987d46SWarner Losh (EFIAPI *EFI_PCI_IO_PROTOCOL_POLL_IO_MEM)( 155ca987d46SWarner Losh IN EFI_PCI_IO_PROTOCOL *This, 156ca987d46SWarner Losh IN EFI_PCI_IO_PROTOCOL_WIDTH Width, 157ca987d46SWarner Losh IN UINT8 BarIndex, 158ca987d46SWarner Losh IN UINT64 Offset, 159ca987d46SWarner Losh IN UINT64 Mask, 160ca987d46SWarner Losh IN UINT64 Value, 161ca987d46SWarner Losh IN UINT64 Delay, 162ca987d46SWarner Losh OUT UINT64 *Result 163ca987d46SWarner Losh ); 164ca987d46SWarner Losh 165ca987d46SWarner Losh /** 166ca987d46SWarner Losh Enable a PCI driver to access PCI controller registers in the PCI memory or I/O space. 167ca987d46SWarner Losh 168ca987d46SWarner Losh @param This A pointer to the EFI_PCI_IO_PROTOCOL instance. 169ca987d46SWarner Losh @param Width Signifies the width of the memory or I/O operations. 170ca987d46SWarner Losh @param BarIndex The BAR index of the standard PCI Configuration header to use as the 171ca987d46SWarner Losh base address for the memory or I/O operation to perform. 172ca987d46SWarner Losh @param Offset The offset within the selected BAR to start the memory or I/O operation. 173ca987d46SWarner Losh @param Count The number of memory or I/O operations to perform. 174ca987d46SWarner Losh @param Buffer For read operations, the destination buffer to store the results. For write 175ca987d46SWarner Losh operations, the source buffer to write data from. 176ca987d46SWarner Losh 177ca987d46SWarner Losh @retval EFI_SUCCESS The data was read from or written to the PCI controller. 178ca987d46SWarner Losh @retval EFI_UNSUPPORTED BarIndex not valid for this PCI controller. 179ca987d46SWarner Losh @retval EFI_UNSUPPORTED The address range specified by Offset, Width, and Count is not 180ca987d46SWarner Losh valid for the PCI BAR specified by BarIndex. 181ca987d46SWarner Losh @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. 182ca987d46SWarner Losh @retval EFI_INVALID_PARAMETER One or more parameters are invalid. 183ca987d46SWarner Losh 184ca987d46SWarner Losh **/ 185ca987d46SWarner Losh typedef 186ca987d46SWarner Losh EFI_STATUS 187ca987d46SWarner Losh (EFIAPI *EFI_PCI_IO_PROTOCOL_IO_MEM)( 188ca987d46SWarner Losh IN EFI_PCI_IO_PROTOCOL *This, 189ca987d46SWarner Losh IN EFI_PCI_IO_PROTOCOL_WIDTH Width, 190ca987d46SWarner Losh IN UINT8 BarIndex, 191ca987d46SWarner Losh IN UINT64 Offset, 192ca987d46SWarner Losh IN UINTN Count, 193ca987d46SWarner Losh IN OUT VOID *Buffer 194ca987d46SWarner Losh ); 195ca987d46SWarner Losh 196ca987d46SWarner Losh typedef struct { 197ca987d46SWarner Losh /// 198ca987d46SWarner Losh /// Read PCI controller registers in the PCI memory or I/O space. 199ca987d46SWarner Losh /// 200ca987d46SWarner Losh EFI_PCI_IO_PROTOCOL_IO_MEM Read; 201ca987d46SWarner Losh /// 202ca987d46SWarner Losh /// Write PCI controller registers in the PCI memory or I/O space. 203ca987d46SWarner Losh /// 204ca987d46SWarner Losh EFI_PCI_IO_PROTOCOL_IO_MEM Write; 205ca987d46SWarner Losh } EFI_PCI_IO_PROTOCOL_ACCESS; 206ca987d46SWarner Losh 207ca987d46SWarner Losh /** 208ca987d46SWarner Losh Enable a PCI driver to access PCI controller registers in PCI configuration space. 209ca987d46SWarner Losh 210ca987d46SWarner Losh @param This A pointer to the EFI_PCI_IO_PROTOCOL instance. 211ca987d46SWarner Losh @param Width Signifies the width of the memory operations. 212ca987d46SWarner Losh @param Offset The offset within the PCI configuration space for the PCI controller. 213ca987d46SWarner Losh @param Count The number of PCI configuration operations to perform. 214ca987d46SWarner Losh @param Buffer For read operations, the destination buffer to store the results. For write 215ca987d46SWarner Losh operations, the source buffer to write data from. 216ca987d46SWarner Losh 217ca987d46SWarner Losh 218ca987d46SWarner Losh @retval EFI_SUCCESS The data was read from or written to the PCI controller. 219ca987d46SWarner Losh @retval EFI_UNSUPPORTED The address range specified by Offset, Width, and Count is not 220ca987d46SWarner Losh valid for the PCI configuration header of the PCI controller. 221ca987d46SWarner Losh @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. 222ca987d46SWarner Losh @retval EFI_INVALID_PARAMETER Buffer is NULL or Width is invalid. 223ca987d46SWarner Losh 224ca987d46SWarner Losh **/ 225ca987d46SWarner Losh typedef 226ca987d46SWarner Losh EFI_STATUS 227ca987d46SWarner Losh (EFIAPI *EFI_PCI_IO_PROTOCOL_CONFIG)( 228ca987d46SWarner Losh IN EFI_PCI_IO_PROTOCOL *This, 229ca987d46SWarner Losh IN EFI_PCI_IO_PROTOCOL_WIDTH Width, 230ca987d46SWarner Losh IN UINT32 Offset, 231ca987d46SWarner Losh IN UINTN Count, 232ca987d46SWarner Losh IN OUT VOID *Buffer 233ca987d46SWarner Losh ); 234ca987d46SWarner Losh 235ca987d46SWarner Losh typedef struct { 236ca987d46SWarner Losh /// 237ca987d46SWarner Losh /// Read PCI controller registers in PCI configuration space. 238ca987d46SWarner Losh /// 239ca987d46SWarner Losh EFI_PCI_IO_PROTOCOL_CONFIG Read; 240ca987d46SWarner Losh /// 241ca987d46SWarner Losh /// Write PCI controller registers in PCI configuration space. 242ca987d46SWarner Losh /// 243ca987d46SWarner Losh EFI_PCI_IO_PROTOCOL_CONFIG Write; 244ca987d46SWarner Losh } EFI_PCI_IO_PROTOCOL_CONFIG_ACCESS; 245ca987d46SWarner Losh 246ca987d46SWarner Losh /** 247ca987d46SWarner Losh Enables a PCI driver to copy one region of PCI memory space to another region of PCI 248ca987d46SWarner Losh memory space. 249ca987d46SWarner Losh 250ca987d46SWarner Losh @param This A pointer to the EFI_PCI_IO_PROTOCOL instance. 251ca987d46SWarner Losh @param Width Signifies the width of the memory operations. 252ca987d46SWarner Losh @param DestBarIndex The BAR index in the standard PCI Configuration header to use as the 253ca987d46SWarner Losh base address for the memory operation to perform. 254ca987d46SWarner Losh @param DestOffset The destination offset within the BAR specified by DestBarIndex to 255ca987d46SWarner Losh start the memory writes for the copy operation. 256ca987d46SWarner Losh @param SrcBarIndex The BAR index in the standard PCI Configuration header to use as the 257ca987d46SWarner Losh base address for the memory operation to perform. 258ca987d46SWarner Losh @param SrcOffset The source offset within the BAR specified by SrcBarIndex to start 259ca987d46SWarner Losh the memory reads for the copy operation. 260ca987d46SWarner Losh @param Count The number of memory operations to perform. Bytes moved is Width 261ca987d46SWarner Losh size * Count, starting at DestOffset and SrcOffset. 262ca987d46SWarner Losh 263ca987d46SWarner Losh @retval EFI_SUCCESS The data was copied from one memory region to another memory region. 264ca987d46SWarner Losh @retval EFI_UNSUPPORTED DestBarIndex not valid for this PCI controller. 265ca987d46SWarner Losh @retval EFI_UNSUPPORTED SrcBarIndex not valid for this PCI controller. 266ca987d46SWarner Losh @retval EFI_UNSUPPORTED The address range specified by DestOffset, Width, and Count 267ca987d46SWarner Losh is not valid for the PCI BAR specified by DestBarIndex. 268ca987d46SWarner Losh @retval EFI_UNSUPPORTED The address range specified by SrcOffset, Width, and Count is 269ca987d46SWarner Losh not valid for the PCI BAR specified by SrcBarIndex. 270ca987d46SWarner Losh @retval EFI_INVALID_PARAMETER Width is invalid. 271ca987d46SWarner Losh @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. 272ca987d46SWarner Losh 273ca987d46SWarner Losh **/ 274ca987d46SWarner Losh typedef 275ca987d46SWarner Losh EFI_STATUS 276ca987d46SWarner Losh (EFIAPI *EFI_PCI_IO_PROTOCOL_COPY_MEM)( 277ca987d46SWarner Losh IN EFI_PCI_IO_PROTOCOL *This, 278ca987d46SWarner Losh IN EFI_PCI_IO_PROTOCOL_WIDTH Width, 279ca987d46SWarner Losh IN UINT8 DestBarIndex, 280ca987d46SWarner Losh IN UINT64 DestOffset, 281ca987d46SWarner Losh IN UINT8 SrcBarIndex, 282ca987d46SWarner Losh IN UINT64 SrcOffset, 283ca987d46SWarner Losh IN UINTN Count 284ca987d46SWarner Losh ); 285ca987d46SWarner Losh 286ca987d46SWarner Losh /** 287ca987d46SWarner Losh Provides the PCI controller-specific addresses needed to access system memory. 288ca987d46SWarner Losh 289ca987d46SWarner Losh @param This A pointer to the EFI_PCI_IO_PROTOCOL instance. 290ca987d46SWarner Losh @param Operation Indicates if the bus master is going to read or write to system memory. 291ca987d46SWarner Losh @param HostAddress The system memory address to map to the PCI controller. 292ca987d46SWarner Losh @param NumberOfBytes On input the number of bytes to map. On output the number of bytes 293ca987d46SWarner Losh that were mapped. 294ca987d46SWarner Losh @param DeviceAddress The resulting map address for the bus master PCI controller to use to 295ca987d46SWarner Losh access the hosts HostAddress. 296ca987d46SWarner Losh @param Mapping A resulting value to pass to Unmap(). 297ca987d46SWarner Losh 298ca987d46SWarner Losh @retval EFI_SUCCESS The range was mapped for the returned NumberOfBytes. 299ca987d46SWarner Losh @retval EFI_UNSUPPORTED The HostAddress cannot be mapped as a common buffer. 300ca987d46SWarner Losh @retval EFI_INVALID_PARAMETER One or more parameters are invalid. 301ca987d46SWarner Losh @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. 302ca987d46SWarner Losh @retval EFI_DEVICE_ERROR The system hardware could not map the requested address. 303ca987d46SWarner Losh 304ca987d46SWarner Losh **/ 305ca987d46SWarner Losh typedef 306ca987d46SWarner Losh EFI_STATUS 307ca987d46SWarner Losh (EFIAPI *EFI_PCI_IO_PROTOCOL_MAP)( 308ca987d46SWarner Losh IN EFI_PCI_IO_PROTOCOL *This, 309ca987d46SWarner Losh IN EFI_PCI_IO_PROTOCOL_OPERATION Operation, 310ca987d46SWarner Losh IN VOID *HostAddress, 311ca987d46SWarner Losh IN OUT UINTN *NumberOfBytes, 312ca987d46SWarner Losh OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, 313ca987d46SWarner Losh OUT VOID **Mapping 314ca987d46SWarner Losh ); 315ca987d46SWarner Losh 316ca987d46SWarner Losh /** 317ca987d46SWarner Losh Completes the Map() operation and releases any corresponding resources. 318ca987d46SWarner Losh 319ca987d46SWarner Losh @param This A pointer to the EFI_PCI_IO_PROTOCOL instance. 320ca987d46SWarner Losh @param Mapping The mapping value returned from Map(). 321ca987d46SWarner Losh 322ca987d46SWarner Losh @retval EFI_SUCCESS The range was unmapped. 323ca987d46SWarner Losh @retval EFI_DEVICE_ERROR The data was not committed to the target system memory. 324ca987d46SWarner Losh 325ca987d46SWarner Losh **/ 326ca987d46SWarner Losh typedef 327ca987d46SWarner Losh EFI_STATUS 328ca987d46SWarner Losh (EFIAPI *EFI_PCI_IO_PROTOCOL_UNMAP)( 329ca987d46SWarner Losh IN EFI_PCI_IO_PROTOCOL *This, 330ca987d46SWarner Losh IN VOID *Mapping 331ca987d46SWarner Losh ); 332ca987d46SWarner Losh 333ca987d46SWarner Losh /** 334ca987d46SWarner Losh Allocates pages that are suitable for an EfiPciIoOperationBusMasterCommonBuffer 335ca987d46SWarner Losh mapping. 336ca987d46SWarner Losh 337ca987d46SWarner Losh @param This A pointer to the EFI_PCI_IO_PROTOCOL instance. 338ca987d46SWarner Losh @param Type This parameter is not used and must be ignored. 339ca987d46SWarner Losh @param MemoryType The type of memory to allocate, EfiBootServicesData or 340ca987d46SWarner Losh EfiRuntimeServicesData. 341ca987d46SWarner Losh @param Pages The number of pages to allocate. 342ca987d46SWarner Losh @param HostAddress A pointer to store the base system memory address of the 343ca987d46SWarner Losh allocated range. 344ca987d46SWarner Losh @param Attributes The requested bit mask of attributes for the allocated range. 345ca987d46SWarner Losh 346ca987d46SWarner Losh @retval EFI_SUCCESS The requested memory pages were allocated. 347ca987d46SWarner Losh @retval EFI_UNSUPPORTED Attributes is unsupported. The only legal attribute bits are 348ca987d46SWarner Losh MEMORY_WRITE_COMBINE and MEMORY_CACHED. 349ca987d46SWarner Losh @retval EFI_INVALID_PARAMETER One or more parameters are invalid. 350ca987d46SWarner Losh @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated. 351ca987d46SWarner Losh 352ca987d46SWarner Losh **/ 353ca987d46SWarner Losh typedef 354ca987d46SWarner Losh EFI_STATUS 355ca987d46SWarner Losh (EFIAPI *EFI_PCI_IO_PROTOCOL_ALLOCATE_BUFFER)( 356ca987d46SWarner Losh IN EFI_PCI_IO_PROTOCOL *This, 357ca987d46SWarner Losh IN EFI_ALLOCATE_TYPE Type, 358ca987d46SWarner Losh IN EFI_MEMORY_TYPE MemoryType, 359ca987d46SWarner Losh IN UINTN Pages, 360ca987d46SWarner Losh OUT VOID **HostAddress, 361ca987d46SWarner Losh IN UINT64 Attributes 362ca987d46SWarner Losh ); 363ca987d46SWarner Losh 364ca987d46SWarner Losh /** 365ca987d46SWarner Losh Frees memory that was allocated with AllocateBuffer(). 366ca987d46SWarner Losh 367ca987d46SWarner Losh @param This A pointer to the EFI_PCI_IO_PROTOCOL instance. 368ca987d46SWarner Losh @param Pages The number of pages to free. 369ca987d46SWarner Losh @param HostAddress The base system memory address of the allocated range. 370ca987d46SWarner Losh 371ca987d46SWarner Losh @retval EFI_SUCCESS The requested memory pages were freed. 372ca987d46SWarner Losh @retval EFI_INVALID_PARAMETER The memory range specified by HostAddress and Pages 373ca987d46SWarner Losh was not allocated with AllocateBuffer(). 374ca987d46SWarner Losh 375ca987d46SWarner Losh **/ 376ca987d46SWarner Losh typedef 377ca987d46SWarner Losh EFI_STATUS 378ca987d46SWarner Losh (EFIAPI *EFI_PCI_IO_PROTOCOL_FREE_BUFFER)( 379ca987d46SWarner Losh IN EFI_PCI_IO_PROTOCOL *This, 380ca987d46SWarner Losh IN UINTN Pages, 381ca987d46SWarner Losh IN VOID *HostAddress 382ca987d46SWarner Losh ); 383ca987d46SWarner Losh 384ca987d46SWarner Losh /** 385ca987d46SWarner Losh Flushes all PCI posted write transactions from a PCI host bridge to system memory. 386ca987d46SWarner Losh 387ca987d46SWarner Losh @param This A pointer to the EFI_PCI_IO_PROTOCOL instance. 388ca987d46SWarner Losh 389ca987d46SWarner Losh @retval EFI_SUCCESS The PCI posted write transactions were flushed from the PCI host 390ca987d46SWarner Losh bridge to system memory. 391ca987d46SWarner Losh @retval EFI_DEVICE_ERROR The PCI posted write transactions were not flushed from the PCI 392ca987d46SWarner Losh host bridge due to a hardware error. 393ca987d46SWarner Losh 394ca987d46SWarner Losh **/ 395ca987d46SWarner Losh typedef 396ca987d46SWarner Losh EFI_STATUS 397ca987d46SWarner Losh (EFIAPI *EFI_PCI_IO_PROTOCOL_FLUSH)( 398ca987d46SWarner Losh IN EFI_PCI_IO_PROTOCOL *This 399ca987d46SWarner Losh ); 400ca987d46SWarner Losh 401ca987d46SWarner Losh /** 402ca987d46SWarner Losh Retrieves this PCI controller's current PCI bus number, device number, and function number. 403ca987d46SWarner Losh 404ca987d46SWarner Losh @param This A pointer to the EFI_PCI_IO_PROTOCOL instance. 405ca987d46SWarner Losh @param SegmentNumber The PCI controller's current PCI segment number. 406ca987d46SWarner Losh @param BusNumber The PCI controller's current PCI bus number. 407ca987d46SWarner Losh @param DeviceNumber The PCI controller's current PCI device number. 408ca987d46SWarner Losh @param FunctionNumber The PCI controller's current PCI function number. 409ca987d46SWarner Losh 410ca987d46SWarner Losh @retval EFI_SUCCESS The PCI controller location was returned. 411ca987d46SWarner Losh @retval EFI_INVALID_PARAMETER One or more parameters are invalid. 412ca987d46SWarner Losh 413ca987d46SWarner Losh **/ 414ca987d46SWarner Losh typedef 415ca987d46SWarner Losh EFI_STATUS 416ca987d46SWarner Losh (EFIAPI *EFI_PCI_IO_PROTOCOL_GET_LOCATION)( 417ca987d46SWarner Losh IN EFI_PCI_IO_PROTOCOL *This, 418ca987d46SWarner Losh OUT UINTN *SegmentNumber, 419ca987d46SWarner Losh OUT UINTN *BusNumber, 420ca987d46SWarner Losh OUT UINTN *DeviceNumber, 421ca987d46SWarner Losh OUT UINTN *FunctionNumber 422ca987d46SWarner Losh ); 423ca987d46SWarner Losh 424ca987d46SWarner Losh /** 425ca987d46SWarner Losh Performs an operation on the attributes that this PCI controller supports. The operations include 426ca987d46SWarner Losh getting the set of supported attributes, retrieving the current attributes, setting the current 427ca987d46SWarner Losh attributes, enabling attributes, and disabling attributes. 428ca987d46SWarner Losh 429ca987d46SWarner Losh @param This A pointer to the EFI_PCI_IO_PROTOCOL instance. 430ca987d46SWarner Losh @param Operation The operation to perform on the attributes for this PCI controller. 431ca987d46SWarner Losh @param Attributes The mask of attributes that are used for Set, Enable, and Disable 432ca987d46SWarner Losh operations. 433ca987d46SWarner Losh @param Result A pointer to the result mask of attributes that are returned for the Get 434ca987d46SWarner Losh and Supported operations. 435ca987d46SWarner Losh 436ca987d46SWarner Losh @retval EFI_SUCCESS The operation on the PCI controller's attributes was completed. 437ca987d46SWarner Losh @retval EFI_INVALID_PARAMETER One or more parameters are invalid. 438ca987d46SWarner Losh @retval EFI_UNSUPPORTED one or more of the bits set in 439ca987d46SWarner Losh Attributes are not supported by this PCI controller or one of 440ca987d46SWarner Losh its parent bridges when Operation is Set, Enable or Disable. 441ca987d46SWarner Losh 442ca987d46SWarner Losh **/ 443ca987d46SWarner Losh typedef 444ca987d46SWarner Losh EFI_STATUS 445ca987d46SWarner Losh (EFIAPI *EFI_PCI_IO_PROTOCOL_ATTRIBUTES)( 446ca987d46SWarner Losh IN EFI_PCI_IO_PROTOCOL *This, 447ca987d46SWarner Losh IN EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION Operation, 448ca987d46SWarner Losh IN UINT64 Attributes, 449ca987d46SWarner Losh OUT UINT64 *Result OPTIONAL 450ca987d46SWarner Losh ); 451ca987d46SWarner Losh 452ca987d46SWarner Losh /** 453ca987d46SWarner Losh Gets the attributes that this PCI controller supports setting on a BAR using 454ca987d46SWarner Losh SetBarAttributes(), and retrieves the list of resource descriptors for a BAR. 455ca987d46SWarner Losh 456ca987d46SWarner Losh @param This A pointer to the EFI_PCI_IO_PROTOCOL instance. 457ca987d46SWarner Losh @param BarIndex The BAR index of the standard PCI Configuration header to use as the 458ca987d46SWarner Losh base address for resource range. The legal range for this field is 0..5. 459ca987d46SWarner Losh @param Supports A pointer to the mask of attributes that this PCI controller supports 460ca987d46SWarner Losh setting for this BAR with SetBarAttributes(). 461ca987d46SWarner Losh @param Resources A pointer to the ACPI 2.0 resource descriptors that describe the current 462ca987d46SWarner Losh configuration of this BAR of the PCI controller. 463ca987d46SWarner Losh 464ca987d46SWarner Losh @retval EFI_SUCCESS If Supports is not NULL, then the attributes that the PCI 465ca987d46SWarner Losh controller supports are returned in Supports. If Resources 466ca987d46SWarner Losh is not NULL, then the ACPI 2.0 resource descriptors that the PCI 467ca987d46SWarner Losh controller is currently using are returned in Resources. 468ca987d46SWarner Losh @retval EFI_INVALID_PARAMETER Both Supports and Attributes are NULL. 469ca987d46SWarner Losh @retval EFI_UNSUPPORTED BarIndex not valid for this PCI controller. 470ca987d46SWarner Losh @retval EFI_OUT_OF_RESOURCES There are not enough resources available to allocate 471ca987d46SWarner Losh Resources. 472ca987d46SWarner Losh 473ca987d46SWarner Losh **/ 474ca987d46SWarner Losh typedef 475ca987d46SWarner Losh EFI_STATUS 476ca987d46SWarner Losh (EFIAPI *EFI_PCI_IO_PROTOCOL_GET_BAR_ATTRIBUTES)( 477ca987d46SWarner Losh IN EFI_PCI_IO_PROTOCOL *This, 478ca987d46SWarner Losh IN UINT8 BarIndex, 479ca987d46SWarner Losh OUT UINT64 *Supports, OPTIONAL 480ca987d46SWarner Losh OUT VOID **Resources OPTIONAL 481ca987d46SWarner Losh ); 482ca987d46SWarner Losh 483ca987d46SWarner Losh /** 484ca987d46SWarner Losh Sets the attributes for a range of a BAR on a PCI controller. 485ca987d46SWarner Losh 486ca987d46SWarner Losh @param This A pointer to the EFI_PCI_IO_PROTOCOL instance. 487ca987d46SWarner Losh @param Attributes The mask of attributes to set for the resource range specified by 488ca987d46SWarner Losh BarIndex, Offset, and Length. 489ca987d46SWarner Losh @param BarIndex The BAR index of the standard PCI Configuration header to use as the 490ca987d46SWarner Losh base address for resource range. The legal range for this field is 0..5. 491ca987d46SWarner Losh @param Offset A pointer to the BAR relative base address of the resource range to be 492ca987d46SWarner Losh modified by the attributes specified by Attributes. 493ca987d46SWarner Losh @param Length A pointer to the length of the resource range to be modified by the 494ca987d46SWarner Losh attributes specified by Attributes. 495ca987d46SWarner Losh 496ca987d46SWarner Losh @retval EFI_SUCCESS The set of attributes specified by Attributes for the resource 497ca987d46SWarner Losh range specified by BarIndex, Offset, and Length were 498ca987d46SWarner Losh set on the PCI controller, and the actual resource range is returned 499ca987d46SWarner Losh in Offset and Length. 500ca987d46SWarner Losh @retval EFI_INVALID_PARAMETER Offset or Length is NULL. 501ca987d46SWarner Losh @retval EFI_UNSUPPORTED BarIndex not valid for this PCI controller. 502ca987d46SWarner Losh @retval EFI_OUT_OF_RESOURCES There are not enough resources to set the attributes on the 503ca987d46SWarner Losh resource range specified by BarIndex, Offset, and 504ca987d46SWarner Losh Length. 505ca987d46SWarner Losh 506ca987d46SWarner Losh **/ 507ca987d46SWarner Losh typedef 508ca987d46SWarner Losh EFI_STATUS 509ca987d46SWarner Losh (EFIAPI *EFI_PCI_IO_PROTOCOL_SET_BAR_ATTRIBUTES)( 510ca987d46SWarner Losh IN EFI_PCI_IO_PROTOCOL *This, 511ca987d46SWarner Losh IN UINT64 Attributes, 512ca987d46SWarner Losh IN UINT8 BarIndex, 513ca987d46SWarner Losh IN OUT UINT64 *Offset, 514ca987d46SWarner Losh IN OUT UINT64 *Length 515ca987d46SWarner Losh ); 516ca987d46SWarner Losh 517ca987d46SWarner Losh /// 518ca987d46SWarner Losh /// The EFI_PCI_IO_PROTOCOL provides the basic Memory, I/O, PCI configuration, 519ca987d46SWarner Losh /// and DMA interfaces used to abstract accesses to PCI controllers. 520ca987d46SWarner Losh /// There is one EFI_PCI_IO_PROTOCOL instance for each PCI controller on a PCI bus. 521ca987d46SWarner Losh /// A device driver that wishes to manage a PCI controller in a system will have to 522ca987d46SWarner Losh /// retrieve the EFI_PCI_IO_PROTOCOL instance that is associated with the PCI controller. 523ca987d46SWarner Losh /// 524ca987d46SWarner Losh struct _EFI_PCI_IO_PROTOCOL { 525ca987d46SWarner Losh EFI_PCI_IO_PROTOCOL_POLL_IO_MEM PollMem; 526ca987d46SWarner Losh EFI_PCI_IO_PROTOCOL_POLL_IO_MEM PollIo; 527ca987d46SWarner Losh EFI_PCI_IO_PROTOCOL_ACCESS Mem; 528ca987d46SWarner Losh EFI_PCI_IO_PROTOCOL_ACCESS Io; 529ca987d46SWarner Losh EFI_PCI_IO_PROTOCOL_CONFIG_ACCESS Pci; 530ca987d46SWarner Losh EFI_PCI_IO_PROTOCOL_COPY_MEM CopyMem; 531ca987d46SWarner Losh EFI_PCI_IO_PROTOCOL_MAP Map; 532ca987d46SWarner Losh EFI_PCI_IO_PROTOCOL_UNMAP Unmap; 533ca987d46SWarner Losh EFI_PCI_IO_PROTOCOL_ALLOCATE_BUFFER AllocateBuffer; 534ca987d46SWarner Losh EFI_PCI_IO_PROTOCOL_FREE_BUFFER FreeBuffer; 535ca987d46SWarner Losh EFI_PCI_IO_PROTOCOL_FLUSH Flush; 536ca987d46SWarner Losh EFI_PCI_IO_PROTOCOL_GET_LOCATION GetLocation; 537ca987d46SWarner Losh EFI_PCI_IO_PROTOCOL_ATTRIBUTES Attributes; 538ca987d46SWarner Losh EFI_PCI_IO_PROTOCOL_GET_BAR_ATTRIBUTES GetBarAttributes; 539ca987d46SWarner Losh EFI_PCI_IO_PROTOCOL_SET_BAR_ATTRIBUTES SetBarAttributes; 540ca987d46SWarner Losh 541ca987d46SWarner Losh /// 542ca987d46SWarner Losh /// The size, in bytes, of the ROM image. 543ca987d46SWarner Losh /// 544ca987d46SWarner Losh UINT64 RomSize; 545ca987d46SWarner Losh 546ca987d46SWarner Losh /// 547ca987d46SWarner Losh /// A pointer to the in memory copy of the ROM image. The PCI Bus Driver is responsible 548ca987d46SWarner Losh /// for allocating memory for the ROM image, and copying the contents of the ROM to memory. 549ca987d46SWarner Losh /// The contents of this buffer are either from the PCI option ROM that can be accessed 550ca987d46SWarner Losh /// through the ROM BAR of the PCI controller, or it is from a platform-specific location. 551ca987d46SWarner Losh /// The Attributes() function can be used to determine from which of these two sources 552ca987d46SWarner Losh /// the RomImage buffer was initialized. 553ca987d46SWarner Losh /// 554ca987d46SWarner Losh VOID *RomImage; 555ca987d46SWarner Losh }; 556ca987d46SWarner Losh 557ca987d46SWarner Losh extern EFI_GUID gEfiPciIoProtocolGuid; 558ca987d46SWarner Losh 559ca987d46SWarner Losh #endif 560