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.

494 lines
11 KiB

  1. //
  2. // Hal specific PCI bus structures
  3. //
  4. // Copyright (c) 1995-1999 Microsoft Corporation
  5. //
  6. typedef struct _TYPE2EXTRAS {
  7. USHORT SubVendorID;
  8. USHORT SubSystemID;
  9. ULONG LegacyModeBaseAddress;
  10. } TYPE2EXTRAS;
  11. typedef NTSTATUS
  12. (*PciIrqRange) (
  13. IN PBUS_HANDLER BusHandler,
  14. IN PBUS_HANDLER RootHandler,
  15. IN PCI_SLOT_NUMBER PciSlot,
  16. OUT PSUPPORTED_RANGE *Interrupt
  17. );
  18. typedef struct tagPCIPBUSDATA {
  19. //
  20. // Defined PCI data
  21. //
  22. PCIBUSDATA CommonData;
  23. //
  24. // Implementation specific data
  25. //
  26. union {
  27. struct {
  28. PULONG Address;
  29. ULONG Data;
  30. } Type1;
  31. struct {
  32. PUCHAR CSE;
  33. PUCHAR Forward;
  34. ULONG Base;
  35. } Type2;
  36. } Config;
  37. ULONG MaxDevice;
  38. PciIrqRange GetIrqRange;
  39. BOOLEAN BridgeConfigRead;
  40. UCHAR ParentBus;
  41. BOOLEAN Subtractive;
  42. UCHAR reserved[1];
  43. UCHAR SwizzleIn[4];
  44. RTL_BITMAP DeviceConfigured;
  45. ULONG ConfiguredBits[PCI_MAX_DEVICES * PCI_MAX_FUNCTION / 32];
  46. USHORT IrqMask;
  47. } PCIPBUSDATA, *PPCIPBUSDATA;
  48. #define PciBitIndex(Dev,Fnc) (Fnc*32 + Dev);
  49. #define PCI_CONFIG_TYPE(PciData) ((PciData)->HeaderType & ~PCI_MULTIFUNCTION)
  50. #define Is64BitBaseAddress(a) \
  51. (((a & PCI_ADDRESS_IO_SPACE) == 0) && \
  52. ((a & PCI_ADDRESS_MEMORY_TYPE_MASK) == PCI_TYPE_64BIT))
  53. //
  54. // Orion B0 errata workaround
  55. //
  56. struct {
  57. PBUS_HANDLER Handler;
  58. PCI_SLOT_NUMBER Slot;
  59. } HalpOrionOPB;
  60. typedef ULONG (*FncConfigIO) (
  61. IN PPCIPBUSDATA BusData,
  62. IN PVOID State,
  63. IN PUCHAR Buffer,
  64. IN ULONG Offset
  65. );
  66. typedef VOID (*FncSync) (
  67. IN PBUS_HANDLER BusHandler,
  68. IN PCI_SLOT_NUMBER Slot,
  69. IN PKIRQL Irql,
  70. IN PVOID State
  71. );
  72. typedef VOID (*FncReleaseSync) (
  73. IN PBUS_HANDLER BusHandler,
  74. IN KIRQL Irql
  75. );
  76. typedef struct _PCI_CONFIG_HANDLER {
  77. FncSync Synchronize;
  78. FncReleaseSync ReleaseSynchronzation;
  79. FncConfigIO ConfigRead[3];
  80. FncConfigIO ConfigWrite[3];
  81. } PCI_CONFIG_HANDLER, *PPCI_CONFIG_HANDLER;
  82. extern KSPIN_LOCK HalpPCIConfigLock;
  83. extern PCI_CONFIG_HANDLER PCIConfigHandler;
  84. extern const PCI_CONFIG_HANDLER PCIConfigHandlerType1;
  85. extern const PCI_CONFIG_HANDLER PCIConfigHandlerType2;
  86. //
  87. // Feature types (for PCI_CARD_DESCRIPTOR)
  88. //
  89. #define PCIFT_FULLDECODE_HOSTBRIDGE 0x00001
  90. //
  91. // Card flags (for PCI_CARD_DESCRIPTOR)
  92. //
  93. #define PCICF_CHECK_REVISIONID 0x10000
  94. #define PCICF_CHECK_SSVID 0x20000
  95. #define PCICF_CHECK_SSID 0x40000
  96. //
  97. // Description of a PCI card.
  98. //
  99. typedef struct _PCI_CARD_DESCRIPTOR {
  100. ULONG Flags;
  101. USHORT VendorID;
  102. USHORT DeviceID;
  103. USHORT RevisionID;
  104. USHORT SubsystemVendorID;
  105. USHORT SubsystemID;
  106. USHORT Reserved;
  107. } PCI_CARD_DESCRIPTOR;
  108. //
  109. // Superclass of PCI_REGISTRY_INFO
  110. //
  111. typedef struct _PCI_REGISTRY_INFO_INTERNAL {
  112. struct _PCI_REGISTRY_INFO; // unnamed structure.
  113. ULONG ElementCount;
  114. PCI_CARD_DESCRIPTOR CardList[]; // Zero entries.
  115. } PCI_REGISTRY_INFO_INTERNAL, *PPCI_REGISTRY_INFO_INTERNAL;
  116. //
  117. // The venerable IRQXOR has got to go, as it now has to extend into
  118. // the PCI driver. And that would require the PCI driver to match
  119. // the HAL in its checked/free nature.
  120. //
  121. //#if DBG
  122. //#define IRQXOR 0x2B
  123. //#else
  124. #define IRQXOR 0
  125. //#endif
  126. //
  127. // Prototypes for functions in ixpcibus.c
  128. //
  129. VOID
  130. HalpInitializePciBus (
  131. VOID
  132. );
  133. VOID
  134. HalpInitializePciStubs (
  135. VOID
  136. );
  137. PPCI_REGISTRY_INFO_INTERNAL
  138. HalpQueryPciRegistryInfo (
  139. VOID
  140. );
  141. BOOLEAN
  142. HalpIsRecognizedCard(
  143. IN PPCI_REGISTRY_INFO_INTERNAL PCIRegInfo,
  144. IN PPCI_COMMON_CONFIG PciData,
  145. IN ULONG FeatureMask
  146. );
  147. VOID
  148. HalpReadPCIConfig (
  149. IN PBUS_HANDLER BusHandler,
  150. IN PCI_SLOT_NUMBER Slot,
  151. IN PVOID Buffer,
  152. IN ULONG Offset,
  153. IN ULONG Length
  154. );
  155. VOID
  156. HalpWritePCIConfig (
  157. IN PBUS_HANDLER BusHandler,
  158. IN PCI_SLOT_NUMBER Slot,
  159. IN PVOID Buffer,
  160. IN ULONG Offset,
  161. IN ULONG Length
  162. );
  163. PBUS_HANDLER
  164. HalpAllocateAndInitPciBusHandler (
  165. IN ULONG HwType,
  166. IN ULONG BusNo,
  167. IN BOOLEAN TestAllocation
  168. );
  169. BOOLEAN
  170. HalpIsValidPCIDevice (
  171. IN PBUS_HANDLER BusHandler,
  172. IN PCI_SLOT_NUMBER Slot
  173. );
  174. BOOLEAN
  175. HalpValidPCISlot (
  176. IN PBUS_HANDLER BusHandler,
  177. IN PCI_SLOT_NUMBER Slot
  178. );
  179. VOID HalpPCISynchronizeType1 (
  180. IN PBUS_HANDLER BusHandler,
  181. IN PCI_SLOT_NUMBER Slot,
  182. IN PKIRQL Irql,
  183. IN PVOID State
  184. );
  185. VOID HalpPCIReleaseSynchronzationType1 (
  186. IN PBUS_HANDLER BusHandler,
  187. IN KIRQL Irql
  188. );
  189. VOID
  190. HalpPCISynchronizeOrionB0 (
  191. IN PBUS_HANDLER BusHandler,
  192. IN PCI_SLOT_NUMBER Slot,
  193. IN PKIRQL Irql,
  194. IN PPCI_TYPE1_CFG_BITS PciCfg1
  195. );
  196. VOID
  197. HalpPCIReleaseSynchronzationOrionB0 (
  198. IN PBUS_HANDLER BusHandler,
  199. IN KIRQL Irql
  200. );
  201. ULONG HalpPCIReadUlongType1 (
  202. IN PPCIPBUSDATA BusData,
  203. IN PVOID State,
  204. IN PUCHAR Buffer,
  205. IN ULONG Offset
  206. );
  207. ULONG HalpPCIReadUcharType1 (
  208. IN PPCIPBUSDATA BusData,
  209. IN PVOID State,
  210. IN PUCHAR Buffer,
  211. IN ULONG Offset
  212. );
  213. ULONG HalpPCIReadUshortType1 (
  214. IN PPCIPBUSDATA BusData,
  215. IN PVOID State,
  216. IN PUCHAR Buffer,
  217. IN ULONG Offset
  218. );
  219. ULONG HalpPCIWriteUlongType1 (
  220. IN PPCIPBUSDATA BusData,
  221. IN PVOID State,
  222. IN PUCHAR Buffer,
  223. IN ULONG Offset
  224. );
  225. ULONG HalpPCIWriteUcharType1 (
  226. IN PPCIPBUSDATA BusData,
  227. IN PVOID State,
  228. IN PUCHAR Buffer,
  229. IN ULONG Offset
  230. );
  231. ULONG HalpPCIWriteUshortType1 (
  232. IN PPCIPBUSDATA BusData,
  233. IN PVOID State,
  234. IN PUCHAR Buffer,
  235. IN ULONG Offset
  236. );
  237. VOID HalpPCISynchronizeType2 (
  238. IN PBUS_HANDLER BusHandler,
  239. IN PCI_SLOT_NUMBER Slot,
  240. IN PKIRQL Irql,
  241. IN PVOID State
  242. );
  243. VOID HalpPCIReleaseSynchronzationType2 (
  244. IN PBUS_HANDLER BusHandler,
  245. IN KIRQL Irql
  246. );
  247. ULONG HalpPCIReadUlongType2 (
  248. IN PPCIPBUSDATA BusData,
  249. IN PVOID State,
  250. IN PUCHAR Buffer,
  251. IN ULONG Offset
  252. );
  253. ULONG HalpPCIReadUcharType2 (
  254. IN PPCIPBUSDATA BusData,
  255. IN PVOID State,
  256. IN PUCHAR Buffer,
  257. IN ULONG Offset
  258. );
  259. ULONG HalpPCIReadUshortType2 (
  260. IN PPCIPBUSDATA BusData,
  261. IN PVOID State,
  262. IN PUCHAR Buffer,
  263. IN ULONG Offset
  264. );
  265. ULONG HalpPCIWriteUlongType2 (
  266. IN PPCIPBUSDATA BusData,
  267. IN PVOID State,
  268. IN PUCHAR Buffer,
  269. IN ULONG Offset
  270. );
  271. ULONG HalpPCIWriteUcharType2 (
  272. IN PPCIPBUSDATA BusData,
  273. IN PVOID State,
  274. IN PUCHAR Buffer,
  275. IN ULONG Offset
  276. );
  277. ULONG HalpPCIWriteUshortType2 (
  278. IN PPCIPBUSDATA BusData,
  279. IN PVOID State,
  280. IN PUCHAR Buffer,
  281. IN ULONG Offset
  282. );
  283. ULONG
  284. HalpGetPCIData (
  285. IN PBUS_HANDLER BusHandler,
  286. IN PBUS_HANDLER RootHandler,
  287. IN PCI_SLOT_NUMBER SlotNumber,
  288. IN PVOID Buffer,
  289. IN ULONG Offset,
  290. IN ULONG Length
  291. );
  292. ULONG
  293. HalpSetPCIData (
  294. IN PBUS_HANDLER BusHandler,
  295. IN PBUS_HANDLER RootHandler,
  296. IN PCI_SLOT_NUMBER SlotNumber,
  297. IN PVOID Buffer,
  298. IN ULONG Offset,
  299. IN ULONG Length
  300. );
  301. NTSTATUS
  302. HalpAssignPCISlotResources (
  303. IN PBUS_HANDLER BusHandler,
  304. IN PBUS_HANDLER RootHandler,
  305. IN PUNICODE_STRING RegistryPath,
  306. IN PUNICODE_STRING DriverClassName OPTIONAL,
  307. IN PDRIVER_OBJECT DriverObject,
  308. IN PDEVICE_OBJECT DeviceObject OPTIONAL,
  309. IN ULONG SlotNumber,
  310. IN OUT PCM_RESOURCE_LIST *AllocatedResources
  311. );
  312. //
  313. // Prototypes for functions in ixpciint.c
  314. //
  315. ULONG
  316. HalpGetPCIIntOnISABus (
  317. IN PBUS_HANDLER BusHandler,
  318. IN PBUS_HANDLER RootHandler,
  319. IN ULONG BusInterruptLevel,
  320. IN ULONG BusInterruptVector,
  321. OUT PKIRQL Irql,
  322. OUT PKAFFINITY Affinity
  323. );
  324. VOID
  325. HalpPCIAcquireType2Lock (
  326. PKSPIN_LOCK SpinLock,
  327. PKIRQL Irql
  328. );
  329. VOID
  330. HalpPCIReleaseType2Lock (
  331. PKSPIN_LOCK SpinLock,
  332. KIRQL Irql
  333. );
  334. NTSTATUS
  335. HalpAdjustPCIResourceList (
  336. IN PBUS_HANDLER BusHandler,
  337. IN PBUS_HANDLER RootHandler,
  338. IN OUT PIO_RESOURCE_REQUIREMENTS_LIST *pResourceList
  339. );
  340. VOID
  341. HalpPCIPin2ISALine (
  342. IN PBUS_HANDLER BusHandler,
  343. IN PBUS_HANDLER RootHandler,
  344. IN PCI_SLOT_NUMBER SlotNumber,
  345. IN PPCI_COMMON_CONFIG PciData
  346. );
  347. VOID
  348. HalpPCIISALine2Pin (
  349. IN PBUS_HANDLER BusHandler,
  350. IN PBUS_HANDLER RootHandler,
  351. IN PCI_SLOT_NUMBER SlotNumber,
  352. IN PPCI_COMMON_CONFIG PciNewData,
  353. IN PPCI_COMMON_CONFIG PciOldData
  354. );
  355. NTSTATUS
  356. HalpGetISAFixedPCIIrq (
  357. IN PBUS_HANDLER BusHandler,
  358. IN PBUS_HANDLER RootHandler,
  359. IN PCI_SLOT_NUMBER PciSlot,
  360. OUT PSUPPORTED_RANGE *Interrupt
  361. );
  362. //
  363. // Prototypes for functions in ixpcibrd.c
  364. //
  365. BOOLEAN
  366. HalpGetPciBridgeConfig (
  367. IN ULONG HwType,
  368. IN PUCHAR MaxPciBus
  369. );
  370. VOID
  371. HalpFixupPciSupportedRanges (
  372. IN ULONG MaxBuses
  373. );
  374. //
  375. // Prototypes for functions in pmpcisup.c
  376. //
  377. ULONG
  378. HaliPciInterfaceReadConfig(
  379. IN PVOID Context,
  380. IN UCHAR BusOffset,
  381. IN ULONG Slot,
  382. IN PVOID Buffer,
  383. IN ULONG Offset,
  384. IN ULONG Length
  385. );
  386. ULONG
  387. HaliPciInterfaceWriteConfig(
  388. IN PVOID Context,
  389. IN UCHAR BusOffset,
  390. IN ULONG Slot,
  391. IN PVOID Buffer,
  392. IN ULONG Offset,
  393. IN ULONG Length
  394. );
  395. #if DBG
  396. #define DBGMSG(a) DbgPrint(a)
  397. VOID
  398. HalpTestPci (
  399. ULONG
  400. );
  401. #else
  402. #define DBGMSG(a)
  403. #endif
  404. #ifdef SUBCLASSPCI
  405. VOID
  406. HalpSubclassPCISupport (
  407. IN PBUS_HANDLER BusHandler,
  408. IN ULONG HwType
  409. );
  410. #endif