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.

724 lines
20 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. //
  12. // A PCI driver can read the complete 256 bytes of configuration
  13. // information for any PCI device by calling:
  14. //
  15. // ULONG
  16. // HalGetBusData (
  17. // IN BUS_DATA_TYPE PCIConfiguration,
  18. // IN ULONG PciBusNumber,
  19. // IN PCI_SLOT_NUMBER VirtualSlotNumber,
  20. // IN PPCI_COMMON_CONFIG &PCIDeviceConfig,
  21. // IN ULONG sizeof (PCIDeviceConfig)
  22. // );
  23. //
  24. // A return value of 0 means that the specified PCI bus does not exist.
  25. //
  26. // A return value of 2, with a VendorID of PCI_INVALID_VENDORID means
  27. // that the PCI bus does exist, but there is no device at the specified
  28. // VirtualSlotNumber (PCI Device/Function number).
  29. //
  30. //
  31. // begin_wdm begin_ntminiport begin_ntndis
  32. typedef struct _PCI_SLOT_NUMBER {
  33. union {
  34. struct {
  35. ULONG DeviceNumber:5;
  36. ULONG FunctionNumber:3;
  37. ULONG Reserved:24;
  38. } bits;
  39. ULONG AsULONG;
  40. } u;
  41. } PCI_SLOT_NUMBER, *PPCI_SLOT_NUMBER;
  42. #define PCI_TYPE0_ADDRESSES 6
  43. #define PCI_TYPE1_ADDRESSES 2
  44. #define PCI_TYPE2_ADDRESSES 5
  45. typedef struct _PCI_COMMON_CONFIG {
  46. USHORT VendorID; // (ro)
  47. USHORT DeviceID; // (ro)
  48. USHORT Command; // Device control
  49. USHORT Status;
  50. UCHAR RevisionID; // (ro)
  51. UCHAR ProgIf; // (ro)
  52. UCHAR SubClass; // (ro)
  53. UCHAR BaseClass; // (ro)
  54. UCHAR CacheLineSize; // (ro+)
  55. UCHAR LatencyTimer; // (ro+)
  56. UCHAR HeaderType; // (ro)
  57. UCHAR BIST; // Built in self test
  58. union {
  59. struct _PCI_HEADER_TYPE_0 {
  60. ULONG BaseAddresses[PCI_TYPE0_ADDRESSES];
  61. ULONG CIS;
  62. USHORT SubVendorID;
  63. USHORT SubSystemID;
  64. ULONG ROMBaseAddress;
  65. UCHAR CapabilitiesPtr;
  66. UCHAR Reserved1[3];
  67. ULONG Reserved2;
  68. UCHAR InterruptLine; //
  69. UCHAR InterruptPin; // (ro)
  70. UCHAR MinimumGrant; // (ro)
  71. UCHAR MaximumLatency; // (ro)
  72. } type0;
  73. // end_wdm end_ntminiport end_ntndis
  74. //
  75. // PCI to PCI Bridge
  76. //
  77. struct _PCI_HEADER_TYPE_1 {
  78. ULONG BaseAddresses[PCI_TYPE1_ADDRESSES];
  79. UCHAR PrimaryBus;
  80. UCHAR SecondaryBus;
  81. UCHAR SubordinateBus;
  82. UCHAR SecondaryLatency;
  83. UCHAR IOBase;
  84. UCHAR IOLimit;
  85. USHORT SecondaryStatus;
  86. USHORT MemoryBase;
  87. USHORT MemoryLimit;
  88. USHORT PrefetchBase;
  89. USHORT PrefetchLimit;
  90. ULONG PrefetchBaseUpper32;
  91. ULONG PrefetchLimitUpper32;
  92. USHORT IOBaseUpper16;
  93. USHORT IOLimitUpper16;
  94. UCHAR CapabilitiesPtr;
  95. UCHAR Reserved1[3];
  96. ULONG ROMBaseAddress;
  97. UCHAR InterruptLine;
  98. UCHAR InterruptPin;
  99. USHORT BridgeControl;
  100. } type1;
  101. //
  102. // PCI to CARDBUS Bridge
  103. //
  104. struct _PCI_HEADER_TYPE_2 {
  105. ULONG SocketRegistersBaseAddress;
  106. UCHAR CapabilitiesPtr;
  107. UCHAR Reserved;
  108. USHORT SecondaryStatus;
  109. UCHAR PrimaryBus;
  110. UCHAR SecondaryBus;
  111. UCHAR SubordinateBus;
  112. UCHAR SecondaryLatency;
  113. struct {
  114. ULONG Base;
  115. ULONG Limit;
  116. } Range[PCI_TYPE2_ADDRESSES-1];
  117. UCHAR InterruptLine;
  118. UCHAR InterruptPin;
  119. USHORT BridgeControl;
  120. } type2;
  121. // begin_wdm begin_ntminiport begin_ntndis
  122. } u;
  123. UCHAR DeviceSpecific[192];
  124. } PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG;
  125. #define PCI_COMMON_HDR_LENGTH (FIELD_OFFSET (PCI_COMMON_CONFIG, DeviceSpecific))
  126. #define PCI_MAX_DEVICES 32
  127. #define PCI_MAX_FUNCTION 8
  128. #define PCI_MAX_BRIDGE_NUMBER 0xFF
  129. #define PCI_INVALID_VENDORID 0xFFFF
  130. //
  131. // Bit encodings for PCI_COMMON_CONFIG.HeaderType
  132. //
  133. #define PCI_MULTIFUNCTION 0x80
  134. #define PCI_DEVICE_TYPE 0x00
  135. #define PCI_BRIDGE_TYPE 0x01
  136. #define PCI_CARDBUS_BRIDGE_TYPE 0x02
  137. #define PCI_CONFIGURATION_TYPE(PciData) \
  138. (((PPCI_COMMON_CONFIG)(PciData))->HeaderType & ~PCI_MULTIFUNCTION)
  139. #define PCI_MULTIFUNCTION_DEVICE(PciData) \
  140. ((((PPCI_COMMON_CONFIG)(PciData))->HeaderType & PCI_MULTIFUNCTION) != 0)
  141. //
  142. // Bit encodings for PCI_COMMON_CONFIG.Command
  143. //
  144. #define PCI_ENABLE_IO_SPACE 0x0001
  145. #define PCI_ENABLE_MEMORY_SPACE 0x0002
  146. #define PCI_ENABLE_BUS_MASTER 0x0004
  147. #define PCI_ENABLE_SPECIAL_CYCLES 0x0008
  148. #define PCI_ENABLE_WRITE_AND_INVALIDATE 0x0010
  149. #define PCI_ENABLE_VGA_COMPATIBLE_PALETTE 0x0020
  150. #define PCI_ENABLE_PARITY 0x0040 // (ro+)
  151. #define PCI_ENABLE_WAIT_CYCLE 0x0080 // (ro+)
  152. #define PCI_ENABLE_SERR 0x0100 // (ro+)
  153. #define PCI_ENABLE_FAST_BACK_TO_BACK 0x0200 // (ro)
  154. //
  155. // Bit encodings for PCI_COMMON_CONFIG.Status
  156. //
  157. #define PCI_STATUS_CAPABILITIES_LIST 0x0010 // (ro)
  158. #define PCI_STATUS_66MHZ_CAPABLE 0x0020 // (ro)
  159. #define PCI_STATUS_UDF_SUPPORTED 0x0040 // (ro)
  160. #define PCI_STATUS_FAST_BACK_TO_BACK 0x0080 // (ro)
  161. #define PCI_STATUS_DATA_PARITY_DETECTED 0x0100
  162. #define PCI_STATUS_DEVSEL 0x0600 // 2 bits wide
  163. #define PCI_STATUS_SIGNALED_TARGET_ABORT 0x0800
  164. #define PCI_STATUS_RECEIVED_TARGET_ABORT 0x1000
  165. #define PCI_STATUS_RECEIVED_MASTER_ABORT 0x2000
  166. #define PCI_STATUS_SIGNALED_SYSTEM_ERROR 0x4000
  167. #define PCI_STATUS_DETECTED_PARITY_ERROR 0x8000
  168. //
  169. // The NT PCI Driver uses a WhichSpace parameter on its CONFIG_READ/WRITE
  170. // routines. The following values are defined-
  171. //
  172. #define PCI_WHICHSPACE_CONFIG 0x0
  173. #define PCI_WHICHSPACE_ROM 0x52696350
  174. // end_wdm
  175. //
  176. // PCI Capability IDs
  177. //
  178. #define PCI_CAPABILITY_ID_POWER_MANAGEMENT 0x01
  179. #define PCI_CAPABILITY_ID_AGP 0x02
  180. #define PCI_CAPABILITY_ID_MSI 0x05
  181. //
  182. // All PCI Capability structures have the following header.
  183. //
  184. // CapabilityID is used to identify the type of the structure (is
  185. // one of the PCI_CAPABILITY_ID values above.
  186. //
  187. // Next is the offset in PCI Configuration space (0x40 - 0xfc) of the
  188. // next capability structure in the list, or 0x00 if there are no more
  189. // entries.
  190. //
  191. typedef struct _PCI_CAPABILITIES_HEADER {
  192. UCHAR CapabilityID;
  193. UCHAR Next;
  194. } PCI_CAPABILITIES_HEADER, *PPCI_CAPABILITIES_HEADER;
  195. //
  196. // Power Management Capability
  197. //
  198. typedef struct _PCI_PMC {
  199. UCHAR Version:3;
  200. UCHAR PMEClock:1;
  201. UCHAR Rsvd1:1;
  202. UCHAR DeviceSpecificInitialization:1;
  203. UCHAR Rsvd2:2;
  204. struct _PM_SUPPORT {
  205. UCHAR Rsvd2:1;
  206. UCHAR D1:1;
  207. UCHAR D2:1;
  208. UCHAR PMED0:1;
  209. UCHAR PMED1:1;
  210. UCHAR PMED2:1;
  211. UCHAR PMED3Hot:1;
  212. UCHAR PMED3Cold:1;
  213. } Support;
  214. } PCI_PMC, *PPCI_PMC;
  215. typedef struct _PCI_PMCSR {
  216. USHORT PowerState:2;
  217. USHORT Rsvd1:6;
  218. USHORT PMEEnable:1;
  219. USHORT DataSelect:4;
  220. USHORT DataScale:2;
  221. USHORT PMEStatus:1;
  222. } PCI_PMCSR, *PPCI_PMCSR;
  223. typedef struct _PCI_PMCSR_BSE {
  224. UCHAR Rsvd1:6;
  225. UCHAR D3HotSupportsStopClock:1; // B2_B3#
  226. UCHAR BusPowerClockControlEnabled:1; // BPCC_EN
  227. } PCI_PMCSR_BSE, *PPCI_PMCSR_BSE;
  228. typedef struct _PCI_PM_CAPABILITY {
  229. PCI_CAPABILITIES_HEADER Header;
  230. //
  231. // Power Management Capabilities (Offset = 2)
  232. //
  233. union {
  234. PCI_PMC Capabilities;
  235. USHORT AsUSHORT;
  236. } PMC;
  237. //
  238. // Power Management Control/Status (Offset = 4)
  239. //
  240. union {
  241. PCI_PMCSR ControlStatus;
  242. USHORT AsUSHORT;
  243. } PMCSR;
  244. //
  245. // PMCSR PCI-PCI Bridge Support Extensions
  246. //
  247. union {
  248. PCI_PMCSR_BSE BridgeSupport;
  249. UCHAR AsUCHAR;
  250. } PMCSR_BSE;
  251. //
  252. // Optional read only 8 bit Data register. Contents controlled by
  253. // DataSelect and DataScale in ControlStatus.
  254. //
  255. UCHAR Data;
  256. } PCI_PM_CAPABILITY, *PPCI_PM_CAPABILITY;
  257. //
  258. // AGP Capability
  259. //
  260. typedef struct _PCI_AGP_CAPABILITY {
  261. PCI_CAPABILITIES_HEADER Header;
  262. USHORT Minor:4;
  263. USHORT Major:4;
  264. USHORT Rsvd1:8;
  265. struct _PCI_AGP_STATUS {
  266. ULONG Rate:3;
  267. ULONG Rsvd1:1;
  268. ULONG FastWrite:1;
  269. ULONG FourGB:1;
  270. ULONG Rsvd2:3;
  271. ULONG SideBandAddressing:1; // SBA
  272. ULONG Rsvd3:14;
  273. ULONG RequestQueueDepthMaximum:8; // RQ
  274. } AGPStatus;
  275. struct _PCI_AGP_COMMAND {
  276. ULONG Rate:3;
  277. ULONG Rsvd1:1;
  278. ULONG FastWriteEnable:1;
  279. ULONG FourGBEnable:1;
  280. ULONG Rsvd2:2;
  281. ULONG AGPEnable:1;
  282. ULONG SBAEnable:1;
  283. ULONG Rsvd3:14;
  284. ULONG RequestQueueDepth:8;
  285. } AGPCommand;
  286. } PCI_AGP_CAPABILITY, *PPCI_AGP_CAPABILITY;
  287. #define PCI_AGP_RATE_1X 0x1
  288. #define PCI_AGP_RATE_2X 0x2
  289. #define PCI_AGP_RATE_4X 0x4
  290. //
  291. // MSI (Message Signalled Interrupts) Capability
  292. //
  293. typedef struct _PCI_MSI_CAPABILITY {
  294. PCI_CAPABILITIES_HEADER Header;
  295. struct _PCI_MSI_MESSAGE_CONTROL {
  296. USHORT MSIEnable:1;
  297. USHORT MultipleMessageCapable:3;
  298. USHORT MultipleMessageEnable:3;
  299. USHORT CapableOf64Bits:1;
  300. USHORT Reserved:8;
  301. } MessageControl;
  302. union {
  303. struct _PCI_MSI_MESSAGE_ADDRESS {
  304. ULONG Reserved:2; // always zero, DWORD aligned address
  305. ULONG Address:30;
  306. } Register;
  307. ULONG Raw;
  308. } MessageAddress; // was ULONG_PTR
  309. //
  310. // The rest of the Capability structure differs depending on whether
  311. // 32bit or 64bit addressing is being used.
  312. //
  313. // (The CapableOf64Bits bit above determines this)
  314. //
  315. union {
  316. // For 64 bit devices
  317. struct _PCI_MSI_64BIT_DATA {
  318. ULONG MessageUpperAddress;
  319. USHORT MessageData;
  320. } Bit64;
  321. // For 32 bit devices
  322. struct _PCI_MSI_32BIT_DATA {
  323. USHORT MessageData;
  324. ULONG Unused;
  325. } Bit32;
  326. } Data;
  327. } PCI_MSI_CAPABILITY, *PPCI_PCI_CAPABILITY;
  328. // begin_wdm
  329. //
  330. // Base Class Code encodings for Base Class (from PCI spec rev 2.1).
  331. //
  332. #define PCI_CLASS_PRE_20 0x00
  333. #define PCI_CLASS_MASS_STORAGE_CTLR 0x01
  334. #define PCI_CLASS_NETWORK_CTLR 0x02
  335. #define PCI_CLASS_DISPLAY_CTLR 0x03
  336. #define PCI_CLASS_MULTIMEDIA_DEV 0x04
  337. #define PCI_CLASS_MEMORY_CTLR 0x05
  338. #define PCI_CLASS_BRIDGE_DEV 0x06
  339. #define PCI_CLASS_SIMPLE_COMMS_CTLR 0x07
  340. #define PCI_CLASS_BASE_SYSTEM_DEV 0x08
  341. #define PCI_CLASS_INPUT_DEV 0x09
  342. #define PCI_CLASS_DOCKING_STATION 0x0a
  343. #define PCI_CLASS_PROCESSOR 0x0b
  344. #define PCI_CLASS_SERIAL_BUS_CTLR 0x0c
  345. // 0d thru fe reserved
  346. #define PCI_CLASS_NOT_DEFINED 0xff
  347. //
  348. // Sub Class Code encodings (PCI rev 2.1).
  349. //
  350. // Class 00 - PCI_CLASS_PRE_20
  351. #define PCI_SUBCLASS_PRE_20_NON_VGA 0x00
  352. #define PCI_SUBCLASS_PRE_20_VGA 0x01
  353. // Class 01 - PCI_CLASS_MASS_STORAGE_CTLR
  354. #define PCI_SUBCLASS_MSC_SCSI_BUS_CTLR 0x00
  355. #define PCI_SUBCLASS_MSC_IDE_CTLR 0x01
  356. #define PCI_SUBCLASS_MSC_FLOPPY_CTLR 0x02
  357. #define PCI_SUBCLASS_MSC_IPI_CTLR 0x03
  358. #define PCI_SUBCLASS_MSC_RAID_CTLR 0x04
  359. #define PCI_SUBCLASS_MSC_OTHER 0x80
  360. // Class 02 - PCI_CLASS_NETWORK_CTLR
  361. #define PCI_SUBCLASS_NET_ETHERNET_CTLR 0x00
  362. #define PCI_SUBCLASS_NET_TOKEN_RING_CTLR 0x01
  363. #define PCI_SUBCLASS_NET_FDDI_CTLR 0x02
  364. #define PCI_SUBCLASS_NET_ATM_CTLR 0x03
  365. #define PCI_SUBCLASS_NET_OTHER 0x80
  366. // Class 03 - PCI_CLASS_DISPLAY_CTLR
  367. // N.B. Sub Class 00 could be VGA or 8514 depending on Interface byte
  368. #define PCI_SUBCLASS_VID_VGA_CTLR 0x00
  369. #define PCI_SUBCLASS_VID_XGA_CTLR 0x01
  370. #define PCI_SUBCLASS_VID_OTHER 0x80
  371. // Class 04 - PCI_CLASS_MULTIMEDIA_DEV
  372. #define PCI_SUBCLASS_MM_VIDEO_DEV 0x00
  373. #define PCI_SUBCLASS_MM_AUDIO_DEV 0x01
  374. #define PCI_SUBCLASS_MM_OTHER 0x80
  375. // Class 05 - PCI_CLASS_MEMORY_CTLR
  376. #define PCI_SUBCLASS_MEM_RAM 0x00
  377. #define PCI_SUBCLASS_MEM_FLASH 0x01
  378. #define PCI_SUBCLASS_MEM_OTHER 0x80
  379. // Class 06 - PCI_CLASS_BRIDGE_DEV
  380. #define PCI_SUBCLASS_BR_HOST 0x00
  381. #define PCI_SUBCLASS_BR_ISA 0x01
  382. #define PCI_SUBCLASS_BR_EISA 0x02
  383. #define PCI_SUBCLASS_BR_MCA 0x03
  384. #define PCI_SUBCLASS_BR_PCI_TO_PCI 0x04
  385. #define PCI_SUBCLASS_BR_PCMCIA 0x05
  386. #define PCI_SUBCLASS_BR_NUBUS 0x06
  387. #define PCI_SUBCLASS_BR_CARDBUS 0x07
  388. #define PCI_SUBCLASS_BR_OTHER 0x80
  389. // Class 07 - PCI_CLASS_SIMPLE_COMMS_CTLR
  390. // N.B. Sub Class 00 and 01 additional info in Interface byte
  391. #define PCI_SUBCLASS_COM_SERIAL 0x00
  392. #define PCI_SUBCLASS_COM_PARALLEL 0x01
  393. #define PCI_SUBCLASS_COM_OTHER 0x80
  394. // Class 08 - PCI_CLASS_BASE_SYSTEM_DEV
  395. // N.B. See Interface byte for additional info.
  396. #define PCI_SUBCLASS_SYS_INTERRUPT_CTLR 0x00
  397. #define PCI_SUBCLASS_SYS_DMA_CTLR 0x01
  398. #define PCI_SUBCLASS_SYS_SYSTEM_TIMER 0x02
  399. #define PCI_SUBCLASS_SYS_REAL_TIME_CLOCK 0x03
  400. #define PCI_SUBCLASS_SYS_OTHER 0x80
  401. // Class 09 - PCI_CLASS_INPUT_DEV
  402. #define PCI_SUBCLASS_INP_KEYBOARD 0x00
  403. #define PCI_SUBCLASS_INP_DIGITIZER 0x01
  404. #define PCI_SUBCLASS_INP_MOUSE 0x02
  405. #define PCI_SUBCLASS_INP_OTHER 0x80
  406. // Class 0a - PCI_CLASS_DOCKING_STATION
  407. #define PCI_SUBCLASS_DOC_GENERIC 0x00
  408. #define PCI_SUBCLASS_DOC_OTHER 0x80
  409. // Class 0b - PCI_CLASS_PROCESSOR
  410. #define PCI_SUBCLASS_PROC_386 0x00
  411. #define PCI_SUBCLASS_PROC_486 0x01
  412. #define PCI_SUBCLASS_PROC_PENTIUM 0x02
  413. #define PCI_SUBCLASS_PROC_ALPHA 0x10
  414. #define PCI_SUBCLASS_PROC_POWERPC 0x20
  415. #define PCI_SUBCLASS_PROC_COPROCESSOR 0x40
  416. // Class 0c - PCI_CLASS_SERIAL_BUS_CTLR
  417. #define PCI_SUBCLASS_SB_IEEE1394 0x00
  418. #define PCI_SUBCLASS_SB_ACCESS 0x01
  419. #define PCI_SUBCLASS_SB_SSA 0x02
  420. #define PCI_SUBCLASS_SB_USB 0x03
  421. #define PCI_SUBCLASS_SB_FIBRE_CHANNEL 0x04
  422. // end_ntndis
  423. //
  424. // Bit encodes for PCI_COMMON_CONFIG.u.type0.BaseAddresses
  425. //
  426. #define PCI_ADDRESS_IO_SPACE 0x00000001 // (ro)
  427. #define PCI_ADDRESS_MEMORY_TYPE_MASK 0x00000006 // (ro)
  428. #define PCI_ADDRESS_MEMORY_PREFETCHABLE 0x00000008 // (ro)
  429. #define PCI_ADDRESS_IO_ADDRESS_MASK 0xfffffffc
  430. #define PCI_ADDRESS_MEMORY_ADDRESS_MASK 0xfffffff0
  431. #define PCI_ADDRESS_ROM_ADDRESS_MASK 0xfffff800
  432. #define PCI_TYPE_32BIT 0
  433. #define PCI_TYPE_20BIT 2
  434. #define PCI_TYPE_64BIT 4
  435. //
  436. // Bit encodes for PCI_COMMON_CONFIG.u.type0.ROMBaseAddresses
  437. //
  438. #define PCI_ROMADDRESS_ENABLED 0x00000001
  439. //
  440. // Reference notes for PCI configuration fields:
  441. //
  442. // ro these field are read only. changes to these fields are ignored
  443. //
  444. // ro+ these field are intended to be read only and should be initialized
  445. // by the system to their proper values. However, driver may change
  446. // these settings.
  447. //
  448. // ---
  449. //
  450. // All resources comsumed by a PCI device start as unitialized
  451. // under NT. An uninitialized memory or I/O base address can be
  452. // determined by checking it's corrisponding enabled bit in the
  453. // PCI_COMMON_CONFIG.Command value. An InterruptLine is unitialized
  454. // if it contains the value of -1.
  455. //
  456. // end_wdm end_ntminiport
  457. // end_ntddk end_ntosp
  458. //
  459. // PCI_REGISTRY_INFO - this structure is passed into the HAL from
  460. // the firmware. It signifies how many PCI bus(es) are present and
  461. // what style of access the PCI bus(es) support.
  462. //
  463. typedef struct _PCI_REGISTRY_INFO {
  464. UCHAR MajorRevision;
  465. UCHAR MinorRevision;
  466. UCHAR NoBuses;
  467. UCHAR HardwareMechanism;
  468. } PCI_REGISTRY_INFO, *PPCI_REGISTRY_INFO;
  469. //
  470. // PCI definitions for IOBase & IOLimit
  471. // PCIBridgeIO2Base(a,b) - convert IOBase & IOBaseUpper16 to ULONG IOBase
  472. // PCIBridgeIO2Limit(a,b) - convert IOLimit & IOLimitUpper6 to ULONG IOLimit
  473. //
  474. #define PciBridgeIO2Base(a,b) \
  475. ( ((a >> 4) << 12) + (((a & 0xf) == 1) ? (b << 16) : 0) )
  476. #define PciBridgeIO2Limit(a,b) (PciBridgeIO2Base(a,b) | 0xfff)
  477. #define PciBridgeMemory2Base(a) (ULONG) ((a & 0xfff0) << 16)
  478. #define PciBridgeMemory2Limit(a) (PciBridgeMemory2Base(a) | 0xfffff)
  479. //
  480. // Bit encodes for PCI_COMMON_CONFIG.u.type1/2.BridgeControl
  481. //
  482. #define PCI_ENABLE_BRIDGE_PARITY_ERROR 0x0001
  483. #define PCI_ENABLE_BRIDGE_SERR 0x0002
  484. #define PCI_ENABLE_BRIDGE_ISA 0x0004
  485. #define PCI_ENABLE_BRIDGE_VGA 0x0008
  486. #define PCI_ENABLE_BRIDGE_MASTER_ABORT_SERR 0x0020
  487. #define PCI_ASSERT_BRIDGE_RESET 0x0040
  488. //
  489. // Bit encodes for PCI_COMMON_CONFIG.u.type1.BridgeControl
  490. //
  491. #define PCI_ENABLE_BRIDGE_FAST_BACK_TO_BACK 0x0080
  492. //
  493. // Bit encodes for PCI_COMMON_CONFIG.u.type2.BridgeControl
  494. //
  495. #define PCI_ENABLE_CARDBUS_IRQ_ROUTING 0x0080
  496. #define PCI_ENABLE_CARDBUS_MEM0_PREFETCH 0x0100
  497. #define PCI_ENABLE_CARDBUS_MEM1_PREFETCH 0x0200
  498. #define PCI_ENABLE_CARDBUS_WRITE_POSTING 0x0400
  499. //
  500. // Definitions needed for Access to Hardware Type 1
  501. //
  502. #define PCI_TYPE1_ADDR_PORT (0xCF8)
  503. #define PCI_TYPE1_DATA_PORT 0xCFC
  504. typedef struct _PCI_TYPE1_CFG_BITS {
  505. union {
  506. struct {
  507. ULONG Reserved1:2;
  508. ULONG RegisterNumber:6;
  509. ULONG FunctionNumber:3;
  510. ULONG DeviceNumber:5;
  511. ULONG BusNumber:8;
  512. ULONG Reserved2:7;
  513. ULONG Enable:1;
  514. } bits;
  515. ULONG AsULONG;
  516. } u;
  517. } PCI_TYPE1_CFG_BITS, *PPCI_TYPE1_CFG_BITS;
  518. //
  519. // Definitions needed for Access to Hardware Type 2
  520. //
  521. #define PCI_TYPE2_CSE_PORT ((PUCHAR) 0xCF8)
  522. #define PCI_TYPE2_FORWARD_PORT ((PUCHAR) 0xCFA)
  523. #define PCI_TYPE2_ADDRESS_BASE 0xC
  524. typedef struct _PCI_TYPE2_CSE_BITS {
  525. union {
  526. struct {
  527. UCHAR Enable:1;
  528. UCHAR FunctionNumber:3;
  529. UCHAR Key:4;
  530. } bits;
  531. UCHAR AsUCHAR;
  532. } u;
  533. } PCI_TYPE2_CSE_BITS, PPCI_TYPE2_CSE_BITS;
  534. typedef struct _PCI_TYPE2_ADDRESS_BITS {
  535. union {
  536. struct {
  537. USHORT RegisterNumber:8;
  538. USHORT Agent:4;
  539. USHORT AddressBase:4;
  540. } bits;
  541. USHORT AsUSHORT;
  542. } u;
  543. } PCI_TYPE2_ADDRESS_BITS, *PPCI_TYPE2_ADDRESS_BITS;
  544. //
  545. // Definitions for the config cycle format on the PCI bus.
  546. //
  547. typedef struct _PCI_TYPE0_CFG_CYCLE_BITS {
  548. union {
  549. struct {
  550. ULONG Reserved1:2;
  551. ULONG RegisterNumber:6;
  552. ULONG FunctionNumber:3;
  553. ULONG Reserved2:21;
  554. } bits;
  555. ULONG AsULONG;
  556. } u;
  557. } PCI_TYPE0_CFG_CYCLE_BITS, *PPCI_TYPE0_CFG_CYCLE_BITS;
  558. typedef struct _PCI_TYPE1_CFG_CYCLE_BITS {
  559. union {
  560. struct {
  561. ULONG Reserved1:2;
  562. ULONG RegisterNumber:6;
  563. ULONG FunctionNumber:3;
  564. ULONG DeviceNumber:5;
  565. ULONG BusNumber:8;
  566. ULONG Reserved2:8;
  567. } bits;
  568. ULONG AsULONG;
  569. } u;
  570. } PCI_TYPE1_CFG_CYCLE_BITS, *PPCI_TYPE1_CFG_CYCLE_BITS;
  571. #endif