VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/MdePkg/Include/Protocol/PciRootBridgeIo.h

最後變更 在這個檔案是 99404,由 vboxsync 提交於 2 年 前

Devices/EFI/FirmwareNew: Update to edk2-stable202302 and make it build, bugref:4643

  • 屬性 svn:eol-style 設為 native
檔案大小: 18.7 KB
 
1/** @file
2 PCI Root Bridge I/O protocol as defined in the UEFI 2.0 specification.
3
4 PCI Root Bridge I/O protocol is used by PCI Bus Driver to perform PCI Memory, PCI I/O,
5 and PCI Configuration cycles on a PCI Root Bridge. It also provides services to perform
6 defferent types of bus mastering DMA.
7
8 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
9 SPDX-License-Identifier: BSD-2-Clause-Patent
10
11**/
12
13#ifndef __PCI_ROOT_BRIDGE_IO_H__
14#define __PCI_ROOT_BRIDGE_IO_H__
15
16#include <Library/BaseLib.h>
17
18#define EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GUID \
19 { \
20 0x2f707ebb, 0x4a1a, 0x11d4, {0x9a, 0x38, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
21 }
22
23typedef struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL;
24
25///
26/// *******************************************************
27/// EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH
28/// *******************************************************
29///
30typedef enum {
31 EfiPciWidthUint8,
32 EfiPciWidthUint16,
33 EfiPciWidthUint32,
34 EfiPciWidthUint64,
35 EfiPciWidthFifoUint8,
36 EfiPciWidthFifoUint16,
37 EfiPciWidthFifoUint32,
38 EfiPciWidthFifoUint64,
39 EfiPciWidthFillUint8,
40 EfiPciWidthFillUint16,
41 EfiPciWidthFillUint32,
42 EfiPciWidthFillUint64,
43 EfiPciWidthMaximum
44} EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH;
45
46///
47/// *******************************************************
48/// EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION
49/// *******************************************************
50///
51typedef enum {
52 ///
53 /// A read operation from system memory by a bus master that is not capable of producing
54 /// PCI dual address cycles.
55 ///
56 EfiPciOperationBusMasterRead,
57 ///
58 /// A write operation from system memory by a bus master that is not capable of producing
59 /// PCI dual address cycles.
60 ///
61 EfiPciOperationBusMasterWrite,
62 ///
63 /// Provides both read and write access to system memory by both the processor and a bus
64 /// master that is not capable of producing PCI dual address cycles.
65 ///
66 EfiPciOperationBusMasterCommonBuffer,
67 ///
68 /// A read operation from system memory by a bus master that is capable of producing PCI
69 /// dual address cycles.
70 ///
71 EfiPciOperationBusMasterRead64,
72 ///
73 /// A write operation to system memory by a bus master that is capable of producing PCI
74 /// dual address cycles.
75 ///
76 EfiPciOperationBusMasterWrite64,
77 ///
78 /// Provides both read and write access to system memory by both the processor and a bus
79 /// master that is capable of producing PCI dual address cycles.
80 ///
81 EfiPciOperationBusMasterCommonBuffer64,
82 EfiPciOperationMaximum
83} EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION;
84
85#define EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO 0x0001
86#define EFI_PCI_ATTRIBUTE_ISA_IO 0x0002
87#define EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO 0x0004
88#define EFI_PCI_ATTRIBUTE_VGA_MEMORY 0x0008
89#define EFI_PCI_ATTRIBUTE_VGA_IO 0x0010
90#define EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO 0x0020
91#define EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO 0x0040
92#define EFI_PCI_ATTRIBUTE_MEMORY_WRITE_COMBINE 0x0080
93#define EFI_PCI_ATTRIBUTE_MEMORY_CACHED 0x0800
94#define EFI_PCI_ATTRIBUTE_MEMORY_DISABLE 0x1000
95#define EFI_PCI_ATTRIBUTE_DUAL_ADDRESS_CYCLE 0x8000
96#define EFI_PCI_ATTRIBUTE_ISA_IO_16 0x10000
97#define EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16 0x20000
98#define EFI_PCI_ATTRIBUTE_VGA_IO_16 0x40000
99
100#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)
101
102#define EFI_PCI_ATTRIBUTE_INVALID_FOR_ALLOCATE_BUFFER (~EFI_PCI_ATTRIBUTE_VALID_FOR_ALLOCATE_BUFFER)
103
104#if defined(__GNUC__) && defined(VBOX) /* VBox: work around: warning: comparison is always false due to limited range of data type */
105#define EFI_PCI_ADDRESS(bus, dev, func, reg) \
106 (UINT64) ( \
107 (((UINTN) bus) << 24) | \
108 (((UINTN) dev) << 16) | \
109 (((UINTN) func) << 8) | \
110 ((512U + (UINTN) (reg)) < (256U + 512U) ? ((UINTN) (reg)) : (UINT64) (LShiftU64 ((UINT64) (reg), 32))))
111#else
112#define EFI_PCI_ADDRESS(bus, dev, func, reg) \
113 (UINT64) ( \
114 (((UINTN) bus) << 24) | \
115 (((UINTN) dev) << 16) | \
116 (((UINTN) func) << 8) | \
117 (((UINTN) (reg)) < 256 ? ((UINTN) (reg)) : (UINT64) (LShiftU64 ((UINT64) (reg), 32))))
118#endif
119
120typedef struct {
121 UINT8 Register;
122 UINT8 Function;
123 UINT8 Device;
124 UINT8 Bus;
125 UINT32 ExtendedRegister;
126} EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS;
127
128/**
129 Reads from the I/O space of a PCI Root Bridge. Returns when either the polling exit criteria is
130 satisfied or after a defined duration.
131
132 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
133 @param Width Signifies the width of the memory or I/O operations.
134 @param Address The base address of the memory or I/O operations.
135 @param Mask Mask used for the polling criteria.
136 @param Value The comparison value used for the polling exit criteria.
137 @param Delay The number of 100 ns units to poll.
138 @param Result Pointer to the last value read from the memory location.
139
140 @retval EFI_SUCCESS The last data returned from the access matched the poll exit criteria.
141 @retval EFI_TIMEOUT Delay expired before a match occurred.
142 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
143 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
144
145**/
146typedef
147EFI_STATUS
148(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_POLL_IO_MEM)(
149 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
150 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
151 IN UINT64 Address,
152 IN UINT64 Mask,
153 IN UINT64 Value,
154 IN UINT64 Delay,
155 OUT UINT64 *Result
156 );
157
158/**
159 Enables a PCI driver to access PCI controller registers in the PCI root bridge memory space.
160
161 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
162 @param Width Signifies the width of the memory operations.
163 @param Address The base address of the memory operations.
164 @param Count The number of memory operations to perform.
165 @param Buffer For read operations, the destination buffer to store the results. For write
166 operations, the source buffer to write data from.
167
168 @retval EFI_SUCCESS The data was read from or written to the PCI root bridge.
169 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
170 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
171
172**/
173typedef
174EFI_STATUS
175(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_IO_MEM)(
176 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
177 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
178 IN UINT64 Address,
179 IN UINTN Count,
180 IN OUT VOID *Buffer
181 );
182
183typedef struct {
184 ///
185 /// Read PCI controller registers in the PCI root bridge memory space.
186 ///
187 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_IO_MEM Read;
188 ///
189 /// Write PCI controller registers in the PCI root bridge memory space.
190 ///
191 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_IO_MEM Write;
192} EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS;
193
194/**
195 Enables a PCI driver to copy one region of PCI root bridge memory space to another region of PCI
196 root bridge memory space.
197
198 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL instance.
199 @param Width Signifies the width of the memory operations.
200 @param DestAddress The destination address of the memory operation.
201 @param SrcAddress The source address of the memory operation.
202 @param Count The number of memory operations to perform.
203
204 @retval EFI_SUCCESS The data was copied from one memory region to another memory region.
205 @retval EFI_INVALID_PARAMETER Width is invalid for this PCI root bridge.
206 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
207
208**/
209typedef
210EFI_STATUS
211(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_COPY_MEM)(
212 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
213 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
214 IN UINT64 DestAddress,
215 IN UINT64 SrcAddress,
216 IN UINTN Count
217 );
218
219/**
220 Provides the PCI controller-specific addresses required to access system memory from a
221 DMA bus master.
222
223 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
224 @param Operation Indicates if the bus master is going to read or write to system memory.
225 @param HostAddress The system memory address to map to the PCI controller.
226 @param NumberOfBytes On input the number of bytes to map. On output the number of bytes
227 that were mapped.
228 @param DeviceAddress The resulting map address for the bus master PCI controller to use to
229 access the hosts HostAddress.
230 @param Mapping A resulting value to pass to Unmap().
231
232 @retval EFI_SUCCESS The range was mapped for the returned NumberOfBytes.
233 @retval EFI_UNSUPPORTED The HostAddress cannot be mapped as a common buffer.
234 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
235 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
236 @retval EFI_DEVICE_ERROR The system hardware could not map the requested address.
237
238**/
239typedef
240EFI_STATUS
241(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_MAP)(
242 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
243 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION Operation,
244 IN VOID *HostAddress,
245 IN OUT UINTN *NumberOfBytes,
246 OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
247 OUT VOID **Mapping
248 );
249
250/**
251 Completes the Map() operation and releases any corresponding resources.
252
253 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
254 @param Mapping The mapping value returned from Map().
255
256 @retval EFI_SUCCESS The range was unmapped.
257 @retval EFI_INVALID_PARAMETER Mapping is not a value that was returned by Map().
258 @retval EFI_DEVICE_ERROR The data was not committed to the target system memory.
259
260**/
261typedef
262EFI_STATUS
263(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_UNMAP)(
264 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
265 IN VOID *Mapping
266 );
267
268/**
269 Allocates pages that are suitable for an EfiPciOperationBusMasterCommonBuffer or
270 EfiPciOperationBusMasterCommonBuffer64 mapping.
271
272 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
273 @param Type This parameter is not used and must be ignored.
274 @param MemoryType The type of memory to allocate, EfiBootServicesData or
275 EfiRuntimeServicesData.
276 @param Pages The number of pages to allocate.
277 @param HostAddress A pointer to store the base system memory address of the
278 allocated range.
279 @param Attributes The requested bit mask of attributes for the allocated range.
280
281 @retval EFI_SUCCESS The requested memory pages were allocated.
282 @retval EFI_UNSUPPORTED Attributes is unsupported. The only legal attribute bits are
283 MEMORY_WRITE_COMBINE and MEMORY_CACHED.
284 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
285 @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.
286
287**/
288typedef
289EFI_STATUS
290(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ALLOCATE_BUFFER)(
291 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
292 IN EFI_ALLOCATE_TYPE Type,
293 IN EFI_MEMORY_TYPE MemoryType,
294 IN UINTN Pages,
295 IN OUT VOID **HostAddress,
296 IN UINT64 Attributes
297 );
298
299/**
300 Frees memory that was allocated with AllocateBuffer().
301
302 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
303 @param Pages The number of pages to free.
304 @param HostAddress The base system memory address of the allocated range.
305
306 @retval EFI_SUCCESS The requested memory pages were freed.
307 @retval EFI_INVALID_PARAMETER The memory range specified by HostAddress and Pages
308 was not allocated with AllocateBuffer().
309
310**/
311typedef
312EFI_STATUS
313(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FREE_BUFFER)(
314 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
315 IN UINTN Pages,
316 IN VOID *HostAddress
317 );
318
319/**
320 Flushes all PCI posted write transactions from a PCI host bridge to system memory.
321
322 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
323
324 @retval EFI_SUCCESS The PCI posted write transactions were flushed from the PCI host
325 bridge to system memory.
326 @retval EFI_DEVICE_ERROR The PCI posted write transactions were not flushed from the PCI
327 host bridge due to a hardware error.
328
329**/
330typedef
331EFI_STATUS
332(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FLUSH)(
333 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This
334 );
335
336/**
337 Gets the attributes that a PCI root bridge supports setting with SetAttributes(), and the
338 attributes that a PCI root bridge is currently using.
339
340 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
341 @param Supports A pointer to the mask of attributes that this PCI root bridge supports
342 setting with SetAttributes().
343 @param Attributes A pointer to the mask of attributes that this PCI root bridge is currently
344 using.
345
346 @retval EFI_SUCCESS If Supports is not NULL, then the attributes that the PCI root
347 bridge supports is returned in Supports. If Attributes is
348 not NULL, then the attributes that the PCI root bridge is currently
349 using is returned in Attributes.
350 @retval EFI_INVALID_PARAMETER Both Supports and Attributes are NULL.
351
352
353**/
354typedef
355EFI_STATUS
356(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GET_ATTRIBUTES)(
357 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
358 OUT UINT64 *Supports,
359 OUT UINT64 *Attributes
360 );
361
362/**
363 Sets attributes for a resource range on a PCI root bridge.
364
365 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
366 @param Attributes The mask of attributes to set.
367 @param ResourceBase A pointer to the base address of the resource range to be modified by the
368 attributes specified by Attributes.
369 @param ResourceLength A pointer to the length of the resource range to be modified by the
370 attributes specified by Attributes.
371
372 @retval EFI_SUCCESS The set of attributes specified by Attributes for the resource
373 range specified by ResourceBase and ResourceLength
374 were set on the PCI root bridge, and the actual resource range is
375 returned in ResuourceBase and ResourceLength.
376 @retval EFI_UNSUPPORTED A bit is set in Attributes that is not supported by the PCI Root
377 Bridge.
378 @retval EFI_OUT_OF_RESOURCES There are not enough resources to set the attributes on the
379 resource range specified by BaseAddress and Length.
380 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
381
382**/
383typedef
384EFI_STATUS
385(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_SET_ATTRIBUTES)(
386 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
387 IN UINT64 Attributes,
388 IN OUT UINT64 *ResourceBase,
389 IN OUT UINT64 *ResourceLength
390 );
391
392/**
393 Retrieves the current resource settings of this PCI root bridge in the form of a set of ACPI
394 resource descriptors.
395
396 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
397 @param Resources A pointer to the resource descriptors that describe the current
398 configuration of this PCI root bridge.
399
400 @retval EFI_SUCCESS The current configuration of this PCI root bridge was returned in
401 Resources.
402 @retval EFI_UNSUPPORTED The current configuration of this PCI root bridge could not be
403 retrieved.
404
405**/
406typedef
407EFI_STATUS
408(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_CONFIGURATION)(
409 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
410 OUT VOID **Resources
411 );
412
413///
414/// Provides the basic Memory, I/O, PCI configuration, and DMA interfaces that are
415/// used to abstract accesses to PCI controllers behind a PCI Root Bridge Controller.
416///
417struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL {
418 ///
419 /// The EFI_HANDLE of the PCI Host Bridge of which this PCI Root Bridge is a member.
420 ///
421 EFI_HANDLE ParentHandle;
422 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_POLL_IO_MEM PollMem;
423 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_POLL_IO_MEM PollIo;
424 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS Mem;
425 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS Io;
426 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS Pci;
427 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_COPY_MEM CopyMem;
428 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_MAP Map;
429 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_UNMAP Unmap;
430 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ALLOCATE_BUFFER AllocateBuffer;
431 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FREE_BUFFER FreeBuffer;
432 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FLUSH Flush;
433 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GET_ATTRIBUTES GetAttributes;
434 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_SET_ATTRIBUTES SetAttributes;
435 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_CONFIGURATION Configuration;
436
437 ///
438 /// The segment number that this PCI root bridge resides.
439 ///
440 UINT32 SegmentNumber;
441};
442
443extern EFI_GUID gEfiPciRootBridgeIoProtocolGuid;
444
445#endif
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette