3 Copyright (c) 2004 - 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
28 // Global ID for the PCI I/O Protocol
30 #define EFI_PCI_IO_PROTOCOL_GUID \
32 0x4cf5b200, 0x68b8, 0x4ca5, 0x9e, 0xec, 0xb2, 0x3e, 0x3f, 0x50, 0x2, 0x9a \
35 EFI_FORWARD_DECLARATION (EFI_PCI_IO_PROTOCOL
);
38 // Prototypes for the PCI I/O Protocol
41 EfiPciIoWidthUint8
= 0,
45 EfiPciIoWidthFifoUint8
,
46 EfiPciIoWidthFifoUint16
,
47 EfiPciIoWidthFifoUint32
,
48 EfiPciIoWidthFifoUint64
,
49 EfiPciIoWidthFillUint8
,
50 EfiPciIoWidthFillUint16
,
51 EfiPciIoWidthFillUint32
,
52 EfiPciIoWidthFillUint64
,
54 } EFI_PCI_IO_PROTOCOL_WIDTH
;
57 // Complete PCI address generater
59 #define EFI_PCI_IO_PASS_THROUGH_BAR 0xff // Special BAR that passes a memory or I/O cycle through unchanged
60 #define EFI_PCI_IO_ATTRIBUTE_MASK 0x077f // All the following I/O and Memory cycles
61 #define EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO 0x0001 // I/O cycles 0x0000-0x00FF (10 bit decode)
62 #define EFI_PCI_IO_ATTRIBUTE_ISA_IO 0x0002 // I/O cycles 0x0000-0x03FF (10 bit decode)
63 #define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO 0x0004 // I/O cycles 0x3C6, 0x3C8, 0x3C9 (10 bit decode)
64 #define EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY 0x0008 // MEM cycles 0xA0000-0xBFFFF (24 bit decode)
65 #define EFI_PCI_IO_ATTRIBUTE_VGA_IO 0x0010 // I/O cycles 0x3B0-0x3BB and 0x3C0-0x3DF (10 bit decode)
66 #define EFI_PCI_IO_ATTRIBUTE_IDE_PRIMARY_IO 0x0020 // I/O cycles 0x1F0-0x1F7, 0x3F6, 0x3F7 (10 bit decode)
67 #define EFI_PCI_IO_ATTRIBUTE_IDE_SECONDARY_IO 0x0040 // I/O cycles 0x170-0x177, 0x376, 0x377 (10 bit decode)
68 #define EFI_PCI_IO_ATTRIBUTE_MEMORY_WRITE_COMBINE 0x0080 // Map a memory range so write are combined
69 #define EFI_PCI_IO_ATTRIBUTE_IO 0x0100 // Enable the I/O decode bit in the PCI Config Header
70 #define EFI_PCI_IO_ATTRIBUTE_MEMORY 0x0200 // Enable the Memory decode bit in the PCI Config Header
71 #define EFI_PCI_IO_ATTRIBUTE_BUS_MASTER 0x0400 // Enable the DMA bit in the PCI Config Header
72 #define EFI_PCI_IO_ATTRIBUTE_MEMORY_CACHED 0x0800 // Map a memory range so all r/w accesses are cached
73 #define EFI_PCI_IO_ATTRIBUTE_MEMORY_DISABLE 0x1000 // Disable a memory range
74 #define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_DEVICE 0x2000 // Clear for an add-in PCI Device
75 #define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_ROM 0x4000 // Clear for a physical PCI Option ROM accessed through ROM BAR
76 #define EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE 0x8000 // Clear for PCI controllers that can not genrate a DAC
78 // The following definition is added in EFI1.1 spec update and UEFI2.0 spec.
80 #define EFI_PCI_IO_ATTRIBUTE_ISA_IO_16 0x10000 // I/O cycles 0x0100-0x03FF (16 bit decode)
81 #define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO_16 0x20000 // I/O cycles 0x3C6, 0x3C8, 0x3C9 (16 bit decode)
82 #define EFI_PCI_IO_ATTRIBUTE_VGA_IO_16 0x40000 // I/O cycles 0x3B0-0x3BB and 0x3C0-0x3DF (16 bit decode)
84 #define EFI_PCI_DEVICE_ENABLE (EFI_PCI_IO_ATTRIBUTE_IO | EFI_PCI_IO_ATTRIBUTE_MEMORY | EFI_PCI_IO_ATTRIBUTE_BUS_MASTER)
85 #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)
88 // *******************************************************
89 // EFI_PCI_IO_PROTOCOL_OPERATION
90 // *******************************************************
93 EfiPciIoOperationBusMasterRead
,
94 EfiPciIoOperationBusMasterWrite
,
95 EfiPciIoOperationBusMasterCommonBuffer
,
96 EfiPciIoOperationMaximum
97 } EFI_PCI_IO_PROTOCOL_OPERATION
;
100 // *******************************************************
101 // EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION
102 // *******************************************************
105 EfiPciIoAttributeOperationGet
,
106 EfiPciIoAttributeOperationSet
,
107 EfiPciIoAttributeOperationEnable
,
108 EfiPciIoAttributeOperationDisable
,
109 EfiPciIoAttributeOperationSupported
,
110 EfiPciIoAttributeOperationMaximum
111 } EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION
;
115 (EFIAPI
*EFI_PCI_IO_PROTOCOL_POLL_IO_MEM
) (
116 IN EFI_PCI_IO_PROTOCOL
* This
,
117 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
128 (EFIAPI
*EFI_PCI_IO_PROTOCOL_IO_MEM
) (
129 IN EFI_PCI_IO_PROTOCOL
* This
,
130 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
138 EFI_PCI_IO_PROTOCOL_IO_MEM Read
;
139 EFI_PCI_IO_PROTOCOL_IO_MEM Write
;
140 } EFI_PCI_IO_PROTOCOL_ACCESS
;
144 (EFIAPI
*EFI_PCI_IO_PROTOCOL_CONFIG
) (
145 IN EFI_PCI_IO_PROTOCOL
* This
,
146 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
153 EFI_PCI_IO_PROTOCOL_CONFIG Read
;
154 EFI_PCI_IO_PROTOCOL_CONFIG Write
;
155 } EFI_PCI_IO_PROTOCOL_CONFIG_ACCESS
;
159 (EFIAPI
*EFI_PCI_IO_PROTOCOL_COPY_MEM
) (
160 IN EFI_PCI_IO_PROTOCOL
* This
,
161 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
162 IN UINT8 DestBarIndex
,
163 IN UINT64 DestOffset
,
164 IN UINT8 SrcBarIndex
,
171 (EFIAPI
*EFI_PCI_IO_PROTOCOL_MAP
) (
172 IN EFI_PCI_IO_PROTOCOL
* This
,
173 IN EFI_PCI_IO_PROTOCOL_OPERATION Operation
,
174 IN VOID
*HostAddress
,
175 IN OUT UINTN
*NumberOfBytes
,
176 OUT EFI_PHYSICAL_ADDRESS
* DeviceAddress
,
182 (EFIAPI
*EFI_PCI_IO_PROTOCOL_UNMAP
) (
183 IN EFI_PCI_IO_PROTOCOL
* This
,
189 (EFIAPI
*EFI_PCI_IO_PROTOCOL_ALLOCATE_BUFFER
) (
190 IN EFI_PCI_IO_PROTOCOL
* This
,
191 IN EFI_ALLOCATE_TYPE Type
,
192 IN EFI_MEMORY_TYPE MemoryType
,
194 OUT VOID
**HostAddress
,
200 (EFIAPI
*EFI_PCI_IO_PROTOCOL_FREE_BUFFER
) (
201 IN EFI_PCI_IO_PROTOCOL
* This
,
208 (EFIAPI
*EFI_PCI_IO_PROTOCOL_FLUSH
) (
209 IN EFI_PCI_IO_PROTOCOL
* This
214 (EFIAPI
*EFI_PCI_IO_PROTOCOL_GET_LOCATION
) (
215 IN EFI_PCI_IO_PROTOCOL
* This
,
216 OUT UINTN
*SegmentNumber
,
217 OUT UINTN
*BusNumber
,
218 OUT UINTN
*DeviceNumber
,
219 OUT UINTN
*FunctionNumber
224 (EFIAPI
*EFI_PCI_IO_PROTOCOL_ATTRIBUTES
) (
225 IN EFI_PCI_IO_PROTOCOL
* This
,
226 IN EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION Operation
,
227 IN UINT64 Attributes
,
228 OUT UINT64
*Result OPTIONAL
233 (EFIAPI
*EFI_PCI_IO_PROTOCOL_GET_BAR_ATTRIBUTES
) (
234 IN EFI_PCI_IO_PROTOCOL
* This
,
236 OUT UINT64
*Supports
, OPTIONAL
237 OUT VOID
**Resources OPTIONAL
242 (EFIAPI
*EFI_PCI_IO_PROTOCOL_SET_BAR_ATTRIBUTES
) (
243 IN EFI_PCI_IO_PROTOCOL
* This
,
244 IN UINT64 Attributes
,
246 IN OUT UINT64
*Offset
,
247 IN OUT UINT64
*Length
251 // Interface structure for the PCI I/O Protocol
253 struct _EFI_PCI_IO_PROTOCOL
{
254 EFI_PCI_IO_PROTOCOL_POLL_IO_MEM PollMem
;
255 EFI_PCI_IO_PROTOCOL_POLL_IO_MEM PollIo
;
256 EFI_PCI_IO_PROTOCOL_ACCESS Mem
;
257 EFI_PCI_IO_PROTOCOL_ACCESS Io
;
258 EFI_PCI_IO_PROTOCOL_CONFIG_ACCESS Pci
;
259 EFI_PCI_IO_PROTOCOL_COPY_MEM CopyMem
;
260 EFI_PCI_IO_PROTOCOL_MAP Map
;
261 EFI_PCI_IO_PROTOCOL_UNMAP Unmap
;
262 EFI_PCI_IO_PROTOCOL_ALLOCATE_BUFFER AllocateBuffer
;
263 EFI_PCI_IO_PROTOCOL_FREE_BUFFER FreeBuffer
;
264 EFI_PCI_IO_PROTOCOL_FLUSH Flush
;
265 EFI_PCI_IO_PROTOCOL_GET_LOCATION GetLocation
;
266 EFI_PCI_IO_PROTOCOL_ATTRIBUTES Attributes
;
267 EFI_PCI_IO_PROTOCOL_GET_BAR_ATTRIBUTES GetBarAttributes
;
268 EFI_PCI_IO_PROTOCOL_SET_BAR_ATTRIBUTES SetBarAttributes
;
273 extern EFI_GUID gEfiPciIoProtocolGuid
;