Source code of Windows XP (NT5)
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.

931 lines
25 KiB

  1. /*++
  2. Module Name:
  3. pci.h
  4. Abstract:
  5. This is the PCI bus specific header file used by device drivers.
  6. Author:
  7. Revision History:
  8. --*/
  9. #ifndef _PCI_
  10. #define _PCI_
  11. // begin_ntddk begin_ntosp
  12. //
  13. // A PCI driver can read the complete 256 bytes of configuration
  14. // information for any PCI device by calling:
  15. //
  16. // ULONG
  17. // HalGetBusData (
  18. // IN BUS_DATA_TYPE PCIConfiguration,
  19. // IN ULONG PciBusNumber,
  20. // IN PCI_SLOT_NUMBER VirtualSlotNumber,
  21. // IN PPCI_COMMON_CONFIG &PCIDeviceConfig,
  22. // IN ULONG sizeof (PCIDeviceConfig)
  23. // );
  24. //
  25. // A return value of 0 means that the specified PCI bus does not exist.
  26. //
  27. // A return value of 2, with a VendorID of PCI_INVALID_VENDORID means
  28. // that the PCI bus does exist, but there is no device at the specified
  29. // VirtualSlotNumber (PCI Device/Function number).
  30. //
  31. //
  32. // begin_wdm begin_ntminiport begin_ntndis
  33. typedef struct _PCI_SLOT_NUMBER {
  34. union {
  35. struct {
  36. ULONG DeviceNumber:5;
  37. ULONG FunctionNumber:3;
  38. ULONG Reserved:24;
  39. } bits;
  40. ULONG AsULONG;
  41. } u;
  42. } PCI_SLOT_NUMBER, *PPCI_SLOT_NUMBER;
  43. #define PCI_TYPE0_ADDRESSES 6
  44. #define PCI_TYPE1_ADDRESSES 2
  45. #define PCI_TYPE2_ADDRESSES 5
  46. typedef struct _PCI_COMMON_CONFIG {
  47. USHORT VendorID; // (ro)
  48. USHORT DeviceID; // (ro)
  49. USHORT Command; // Device control
  50. USHORT Status;
  51. UCHAR RevisionID; // (ro)
  52. UCHAR ProgIf; // (ro)
  53. UCHAR SubClass; // (ro)
  54. UCHAR BaseClass; // (ro)
  55. UCHAR CacheLineSize; // (ro+)
  56. UCHAR LatencyTimer; // (ro+)
  57. UCHAR HeaderType; // (ro)
  58. UCHAR BIST; // Built in self test
  59. union {
  60. struct _PCI_HEADER_TYPE_0 {
  61. ULONG BaseAddresses[PCI_TYPE0_ADDRESSES];
  62. ULONG CIS;
  63. USHORT SubVendorID;
  64. USHORT SubSystemID;
  65. ULONG ROMBaseAddress;
  66. UCHAR CapabilitiesPtr;
  67. UCHAR Reserved1[3];
  68. ULONG Reserved2;
  69. UCHAR InterruptLine; //
  70. UCHAR InterruptPin; // (ro)
  71. UCHAR MinimumGrant; // (ro)
  72. UCHAR MaximumLatency; // (ro)
  73. } type0;
  74. // end_wdm end_ntminiport end_ntndis
  75. //
  76. // PCI to PCI Bridge
  77. //
  78. struct _PCI_HEADER_TYPE_1 {
  79. ULONG BaseAddresses[PCI_TYPE1_ADDRESSES];
  80. UCHAR PrimaryBus;
  81. UCHAR SecondaryBus;
  82. UCHAR SubordinateBus;
  83. UCHAR SecondaryLatency;
  84. UCHAR IOBase;
  85. UCHAR IOLimit;
  86. USHORT SecondaryStatus;
  87. USHORT MemoryBase;
  88. USHORT MemoryLimit;
  89. USHORT PrefetchBase;
  90. USHORT PrefetchLimit;
  91. ULONG PrefetchBaseUpper32;
  92. ULONG PrefetchLimitUpper32;
  93. USHORT IOBaseUpper16;
  94. USHORT IOLimitUpper16;
  95. UCHAR CapabilitiesPtr;
  96. UCHAR Reserved1[3];
  97. ULONG ROMBaseAddress;
  98. UCHAR InterruptLine;
  99. UCHAR InterruptPin;
  100. USHORT BridgeControl;
  101. } type1;
  102. //
  103. // PCI to CARDBUS Bridge
  104. //
  105. struct _PCI_HEADER_TYPE_2 {
  106. ULONG SocketRegistersBaseAddress;
  107. UCHAR CapabilitiesPtr;
  108. UCHAR Reserved;
  109. USHORT SecondaryStatus;
  110. UCHAR PrimaryBus;
  111. UCHAR SecondaryBus;
  112. UCHAR SubordinateBus;
  113. UCHAR SecondaryLatency;
  114. struct {
  115. ULONG Base;
  116. ULONG Limit;
  117. } Range[PCI_TYPE2_ADDRESSES-1];
  118. UCHAR InterruptLine;
  119. UCHAR InterruptPin;
  120. USHORT BridgeControl;
  121. } type2;
  122. // begin_wdm begin_ntminiport begin_ntndis
  123. } u;
  124. UCHAR DeviceSpecific[192];
  125. } PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG;
  126. #define PCI_COMMON_HDR_LENGTH (FIELD_OFFSET (PCI_COMMON_CONFIG, DeviceSpecific))
  127. #define PCI_MAX_DEVICES 32
  128. #define PCI_MAX_FUNCTION 8
  129. #define PCI_MAX_BRIDGE_NUMBER 0xFF
  130. #define PCI_INVALID_VENDORID 0xFFFF
  131. //
  132. // Bit encodings for PCI_COMMON_CONFIG.HeaderType
  133. //
  134. #define PCI_MULTIFUNCTION 0x80
  135. #define PCI_DEVICE_TYPE 0x00
  136. #define PCI_BRIDGE_TYPE 0x01
  137. #define PCI_CARDBUS_BRIDGE_TYPE 0x02
  138. #define PCI_CONFIGURATION_TYPE(PciData) \
  139. (((PPCI_COMMON_CONFIG)(PciData))->HeaderType & ~PCI_MULTIFUNCTION)
  140. #define PCI_MULTIFUNCTION_DEVICE(PciData) \
  141. ((((PPCI_COMMON_CONFIG)(PciData))->HeaderType & PCI_MULTIFUNCTION) != 0)
  142. //
  143. // Bit encodings for PCI_COMMON_CONFIG.Command
  144. //
  145. #define PCI_ENABLE_IO_SPACE 0x0001
  146. #define PCI_ENABLE_MEMORY_SPACE 0x0002
  147. #define PCI_ENABLE_BUS_MASTER 0x0004
  148. #define PCI_ENABLE_SPECIAL_CYCLES 0x0008
  149. #define PCI_ENABLE_WRITE_AND_INVALIDATE 0x0010
  150. #define PCI_ENABLE_VGA_COMPATIBLE_PALETTE 0x0020
  151. #define PCI_ENABLE_PARITY 0x0040 // (ro+)
  152. #define PCI_ENABLE_WAIT_CYCLE 0x0080 // (ro+)
  153. #define PCI_ENABLE_SERR 0x0100 // (ro+)
  154. #define PCI_ENABLE_FAST_BACK_TO_BACK 0x0200 // (ro)
  155. //
  156. // Bit encodings for PCI_COMMON_CONFIG.Status
  157. //
  158. #define PCI_STATUS_CAPABILITIES_LIST 0x0010 // (ro)
  159. #define PCI_STATUS_66MHZ_CAPABLE 0x0020 // (ro)
  160. #define PCI_STATUS_UDF_SUPPORTED 0x0040 // (ro)
  161. #define PCI_STATUS_FAST_BACK_TO_BACK 0x0080 // (ro)
  162. #define PCI_STATUS_DATA_PARITY_DETECTED 0x0100
  163. #define PCI_STATUS_DEVSEL 0x0600 // 2 bits wide
  164. #define PCI_STATUS_SIGNALED_TARGET_ABORT 0x0800
  165. #define PCI_STATUS_RECEIVED_TARGET_ABORT 0x1000
  166. #define PCI_STATUS_RECEIVED_MASTER_ABORT 0x2000
  167. #define PCI_STATUS_SIGNALED_SYSTEM_ERROR 0x4000
  168. #define PCI_STATUS_DETECTED_PARITY_ERROR 0x8000
  169. //
  170. // The NT PCI Driver uses a WhichSpace parameter on its CONFIG_READ/WRITE
  171. // routines. The following values are defined-
  172. //
  173. #define PCI_WHICHSPACE_CONFIG 0x0
  174. #define PCI_WHICHSPACE_ROM 0x52696350
  175. // end_wdm
  176. //
  177. // PCI Capability IDs
  178. //
  179. #define PCI_CAPABILITY_ID_POWER_MANAGEMENT 0x01
  180. #define PCI_CAPABILITY_ID_AGP 0x02
  181. #define PCI_CAPABILITY_ID_MSI 0x05
  182. //
  183. // All PCI Capability structures have the following header.
  184. //
  185. // CapabilityID is used to identify the type of the structure (is
  186. // one of the PCI_CAPABILITY_ID values above.
  187. //
  188. // Next is the offset in PCI Configuration space (0x40 - 0xfc) of the
  189. // next capability structure in the list, or 0x00 if there are no more
  190. // entries.
  191. //
  192. typedef struct _PCI_CAPABILITIES_HEADER {
  193. UCHAR CapabilityID;
  194. UCHAR Next;
  195. } PCI_CAPABILITIES_HEADER, *PPCI_CAPABILITIES_HEADER;
  196. //
  197. // Power Management Capability
  198. //
  199. typedef struct _PCI_PMC {
  200. UCHAR Version:3;
  201. UCHAR PMEClock:1;
  202. UCHAR Rsvd1:1;
  203. UCHAR DeviceSpecificInitialization:1;
  204. UCHAR Rsvd2:2;
  205. struct _PM_SUPPORT {
  206. UCHAR Rsvd2:1;
  207. UCHAR D1:1;
  208. UCHAR D2:1;
  209. UCHAR PMED0:1;
  210. UCHAR PMED1:1;
  211. UCHAR PMED2:1;
  212. UCHAR PMED3Hot:1;
  213. UCHAR PMED3Cold:1;
  214. } Support;
  215. } PCI_PMC, *PPCI_PMC;
  216. typedef struct _PCI_PMCSR {
  217. USHORT PowerState:2;
  218. USHORT Rsvd1:6;
  219. USHORT PMEEnable:1;
  220. USHORT DataSelect:4;
  221. USHORT DataScale:2;
  222. USHORT PMEStatus:1;
  223. } PCI_PMCSR, *PPCI_PMCSR;
  224. typedef struct _PCI_PMCSR_BSE {
  225. UCHAR Rsvd1:6;
  226. UCHAR D3HotSupportsStopClock:1; // B2_B3#
  227. UCHAR BusPowerClockControlEnabled:1; // BPCC_EN
  228. } PCI_PMCSR_BSE, *PPCI_PMCSR_BSE;
  229. typedef struct _PCI_PM_CAPABILITY {
  230. PCI_CAPABILITIES_HEADER Header;
  231. //
  232. // Power Management Capabilities (Offset = 2)
  233. //
  234. union {
  235. PCI_PMC Capabilities;
  236. USHORT AsUSHORT;
  237. } PMC;
  238. //
  239. // Power Management Control/Status (Offset = 4)
  240. //
  241. union {
  242. PCI_PMCSR ControlStatus;
  243. USHORT AsUSHORT;
  244. } PMCSR;
  245. //
  246. // PMCSR PCI-PCI Bridge Support Extensions
  247. //
  248. union {
  249. PCI_PMCSR_BSE BridgeSupport;
  250. UCHAR AsUCHAR;
  251. } PMCSR_BSE;
  252. //
  253. // Optional read only 8 bit Data register. Contents controlled by
  254. // DataSelect and DataScale in ControlStatus.
  255. //
  256. UCHAR Data;
  257. } PCI_PM_CAPABILITY, *PPCI_PM_CAPABILITY;
  258. //
  259. // AGP Capability
  260. //
  261. typedef struct _PCI_AGP_CAPABILITY {
  262. PCI_CAPABILITIES_HEADER Header;
  263. USHORT Minor:4;
  264. USHORT Major:4;
  265. USHORT Rsvd1:8;
  266. struct _PCI_AGP_STATUS {
  267. ULONG Rate:3;
  268. ULONG Rsvd1:1;
  269. ULONG FastWrite:1;
  270. ULONG FourGB:1;
  271. ULONG Rsvd2:3;
  272. ULONG SideBandAddressing:1; // SBA
  273. ULONG Rsvd3:14;
  274. ULONG RequestQueueDepthMaximum:8; // RQ
  275. } AGPStatus;
  276. struct _PCI_AGP_COMMAND {
  277. ULONG Rate:3;
  278. ULONG Rsvd1:1;
  279. ULONG FastWriteEnable:1;
  280. ULONG FourGBEnable:1;
  281. ULONG Rsvd2:2;
  282. ULONG AGPEnable:1;
  283. ULONG SBAEnable:1;
  284. ULONG Rsvd3:14;
  285. ULONG RequestQueueDepth:8;
  286. } AGPCommand;
  287. } PCI_AGP_CAPABILITY, *PPCI_AGP_CAPABILITY;
  288. #define PCI_AGP_RATE_1X 0x1
  289. #define PCI_AGP_RATE_2X 0x2
  290. #define PCI_AGP_RATE_4X 0x4
  291. //
  292. // MSI (Message Signalled Interrupts) Capability
  293. //
  294. typedef struct _PCI_MSI_CAPABILITY {
  295. PCI_CAPABILITIES_HEADER Header;
  296. struct _PCI_MSI_MESSAGE_CONTROL {
  297. USHORT MSIEnable:1;
  298. USHORT MultipleMessageCapable:3;
  299. USHORT MultipleMessageEnable:3;
  300. USHORT CapableOf64Bits:1;
  301. USHORT Reserved:8;
  302. } MessageControl;
  303. union {
  304. struct _PCI_MSI_MESSAGE_ADDRESS {
  305. ULONG_PTR Reserved:2; // always zero, DWORD aligned address
  306. ULONG_PTR Address:30;
  307. } Register;
  308. ULONG_PTR Raw;
  309. } MessageAddress;
  310. //
  311. // The rest of the Capability structure differs depending on whether
  312. // 32bit or 64bit addressing is being used.
  313. //
  314. // (The CapableOf64Bits bit above determines this)
  315. //
  316. union {
  317. // For 64 bit devices
  318. struct _PCI_MSI_64BIT_DATA {
  319. ULONG MessageUpperAddress;
  320. USHORT MessageData;
  321. } Bit64;
  322. // For 32 bit devices
  323. struct _PCI_MSI_32BIT_DATA {
  324. USHORT MessageData;
  325. ULONG Unused;
  326. } Bit32;
  327. } Data;
  328. } PCI_MSI_CAPABILITY, *PPCI_PCI_CAPABILITY;
  329. // begin_wdm
  330. //
  331. // Base Class Code encodings for Base Class (from PCI spec rev 2.1).
  332. //
  333. #define PCI_CLASS_PRE_20 0x00
  334. #define PCI_CLASS_MASS_STORAGE_CTLR 0x01
  335. #define PCI_CLASS_NETWORK_CTLR 0x02
  336. #define PCI_CLASS_DISPLAY_CTLR 0x03
  337. #define PCI_CLASS_MULTIMEDIA_DEV 0x04
  338. #define PCI_CLASS_MEMORY_CTLR 0x05
  339. #define PCI_CLASS_BRIDGE_DEV 0x06
  340. #define PCI_CLASS_SIMPLE_COMMS_CTLR 0x07
  341. #define PCI_CLASS_BASE_SYSTEM_DEV 0x08
  342. #define PCI_CLASS_INPUT_DEV 0x09
  343. #define PCI_CLASS_DOCKING_STATION 0x0a
  344. #define PCI_CLASS_PROCESSOR 0x0b
  345. #define PCI_CLASS_SERIAL_BUS_CTLR 0x0c
  346. #define PCI_CLASS_WIRELESS_CTLR 0x0d
  347. #define PCI_CLASS_INTELLIGENT_IO_CTLR 0x0e
  348. #define PCI_CLASS_SATELLITE_COMMS_CTLR 0x0f
  349. #define PCI_CLASS_ENCRYPTION_DECRYPTION 0x10
  350. #define PCI_CLASS_DATA_ACQ_SIGNAL_PROC 0x11
  351. // 0d thru fe reserved
  352. #define PCI_CLASS_NOT_DEFINED 0xff
  353. //
  354. // Sub Class Code encodings (PCI rev 2.1).
  355. //
  356. // Class 00 - PCI_CLASS_PRE_20
  357. #define PCI_SUBCLASS_PRE_20_NON_VGA 0x00
  358. #define PCI_SUBCLASS_PRE_20_VGA 0x01
  359. // Class 01 - PCI_CLASS_MASS_STORAGE_CTLR
  360. #define PCI_SUBCLASS_MSC_SCSI_BUS_CTLR 0x00
  361. #define PCI_SUBCLASS_MSC_IDE_CTLR 0x01
  362. #define PCI_SUBCLASS_MSC_FLOPPY_CTLR 0x02
  363. #define PCI_SUBCLASS_MSC_IPI_CTLR 0x03
  364. #define PCI_SUBCLASS_MSC_RAID_CTLR 0x04
  365. #define PCI_SUBCLASS_MSC_OTHER 0x80
  366. // Class 02 - PCI_CLASS_NETWORK_CTLR
  367. #define PCI_SUBCLASS_NET_ETHERNET_CTLR 0x00
  368. #define PCI_SUBCLASS_NET_TOKEN_RING_CTLR 0x01
  369. #define PCI_SUBCLASS_NET_FDDI_CTLR 0x02
  370. #define PCI_SUBCLASS_NET_ATM_CTLR 0x03
  371. #define PCI_SUBCLASS_NET_ISDN_CTLR 0x04
  372. #define PCI_SUBCLASS_NET_OTHER 0x80
  373. // Class 03 - PCI_CLASS_DISPLAY_CTLR
  374. // N.B. Sub Class 00 could be VGA or 8514 depending on Interface byte
  375. #define PCI_SUBCLASS_VID_VGA_CTLR 0x00
  376. #define PCI_SUBCLASS_VID_XGA_CTLR 0x01
  377. #define PCI_SUBLCASS_VID_3D_CTLR 0x02
  378. #define PCI_SUBCLASS_VID_OTHER 0x80
  379. // Class 04 - PCI_CLASS_MULTIMEDIA_DEV
  380. #define PCI_SUBCLASS_MM_VIDEO_DEV 0x00
  381. #define PCI_SUBCLASS_MM_AUDIO_DEV 0x01
  382. #define PCI_SUBCLASS_MM_TELEPHONY_DEV 0x02
  383. #define PCI_SUBCLASS_MM_OTHER 0x80
  384. // Class 05 - PCI_CLASS_MEMORY_CTLR
  385. #define PCI_SUBCLASS_MEM_RAM 0x00
  386. #define PCI_SUBCLASS_MEM_FLASH 0x01
  387. #define PCI_SUBCLASS_MEM_OTHER 0x80
  388. // Class 06 - PCI_CLASS_BRIDGE_DEV
  389. #define PCI_SUBCLASS_BR_HOST 0x00
  390. #define PCI_SUBCLASS_BR_ISA 0x01
  391. #define PCI_SUBCLASS_BR_EISA 0x02
  392. #define PCI_SUBCLASS_BR_MCA 0x03
  393. #define PCI_SUBCLASS_BR_PCI_TO_PCI 0x04
  394. #define PCI_SUBCLASS_BR_PCMCIA 0x05
  395. #define PCI_SUBCLASS_BR_NUBUS 0x06
  396. #define PCI_SUBCLASS_BR_CARDBUS 0x07
  397. #define PCI_SUBCLASS_BR_RACEWAY 0x08
  398. #define PCI_SUBCLASS_BR_OTHER 0x80
  399. // Class 07 - PCI_CLASS_SIMPLE_COMMS_CTLR
  400. // N.B. Sub Class 00 and 01 additional info in Interface byte
  401. #define PCI_SUBCLASS_COM_SERIAL 0x00
  402. #define PCI_SUBCLASS_COM_PARALLEL 0x01
  403. #define PCI_SUBCLASS_COM_MULTIPORT 0x02
  404. #define PCI_SUBCLASS_COM_MODEM 0x03
  405. #define PCI_SUBCLASS_COM_OTHER 0x80
  406. // Class 08 - PCI_CLASS_BASE_SYSTEM_DEV
  407. // N.B. See Interface byte for additional info.
  408. #define PCI_SUBCLASS_SYS_INTERRUPT_CTLR 0x00
  409. #define PCI_SUBCLASS_SYS_DMA_CTLR 0x01
  410. #define PCI_SUBCLASS_SYS_SYSTEM_TIMER 0x02
  411. #define PCI_SUBCLASS_SYS_REAL_TIME_CLOCK 0x03
  412. #define PCI_SUBCLASS_SYS_GEN_HOTPLUG_CTLR 0x04
  413. #define PCI_SUBCLASS_SYS_OTHER 0x80
  414. // Class 09 - PCI_CLASS_INPUT_DEV
  415. #define PCI_SUBCLASS_INP_KEYBOARD 0x00
  416. #define PCI_SUBCLASS_INP_DIGITIZER 0x01
  417. #define PCI_SUBCLASS_INP_MOUSE 0x02
  418. #define PCI_SUBCLASS_INP_SCANNER 0x03
  419. #define PCI_SUBCLASS_INP_GAMEPORT 0x04
  420. #define PCI_SUBCLASS_INP_OTHER 0x80
  421. // Class 0a - PCI_CLASS_DOCKING_STATION
  422. #define PCI_SUBCLASS_DOC_GENERIC 0x00
  423. #define PCI_SUBCLASS_DOC_OTHER 0x80
  424. // Class 0b - PCI_CLASS_PROCESSOR
  425. #define PCI_SUBCLASS_PROC_386 0x00
  426. #define PCI_SUBCLASS_PROC_486 0x01
  427. #define PCI_SUBCLASS_PROC_PENTIUM 0x02
  428. #define PCI_SUBCLASS_PROC_ALPHA 0x10
  429. #define PCI_SUBCLASS_PROC_POWERPC 0x20
  430. #define PCI_SUBCLASS_PROC_COPROCESSOR 0x40
  431. // Class 0c - PCI_CLASS_SERIAL_BUS_CTLR
  432. #define PCI_SUBCLASS_SB_IEEE1394 0x00
  433. #define PCI_SUBCLASS_SB_ACCESS 0x01
  434. #define PCI_SUBCLASS_SB_SSA 0x02
  435. #define PCI_SUBCLASS_SB_USB 0x03
  436. #define PCI_SUBCLASS_SB_FIBRE_CHANNEL 0x04
  437. #define PCI_SUBCLASS_SB_SMBUS 0x05
  438. // Class 0d - PCI_CLASS_WIRELESS_CTLR
  439. #define PCI_SUBCLASS_WIRELESS_IRDA 0x00
  440. #define PCI_SUBCLASS_WIRELESS_CON_IR 0x01
  441. #define PCI_SUBCLASS_WIRELESS_RF 0x10
  442. #define PCI_SUBCLASS_WIRELESS_OTHER 0x80
  443. // Class 0e - PCI_CLASS_INTELLIGENT_IO_CTLR
  444. #define PCI_SUBCLASS_INTIO_I2O 0x00
  445. // Class 0f - PCI_CLASS_SATELLITE_CTLR
  446. #define PCI_SUBCLASS_SAT_TV 0x01
  447. #define PCI_SUBCLASS_SAT_AUDIO 0x02
  448. #define PCI_SUBCLASS_SAT_VOICE 0x03
  449. #define PCI_SUBCLASS_SAT_DATA 0x04
  450. // Class 10 - PCI_CLASS_ENCRYPTION_DECRYPTION
  451. #define PCI_SUBCLASS_CRYPTO_NET_COMP 0x00
  452. #define PCI_SUBCLASS_CRYPTO_ENTERTAINMENT 0x10
  453. #define PCI_SUBCLASS_CRYPTO_OTHER 0x80
  454. // Class 11 - PCI_CLASS_DATA_ACQ_SIGNAL_PROC
  455. #define PCI_SUBCLASS_DASP_DPIO 0x00
  456. #define PCI_SUBCLASS_DASP_OTHER 0x80
  457. // end_ntndis
  458. //
  459. // Bit encodes for PCI_COMMON_CONFIG.u.type0.BaseAddresses
  460. //
  461. #define PCI_ADDRESS_IO_SPACE 0x00000001 // (ro)
  462. #define PCI_ADDRESS_MEMORY_TYPE_MASK 0x00000006 // (ro)
  463. #define PCI_ADDRESS_MEMORY_PREFETCHABLE 0x00000008 // (ro)
  464. #define PCI_ADDRESS_IO_ADDRESS_MASK 0xfffffffc
  465. #define PCI_ADDRESS_MEMORY_ADDRESS_MASK 0xfffffff0
  466. #define PCI_ADDRESS_ROM_ADDRESS_MASK 0xfffff800
  467. #define PCI_TYPE_32BIT 0
  468. #define PCI_TYPE_20BIT 2
  469. #define PCI_TYPE_64BIT 4
  470. //
  471. // Bit encodes for PCI_COMMON_CONFIG.u.type0.ROMBaseAddresses
  472. //
  473. #define PCI_ROMADDRESS_ENABLED 0x00000001
  474. //
  475. // Reference notes for PCI configuration fields:
  476. //
  477. // ro these field are read only. changes to these fields are ignored
  478. //
  479. // ro+ these field are intended to be read only and should be initialized
  480. // by the system to their proper values. However, driver may change
  481. // these settings.
  482. //
  483. // ---
  484. //
  485. // All resources comsumed by a PCI device start as unitialized
  486. // under NT. An uninitialized memory or I/O base address can be
  487. // determined by checking it's corrisponding enabled bit in the
  488. // PCI_COMMON_CONFIG.Command value. An InterruptLine is unitialized
  489. // if it contains the value of -1.
  490. //
  491. // end_wdm end_ntminiport
  492. // end_ntddk end_ntosp
  493. //
  494. // PCI_REGISTRY_INFO - this structure is passed into the HAL from
  495. // the firmware. It signifies how many PCI bus(es) are present and
  496. // what style of access the PCI bus(es) support.
  497. //
  498. typedef struct _PCI_REGISTRY_INFO {
  499. UCHAR MajorRevision;
  500. UCHAR MinorRevision;
  501. UCHAR NoBuses;
  502. UCHAR HardwareMechanism;
  503. } PCI_REGISTRY_INFO, *PPCI_REGISTRY_INFO;
  504. //
  505. // PCI definitions for IOBase & IOLimit
  506. // PCIBridgeIO2Base(a,b) - convert IOBase & IOBaseUpper16 to ULONG IOBase
  507. // PCIBridgeIO2Limit(a,b) - convert IOLimit & IOLimitUpper6 to ULONG IOLimit
  508. //
  509. #define PciBridgeIO2Base(a,b) \
  510. ( ((a >> 4) << 12) + (((a & 0xf) == 1) ? (b << 16) : 0) )
  511. #define PciBridgeIO2Limit(a,b) (PciBridgeIO2Base(a,b) | 0xfff)
  512. #define PciBridgeMemory2Base(a) (ULONG) ((a & 0xfff0) << 16)
  513. #define PciBridgeMemory2Limit(a) (PciBridgeMemory2Base(a) | 0xfffff)
  514. //
  515. // Bit encodes for PCI_COMMON_CONFIG.u.type1/2.BridgeControl
  516. //
  517. #define PCI_ENABLE_BRIDGE_PARITY_ERROR 0x0001
  518. #define PCI_ENABLE_BRIDGE_SERR 0x0002
  519. #define PCI_ENABLE_BRIDGE_ISA 0x0004
  520. #define PCI_ENABLE_BRIDGE_VGA 0x0008
  521. #define PCI_ENABLE_BRIDGE_MASTER_ABORT_SERR 0x0020
  522. #define PCI_ASSERT_BRIDGE_RESET 0x0040
  523. //
  524. // Bit encodes for PCI_COMMON_CONFIG.u.type1.BridgeControl
  525. //
  526. #define PCI_ENABLE_BRIDGE_FAST_BACK_TO_BACK 0x0080
  527. //
  528. // Bit encodes for PCI_COMMON_CONFIG.u.type2.BridgeControl
  529. //
  530. #define PCI_ENABLE_CARDBUS_IRQ_ROUTING 0x0080
  531. #define PCI_ENABLE_CARDBUS_MEM0_PREFETCH 0x0100
  532. #define PCI_ENABLE_CARDBUS_MEM1_PREFETCH 0x0200
  533. #define PCI_ENABLE_CARDBUS_WRITE_POSTING 0x0400
  534. //
  535. // Definitions needed for Access to Hardware Type 1
  536. //
  537. #define PCI_TYPE1_ADDR_PORT ((PULONG) 0xCF8)
  538. #define PCI_TYPE1_DATA_PORT 0xCFC
  539. typedef struct _PCI_TYPE1_CFG_BITS {
  540. union {
  541. struct {
  542. ULONG Reserved1:2;
  543. ULONG RegisterNumber:6;
  544. ULONG FunctionNumber:3;
  545. ULONG DeviceNumber:5;
  546. ULONG BusNumber:8;
  547. ULONG Reserved2:7;
  548. ULONG Enable:1;
  549. } bits;
  550. ULONG AsULONG;
  551. } u;
  552. } PCI_TYPE1_CFG_BITS, *PPCI_TYPE1_CFG_BITS;
  553. //
  554. // Definitions needed for Access to Hardware Type 2
  555. //
  556. #define PCI_TYPE2_CSE_PORT ((PUCHAR) 0xCF8)
  557. #define PCI_TYPE2_FORWARD_PORT ((PUCHAR) 0xCFA)
  558. #define PCI_TYPE2_ADDRESS_BASE 0xC
  559. typedef struct _PCI_TYPE2_CSE_BITS {
  560. union {
  561. struct {
  562. UCHAR Enable:1;
  563. UCHAR FunctionNumber:3;
  564. UCHAR Key:4;
  565. } bits;
  566. UCHAR AsUCHAR;
  567. } u;
  568. } PCI_TYPE2_CSE_BITS, PPCI_TYPE2_CSE_BITS;
  569. typedef struct _PCI_TYPE2_ADDRESS_BITS {
  570. union {
  571. struct {
  572. USHORT RegisterNumber:8;
  573. USHORT Agent:4;
  574. USHORT AddressBase:4;
  575. } bits;
  576. USHORT AsUSHORT;
  577. } u;
  578. } PCI_TYPE2_ADDRESS_BITS, *PPCI_TYPE2_ADDRESS_BITS;
  579. //
  580. // Definitions for the config cycle format on the PCI bus.
  581. //
  582. typedef struct _PCI_TYPE0_CFG_CYCLE_BITS {
  583. union {
  584. struct {
  585. ULONG Reserved1:2;
  586. ULONG RegisterNumber:6;
  587. ULONG FunctionNumber:3;
  588. ULONG Reserved2:21;
  589. } bits;
  590. ULONG AsULONG;
  591. } u;
  592. } PCI_TYPE0_CFG_CYCLE_BITS, *PPCI_TYPE0_CFG_CYCLE_BITS;
  593. typedef struct _PCI_TYPE1_CFG_CYCLE_BITS {
  594. union {
  595. struct {
  596. ULONG Reserved1:2;
  597. ULONG RegisterNumber:6;
  598. ULONG FunctionNumber:3;
  599. ULONG DeviceNumber:5;
  600. ULONG BusNumber:8;
  601. ULONG Reserved2:8;
  602. } bits;
  603. ULONG AsULONG;
  604. } u;
  605. } PCI_TYPE1_CFG_CYCLE_BITS, *PPCI_TYPE1_CFG_CYCLE_BITS;
  606. // begin_ntddk begin_ntosp
  607. //
  608. // Portable portion of HAL & HAL bus extender definitions for BUSHANDLER
  609. // BusData for installed PCI buses.
  610. //
  611. typedef VOID
  612. (*PciPin2Line) (
  613. IN struct _BUS_HANDLER *BusHandler,
  614. IN struct _BUS_HANDLER *RootHandler,
  615. IN PCI_SLOT_NUMBER SlotNumber,
  616. IN PPCI_COMMON_CONFIG PciData
  617. );
  618. typedef VOID
  619. (*PciLine2Pin) (
  620. IN struct _BUS_HANDLER *BusHandler,
  621. IN struct _BUS_HANDLER *RootHandler,
  622. IN PCI_SLOT_NUMBER SlotNumber,
  623. IN PPCI_COMMON_CONFIG PciNewData,
  624. IN PPCI_COMMON_CONFIG PciOldData
  625. );
  626. typedef VOID
  627. (*PciReadWriteConfig) (
  628. IN struct _BUS_HANDLER *BusHandler,
  629. IN PCI_SLOT_NUMBER Slot,
  630. IN PVOID Buffer,
  631. IN ULONG Offset,
  632. IN ULONG Length
  633. );
  634. #define PCI_DATA_TAG ' ICP'
  635. #define PCI_DATA_VERSION 1
  636. typedef struct _PCIBUSDATA {
  637. ULONG Tag;
  638. ULONG Version;
  639. PciReadWriteConfig ReadConfig;
  640. PciReadWriteConfig WriteConfig;
  641. PciPin2Line Pin2Line;
  642. PciLine2Pin Line2Pin;
  643. PCI_SLOT_NUMBER ParentSlot;
  644. PVOID Reserved[4];
  645. } PCIBUSDATA, *PPCIBUSDATA;
  646. typedef ULONG (*PCI_READ_WRITE_CONFIG)(
  647. IN PVOID Context,
  648. IN UCHAR BusOffset,
  649. IN ULONG Slot,
  650. IN PVOID Buffer,
  651. IN ULONG Offset,
  652. IN ULONG Length
  653. );
  654. typedef VOID (*PCI_PIN_TO_LINE)(
  655. IN PVOID Context,
  656. IN PPCI_COMMON_CONFIG PciData
  657. );
  658. typedef VOID (*PCI_LINE_TO_PIN)(
  659. IN PVOID Context,
  660. IN PPCI_COMMON_CONFIG PciNewData,
  661. IN PPCI_COMMON_CONFIG PciOldData
  662. );
  663. typedef struct _PCI_BUS_INTERFACE_STANDARD {
  664. //
  665. // generic interface header
  666. //
  667. USHORT Size;
  668. USHORT Version;
  669. PVOID Context;
  670. PINTERFACE_REFERENCE InterfaceReference;
  671. PINTERFACE_DEREFERENCE InterfaceDereference;
  672. //
  673. // standard PCI bus interfaces
  674. //
  675. PCI_READ_WRITE_CONFIG ReadConfig;
  676. PCI_READ_WRITE_CONFIG WriteConfig;
  677. PCI_PIN_TO_LINE PinToLine;
  678. PCI_LINE_TO_PIN LineToPin;
  679. } PCI_BUS_INTERFACE_STANDARD, *PPCI_BUS_INTERFACE_STANDARD;
  680. #define PCI_BUS_INTERFACE_STANDARD_VERSION 1
  681. // begin_wdm
  682. #define PCI_DEVICE_PRESENT_INTERFACE_VERSION 1
  683. //
  684. // Flags for PCI_DEVICE_PRESENCE_PARAMETERS
  685. //
  686. #define PCI_USE_SUBSYSTEM_IDS 0x00000001
  687. #define PCI_USE_REVISION 0x00000002
  688. // The following flags are only valid for IsDevicePresentEx
  689. #define PCI_USE_VENDEV_IDS 0x00000004
  690. #define PCI_USE_CLASS_SUBCLASS 0x00000008
  691. #define PCI_USE_PROGIF 0x00000010
  692. #define PCI_USE_LOCAL_BUS 0x00000020
  693. #define PCI_USE_LOCAL_DEVICE 0x00000040
  694. //
  695. // Search parameters structure for IsDevicePresentEx
  696. //
  697. typedef struct _PCI_DEVICE_PRESENCE_PARAMETERS {
  698. ULONG Size;
  699. ULONG Flags;
  700. USHORT VendorID;
  701. USHORT DeviceID;
  702. UCHAR RevisionID;
  703. USHORT SubVendorID;
  704. USHORT SubSystemID;
  705. UCHAR BaseClass;
  706. UCHAR SubClass;
  707. UCHAR ProgIf;
  708. } PCI_DEVICE_PRESENCE_PARAMETERS, *PPCI_DEVICE_PRESENCE_PARAMETERS;
  709. typedef
  710. BOOLEAN
  711. (*PPCI_IS_DEVICE_PRESENT) (
  712. IN USHORT VendorID,
  713. IN USHORT DeviceID,
  714. IN UCHAR RevisionID,
  715. IN USHORT SubVendorID,
  716. IN USHORT SubSystemID,
  717. IN ULONG Flags
  718. );
  719. typedef
  720. BOOLEAN
  721. (*PPCI_IS_DEVICE_PRESENT_EX) (
  722. IN PVOID Context,
  723. IN PPCI_DEVICE_PRESENCE_PARAMETERS Parameters
  724. );
  725. typedef struct _PCI_DEVICE_PRESENT_INTERFACE {
  726. //
  727. // generic interface header
  728. //
  729. USHORT Size;
  730. USHORT Version;
  731. PVOID Context;
  732. PINTERFACE_REFERENCE InterfaceReference;
  733. PINTERFACE_DEREFERENCE InterfaceDereference;
  734. //
  735. // pci device info
  736. //
  737. PPCI_IS_DEVICE_PRESENT IsDevicePresent;
  738. PPCI_IS_DEVICE_PRESENT_EX IsDevicePresentEx;
  739. } PCI_DEVICE_PRESENT_INTERFACE, *PPCI_DEVICE_PRESENT_INTERFACE;
  740. // end_wdm end_ntddk end_ntosp
  741. #endif