Leaked source code of windows server 2003
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.

1148 lines
32 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. typedef struct _PCI_SLOT_NUMBER {
  12. union {
  13. struct {
  14. ULONG DeviceNumber:5;
  15. ULONG FunctionNumber:3;
  16. ULONG Reserved:24;
  17. } bits;
  18. ULONG AsULONG;
  19. } u;
  20. } PCI_SLOT_NUMBER, *PPCI_SLOT_NUMBER;
  21. #define PCI_TYPE0_ADDRESSES 6
  22. #define PCI_TYPE1_ADDRESSES 2
  23. #define PCI_TYPE2_ADDRESSES 5
  24. typedef struct _PCI_COMMON_CONFIG {
  25. USHORT VendorID; // (ro)
  26. USHORT DeviceID; // (ro)
  27. USHORT Command; // Device control
  28. USHORT Status;
  29. UCHAR RevisionID; // (ro)
  30. UCHAR ProgIf; // (ro)
  31. UCHAR SubClass; // (ro)
  32. UCHAR BaseClass; // (ro)
  33. UCHAR CacheLineSize; // (ro+)
  34. UCHAR LatencyTimer; // (ro+)
  35. UCHAR HeaderType; // (ro)
  36. UCHAR BIST; // Built in self test
  37. union {
  38. struct _PCI_HEADER_TYPE_0 {
  39. ULONG BaseAddresses[PCI_TYPE0_ADDRESSES];
  40. ULONG CIS;
  41. USHORT SubVendorID;
  42. USHORT SubSystemID;
  43. ULONG ROMBaseAddress;
  44. UCHAR CapabilitiesPtr;
  45. UCHAR Reserved1[3];
  46. ULONG Reserved2;
  47. UCHAR InterruptLine; //
  48. UCHAR InterruptPin; // (ro)
  49. UCHAR MinimumGrant; // (ro)
  50. UCHAR MaximumLatency; // (ro)
  51. } type0;
  52. // end_wdm end_ntminiport end_ntndis
  53. //
  54. // PCI to PCI Bridge
  55. //
  56. struct _PCI_HEADER_TYPE_1 {
  57. ULONG BaseAddresses[PCI_TYPE1_ADDRESSES];
  58. UCHAR PrimaryBus;
  59. UCHAR SecondaryBus;
  60. UCHAR SubordinateBus;
  61. UCHAR SecondaryLatency;
  62. UCHAR IOBase;
  63. UCHAR IOLimit;
  64. USHORT SecondaryStatus;
  65. USHORT MemoryBase;
  66. USHORT MemoryLimit;
  67. USHORT PrefetchBase;
  68. USHORT PrefetchLimit;
  69. ULONG PrefetchBaseUpper32;
  70. ULONG PrefetchLimitUpper32;
  71. USHORT IOBaseUpper16;
  72. USHORT IOLimitUpper16;
  73. UCHAR CapabilitiesPtr;
  74. UCHAR Reserved1[3];
  75. ULONG ROMBaseAddress;
  76. UCHAR InterruptLine;
  77. UCHAR InterruptPin;
  78. USHORT BridgeControl;
  79. } type1;
  80. //
  81. // PCI to CARDBUS Bridge
  82. //
  83. struct _PCI_HEADER_TYPE_2 {
  84. ULONG SocketRegistersBaseAddress;
  85. UCHAR CapabilitiesPtr;
  86. UCHAR Reserved;
  87. USHORT SecondaryStatus;
  88. UCHAR PrimaryBus;
  89. UCHAR SecondaryBus;
  90. UCHAR SubordinateBus;
  91. UCHAR SecondaryLatency;
  92. struct {
  93. ULONG Base;
  94. ULONG Limit;
  95. } Range[PCI_TYPE2_ADDRESSES-1];
  96. UCHAR InterruptLine;
  97. UCHAR InterruptPin;
  98. USHORT BridgeControl;
  99. } type2;
  100. // begin_wdm begin_ntminiport begin_ntndis
  101. } u;
  102. UCHAR DeviceSpecific[192];
  103. } PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG;
  104. #define PCI_COMMON_HDR_LENGTH (FIELD_OFFSET (PCI_COMMON_CONFIG, DeviceSpecific))
  105. #define PCI_MAX_DEVICES 32
  106. #define PCI_MAX_FUNCTION 8
  107. #define PCI_MAX_BRIDGE_NUMBER 0xFF
  108. #define PCI_INVALID_VENDORID 0xFFFF
  109. //
  110. // Bit encodings for PCI_COMMON_CONFIG.HeaderType
  111. //
  112. #define PCI_MULTIFUNCTION 0x80
  113. #define PCI_DEVICE_TYPE 0x00
  114. #define PCI_BRIDGE_TYPE 0x01
  115. #define PCI_CARDBUS_BRIDGE_TYPE 0x02
  116. #define PCI_CONFIGURATION_TYPE(PciData) \
  117. (((PPCI_COMMON_CONFIG)(PciData))->HeaderType & ~PCI_MULTIFUNCTION)
  118. #define PCI_MULTIFUNCTION_DEVICE(PciData) \
  119. ((((PPCI_COMMON_CONFIG)(PciData))->HeaderType & PCI_MULTIFUNCTION) != 0)
  120. //
  121. // Bit encodings for PCI_COMMON_CONFIG.Command
  122. //
  123. #define PCI_ENABLE_IO_SPACE 0x0001
  124. #define PCI_ENABLE_MEMORY_SPACE 0x0002
  125. #define PCI_ENABLE_BUS_MASTER 0x0004
  126. #define PCI_ENABLE_SPECIAL_CYCLES 0x0008
  127. #define PCI_ENABLE_WRITE_AND_INVALIDATE 0x0010
  128. #define PCI_ENABLE_VGA_COMPATIBLE_PALETTE 0x0020
  129. #define PCI_ENABLE_PARITY 0x0040 // (ro+)
  130. #define PCI_ENABLE_WAIT_CYCLE 0x0080 // (ro+)
  131. #define PCI_ENABLE_SERR 0x0100 // (ro+)
  132. #define PCI_ENABLE_FAST_BACK_TO_BACK 0x0200 // (ro)
  133. //
  134. // Bit encodings for PCI_COMMON_CONFIG.Status
  135. //
  136. #define PCI_STATUS_CAPABILITIES_LIST 0x0010 // (ro)
  137. #define PCI_STATUS_66MHZ_CAPABLE 0x0020 // (ro)
  138. #define PCI_STATUS_UDF_SUPPORTED 0x0040 // (ro)
  139. #define PCI_STATUS_FAST_BACK_TO_BACK 0x0080 // (ro)
  140. #define PCI_STATUS_DATA_PARITY_DETECTED 0x0100
  141. #define PCI_STATUS_DEVSEL 0x0600 // 2 bits wide
  142. #define PCI_STATUS_SIGNALED_TARGET_ABORT 0x0800
  143. #define PCI_STATUS_RECEIVED_TARGET_ABORT 0x1000
  144. #define PCI_STATUS_RECEIVED_MASTER_ABORT 0x2000
  145. #define PCI_STATUS_SIGNALED_SYSTEM_ERROR 0x4000
  146. #define PCI_STATUS_DETECTED_PARITY_ERROR 0x8000
  147. //
  148. // The NT PCI Driver uses a WhichSpace parameter on its CONFIG_READ/WRITE
  149. // routines. The following values are defined-
  150. //
  151. #define PCI_WHICHSPACE_CONFIG 0x0
  152. #define PCI_WHICHSPACE_ROM 0x52696350
  153. // end_wdm
  154. //
  155. // PCI Capability IDs
  156. //
  157. #define PCI_CAPABILITY_ID_POWER_MANAGEMENT 0x01
  158. #define PCI_CAPABILITY_ID_AGP 0x02
  159. #define PCI_CAPABILITY_ID_VPD 0x03
  160. #define PCI_CAPABILITY_ID_SLOT_ID 0x04
  161. #define PCI_CAPABILITY_ID_MSI 0x05
  162. #define PCI_CAPABILITY_ID_CPCI_HOTSWAP 0x06
  163. #define PCI_CAPABILITY_ID_PCIX 0x07
  164. #define PCI_CAPABILITY_ID_HYPERTRANSPORT 0x08
  165. #define PCI_CAPABILITY_ID_VENDOR_SPECIFIC 0x09
  166. #define PCI_CAPABILITY_ID_DEBUG_PORT 0x0A
  167. #define PCI_CAPABILITY_ID_CPCI_RES_CTRL 0x0B
  168. #define PCI_CAPABILITY_ID_SHPC 0x0C
  169. #define PCI_CAPABILITY_ID_AGP_TARGET 0x0E
  170. //
  171. // All PCI Capability structures have the following header.
  172. //
  173. // CapabilityID is used to identify the type of the structure (is
  174. // one of the PCI_CAPABILITY_ID values above.
  175. //
  176. // Next is the offset in PCI Configuration space (0x40 - 0xfc) of the
  177. // next capability structure in the list, or 0x00 if there are no more
  178. // entries.
  179. //
  180. typedef struct _PCI_CAPABILITIES_HEADER {
  181. UCHAR CapabilityID;
  182. UCHAR Next;
  183. } PCI_CAPABILITIES_HEADER, *PPCI_CAPABILITIES_HEADER;
  184. //
  185. // Power Management Capability
  186. //
  187. typedef struct _PCI_PMC {
  188. UCHAR Version:3;
  189. UCHAR PMEClock:1;
  190. UCHAR Rsvd1:1;
  191. UCHAR DeviceSpecificInitialization:1;
  192. UCHAR Rsvd2:2;
  193. struct _PM_SUPPORT {
  194. UCHAR Rsvd2:1;
  195. UCHAR D1:1;
  196. UCHAR D2:1;
  197. UCHAR PMED0:1;
  198. UCHAR PMED1:1;
  199. UCHAR PMED2:1;
  200. UCHAR PMED3Hot:1;
  201. UCHAR PMED3Cold:1;
  202. } Support;
  203. } PCI_PMC, *PPCI_PMC;
  204. typedef struct _PCI_PMCSR {
  205. USHORT PowerState:2;
  206. USHORT Rsvd1:6;
  207. USHORT PMEEnable:1;
  208. USHORT DataSelect:4;
  209. USHORT DataScale:2;
  210. USHORT PMEStatus:1;
  211. } PCI_PMCSR, *PPCI_PMCSR;
  212. typedef struct _PCI_PMCSR_BSE {
  213. UCHAR Rsvd1:6;
  214. UCHAR D3HotSupportsStopClock:1; // B2_B3#
  215. UCHAR BusPowerClockControlEnabled:1; // BPCC_EN
  216. } PCI_PMCSR_BSE, *PPCI_PMCSR_BSE;
  217. typedef struct _PCI_PM_CAPABILITY {
  218. PCI_CAPABILITIES_HEADER Header;
  219. //
  220. // Power Management Capabilities (Offset = 2)
  221. //
  222. union {
  223. PCI_PMC Capabilities;
  224. USHORT AsUSHORT;
  225. } PMC;
  226. //
  227. // Power Management Control/Status (Offset = 4)
  228. //
  229. union {
  230. PCI_PMCSR ControlStatus;
  231. USHORT AsUSHORT;
  232. } PMCSR;
  233. //
  234. // PMCSR PCI-PCI Bridge Support Extensions
  235. //
  236. union {
  237. PCI_PMCSR_BSE BridgeSupport;
  238. UCHAR AsUCHAR;
  239. } PMCSR_BSE;
  240. //
  241. // Optional read only 8 bit Data register. Contents controlled by
  242. // DataSelect and DataScale in ControlStatus.
  243. //
  244. UCHAR Data;
  245. } PCI_PM_CAPABILITY, *PPCI_PM_CAPABILITY;
  246. //
  247. // AGP Capabilities
  248. //
  249. typedef struct _PCI_AGP_CAPABILITY {
  250. PCI_CAPABILITIES_HEADER Header;
  251. USHORT Minor:4;
  252. USHORT Major:4;
  253. USHORT Rsvd1:8;
  254. struct _PCI_AGP_STATUS {
  255. ULONG Rate:3;
  256. ULONG Agp3Mode:1;
  257. ULONG FastWrite:1;
  258. ULONG FourGB:1;
  259. ULONG HostTransDisable:1;
  260. ULONG Gart64:1;
  261. ULONG ITA_Coherent:1;
  262. ULONG SideBandAddressing:1; // SBA
  263. ULONG CalibrationCycle:3;
  264. ULONG AsyncRequestSize:3;
  265. ULONG Rsvd1:1;
  266. ULONG Isoch:1;
  267. ULONG Rsvd2:6;
  268. ULONG RequestQueueDepthMaximum:8; // RQ
  269. } AGPStatus;
  270. struct _PCI_AGP_COMMAND {
  271. ULONG Rate:3;
  272. ULONG Rsvd1:1;
  273. ULONG FastWriteEnable:1;
  274. ULONG FourGBEnable:1;
  275. ULONG Rsvd2:1;
  276. ULONG Gart64:1;
  277. ULONG AGPEnable:1;
  278. ULONG SBAEnable:1;
  279. ULONG CalibrationCycle:3;
  280. ULONG AsyncReqSize:3;
  281. ULONG Rsvd3:8;
  282. ULONG RequestQueueDepth:8;
  283. } AGPCommand;
  284. } PCI_AGP_CAPABILITY, *PPCI_AGP_CAPABILITY;
  285. //
  286. // An AGPv3 Target must have an extended capability,
  287. // but it's only present for a Master when the Isoch
  288. // bit is set in its status register
  289. //
  290. typedef enum _EXTENDED_AGP_REGISTER {
  291. IsochStatus,
  292. AgpControl,
  293. ApertureSize,
  294. AperturePageSize,
  295. GartLow,
  296. GartHigh,
  297. IsochCommand
  298. } EXTENDED_AGP_REGISTER, *PEXTENDED_AGP_REGISTER;
  299. typedef struct _PCI_AGP_ISOCH_STATUS {
  300. ULONG ErrorCode: 2;
  301. ULONG Rsvd1: 1;
  302. ULONG Isoch_L: 3;
  303. ULONG Isoch_Y: 2;
  304. ULONG Isoch_N: 8;
  305. ULONG Rsvd2: 16;
  306. } PCI_AGP_ISOCH_STATUS, *PPCI_AGP_ISOCH_STATUS;
  307. typedef struct _PCI_AGP_CONTROL {
  308. ULONG Rsvd1: 7;
  309. ULONG GTLB_Enable: 1;
  310. ULONG AP_Enable: 1;
  311. ULONG CAL_Disable: 1;
  312. ULONG Rsvd2: 22;
  313. } PCI_AGP_CONTROL, *PPCI_AGP_CONTROL;
  314. typedef struct _PCI_AGP_APERTURE_PAGE_SIZE {
  315. USHORT PageSizeMask: 11;
  316. USHORT Rsvd1: 1;
  317. USHORT PageSizeSelect: 4;
  318. } PCI_AGP_APERTURE_PAGE_SIZE, *PPCI_AGP_APERTURE_PAGE_SIZE;
  319. typedef struct _PCI_AGP_ISOCH_COMMAND {
  320. USHORT Rsvd1: 6;
  321. USHORT Isoch_Y: 2;
  322. USHORT Isoch_N: 8;
  323. } PCI_AGP_ISOCH_COMMAND, *PPCI_AGP_ISOCH_COMMAND;
  324. typedef struct PCI_AGP_EXTENDED_CAPABILITY {
  325. PCI_AGP_ISOCH_STATUS IsochStatus;
  326. //
  327. // Target only ----------------<<-begin->>
  328. //
  329. PCI_AGP_CONTROL AgpControl;
  330. USHORT ApertureSize;
  331. PCI_AGP_APERTURE_PAGE_SIZE AperturePageSize;
  332. ULONG GartLow;
  333. ULONG GartHigh;
  334. //
  335. // ------------------------------<<-end->>
  336. //
  337. PCI_AGP_ISOCH_COMMAND IsochCommand;
  338. } PCI_AGP_EXTENDED_CAPABILITY, *PPCI_AGP_EXTENDED_CAPABILITY;
  339. #define PCI_AGP_RATE_1X 0x1
  340. #define PCI_AGP_RATE_2X 0x2
  341. #define PCI_AGP_RATE_4X 0x4
  342. //
  343. // MSI (Message Signalled Interrupts) Capability
  344. //
  345. typedef struct _PCI_MSI_CAPABILITY {
  346. PCI_CAPABILITIES_HEADER Header;
  347. struct _PCI_MSI_MESSAGE_CONTROL {
  348. USHORT MSIEnable:1;
  349. USHORT MultipleMessageCapable:3;
  350. USHORT MultipleMessageEnable:3;
  351. USHORT CapableOf64Bits:1;
  352. USHORT PerVectorMaskCapable:1;
  353. USHORT Reserved:7;
  354. } MessageControl;
  355. union {
  356. struct _PCI_MSI_MESSAGE_ADDRESS {
  357. ULONG Reserved:2; // always zero, DWORD aligned address
  358. ULONG Address:30;
  359. } Register;
  360. ULONG Raw;
  361. } MessageAddressLower;
  362. //
  363. // This is only valid if CapableOf64Bits is 1.
  364. //
  365. union {
  366. struct {
  367. USHORT MessageData;
  368. } Option32Bit;
  369. struct {
  370. ULONG MessageAddressUpper;
  371. USHORT MessageData;
  372. USHORT Reserved;
  373. ULONG MaskBits;
  374. ULONG PendingBits;
  375. } Option64Bit;
  376. };
  377. } PCI_MSI_CAPABILITY, *PPCI_MSI_CAPABILITY;
  378. //
  379. // MSI-X (Message Signalled Interrupts eXtended) Capability
  380. //
  381. typedef struct {
  382. PCI_CAPABILITIES_HEADER Header;
  383. struct {
  384. USHORT TableSize:11;
  385. USHORT Reserved:4;
  386. USHORT MSIXEnable:1;
  387. } MessageControl;
  388. ULONG MessageAddressUpper;
  389. struct {
  390. ULONG BaseIndexRegister:3;
  391. ULONG TableOffset:29;
  392. } BIR_Offset;
  393. } PCI_MSIX_CAPABILITY, *PPCI_MSIX_CAPABILITY;
  394. typedef struct {
  395. ULONG Pending:1;
  396. ULONG Mask:1;
  397. ULONG MessageAddressLower:30;
  398. } PCI_MSIX_TABLE_ENTRY, *PPCI_MSIX_TABLE_ENTRY;
  399. typedef struct {
  400. PCI_CAPABILITIES_HEADER Header;
  401. union {
  402. struct {
  403. USHORT DataParityErrorRecoveryEnable:1;
  404. USHORT EnableRelaxedOrdering:1;
  405. USHORT MaxMemoryReadByteCount:2;
  406. USHORT MaxOutstandingSplitTransactions:3;
  407. USHORT Reserved:9;
  408. } bits;
  409. USHORT AsUSHORT;
  410. } Command;
  411. union {
  412. struct {
  413. ULONG FunctionNumber:3;
  414. ULONG DeviceNumber:5;
  415. ULONG BusNumber:8;
  416. ULONG Device64Bit:1;
  417. ULONG Capable133MHz:1;
  418. ULONG SplitCompletionDiscarded:1;
  419. ULONG UnexpectedSplitCompletion:1;
  420. ULONG DeviceComplexity:1;
  421. ULONG DesignedMaxMemoryReadByteCount:2;
  422. ULONG DesignedMaxOutstandingSplitTransactions:3;
  423. ULONG DesignedMaxCumulativeReadSize:3;
  424. ULONG ReceivedSplitCompletionErrorMessage:1;
  425. ULONG Reserved:2;
  426. } bits;
  427. ULONG AsULONG;
  428. } Status;
  429. } PCI_X_CAPABILITY, *PPCI_X_CAPABILITY;
  430. //
  431. // AMD HyperTransport (TM) Capabilities structure
  432. //
  433. typedef enum {
  434. HTSlavePrimary = 0,
  435. HTHostSecondary,
  436. HTReserved1,
  437. HTReserved2,
  438. HTInterruptDiscoveryConfig,
  439. HTAddressMapping,
  440. HTReserved3,
  441. HTReserved4
  442. } PCI_HT_CapabilitiesType, *PPCI_HT_CapabilitiesType;
  443. typedef struct {
  444. USHORT Reserved1:1;
  445. USHORT CFlE:1;
  446. USHORT CST:1;
  447. USHORT CFE:1;
  448. USHORT LkFail:1;
  449. USHORT Init:1;
  450. USHORT EOC:1;
  451. USHORT TXO:1;
  452. USHORT CRCError:4;
  453. USHORT IsocEn:1;
  454. USHORT LSEn:1;
  455. USHORT ExtCTL:1;
  456. USHORT Reserved2:1;
  457. } PCI_HT_LinkControl, *PPCI_HT_LinkControl;
  458. typedef struct {
  459. USHORT MaxLinkWidthIn:3;
  460. USHORT DwFlowControlIn:1;
  461. USHORT MaxLinkWidthOut:3;
  462. USHORT DwFlowControlOut:1;
  463. USHORT LinkWidthIn:3;
  464. USHORT DwFlowControlInEn:1;
  465. USHORT LinkWidthOut:3;
  466. USHORT DwFlowControlOutEn:1;
  467. } PCI_HT_LinkConfig, *PPCI_HT_LinkConfig;
  468. typedef enum {
  469. HTMaxLinkWidth8bits = 0,
  470. HTMaxLinkWidth16bits,
  471. HTMaxLinkWidthResevered1,
  472. HTMaxLinkWidth32bits,
  473. HTMaxLinkWidth2bits,
  474. HTMaxLinkWidth4bits,
  475. HTMaxLinkWidthResevered2,
  476. HTMaxLinkWidthNotConnected
  477. } PCI_HT_MaxLinkWidth, *PPCI_HT_MaxLinkWidth;
  478. typedef struct {
  479. UCHAR MinorRev:4;
  480. UCHAR MajorRev:4;
  481. } PCI_HT_RevisionID, *PPCI_HT_RevisionID;
  482. typedef enum {
  483. HTFreq200MHz = 0,
  484. HTFreq300MHz,
  485. HTFreq400MHz,
  486. HTFreq500MHz,
  487. HTFreq600MHz,
  488. HTFreq800MHz,
  489. HTFreq1000MHz,
  490. HTFreqReserved,
  491. HTFreqVendorDefined
  492. } PCI_HT_Frequency, *PPCI_HT_Frequency;
  493. typedef struct {
  494. UCHAR LinkFrequency:4; // use PCI_HT_Frequency
  495. UCHAR ProtocolError:1;
  496. UCHAR OverflowError:1;
  497. UCHAR EndOfChainError:1;
  498. UCHAR CTLTimeout:1;
  499. } PCI_HT_Frequency_Error, *PPCI_HT_Frequency_Error;
  500. typedef struct {
  501. UCHAR IsocMode:1;
  502. UCHAR LDTSTOP:1;
  503. UCHAR CRCTestMode:1;
  504. UCHAR ExtendedCTLTimeReq:1;
  505. UCHAR Reserved:4;
  506. } PCI_HT_FeatureCap, *PPCI_HT_FeatureCap;
  507. typedef struct {
  508. UCHAR ExtendedRegisterSet:1;
  509. UCHAR Reserved:7;
  510. } PCI_HT_FeatureCap_Ex, *PPCI_HT_FeatureCap_Ex;
  511. typedef struct {
  512. USHORT ProtFloodEn:1;
  513. USHORT OverflowFloodEn:1;
  514. USHORT ProtFatalEn:1;
  515. USHORT OverflowFatalEn:1;
  516. USHORT EOCFatalEn:1;
  517. USHORT RespFatalEn:1;
  518. USHORT CRCFatalEn:1;
  519. USHORT SERRFataEn:1;
  520. USHORT ChainFail:1;
  521. USHORT ResponseError:1;
  522. USHORT ProtNonFatalEn:1;
  523. USHORT OverflowNonFatalEn:1;
  524. USHORT EOCNonFatalEn:1;
  525. USHORT RespNonFatalEn:1;
  526. USHORT CRCNonFatalEn:1;
  527. USHORT SERRNonFatalEn:1;
  528. } PCI_HT_ErrorHandling, *PPCI_HT_ErrorHandling;
  529. typedef struct {
  530. USHORT Reserved1;
  531. UCHAR LastInterrupt;
  532. UCHAR Reserved2;
  533. } PCI_HT_INTERRUPT_INDEX_1, *PPCI_HT_INTERRUPT_INDEX_1;
  534. typedef struct {
  535. struct {
  536. ULONG Mask:1;
  537. ULONG Polarity:1;
  538. ULONG MessageType:3;
  539. ULONG RequestEOI:1;
  540. ULONG Reserved:26;
  541. } LowPart;
  542. struct {
  543. ULONG Reserved:30;
  544. ULONG PassPW:1;
  545. ULONG WaitingForEOI:1;
  546. } HighPart;
  547. } PCI_HT_INTERRUPT_INDEX_N, *PPCI_HT_INTERRUPT_INDEX_N;
  548. typedef struct {
  549. PCI_CAPABILITIES_HEADER Header;
  550. //
  551. // Offset 2
  552. //
  553. union {
  554. struct {
  555. USHORT Reserved:12;
  556. USHORT DropOnUnitinit:1;
  557. USHORT CapabilityType:3; // use PCI_HT_CapabilitiesType
  558. } Generic;
  559. struct {
  560. USHORT BaseUnitID:5;
  561. USHORT UnitCount:5;
  562. USHORT MasterHost:1;
  563. USHORT DefaultDirection:1;
  564. USHORT DropOnUnitinit:1;
  565. USHORT CapabilityType:3; // use PCI_HT_CapabilitiesType
  566. } SlavePrimary;
  567. struct {
  568. USHORT WarmReset:1;
  569. USHORT DoubleEnded:1;
  570. USHORT DeviceNumber:5;
  571. USHORT ChainSide:1;
  572. USHORT HostHide:1;
  573. USHORT Rsv:1;
  574. USHORT ActAsSlave:1;
  575. USHORT InboundEOCError:1;
  576. USHORT DropOnUnitinit:1;
  577. USHORT CapabilityType:3; // use PCI_HT_CapabilitiesType
  578. } HostSecondary;
  579. struct {
  580. USHORT Index:8;
  581. USHORT Reserved:5;
  582. USHORT CapabilityType:3; // use PCI_HT_CapabilitiesType
  583. } Interrupt;
  584. } Command;
  585. //
  586. // Offset 4
  587. //
  588. union {
  589. struct {
  590. PCI_HT_LinkControl LinkControl_0;
  591. PCI_HT_LinkConfig LinkConfig_0;
  592. };
  593. ULONG DataPort; // Interrupt DataPort
  594. };
  595. //
  596. // Offset 8
  597. //
  598. union {
  599. struct {
  600. // Offset 0x8
  601. PCI_HT_LinkControl LinkControl_1;
  602. PCI_HT_LinkConfig LinkConfig_1;
  603. // Offset 0xc
  604. PCI_HT_RevisionID RevisionID;
  605. // Offset 0xd
  606. PCI_HT_Frequency_Error FreqErr_0;
  607. // Offset 0xe
  608. USHORT LinkFreqCap_0;
  609. // Offset 0x10
  610. PCI_HT_FeatureCap FeatureCap;
  611. // Offset 0x11
  612. PCI_HT_Frequency_Error FreqErr_1;
  613. // Offset 0x12
  614. USHORT LinkFreqCap_1;
  615. // Offset 0x14
  616. USHORT EnumerationScratchpad;
  617. // Offset 0x16
  618. PCI_HT_ErrorHandling ErrorHandling;
  619. // Offset 0x18
  620. UCHAR MemoryBaseUpper8Bits;
  621. // Offset 0x19
  622. UCHAR MemoryLimitUpper8Bits;
  623. // Offset 0x20
  624. USHORT Reserved;
  625. } SlavePrimary;
  626. struct {
  627. // Offset 0x8
  628. PCI_HT_RevisionID RevisionID;
  629. // Offset 0x9
  630. PCI_HT_Frequency_Error FreqErr_0;
  631. // Offset 0xa
  632. USHORT LinkFreqCap_0;
  633. // Offset 0xc
  634. PCI_HT_FeatureCap FeatureCap;
  635. PCI_HT_FeatureCap_Ex FeatureCapEx;
  636. // Offset 0xe
  637. USHORT Reserved1;
  638. // Offset 0x10
  639. USHORT EnumerationScratchpad;
  640. // Offset 0x12
  641. PCI_HT_ErrorHandling ErrorHandling;
  642. // Offset 0x14
  643. UCHAR MemoryBaseUpper8Bits;
  644. // Offset 0x15
  645. UCHAR MemoryLimitUpper8Bits;
  646. // Offset 0x16
  647. USHORT Reserved2;
  648. } HostSecondary;
  649. };
  650. } PCI_HT_CAPABILITY, *PPCI_HT_CAPABILITY;
  651. // begin_wdm
  652. //
  653. // Base Class Code encodings for Base Class (from PCI spec rev 2.1).
  654. //
  655. #define PCI_CLASS_PRE_20 0x00
  656. #define PCI_CLASS_MASS_STORAGE_CTLR 0x01
  657. #define PCI_CLASS_NETWORK_CTLR 0x02
  658. #define PCI_CLASS_DISPLAY_CTLR 0x03
  659. #define PCI_CLASS_MULTIMEDIA_DEV 0x04
  660. #define PCI_CLASS_MEMORY_CTLR 0x05
  661. #define PCI_CLASS_BRIDGE_DEV 0x06
  662. #define PCI_CLASS_SIMPLE_COMMS_CTLR 0x07
  663. #define PCI_CLASS_BASE_SYSTEM_DEV 0x08
  664. #define PCI_CLASS_INPUT_DEV 0x09
  665. #define PCI_CLASS_DOCKING_STATION 0x0a
  666. #define PCI_CLASS_PROCESSOR 0x0b
  667. #define PCI_CLASS_SERIAL_BUS_CTLR 0x0c
  668. #define PCI_CLASS_WIRELESS_CTLR 0x0d
  669. #define PCI_CLASS_INTELLIGENT_IO_CTLR 0x0e
  670. #define PCI_CLASS_SATELLITE_COMMS_CTLR 0x0f
  671. #define PCI_CLASS_ENCRYPTION_DECRYPTION 0x10
  672. #define PCI_CLASS_DATA_ACQ_SIGNAL_PROC 0x11
  673. // 0d thru fe reserved
  674. #define PCI_CLASS_NOT_DEFINED 0xff
  675. //
  676. // Sub Class Code encodings (PCI rev 2.1).
  677. //
  678. // Class 00 - PCI_CLASS_PRE_20
  679. #define PCI_SUBCLASS_PRE_20_NON_VGA 0x00
  680. #define PCI_SUBCLASS_PRE_20_VGA 0x01
  681. // Class 01 - PCI_CLASS_MASS_STORAGE_CTLR
  682. #define PCI_SUBCLASS_MSC_SCSI_BUS_CTLR 0x00
  683. #define PCI_SUBCLASS_MSC_IDE_CTLR 0x01
  684. #define PCI_SUBCLASS_MSC_FLOPPY_CTLR 0x02
  685. #define PCI_SUBCLASS_MSC_IPI_CTLR 0x03
  686. #define PCI_SUBCLASS_MSC_RAID_CTLR 0x04
  687. #define PCI_SUBCLASS_MSC_OTHER 0x80
  688. // Class 02 - PCI_CLASS_NETWORK_CTLR
  689. #define PCI_SUBCLASS_NET_ETHERNET_CTLR 0x00
  690. #define PCI_SUBCLASS_NET_TOKEN_RING_CTLR 0x01
  691. #define PCI_SUBCLASS_NET_FDDI_CTLR 0x02
  692. #define PCI_SUBCLASS_NET_ATM_CTLR 0x03
  693. #define PCI_SUBCLASS_NET_ISDN_CTLR 0x04
  694. #define PCI_SUBCLASS_NET_OTHER 0x80
  695. // Class 03 - PCI_CLASS_DISPLAY_CTLR
  696. // N.B. Sub Class 00 could be VGA or 8514 depending on Interface byte
  697. #define PCI_SUBCLASS_VID_VGA_CTLR 0x00
  698. #define PCI_SUBCLASS_VID_XGA_CTLR 0x01
  699. #define PCI_SUBLCASS_VID_3D_CTLR 0x02
  700. #define PCI_SUBCLASS_VID_OTHER 0x80
  701. // Class 04 - PCI_CLASS_MULTIMEDIA_DEV
  702. #define PCI_SUBCLASS_MM_VIDEO_DEV 0x00
  703. #define PCI_SUBCLASS_MM_AUDIO_DEV 0x01
  704. #define PCI_SUBCLASS_MM_TELEPHONY_DEV 0x02
  705. #define PCI_SUBCLASS_MM_OTHER 0x80
  706. // Class 05 - PCI_CLASS_MEMORY_CTLR
  707. #define PCI_SUBCLASS_MEM_RAM 0x00
  708. #define PCI_SUBCLASS_MEM_FLASH 0x01
  709. #define PCI_SUBCLASS_MEM_OTHER 0x80
  710. // Class 06 - PCI_CLASS_BRIDGE_DEV
  711. #define PCI_SUBCLASS_BR_HOST 0x00
  712. #define PCI_SUBCLASS_BR_ISA 0x01
  713. #define PCI_SUBCLASS_BR_EISA 0x02
  714. #define PCI_SUBCLASS_BR_MCA 0x03
  715. #define PCI_SUBCLASS_BR_PCI_TO_PCI 0x04
  716. #define PCI_SUBCLASS_BR_PCMCIA 0x05
  717. #define PCI_SUBCLASS_BR_NUBUS 0x06
  718. #define PCI_SUBCLASS_BR_CARDBUS 0x07
  719. #define PCI_SUBCLASS_BR_RACEWAY 0x08
  720. #define PCI_SUBCLASS_BR_OTHER 0x80
  721. // Class 07 - PCI_CLASS_SIMPLE_COMMS_CTLR
  722. // N.B. Sub Class 00 and 01 additional info in Interface byte
  723. #define PCI_SUBCLASS_COM_SERIAL 0x00
  724. #define PCI_SUBCLASS_COM_PARALLEL 0x01
  725. #define PCI_SUBCLASS_COM_MULTIPORT 0x02
  726. #define PCI_SUBCLASS_COM_MODEM 0x03
  727. #define PCI_SUBCLASS_COM_OTHER 0x80
  728. // Class 08 - PCI_CLASS_BASE_SYSTEM_DEV
  729. // N.B. See Interface byte for additional info.
  730. #define PCI_SUBCLASS_SYS_INTERRUPT_CTLR 0x00
  731. #define PCI_SUBCLASS_SYS_DMA_CTLR 0x01
  732. #define PCI_SUBCLASS_SYS_SYSTEM_TIMER 0x02
  733. #define PCI_SUBCLASS_SYS_REAL_TIME_CLOCK 0x03
  734. #define PCI_SUBCLASS_SYS_GEN_HOTPLUG_CTLR 0x04
  735. #define PCI_SUBCLASS_SYS_OTHER 0x80
  736. // Class 09 - PCI_CLASS_INPUT_DEV
  737. #define PCI_SUBCLASS_INP_KEYBOARD 0x00
  738. #define PCI_SUBCLASS_INP_DIGITIZER 0x01
  739. #define PCI_SUBCLASS_INP_MOUSE 0x02
  740. #define PCI_SUBCLASS_INP_SCANNER 0x03
  741. #define PCI_SUBCLASS_INP_GAMEPORT 0x04
  742. #define PCI_SUBCLASS_INP_OTHER 0x80
  743. // Class 0a - PCI_CLASS_DOCKING_STATION
  744. #define PCI_SUBCLASS_DOC_GENERIC 0x00
  745. #define PCI_SUBCLASS_DOC_OTHER 0x80
  746. // Class 0b - PCI_CLASS_PROCESSOR
  747. #define PCI_SUBCLASS_PROC_386 0x00
  748. #define PCI_SUBCLASS_PROC_486 0x01
  749. #define PCI_SUBCLASS_PROC_PENTIUM 0x02
  750. #define PCI_SUBCLASS_PROC_ALPHA 0x10
  751. #define PCI_SUBCLASS_PROC_POWERPC 0x20
  752. #define PCI_SUBCLASS_PROC_COPROCESSOR 0x40
  753. // Class 0c - PCI_CLASS_SERIAL_BUS_CTLR
  754. #define PCI_SUBCLASS_SB_IEEE1394 0x00
  755. #define PCI_SUBCLASS_SB_ACCESS 0x01
  756. #define PCI_SUBCLASS_SB_SSA 0x02
  757. #define PCI_SUBCLASS_SB_USB 0x03
  758. #define PCI_SUBCLASS_SB_FIBRE_CHANNEL 0x04
  759. #define PCI_SUBCLASS_SB_SMBUS 0x05
  760. // Class 0d - PCI_CLASS_WIRELESS_CTLR
  761. #define PCI_SUBCLASS_WIRELESS_IRDA 0x00
  762. #define PCI_SUBCLASS_WIRELESS_CON_IR 0x01
  763. #define PCI_SUBCLASS_WIRELESS_RF 0x10
  764. #define PCI_SUBCLASS_WIRELESS_OTHER 0x80
  765. // Class 0e - PCI_CLASS_INTELLIGENT_IO_CTLR
  766. #define PCI_SUBCLASS_INTIO_I2O 0x00
  767. // Class 0f - PCI_CLASS_SATELLITE_CTLR
  768. #define PCI_SUBCLASS_SAT_TV 0x01
  769. #define PCI_SUBCLASS_SAT_AUDIO 0x02
  770. #define PCI_SUBCLASS_SAT_VOICE 0x03
  771. #define PCI_SUBCLASS_SAT_DATA 0x04
  772. // Class 10 - PCI_CLASS_ENCRYPTION_DECRYPTION
  773. #define PCI_SUBCLASS_CRYPTO_NET_COMP 0x00
  774. #define PCI_SUBCLASS_CRYPTO_ENTERTAINMENT 0x10
  775. #define PCI_SUBCLASS_CRYPTO_OTHER 0x80
  776. // Class 11 - PCI_CLASS_DATA_ACQ_SIGNAL_PROC
  777. #define PCI_SUBCLASS_DASP_DPIO 0x00
  778. #define PCI_SUBCLASS_DASP_OTHER 0x80
  779. // end_ntndis
  780. //
  781. // Bit encodes for PCI_COMMON_CONFIG.u.type0.BaseAddresses
  782. //
  783. #define PCI_ADDRESS_IO_SPACE 0x00000001 // (ro)
  784. #define PCI_ADDRESS_MEMORY_TYPE_MASK 0x00000006 // (ro)
  785. #define PCI_ADDRESS_MEMORY_PREFETCHABLE 0x00000008 // (ro)
  786. #define PCI_ADDRESS_IO_ADDRESS_MASK 0xfffffffc
  787. #define PCI_ADDRESS_MEMORY_ADDRESS_MASK 0xfffffff0
  788. #define PCI_ADDRESS_ROM_ADDRESS_MASK 0xfffff800
  789. #define PCI_TYPE_32BIT 0
  790. #define PCI_TYPE_20BIT 2
  791. #define PCI_TYPE_64BIT 4
  792. //
  793. // Bit encodes for PCI_COMMON_CONFIG.u.type0.ROMBaseAddresses
  794. //
  795. #define PCI_ROMADDRESS_ENABLED 0x00000001
  796. //
  797. // Reference notes for PCI configuration fields:
  798. //
  799. // ro these field are read only. changes to these fields are ignored
  800. //
  801. // ro+ these field are intended to be read only and should be initialized
  802. // by the system to their proper values. However, driver may change
  803. // these settings.
  804. //
  805. // ---
  806. //
  807. // All resources comsumed by a PCI device start as unitialized
  808. // under NT. An uninitialized memory or I/O base address can be
  809. // determined by checking it's corrisponding enabled bit in the
  810. // PCI_COMMON_CONFIG.Command value. An InterruptLine is unitialized
  811. // if it contains the value of -1.
  812. //
  813. // end_wdm end_ntminiport
  814. // end_ntddk end_ntosp
  815. //
  816. // PCI_REGISTRY_INFO - this structure is passed into the HAL from
  817. // the firmware. It signifies how many PCI bus(es) are present and
  818. // what style of access the PCI bus(es) support.
  819. //
  820. typedef struct _PCI_REGISTRY_INFO {
  821. UCHAR MajorRevision;
  822. UCHAR MinorRevision;
  823. UCHAR NoBuses;
  824. UCHAR HardwareMechanism;
  825. } PCI_REGISTRY_INFO, *PPCI_REGISTRY_INFO;
  826. //
  827. // PCI definitions for IOBase & IOLimit
  828. // PCIBridgeIO2Base(a,b) - convert IOBase & IOBaseUpper16 to ULONG IOBase
  829. // PCIBridgeIO2Limit(a,b) - convert IOLimit & IOLimitUpper6 to ULONG IOLimit
  830. //
  831. #define PciBridgeIO2Base(a,b) \
  832. ( ((a >> 4) << 12) + (((a & 0xf) == 1) ? (b << 16) : 0) )
  833. #define PciBridgeIO2Limit(a,b) (PciBridgeIO2Base(a,b) | 0xfff)
  834. #define PciBridgeMemory2Base(a) (ULONG) ((a & 0xfff0) << 16)
  835. #define PciBridgeMemory2Limit(a) (PciBridgeMemory2Base(a) | 0xfffff)
  836. //
  837. // Bit encodes for PCI_COMMON_CONFIG.u.type1/2.BridgeControl
  838. //
  839. #define PCI_ENABLE_BRIDGE_PARITY_ERROR 0x0001
  840. #define PCI_ENABLE_BRIDGE_SERR 0x0002
  841. #define PCI_ENABLE_BRIDGE_ISA 0x0004
  842. #define PCI_ENABLE_BRIDGE_VGA 0x0008
  843. #define PCI_ENABLE_BRIDGE_MASTER_ABORT_SERR 0x0020
  844. #define PCI_ASSERT_BRIDGE_RESET 0x0040
  845. //
  846. // Bit encodes for PCI_COMMON_CONFIG.u.type1.BridgeControl
  847. //
  848. #define PCI_ENABLE_BRIDGE_FAST_BACK_TO_BACK 0x0080
  849. //
  850. // Bit encodes for PCI_COMMON_CONFIG.u.type2.BridgeControl
  851. //
  852. #define PCI_ENABLE_CARDBUS_IRQ_ROUTING 0x0080
  853. #define PCI_ENABLE_CARDBUS_MEM0_PREFETCH 0x0100
  854. #define PCI_ENABLE_CARDBUS_MEM1_PREFETCH 0x0200
  855. #define PCI_ENABLE_CARDBUS_WRITE_POSTING 0x0400
  856. //
  857. // Definitions needed for Access to Hardware Type 1
  858. //
  859. #define PCI_TYPE1_ADDR_PORT (0xCF8)
  860. #define PCI_TYPE1_DATA_PORT 0xCFC
  861. typedef struct _PCI_TYPE1_CFG_BITS {
  862. union {
  863. struct {
  864. ULONG Reserved1:2;
  865. ULONG RegisterNumber:6;
  866. ULONG FunctionNumber:3;
  867. ULONG DeviceNumber:5;
  868. ULONG BusNumber:8;
  869. ULONG Reserved2:7;
  870. ULONG Enable:1;
  871. } bits;
  872. ULONG AsULONG;
  873. } u;
  874. } PCI_TYPE1_CFG_BITS, *PPCI_TYPE1_CFG_BITS;
  875. //
  876. // Definitions needed for Access to Hardware Type 2
  877. //
  878. #define PCI_TYPE2_CSE_PORT ((PUCHAR) 0xCF8)
  879. #define PCI_TYPE2_FORWARD_PORT ((PUCHAR) 0xCFA)
  880. #define PCI_TYPE2_ADDRESS_BASE 0xC
  881. typedef struct _PCI_TYPE2_CSE_BITS {
  882. union {
  883. struct {
  884. UCHAR Enable:1;
  885. UCHAR FunctionNumber:3;
  886. UCHAR Key:4;
  887. } bits;
  888. UCHAR AsUCHAR;
  889. } u;
  890. } PCI_TYPE2_CSE_BITS, PPCI_TYPE2_CSE_BITS;
  891. typedef struct _PCI_TYPE2_ADDRESS_BITS {
  892. union {
  893. struct {
  894. USHORT RegisterNumber:8;
  895. USHORT Agent:4;
  896. USHORT AddressBase:4;
  897. } bits;
  898. USHORT AsUSHORT;
  899. } u;
  900. } PCI_TYPE2_ADDRESS_BITS, *PPCI_TYPE2_ADDRESS_BITS;
  901. //
  902. // Definitions for the config cycle format on the PCI bus.
  903. //
  904. typedef struct _PCI_TYPE0_CFG_CYCLE_BITS {
  905. union {
  906. struct {
  907. ULONG Reserved1:2;
  908. ULONG RegisterNumber:6;
  909. ULONG FunctionNumber:3;
  910. ULONG Reserved2:21;
  911. } bits;
  912. ULONG AsULONG;
  913. } u;
  914. } PCI_TYPE0_CFG_CYCLE_BITS, *PPCI_TYPE0_CFG_CYCLE_BITS;
  915. typedef struct _PCI_TYPE1_CFG_CYCLE_BITS {
  916. union {
  917. struct {
  918. ULONG Reserved1:2;
  919. ULONG RegisterNumber:6;
  920. ULONG FunctionNumber:3;
  921. ULONG DeviceNumber:5;
  922. ULONG BusNumber:8;
  923. ULONG Reserved2:8;
  924. } bits;
  925. ULONG AsULONG;
  926. } u;
  927. } PCI_TYPE1_CFG_CYCLE_BITS, *PPCI_TYPE1_CFG_CYCLE_BITS;
  928. #endif