You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PciRootBridgeIo.h 18KB

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