1287317Smarcel/* $FreeBSD: stable/11/stand/efi/include/efipciio.h 346482 2019-04-21 04:26:02Z kevans $ */ 2287317Smarcel/** @file 3292625Semaste EFI PCI I/O Protocol provides the basic Memory, I/O, PCI configuration, 4287317Smarcel and DMA interfaces that a driver uses to access its PCI controller. 5287317Smarcel 6287317Smarcel Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR> 7292625Semaste This program and the accompanying materials 8292625Semaste are licensed and made available under the terms and conditions of the BSD License 9292625Semaste which accompanies this distribution. The full text of the license may be found at 10292625Semaste http://opensource.org/licenses/bsd-license.php 11287317Smarcel 12292625Semaste THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 13292625Semaste WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 14287317Smarcel 15287317Smarcel**/ 16287317Smarcel 17287317Smarcel#ifndef __PCI_IO_H__ 18287317Smarcel#define __PCI_IO_H__ 19287317Smarcel 20346482Skevans#define EFI_PCI_ROOT_IO_GUID \ 21346482Skevans { 0x2F707EBB, 0x4A1A, 0x11d4, { 0x9A, 0x38, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }} 22346482Skevans 23287317Smarcel/// 24287317Smarcel/// Global ID for the PCI I/O Protocol 25287317Smarcel/// 26287317Smarcel#define EFI_PCI_IO_PROTOCOL_GUID \ 27293724Ssmh { 0x4cf5b200, 0x68b8, 0x4ca5, {0x9e, 0xec, 0xb2, 0x3e, 0x3f, 0x50, 0x2, 0x9a} } 28287317Smarcel 29287317Smarceltypedef struct _EFI_PCI_IO_PROTOCOL EFI_PCI_IO_PROTOCOL; 30287317Smarcel 31287317Smarcel/// 32287317Smarcel/// ******************************************************* 33287317Smarcel/// EFI_PCI_IO_PROTOCOL_WIDTH 34287317Smarcel/// ******************************************************* 35287317Smarcel/// 36287317Smarceltypedef enum { 37287317Smarcel EfiPciIoWidthUint8 = 0, 38287317Smarcel EfiPciIoWidthUint16, 39287317Smarcel EfiPciIoWidthUint32, 40287317Smarcel EfiPciIoWidthUint64, 41287317Smarcel EfiPciIoWidthFifoUint8, 42287317Smarcel EfiPciIoWidthFifoUint16, 43287317Smarcel EfiPciIoWidthFifoUint32, 44287317Smarcel EfiPciIoWidthFifoUint64, 45287317Smarcel EfiPciIoWidthFillUint8, 46287317Smarcel EfiPciIoWidthFillUint16, 47287317Smarcel EfiPciIoWidthFillUint32, 48287317Smarcel EfiPciIoWidthFillUint64, 49287317Smarcel EfiPciIoWidthMaximum 50287317Smarcel} EFI_PCI_IO_PROTOCOL_WIDTH; 51287317Smarcel 52287317Smarcel// 53287317Smarcel// Complete PCI address generater 54287317Smarcel// 55287317Smarcel#define EFI_PCI_IO_PASS_THROUGH_BAR 0xff ///< Special BAR that passes a memory or I/O cycle through unchanged 56287317Smarcel#define EFI_PCI_IO_ATTRIBUTE_MASK 0x077f ///< All the following I/O and Memory cycles 57287317Smarcel#define EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO 0x0001 ///< I/O cycles 0x0000-0x00FF (10 bit decode) 58287317Smarcel#define EFI_PCI_IO_ATTRIBUTE_ISA_IO 0x0002 ///< I/O cycles 0x0100-0x03FF or greater (10 bit decode) 59287317Smarcel#define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO 0x0004 ///< I/O cycles 0x3C6, 0x3C8, 0x3C9 (10 bit decode) 60287317Smarcel#define EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY 0x0008 ///< MEM cycles 0xA0000-0xBFFFF (24 bit decode) 61287317Smarcel#define EFI_PCI_IO_ATTRIBUTE_VGA_IO 0x0010 ///< I/O cycles 0x3B0-0x3BB and 0x3C0-0x3DF (10 bit decode) 62287317Smarcel#define EFI_PCI_IO_ATTRIBUTE_IDE_PRIMARY_IO 0x0020 ///< I/O cycles 0x1F0-0x1F7, 0x3F6, 0x3F7 (10 bit decode) 63287317Smarcel#define EFI_PCI_IO_ATTRIBUTE_IDE_SECONDARY_IO 0x0040 ///< I/O cycles 0x170-0x177, 0x376, 0x377 (10 bit decode) 64287317Smarcel#define EFI_PCI_IO_ATTRIBUTE_MEMORY_WRITE_COMBINE 0x0080 ///< Map a memory range so writes are combined 65287317Smarcel#define EFI_PCI_IO_ATTRIBUTE_IO 0x0100 ///< Enable the I/O decode bit in the PCI Config Header 66287317Smarcel#define EFI_PCI_IO_ATTRIBUTE_MEMORY 0x0200 ///< Enable the Memory decode bit in the PCI Config Header 67287317Smarcel#define EFI_PCI_IO_ATTRIBUTE_BUS_MASTER 0x0400 ///< Enable the DMA bit in the PCI Config Header 68287317Smarcel#define EFI_PCI_IO_ATTRIBUTE_MEMORY_CACHED 0x0800 ///< Map a memory range so all r/w accesses are cached 69287317Smarcel#define EFI_PCI_IO_ATTRIBUTE_MEMORY_DISABLE 0x1000 ///< Disable a memory range 70287317Smarcel#define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_DEVICE 0x2000 ///< Clear for an add-in PCI Device 71287317Smarcel#define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_ROM 0x4000 ///< Clear for a physical PCI Option ROM accessed through ROM BAR 72287317Smarcel#define EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE 0x8000 ///< Clear for PCI controllers that can not genrate a DAC 73287317Smarcel#define EFI_PCI_IO_ATTRIBUTE_ISA_IO_16 0x10000 ///< I/O cycles 0x0100-0x03FF or greater (16 bit decode) 74287317Smarcel#define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO_16 0x20000 ///< I/O cycles 0x3C6, 0x3C8, 0x3C9 (16 bit decode) 75287317Smarcel#define EFI_PCI_IO_ATTRIBUTE_VGA_IO_16 0x40000 ///< I/O cycles 0x3B0-0x3BB and 0x3C0-0x3DF (16 bit decode) 76287317Smarcel 77287317Smarcel#define EFI_PCI_DEVICE_ENABLE (EFI_PCI_IO_ATTRIBUTE_IO | EFI_PCI_IO_ATTRIBUTE_MEMORY | EFI_PCI_IO_ATTRIBUTE_BUS_MASTER) 78287317Smarcel#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) 79287317Smarcel 80287317Smarcel/// 81287317Smarcel/// ******************************************************* 82287317Smarcel/// EFI_PCI_IO_PROTOCOL_OPERATION 83287317Smarcel/// ******************************************************* 84287317Smarcel/// 85287317Smarceltypedef enum { 86287317Smarcel /// 87287317Smarcel /// A read operation from system memory by a bus master. 88287317Smarcel /// 89287317Smarcel EfiPciIoOperationBusMasterRead, 90287317Smarcel /// 91287317Smarcel /// A write operation from system memory by a bus master. 92287317Smarcel /// 93287317Smarcel EfiPciIoOperationBusMasterWrite, 94287317Smarcel /// 95287317Smarcel /// Provides both read and write access to system memory by both the processor and a 96287317Smarcel /// bus master. The buffer is coherent from both the processor's and the bus master's point of view. 97287317Smarcel /// 98287317Smarcel EfiPciIoOperationBusMasterCommonBuffer, 99287317Smarcel EfiPciIoOperationMaximum 100287317Smarcel} EFI_PCI_IO_PROTOCOL_OPERATION; 101287317Smarcel 102287317Smarcel/// 103287317Smarcel/// ******************************************************* 104287317Smarcel/// EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION 105287317Smarcel/// ******************************************************* 106287317Smarcel/// 107287317Smarceltypedef enum { 108287317Smarcel /// 109287317Smarcel /// Retrieve the PCI controller's current attributes, and return them in Result. 110287317Smarcel /// 111287317Smarcel EfiPciIoAttributeOperationGet, 112287317Smarcel /// 113287317Smarcel /// Set the PCI controller's current attributes to Attributes. 114287317Smarcel /// 115287317Smarcel EfiPciIoAttributeOperationSet, 116287317Smarcel /// 117287317Smarcel /// Enable the attributes specified by the bits that are set in Attributes for this PCI controller. 118287317Smarcel /// 119287317Smarcel EfiPciIoAttributeOperationEnable, 120287317Smarcel /// 121287317Smarcel /// Disable the attributes specified by the bits that are set in Attributes for this PCI controller. 122287317Smarcel /// 123287317Smarcel EfiPciIoAttributeOperationDisable, 124287317Smarcel /// 125287317Smarcel /// Retrieve the PCI controller's supported attributes, and return them in Result. 126287317Smarcel /// 127287317Smarcel EfiPciIoAttributeOperationSupported, 128287317Smarcel EfiPciIoAttributeOperationMaximum 129287317Smarcel} EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION; 130287317Smarcel 131287317Smarcel/** 132287317Smarcel Reads from the memory space of a PCI controller. Returns either when the polling exit criteria is 133287317Smarcel satisfied or after a defined duration. 134287317Smarcel 135287317Smarcel @param This A pointer to the EFI_PCI_IO_PROTOCOL instance. 136287317Smarcel @param Width Signifies the width of the memory or I/O operations. 137287317Smarcel @param BarIndex The BAR index of the standard PCI Configuration header to use as the 138287317Smarcel base address for the memory operation to perform. 139287317Smarcel @param Offset The offset within the selected BAR to start the memory operation. 140287317Smarcel @param Mask Mask used for the polling criteria. 141287317Smarcel @param Value The comparison value used for the polling exit criteria. 142287317Smarcel @param Delay The number of 100 ns units to poll. 143287317Smarcel @param Result Pointer to the last value read from the memory location. 144287317Smarcel 145287317Smarcel @retval EFI_SUCCESS The last data returned from the access matched the poll exit criteria. 146287317Smarcel @retval EFI_UNSUPPORTED BarIndex not valid for this PCI controller. 147287317Smarcel @retval EFI_UNSUPPORTED Offset is not valid for the BarIndex of this PCI controller. 148287317Smarcel @retval EFI_TIMEOUT Delay expired before a match occurred. 149287317Smarcel @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. 150287317Smarcel @retval EFI_INVALID_PARAMETER One or more parameters are invalid. 151287317Smarcel 152287317Smarcel**/ 153287317Smarceltypedef 154287317SmarcelEFI_STATUS 155287317Smarcel(EFIAPI *EFI_PCI_IO_PROTOCOL_POLL_IO_MEM)( 156287317Smarcel IN EFI_PCI_IO_PROTOCOL *This, 157287317Smarcel IN EFI_PCI_IO_PROTOCOL_WIDTH Width, 158287317Smarcel IN UINT8 BarIndex, 159287317Smarcel IN UINT64 Offset, 160287317Smarcel IN UINT64 Mask, 161287317Smarcel IN UINT64 Value, 162287317Smarcel IN UINT64 Delay, 163287317Smarcel OUT UINT64 *Result 164287317Smarcel ); 165287317Smarcel 166287317Smarcel/** 167287317Smarcel Enable a PCI driver to access PCI controller registers in the PCI memory or I/O space. 168287317Smarcel 169287317Smarcel @param This A pointer to the EFI_PCI_IO_PROTOCOL instance. 170287317Smarcel @param Width Signifies the width of the memory or I/O operations. 171287317Smarcel @param BarIndex The BAR index of the standard PCI Configuration header to use as the 172287317Smarcel base address for the memory or I/O operation to perform. 173287317Smarcel @param Offset The offset within the selected BAR to start the memory or I/O operation. 174287317Smarcel @param Count The number of memory or I/O operations to perform. 175287317Smarcel @param Buffer For read operations, the destination buffer to store the results. For write 176287317Smarcel operations, the source buffer to write data from. 177287317Smarcel 178287317Smarcel @retval EFI_SUCCESS The data was read from or written to the PCI controller. 179287317Smarcel @retval EFI_UNSUPPORTED BarIndex not valid for this PCI controller. 180287317Smarcel @retval EFI_UNSUPPORTED The address range specified by Offset, Width, and Count is not 181287317Smarcel valid for the PCI BAR specified by BarIndex. 182287317Smarcel @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. 183287317Smarcel @retval EFI_INVALID_PARAMETER One or more parameters are invalid. 184287317Smarcel 185287317Smarcel**/ 186287317Smarceltypedef 187287317SmarcelEFI_STATUS 188287317Smarcel(EFIAPI *EFI_PCI_IO_PROTOCOL_IO_MEM)( 189287317Smarcel IN EFI_PCI_IO_PROTOCOL *This, 190287317Smarcel IN EFI_PCI_IO_PROTOCOL_WIDTH Width, 191287317Smarcel IN UINT8 BarIndex, 192287317Smarcel IN UINT64 Offset, 193287317Smarcel IN UINTN Count, 194287317Smarcel IN OUT VOID *Buffer 195287317Smarcel ); 196287317Smarcel 197287317Smarceltypedef struct { 198287317Smarcel /// 199287317Smarcel /// Read PCI controller registers in the PCI memory or I/O space. 200287317Smarcel /// 201287317Smarcel EFI_PCI_IO_PROTOCOL_IO_MEM Read; 202287317Smarcel /// 203287317Smarcel /// Write PCI controller registers in the PCI memory or I/O space. 204287317Smarcel /// 205287317Smarcel EFI_PCI_IO_PROTOCOL_IO_MEM Write; 206287317Smarcel} EFI_PCI_IO_PROTOCOL_ACCESS; 207287317Smarcel 208287317Smarcel/** 209287317Smarcel Enable a PCI driver to access PCI controller registers in PCI configuration space. 210287317Smarcel 211287317Smarcel @param This A pointer to the EFI_PCI_IO_PROTOCOL instance. 212287317Smarcel @param Width Signifies the width of the memory operations. 213287317Smarcel @param Offset The offset within the PCI configuration space for the PCI controller. 214287317Smarcel @param Count The number of PCI configuration operations to perform. 215287317Smarcel @param Buffer For read operations, the destination buffer to store the results. For write 216287317Smarcel operations, the source buffer to write data from. 217287317Smarcel 218287317Smarcel 219287317Smarcel @retval EFI_SUCCESS The data was read from or written to the PCI controller. 220287317Smarcel @retval EFI_UNSUPPORTED The address range specified by Offset, Width, and Count is not 221287317Smarcel valid for the PCI configuration header of the PCI controller. 222287317Smarcel @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. 223287317Smarcel @retval EFI_INVALID_PARAMETER Buffer is NULL or Width is invalid. 224287317Smarcel 225287317Smarcel**/ 226287317Smarceltypedef 227287317SmarcelEFI_STATUS 228287317Smarcel(EFIAPI *EFI_PCI_IO_PROTOCOL_CONFIG)( 229287317Smarcel IN EFI_PCI_IO_PROTOCOL *This, 230287317Smarcel IN EFI_PCI_IO_PROTOCOL_WIDTH Width, 231287317Smarcel IN UINT32 Offset, 232287317Smarcel IN UINTN Count, 233287317Smarcel IN OUT VOID *Buffer 234287317Smarcel ); 235287317Smarcel 236287317Smarceltypedef struct { 237287317Smarcel /// 238287317Smarcel /// Read PCI controller registers in PCI configuration space. 239287317Smarcel /// 240287317Smarcel EFI_PCI_IO_PROTOCOL_CONFIG Read; 241287317Smarcel /// 242287317Smarcel /// Write PCI controller registers in PCI configuration space. 243287317Smarcel /// 244287317Smarcel EFI_PCI_IO_PROTOCOL_CONFIG Write; 245287317Smarcel} EFI_PCI_IO_PROTOCOL_CONFIG_ACCESS; 246287317Smarcel 247287317Smarcel/** 248287317Smarcel Enables a PCI driver to copy one region of PCI memory space to another region of PCI 249287317Smarcel memory space. 250287317Smarcel 251287317Smarcel @param This A pointer to the EFI_PCI_IO_PROTOCOL instance. 252287317Smarcel @param Width Signifies the width of the memory operations. 253287317Smarcel @param DestBarIndex The BAR index in the standard PCI Configuration header to use as the 254287317Smarcel base address for the memory operation to perform. 255287317Smarcel @param DestOffset The destination offset within the BAR specified by DestBarIndex to 256287317Smarcel start the memory writes for the copy operation. 257287317Smarcel @param SrcBarIndex The BAR index in the standard PCI Configuration header to use as the 258287317Smarcel base address for the memory operation to perform. 259287317Smarcel @param SrcOffset The source offset within the BAR specified by SrcBarIndex to start 260287317Smarcel the memory reads for the copy operation. 261287317Smarcel @param Count The number of memory operations to perform. Bytes moved is Width 262287317Smarcel size * Count, starting at DestOffset and SrcOffset. 263287317Smarcel 264287317Smarcel @retval EFI_SUCCESS The data was copied from one memory region to another memory region. 265287317Smarcel @retval EFI_UNSUPPORTED DestBarIndex not valid for this PCI controller. 266287317Smarcel @retval EFI_UNSUPPORTED SrcBarIndex not valid for this PCI controller. 267287317Smarcel @retval EFI_UNSUPPORTED The address range specified by DestOffset, Width, and Count 268287317Smarcel is not valid for the PCI BAR specified by DestBarIndex. 269287317Smarcel @retval EFI_UNSUPPORTED The address range specified by SrcOffset, Width, and Count is 270287317Smarcel not valid for the PCI BAR specified by SrcBarIndex. 271287317Smarcel @retval EFI_INVALID_PARAMETER Width is invalid. 272287317Smarcel @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. 273287317Smarcel 274287317Smarcel**/ 275287317Smarceltypedef 276287317SmarcelEFI_STATUS 277287317Smarcel(EFIAPI *EFI_PCI_IO_PROTOCOL_COPY_MEM)( 278287317Smarcel IN EFI_PCI_IO_PROTOCOL *This, 279287317Smarcel IN EFI_PCI_IO_PROTOCOL_WIDTH Width, 280287317Smarcel IN UINT8 DestBarIndex, 281287317Smarcel IN UINT64 DestOffset, 282287317Smarcel IN UINT8 SrcBarIndex, 283287317Smarcel IN UINT64 SrcOffset, 284287317Smarcel IN UINTN Count 285287317Smarcel ); 286287317Smarcel 287287317Smarcel/** 288287317Smarcel Provides the PCI controller-specific addresses needed to access system memory. 289287317Smarcel 290287317Smarcel @param This A pointer to the EFI_PCI_IO_PROTOCOL instance. 291287317Smarcel @param Operation Indicates if the bus master is going to read or write to system memory. 292287317Smarcel @param HostAddress The system memory address to map to the PCI controller. 293287317Smarcel @param NumberOfBytes On input the number of bytes to map. On output the number of bytes 294287317Smarcel that were mapped. 295287317Smarcel @param DeviceAddress The resulting map address for the bus master PCI controller to use to 296287317Smarcel access the hosts HostAddress. 297287317Smarcel @param Mapping A resulting value to pass to Unmap(). 298287317Smarcel 299287317Smarcel @retval EFI_SUCCESS The range was mapped for the returned NumberOfBytes. 300287317Smarcel @retval EFI_UNSUPPORTED The HostAddress cannot be mapped as a common buffer. 301287317Smarcel @retval EFI_INVALID_PARAMETER One or more parameters are invalid. 302287317Smarcel @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. 303287317Smarcel @retval EFI_DEVICE_ERROR The system hardware could not map the requested address. 304287317Smarcel 305287317Smarcel**/ 306287317Smarceltypedef 307287317SmarcelEFI_STATUS 308287317Smarcel(EFIAPI *EFI_PCI_IO_PROTOCOL_MAP)( 309287317Smarcel IN EFI_PCI_IO_PROTOCOL *This, 310287317Smarcel IN EFI_PCI_IO_PROTOCOL_OPERATION Operation, 311287317Smarcel IN VOID *HostAddress, 312287317Smarcel IN OUT UINTN *NumberOfBytes, 313287317Smarcel OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, 314287317Smarcel OUT VOID **Mapping 315287317Smarcel ); 316287317Smarcel 317287317Smarcel/** 318287317Smarcel Completes the Map() operation and releases any corresponding resources. 319287317Smarcel 320287317Smarcel @param This A pointer to the EFI_PCI_IO_PROTOCOL instance. 321287317Smarcel @param Mapping The mapping value returned from Map(). 322287317Smarcel 323287317Smarcel @retval EFI_SUCCESS The range was unmapped. 324287317Smarcel @retval EFI_DEVICE_ERROR The data was not committed to the target system memory. 325287317Smarcel 326287317Smarcel**/ 327287317Smarceltypedef 328287317SmarcelEFI_STATUS 329287317Smarcel(EFIAPI *EFI_PCI_IO_PROTOCOL_UNMAP)( 330287317Smarcel IN EFI_PCI_IO_PROTOCOL *This, 331287317Smarcel IN VOID *Mapping 332287317Smarcel ); 333287317Smarcel 334287317Smarcel/** 335287317Smarcel Allocates pages that are suitable for an EfiPciIoOperationBusMasterCommonBuffer 336287317Smarcel mapping. 337287317Smarcel 338287317Smarcel @param This A pointer to the EFI_PCI_IO_PROTOCOL instance. 339287317Smarcel @param Type This parameter is not used and must be ignored. 340287317Smarcel @param MemoryType The type of memory to allocate, EfiBootServicesData or 341287317Smarcel EfiRuntimeServicesData. 342287317Smarcel @param Pages The number of pages to allocate. 343287317Smarcel @param HostAddress A pointer to store the base system memory address of the 344287317Smarcel allocated range. 345287317Smarcel @param Attributes The requested bit mask of attributes for the allocated range. 346287317Smarcel 347287317Smarcel @retval EFI_SUCCESS The requested memory pages were allocated. 348287317Smarcel @retval EFI_UNSUPPORTED Attributes is unsupported. The only legal attribute bits are 349287317Smarcel MEMORY_WRITE_COMBINE and MEMORY_CACHED. 350287317Smarcel @retval EFI_INVALID_PARAMETER One or more parameters are invalid. 351287317Smarcel @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated. 352287317Smarcel 353287317Smarcel**/ 354287317Smarceltypedef 355287317SmarcelEFI_STATUS 356287317Smarcel(EFIAPI *EFI_PCI_IO_PROTOCOL_ALLOCATE_BUFFER)( 357287317Smarcel IN EFI_PCI_IO_PROTOCOL *This, 358287317Smarcel IN EFI_ALLOCATE_TYPE Type, 359287317Smarcel IN EFI_MEMORY_TYPE MemoryType, 360287317Smarcel IN UINTN Pages, 361287317Smarcel OUT VOID **HostAddress, 362287317Smarcel IN UINT64 Attributes 363287317Smarcel ); 364287317Smarcel 365287317Smarcel/** 366287317Smarcel Frees memory that was allocated with AllocateBuffer(). 367287317Smarcel 368287317Smarcel @param This A pointer to the EFI_PCI_IO_PROTOCOL instance. 369287317Smarcel @param Pages The number of pages to free. 370287317Smarcel @param HostAddress The base system memory address of the allocated range. 371287317Smarcel 372287317Smarcel @retval EFI_SUCCESS The requested memory pages were freed. 373287317Smarcel @retval EFI_INVALID_PARAMETER The memory range specified by HostAddress and Pages 374287317Smarcel was not allocated with AllocateBuffer(). 375287317Smarcel 376287317Smarcel**/ 377287317Smarceltypedef 378287317SmarcelEFI_STATUS 379287317Smarcel(EFIAPI *EFI_PCI_IO_PROTOCOL_FREE_BUFFER)( 380287317Smarcel IN EFI_PCI_IO_PROTOCOL *This, 381287317Smarcel IN UINTN Pages, 382287317Smarcel IN VOID *HostAddress 383287317Smarcel ); 384287317Smarcel 385287317Smarcel/** 386287317Smarcel Flushes all PCI posted write transactions from a PCI host bridge to system memory. 387287317Smarcel 388287317Smarcel @param This A pointer to the EFI_PCI_IO_PROTOCOL instance. 389287317Smarcel 390287317Smarcel @retval EFI_SUCCESS The PCI posted write transactions were flushed from the PCI host 391287317Smarcel bridge to system memory. 392287317Smarcel @retval EFI_DEVICE_ERROR The PCI posted write transactions were not flushed from the PCI 393287317Smarcel host bridge due to a hardware error. 394287317Smarcel 395287317Smarcel**/ 396287317Smarceltypedef 397287317SmarcelEFI_STATUS 398287317Smarcel(EFIAPI *EFI_PCI_IO_PROTOCOL_FLUSH)( 399287317Smarcel IN EFI_PCI_IO_PROTOCOL *This 400287317Smarcel ); 401287317Smarcel 402287317Smarcel/** 403287317Smarcel Retrieves this PCI controller's current PCI bus number, device number, and function number. 404287317Smarcel 405287317Smarcel @param This A pointer to the EFI_PCI_IO_PROTOCOL instance. 406287317Smarcel @param SegmentNumber The PCI controller's current PCI segment number. 407287317Smarcel @param BusNumber The PCI controller's current PCI bus number. 408287317Smarcel @param DeviceNumber The PCI controller's current PCI device number. 409287317Smarcel @param FunctionNumber The PCI controller's current PCI function number. 410287317Smarcel 411287317Smarcel @retval EFI_SUCCESS The PCI controller location was returned. 412287317Smarcel @retval EFI_INVALID_PARAMETER One or more parameters are invalid. 413287317Smarcel 414287317Smarcel**/ 415287317Smarceltypedef 416287317SmarcelEFI_STATUS 417287317Smarcel(EFIAPI *EFI_PCI_IO_PROTOCOL_GET_LOCATION)( 418287317Smarcel IN EFI_PCI_IO_PROTOCOL *This, 419287317Smarcel OUT UINTN *SegmentNumber, 420287317Smarcel OUT UINTN *BusNumber, 421287317Smarcel OUT UINTN *DeviceNumber, 422287317Smarcel OUT UINTN *FunctionNumber 423287317Smarcel ); 424287317Smarcel 425287317Smarcel/** 426287317Smarcel Performs an operation on the attributes that this PCI controller supports. The operations include 427287317Smarcel getting the set of supported attributes, retrieving the current attributes, setting the current 428287317Smarcel attributes, enabling attributes, and disabling attributes. 429287317Smarcel 430287317Smarcel @param This A pointer to the EFI_PCI_IO_PROTOCOL instance. 431287317Smarcel @param Operation The operation to perform on the attributes for this PCI controller. 432287317Smarcel @param Attributes The mask of attributes that are used for Set, Enable, and Disable 433287317Smarcel operations. 434287317Smarcel @param Result A pointer to the result mask of attributes that are returned for the Get 435287317Smarcel and Supported operations. 436287317Smarcel 437287317Smarcel @retval EFI_SUCCESS The operation on the PCI controller's attributes was completed. 438287317Smarcel @retval EFI_INVALID_PARAMETER One or more parameters are invalid. 439287317Smarcel @retval EFI_UNSUPPORTED one or more of the bits set in 440287317Smarcel Attributes are not supported by this PCI controller or one of 441287317Smarcel its parent bridges when Operation is Set, Enable or Disable. 442287317Smarcel 443287317Smarcel**/ 444287317Smarceltypedef 445287317SmarcelEFI_STATUS 446287317Smarcel(EFIAPI *EFI_PCI_IO_PROTOCOL_ATTRIBUTES)( 447287317Smarcel IN EFI_PCI_IO_PROTOCOL *This, 448287317Smarcel IN EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION Operation, 449287317Smarcel IN UINT64 Attributes, 450287317Smarcel OUT UINT64 *Result OPTIONAL 451287317Smarcel ); 452287317Smarcel 453287317Smarcel/** 454287317Smarcel Gets the attributes that this PCI controller supports setting on a BAR using 455287317Smarcel SetBarAttributes(), and retrieves the list of resource descriptors for a BAR. 456287317Smarcel 457287317Smarcel @param This A pointer to the EFI_PCI_IO_PROTOCOL instance. 458287317Smarcel @param BarIndex The BAR index of the standard PCI Configuration header to use as the 459287317Smarcel base address for resource range. The legal range for this field is 0..5. 460287317Smarcel @param Supports A pointer to the mask of attributes that this PCI controller supports 461287317Smarcel setting for this BAR with SetBarAttributes(). 462287317Smarcel @param Resources A pointer to the ACPI 2.0 resource descriptors that describe the current 463287317Smarcel configuration of this BAR of the PCI controller. 464287317Smarcel 465287317Smarcel @retval EFI_SUCCESS If Supports is not NULL, then the attributes that the PCI 466287317Smarcel controller supports are returned in Supports. If Resources 467287317Smarcel is not NULL, then the ACPI 2.0 resource descriptors that the PCI 468287317Smarcel controller is currently using are returned in Resources. 469287317Smarcel @retval EFI_INVALID_PARAMETER Both Supports and Attributes are NULL. 470287317Smarcel @retval EFI_UNSUPPORTED BarIndex not valid for this PCI controller. 471287317Smarcel @retval EFI_OUT_OF_RESOURCES There are not enough resources available to allocate 472287317Smarcel Resources. 473287317Smarcel 474287317Smarcel**/ 475287317Smarceltypedef 476287317SmarcelEFI_STATUS 477287317Smarcel(EFIAPI *EFI_PCI_IO_PROTOCOL_GET_BAR_ATTRIBUTES)( 478287317Smarcel IN EFI_PCI_IO_PROTOCOL *This, 479287317Smarcel IN UINT8 BarIndex, 480287317Smarcel OUT UINT64 *Supports, OPTIONAL 481287317Smarcel OUT VOID **Resources OPTIONAL 482287317Smarcel ); 483287317Smarcel 484287317Smarcel/** 485287317Smarcel Sets the attributes for a range of a BAR on a PCI controller. 486287317Smarcel 487287317Smarcel @param This A pointer to the EFI_PCI_IO_PROTOCOL instance. 488287317Smarcel @param Attributes The mask of attributes to set for the resource range specified by 489287317Smarcel BarIndex, Offset, and Length. 490287317Smarcel @param BarIndex The BAR index of the standard PCI Configuration header to use as the 491287317Smarcel base address for resource range. The legal range for this field is 0..5. 492287317Smarcel @param Offset A pointer to the BAR relative base address of the resource range to be 493287317Smarcel modified by the attributes specified by Attributes. 494287317Smarcel @param Length A pointer to the length of the resource range to be modified by the 495287317Smarcel attributes specified by Attributes. 496287317Smarcel 497287317Smarcel @retval EFI_SUCCESS The set of attributes specified by Attributes for the resource 498287317Smarcel range specified by BarIndex, Offset, and Length were 499287317Smarcel set on the PCI controller, and the actual resource range is returned 500287317Smarcel in Offset and Length. 501287317Smarcel @retval EFI_INVALID_PARAMETER Offset or Length is NULL. 502287317Smarcel @retval EFI_UNSUPPORTED BarIndex not valid for this PCI controller. 503287317Smarcel @retval EFI_OUT_OF_RESOURCES There are not enough resources to set the attributes on the 504287317Smarcel resource range specified by BarIndex, Offset, and 505287317Smarcel Length. 506287317Smarcel 507287317Smarcel**/ 508287317Smarceltypedef 509287317SmarcelEFI_STATUS 510287317Smarcel(EFIAPI *EFI_PCI_IO_PROTOCOL_SET_BAR_ATTRIBUTES)( 511287317Smarcel IN EFI_PCI_IO_PROTOCOL *This, 512287317Smarcel IN UINT64 Attributes, 513287317Smarcel IN UINT8 BarIndex, 514287317Smarcel IN OUT UINT64 *Offset, 515287317Smarcel IN OUT UINT64 *Length 516287317Smarcel ); 517287317Smarcel 518287317Smarcel/// 519287317Smarcel/// The EFI_PCI_IO_PROTOCOL provides the basic Memory, I/O, PCI configuration, 520287317Smarcel/// and DMA interfaces used to abstract accesses to PCI controllers. 521287317Smarcel/// There is one EFI_PCI_IO_PROTOCOL instance for each PCI controller on a PCI bus. 522287317Smarcel/// A device driver that wishes to manage a PCI controller in a system will have to 523287317Smarcel/// retrieve the EFI_PCI_IO_PROTOCOL instance that is associated with the PCI controller. 524287317Smarcel/// 525287317Smarcelstruct _EFI_PCI_IO_PROTOCOL { 526287317Smarcel EFI_PCI_IO_PROTOCOL_POLL_IO_MEM PollMem; 527287317Smarcel EFI_PCI_IO_PROTOCOL_POLL_IO_MEM PollIo; 528287317Smarcel EFI_PCI_IO_PROTOCOL_ACCESS Mem; 529287317Smarcel EFI_PCI_IO_PROTOCOL_ACCESS Io; 530287317Smarcel EFI_PCI_IO_PROTOCOL_CONFIG_ACCESS Pci; 531287317Smarcel EFI_PCI_IO_PROTOCOL_COPY_MEM CopyMem; 532287317Smarcel EFI_PCI_IO_PROTOCOL_MAP Map; 533287317Smarcel EFI_PCI_IO_PROTOCOL_UNMAP Unmap; 534287317Smarcel EFI_PCI_IO_PROTOCOL_ALLOCATE_BUFFER AllocateBuffer; 535287317Smarcel EFI_PCI_IO_PROTOCOL_FREE_BUFFER FreeBuffer; 536287317Smarcel EFI_PCI_IO_PROTOCOL_FLUSH Flush; 537287317Smarcel EFI_PCI_IO_PROTOCOL_GET_LOCATION GetLocation; 538287317Smarcel EFI_PCI_IO_PROTOCOL_ATTRIBUTES Attributes; 539287317Smarcel EFI_PCI_IO_PROTOCOL_GET_BAR_ATTRIBUTES GetBarAttributes; 540287317Smarcel EFI_PCI_IO_PROTOCOL_SET_BAR_ATTRIBUTES SetBarAttributes; 541287317Smarcel 542287317Smarcel /// 543287317Smarcel /// The size, in bytes, of the ROM image. 544287317Smarcel /// 545287317Smarcel UINT64 RomSize; 546287317Smarcel 547287317Smarcel /// 548287317Smarcel /// A pointer to the in memory copy of the ROM image. The PCI Bus Driver is responsible 549287317Smarcel /// for allocating memory for the ROM image, and copying the contents of the ROM to memory. 550287317Smarcel /// The contents of this buffer are either from the PCI option ROM that can be accessed 551287317Smarcel /// through the ROM BAR of the PCI controller, or it is from a platform-specific location. 552287317Smarcel /// The Attributes() function can be used to determine from which of these two sources 553287317Smarcel /// the RomImage buffer was initialized. 554287317Smarcel /// 555287317Smarcel VOID *RomImage; 556287317Smarcel}; 557287317Smarcel 558287317Smarcelextern EFI_GUID gEfiPciIoProtocolGuid; 559287317Smarcel 560287317Smarcel#endif 561