efipciio.h 14 KB

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