1 #ifndef _EFI_PCI_IO_H 2 #define _EFI_PCI_IO_H 3 4 #define EFI_PCI_IO_PROTOCOL_GUID \ 5 { 0x4cf5b200, 0x68b8, 0x4ca5, {0x9e, 0xec, 0xb2, 0x3e, 0x3f, 0x50, 0x02, 0x9a} } 6 7 #define EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GUID \ 8 { 0x2f707ebb, 0x4a1a, 0x11d4, {0x9a, 0x38, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } 9 10 INTERFACE_DECL(_EFI_PCI_IO_PROTOCOL); 11 INTERFACE_DECL(_EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL); 12 13 typedef enum { 14 EfiPciIoWidthUint8, 15 EfiPciIoWidthUint16, 16 EfiPciIoWidthUint32, 17 EfiPciIoWidthUint64, 18 EfiPciIoWidthFifoUint8, 19 EfiPciIoWidthFifoUint16, 20 EfiPciIoWidthFifoUint32, 21 EfiPciIoWidthFifoUint64, 22 EfiPciIoWidthFillUint8, 23 EfiPciIoWidthFillUint16, 24 EfiPciIoWidthFillUint32, 25 EfiPciIoWidthFillUint64, 26 EfiPciIoWidthMaximum 27 } EFI_PCI_IO_PROTOCOL_WIDTH, EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH; 28 29 #define EFI_PCI_IO_PASS_THROUGH_BAR 0xff 30 31 typedef 32 EFI_STATUS 33 (EFIAPI *EFI_PCI_IO_PROTOCOL_POLL_IO_MEM) ( 34 IN struct _EFI_PCI_IO_PROTOCOL *This, 35 IN EFI_PCI_IO_PROTOCOL_WIDTH Width, 36 IN UINT8 BarIndex, 37 IN UINT64 Offset, 38 IN UINT64 Mask, 39 IN UINT64 Value, 40 IN UINT64 Delay, 41 OUT UINT64 *Result 42 ); 43 44 typedef 45 EFI_STATUS 46 (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_POLL_IO_MEM) ( 47 IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This, 48 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width, 49 IN UINT64 Address, 50 IN UINT64 Mask, 51 IN UINT64 Value, 52 IN UINT64 Delay, 53 OUT UINT64 *Result 54 ); 55 56 typedef 57 EFI_STATUS 58 (EFIAPI *EFI_PCI_IO_PROTOCOL_IO_MEM) ( 59 IN struct _EFI_PCI_IO_PROTOCOL *This, 60 IN EFI_PCI_IO_PROTOCOL_WIDTH Width, 61 IN UINT8 BarIndex, 62 IN UINT64 Offset, 63 IN UINTN Count, 64 IN OUT VOID *Buffer 65 ); 66 67 typedef 68 EFI_STATUS 69 (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_IO_MEM) ( 70 IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This, 71 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width, 72 IN UINT64 Address, 73 IN UINTN Count, 74 IN OUT VOID *Buffer 75 ); 76 77 typedef struct { 78 EFI_PCI_IO_PROTOCOL_IO_MEM Read; 79 EFI_PCI_IO_PROTOCOL_IO_MEM Write; 80 } EFI_PCI_IO_PROTOCOL_ACCESS; 81 82 typedef struct { 83 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_IO_MEM Read; 84 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_IO_MEM Write; 85 } EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS; 86 87 typedef 88 EFI_STATUS 89 (EFIAPI *EFI_PCI_IO_PROTOCOL_CONFIG) ( 90 IN struct _EFI_PCI_IO_PROTOCOL *This, 91 IN EFI_PCI_IO_PROTOCOL_WIDTH Width, 92 IN UINT32 Offset, 93 IN UINTN Count, 94 IN OUT VOID *Buffer 95 ); 96 97 typedef 98 EFI_STATUS 99 (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_CONFIGURATION) ( 100 IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This, 101 OUT VOID **Resources 102 ); 103 104 typedef struct { 105 EFI_PCI_IO_PROTOCOL_CONFIG Read; 106 EFI_PCI_IO_PROTOCOL_CONFIG Write; 107 } EFI_PCI_IO_PROTOCOL_CONFIG_ACCESS; 108 109 typedef 110 EFI_STATUS 111 (EFIAPI *EFI_PCI_IO_PROTOCOL_COPY_MEM) ( 112 IN struct _EFI_PCI_IO_PROTOCOL *This, 113 IN EFI_PCI_IO_PROTOCOL_WIDTH Width, 114 IN UINT8 DestBarIndex, 115 IN UINT64 DestOffset, 116 IN UINT8 SrcBarIndex, 117 IN UINT64 SrcOffset, 118 IN UINTN Count 119 ); 120 121 typedef 122 EFI_STATUS 123 (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_COPY_MEM) ( 124 IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This, 125 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width, 126 IN UINT64 DestAddress, 127 IN UINT64 SrcAddress, 128 IN UINTN Count 129 ); 130 131 typedef enum { 132 EfiPciIoOperationBusMasterRead, 133 EfiPciIoOperationBusMasterWrite, 134 EfiPciIoOperationBusMasterCommonBuffer, 135 EfiPciIoOperationMaximum 136 } EFI_PCI_IO_PROTOCOL_OPERATION; 137 138 typedef enum { 139 EfiPciOperationBusMasterRead, 140 EfiPciOperationBusMasterWrite, 141 EfiPciOperationBusMasterCommonBuffer, 142 EfiPciOperationBusMasterRead64, 143 EfiPciOperationBusMasterWrite64, 144 EfiPciOperationBusMasterCommonBuffer64, 145 EfiPciOperationMaximum 146 } EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION; 147 148 typedef 149 EFI_STATUS 150 (EFIAPI *EFI_PCI_IO_PROTOCOL_MAP) ( 151 IN struct _EFI_PCI_IO_PROTOCOL *This, 152 IN EFI_PCI_IO_PROTOCOL_OPERATION Operation, 153 IN VOID *HostAddress, 154 IN OUT UINTN *NumberOfBytes, 155 OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, 156 OUT VOID **Mapping 157 ); 158 159 typedef 160 EFI_STATUS 161 (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_MAP) ( 162 IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This, 163 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION Operation, 164 IN VOID *HostAddress, 165 IN OUT UINTN *NumberOfBytes, 166 OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, 167 OUT VOID **Mapping 168 ); 169 170 typedef 171 EFI_STATUS 172 (EFIAPI *EFI_PCI_IO_PROTOCOL_UNMAP) ( 173 IN struct _EFI_PCI_IO_PROTOCOL *This, 174 IN VOID *Mapping 175 ); 176 177 typedef 178 EFI_STATUS 179 (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_UNMAP) ( 180 IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This, 181 IN VOID *Mapping 182 ); 183 184 typedef 185 EFI_STATUS 186 (EFIAPI *EFI_PCI_IO_PROTOCOL_ALLOCATE_BUFFER) ( 187 IN struct _EFI_PCI_IO_PROTOCOL *This, 188 IN EFI_ALLOCATE_TYPE Type, 189 IN EFI_MEMORY_TYPE MemoryType, 190 IN UINTN Pages, 191 OUT VOID **HostAddress, 192 IN UINT64 Attributes 193 ); 194 195 typedef 196 EFI_STATUS 197 (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ALLOCATE_BUFFER) ( 198 IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This, 199 IN EFI_ALLOCATE_TYPE Type, 200 IN EFI_MEMORY_TYPE MemoryType, 201 IN UINTN Pages, 202 IN OUT VOID **HostAddress, 203 IN UINT64 Attributes 204 ); 205 206 typedef 207 EFI_STATUS 208 (EFIAPI *EFI_PCI_IO_PROTOCOL_FREE_BUFFER) ( 209 IN struct _EFI_PCI_IO_PROTOCOL *This, 210 IN UINTN Pages, 211 IN VOID *HostAddress 212 ); 213 214 typedef 215 EFI_STATUS 216 (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FREE_BUFFER) ( 217 IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This, 218 IN UINTN Pages, 219 IN VOID *HostAddress 220 ); 221 222 typedef 223 EFI_STATUS 224 (EFIAPI *EFI_PCI_IO_PROTOCOL_FLUSH) ( 225 IN struct _EFI_PCI_IO_PROTOCOL *This 226 ); 227 228 typedef 229 EFI_STATUS 230 (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FLUSH) ( 231 IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This 232 ); 233 234 typedef 235 EFI_STATUS 236 (EFIAPI *EFI_PCI_IO_PROTOCOL_GET_LOCATION) ( 237 IN struct _EFI_PCI_IO_PROTOCOL *This, 238 OUT UINTN *SegmentNumber, 239 OUT UINTN *BusNumber, 240 OUT UINTN *DeviceNumber, 241 OUT UINTN *FunctionNumber 242 ); 243 244 #define EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO 0x0001 245 #define EFI_PCI_ATTRIBUTE_ISA_IO 0x0002 246 #define EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO 0x0004 247 #define EFI_PCI_ATTRIBUTE_VGA_MEMORY 0x0008 248 #define EFI_PCI_ATTRIBUTE_VGA_IO 0x0010 249 #define EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO 0x0020 250 #define EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO 0x0040 251 #define EFI_PCI_ATTRIBUTE_MEMORY_WRITE_COMBINE 0x0080 252 #define EFI_PCI_ATTRIBUTE_IO 0x0100 253 #define EFI_PCI_ATTRIBUTE_MEMORY 0x0200 254 #define EFI_PCI_ATTRIBUTE_BUS_MASTER 0x0400 255 #define EFI_PCI_ATTRIBUTE_MEMORY_CACHED 0x0800 256 #define EFI_PCI_ATTRIBUTE_MEMORY_DISABLE 0x1000 257 #define EFI_PCI_ATTRIBUTE_EMBEDDED_DEVICE 0x2000 258 #define EFI_PCI_ATTRIBUTE_EMBEDDED_ROM 0x4000 259 #define EFI_PCI_ATTRIBUTE_DUAL_ADDRESS_CYCLE 0x8000 260 #define EFI_PCI_ATTRIBUTE_ISA_IO_16 0x10000 261 #define EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16 0x20000 262 #define EFI_PCI_ATTRIBUTE_VGA_IO_16 0x40000 263 264 #define EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO 265 #define EFI_PCI_IO_ATTRIBUTE_ISA_IO EFI_PCI_ATTRIBUTE_ISA_IO 266 #define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO 267 #define EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY EFI_PCI_ATTRIBUTE_VGA_MEMORY 268 #define EFI_PCI_IO_ATTRIBUTE_VGA_IO EFI_PCI_ATTRIBUTE_VGA_IO 269 #define EFI_PCI_IO_ATTRIBUTE_IDE_PRIMARY_IO EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO 270 #define EFI_PCI_IO_ATTRIBUTE_IDE_SECONDARY_IO EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO 271 #define EFI_PCI_IO_ATTRIBUTE_MEMORY_WRITE_COMBINE EFI_PCI_ATTRIBUTE_MEMORY_WRITE_COMBINE 272 #define EFI_PCI_IO_ATTRIBUTE_IO EFI_PCI_ATTRIBUTE_IO 273 #define EFI_PCI_IO_ATTRIBUTE_MEMORY EFI_PCI_ATTRIBUTE_MEMORY 274 #define EFI_PCI_IO_ATTRIBUTE_BUS_MASTER EFI_PCI_ATTRIBUTE_BUS_MASTER 275 #define EFI_PCI_IO_ATTRIBUTE_MEMORY_CACHED EFI_PCI_ATTRIBUTE_MEMORY_CACHED 276 #define EFI_PCI_IO_ATTRIBUTE_MEMORY_DISABLE EFI_PCI_ATTRIBUTE_MEMORY_DISABLE 277 #define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_DEVICE EFI_PCI_ATTRIBUTE_EMBEDDED_DEVICE 278 #define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_ROM EFI_PCI_ATTRIBUTE_EMBEDDED_ROM 279 #define EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE EFI_PCI_ATTRIBUTE_DUAL_ADDRESS_CYCLE 280 #define EFI_PCI_IO_ATTRIBUTE_ISA_IO_16 EFI_PCI_ATTRIBUTE_ISA_IO_16 281 #define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO_16 EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16 282 #define EFI_PCI_IO_ATTRIBUTE_VGA_IO_16 EFI_PCI_ATTRIBUTE_VGA_IO_16 283 284 #define EFI_PCI_ATTRIBUTE_VALID_FOR_ALLOCATE_BUFFER \ 285 (EFI_PCI_ATTRIBUTE_MEMORY_WRITE_COMBINE | EFI_PCI_ATTRIBUTE_MEMORY_CACHED | EFI_PCI_ATTRIBUTE_DUAL_ADDRESS_CYCLE) 286 287 #define EFI_PCI_ATTRIBUTE_INVALID_FOR_ALLOCATE_BUFFER \ 288 (~EFI_PCI_ATTRIBUTE_VALID_FOR_ALLOCATE_BUFFER) 289 290 typedef struct { 291 UINT8 Register; 292 UINT8 Function; 293 UINT8 Device; 294 UINT8 Bus; 295 UINT32 ExtendedRegister; 296 } EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS; 297 298 typedef enum { 299 EfiPciIoAttributeOperationGet, 300 EfiPciIoAttributeOperationSet, 301 EfiPciIoAttributeOperationEnable, 302 EfiPciIoAttributeOperationDisable, 303 EfiPciIoAttributeOperationSupported, 304 EfiPciIoAttributeOperationMaximum 305 } EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION; 306 307 typedef 308 EFI_STATUS 309 (EFIAPI *EFI_PCI_IO_PROTOCOL_ATTRIBUTES) ( 310 IN struct _EFI_PCI_IO_PROTOCOL *This, 311 IN EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION Operation, 312 IN UINT64 Attributes, 313 OUT UINT64 *Result OPTIONAL 314 ); 315 316 typedef 317 EFI_STATUS 318 (EFIAPI *EFI_PCI_IO_PROTOCOL_GET_BAR_ATTRIBUTES) ( 319 IN struct _EFI_PCI_IO_PROTOCOL *This, 320 IN UINT8 BarIndex, 321 OUT UINT64 *Supports OPTIONAL, 322 OUT VOID **Resources OPTIONAL 323 ); 324 325 typedef 326 EFI_STATUS 327 (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GET_ATTRIBUTES) ( 328 IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This, 329 OUT UINT64 *Supports, 330 OUT UINT64 *Attributes 331 ); 332 333 typedef 334 EFI_STATUS 335 (EFIAPI *EFI_PCI_IO_PROTOCOL_SET_BAR_ATTRIBUTES) ( 336 IN struct _EFI_PCI_IO_PROTOCOL *This, 337 IN UINT64 Attributes, 338 IN UINT8 BarIndex, 339 IN OUT UINT64 *Offset, 340 IN OUT UINT64 *Length 341 ); 342 343 typedef 344 EFI_STATUS 345 (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_SET_ATTRIBUTES) ( 346 IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This, 347 IN UINT64 Attributes, 348 IN OUT UINT64 *ResourceBase, 349 IN OUT UINT64 *ResourceLength 350 ); 351 352 typedef struct _EFI_PCI_IO_PROTOCOL { 353 EFI_PCI_IO_PROTOCOL_POLL_IO_MEM PollMem; 354 EFI_PCI_IO_PROTOCOL_POLL_IO_MEM PollIo; 355 EFI_PCI_IO_PROTOCOL_ACCESS Mem; 356 EFI_PCI_IO_PROTOCOL_ACCESS Io; 357 EFI_PCI_IO_PROTOCOL_CONFIG_ACCESS Pci; 358 EFI_PCI_IO_PROTOCOL_COPY_MEM CopyMem; 359 EFI_PCI_IO_PROTOCOL_MAP Map; 360 EFI_PCI_IO_PROTOCOL_UNMAP Unmap; 361 EFI_PCI_IO_PROTOCOL_ALLOCATE_BUFFER AllocateBuffer; 362 EFI_PCI_IO_PROTOCOL_FREE_BUFFER FreeBuffer; 363 EFI_PCI_IO_PROTOCOL_FLUSH Flush; 364 EFI_PCI_IO_PROTOCOL_GET_LOCATION GetLocation; 365 EFI_PCI_IO_PROTOCOL_ATTRIBUTES Attributes; 366 EFI_PCI_IO_PROTOCOL_GET_BAR_ATTRIBUTES GetBarAttributes; 367 EFI_PCI_IO_PROTOCOL_SET_BAR_ATTRIBUTES SetBarAttributes; 368 UINT64 RomSize; 369 VOID *RomImage; 370 } EFI_PCI_IO_PROTOCOL; 371 372 // Note: Because it conflicted with the EDK2 struct name, the 373 // 'EFI_PCI_IO_PROTOCOL' GUID definition, from older versions 374 // of gnu-efi, is now obsoleted. 375 // Use 'EFI_PCI_IO_PROTOCOL_GUID' instead. 376 377 typedef struct _EFI_PCI_IO_PROTOCOL _EFI_PCI_IO; 378 typedef EFI_PCI_IO_PROTOCOL EFI_PCI_IO; 379 380 typedef struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL { 381 EFI_HANDLE ParentHandle; 382 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_POLL_IO_MEM PollMem; 383 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_POLL_IO_MEM PollIo; 384 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS Mem; 385 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS Io; 386 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS Pci; 387 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_COPY_MEM CopyMem; 388 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_MAP Map; 389 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_UNMAP Unmap; 390 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ALLOCATE_BUFFER AllocateBuffer; 391 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FREE_BUFFER FreeBuffer; 392 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FLUSH Flush; 393 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GET_ATTRIBUTES GetAttributes; 394 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_SET_ATTRIBUTES SetAttributes; 395 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_CONFIGURATION Configuration; 396 UINT32 SegmentNumber; 397 } EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL; 398 399 #endif /* _EFI_PCI_IO_H */ 400