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.

400 lines
7.1 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. pciirqmp.c
  5. Abstract:
  6. This is the PCI IRQ Miniport library.
  7. Author:
  8. Santosh Jodh (santoshj) 09-June-1998
  9. Environment:
  10. kernel mode only
  11. Revision History:
  12. --*/
  13. #include "local.h"
  14. #define NUMBER_OF_CHIPSETS (sizeof(rgChipData) / sizeof(CHIPSET_DATA))
  15. #ifdef ALLOC_DATA_PRAGMA
  16. #pragma data_seg()
  17. #pragma const_seg()
  18. #endif
  19. //
  20. // Table of chipset drivers.
  21. //
  22. const CHIPSET_DATA rgChipData[] = {
  23. DECLARE_EISA_CHIPSET(Mercury), // Intel 82374EB\SB (80860482)
  24. DECLARE_EISA_CHIPSET(Triton), // Intel 82430FX (8086122E)
  25. DECLARE_CHIPSET(VLSI), // VLSI VL82C596/7
  26. DECLARE_CHIPSET(OptiViper), // OPTi Viper-M
  27. DECLARE_EISA_CHIPSET(SiS5503), // SIS P54C
  28. DECLARE_CHIPSET(VLSIEagle), // VLSI VL82C534
  29. DECLARE_EISA_CHIPSET(M1523), // ALi M1523
  30. DECLARE_CHIPSET(NS87560), // Nat Semi NS87560
  31. DECLARE_EISA_CHIPSET(Compaq3), // Compaq MISC 3
  32. DECLARE_EISA_CHIPSET(M1533), // ALi M1533
  33. DECLARE_CHIPSET(OptiFireStar), // OPTI FIRESTAR
  34. DECLARE_EISA_CHIPSET(VT586), // VIATECH 82C586B
  35. DECLARE_EISA_CHIPSET(CPQOSB), // Conpaq OSB
  36. DECLARE_EISA_CHIPSET(CPQ1000), // Conpaq 1000
  37. DECLARE_EISA_CHIPSET(Cx5520), // Cyrix 5520
  38. DECLARE_CHIPSET(Toshiba), // Toshiba
  39. DECLARE_CHIPSET(NEC), // NEC PC9800
  40. DECLARE_CHIPSET(VESUVIUS) //
  41. };
  42. //
  43. // Global variables shared by all modules.
  44. //
  45. ULONG bBusPIC = -1;
  46. ULONG bDevFuncPIC = -1;
  47. CHIPSET_DATA const* rgChipSet = NULL;
  48. #ifdef ALLOC_PRAGMA
  49. #pragma alloc_text(INIT, PciirqmpInit)
  50. #pragma alloc_text(INIT, PciirqmpExit)
  51. #pragma alloc_text(INIT, PciirqmpValidateTable)
  52. #endif //ALLOC_PRAGMA
  53. NTSTATUS
  54. PciirqmpInit (
  55. ULONG Instance,
  56. ULONG RouterBus,
  57. ULONG RouterDevFunc
  58. )
  59. /*++
  60. Routine Description:
  61. This routine initializes calls the individual chipset handler
  62. to validate the Pci Irq Routing Table.
  63. Parameters:
  64. PciIrqRoutingTable - Pci Irq Routing Table.
  65. Flags - Flags specifying source of the Pci Irq Routing Table.
  66. Return Value:
  67. Standard Pci Irq Miniport return value.
  68. Notes:
  69. --*/
  70. {
  71. PAGED_CODE();
  72. //
  73. // Check to make sure that we are not already initialized.
  74. //
  75. if (rgChipSet != NULL)
  76. {
  77. PCIIRQMPPRINT(("IRQ miniport already initialized!"));
  78. return (PCIIRQMP_STATUS_ALREADY_INITIALIZED);
  79. }
  80. //
  81. // Check for invalid instance.
  82. //
  83. if (Instance >= NUMBER_OF_CHIPSETS)
  84. {
  85. PCIIRQMPPRINT(("Invalid IRQ miniport instance %08X", Instance));
  86. return (PCIIRQMP_STATUS_INVALID_INSTANCE);
  87. }
  88. //
  89. // Save our global data.
  90. //
  91. rgChipSet = &rgChipData[Instance];
  92. bBusPIC = RouterBus;
  93. bDevFuncPIC = RouterDevFunc;
  94. return (PCIMP_SUCCESS);
  95. }
  96. NTSTATUS
  97. PciirqmpExit (
  98. VOID
  99. )
  100. /*++
  101. Routine Description:
  102. This routine cleans up after the Pci Irq Routing miniport library.
  103. Parameters:
  104. None.
  105. Return Value:
  106. Standard Pci Irq Miniport return value.
  107. Notes:
  108. --*/
  109. {
  110. PAGED_CODE();
  111. //
  112. // Were we ever initialized?
  113. //
  114. if (rgChipSet == NULL)
  115. {
  116. PCIIRQMPPRINT(("Cannot exit without having been initialized!"));
  117. return (PCIIRQMP_STATUS_NOT_INITIALIZED);
  118. }
  119. //
  120. // Clean up.
  121. //
  122. rgChipSet = NULL;
  123. bBusPIC = -1;
  124. bDevFuncPIC = -1;
  125. return (PCIMP_SUCCESS);
  126. }
  127. NTSTATUS
  128. PciirqmpValidateTable (
  129. IN PPCI_IRQ_ROUTING_TABLE PciIrqRoutingTable,
  130. IN ULONG Flags
  131. )
  132. /*++
  133. Routine Description:
  134. This routine normalizes calls the individual chipset handler
  135. to validate the Pci Irq Routing Table.
  136. Parameters:
  137. PciIrqRoutingTable - Pci Irq Routing Table.
  138. Flags - Flags specifying source of the Pci Irq Routing Table.
  139. Return Value:
  140. Standard Pci Irq Miniport return value.
  141. Notes:
  142. --*/
  143. {
  144. PAGED_CODE();
  145. //
  146. // Were we ever initialized?
  147. //
  148. if (rgChipSet == NULL)
  149. {
  150. PCIIRQMPPRINT(("Not initialized yet!"));
  151. return (PCIIRQMP_STATUS_NOT_INITIALIZED);
  152. }
  153. //
  154. // Call the chipset handler.
  155. //
  156. return (rgChipSet->ValidateTable(PciIrqRoutingTable, Flags));
  157. }
  158. NTSTATUS
  159. PciirqmpGetIrq (
  160. OUT PUCHAR Irq,
  161. IN UCHAR Link
  162. )
  163. /*++
  164. Routine Description:
  165. This routine calls the individual chipset handler
  166. to set the link to the specified Irq.
  167. Parameters:
  168. Irq - Variable that receives the Irq.
  169. Link - Link to be read.
  170. Return Value:
  171. Standard Pci Irq Miniport return value.
  172. Notes:
  173. --*/
  174. {
  175. //
  176. // Were we ever initialized?
  177. //
  178. if (rgChipSet == NULL)
  179. {
  180. PCIIRQMPPRINT(("Not initialized yet!"));
  181. return (PCIIRQMP_STATUS_NOT_INITIALIZED);
  182. }
  183. //
  184. // Call the chipset handler.
  185. //
  186. return (rgChipSet->GetIrq(Irq, Link));
  187. }
  188. NTSTATUS
  189. PciirqmpSetIrq (
  190. IN UCHAR Irq,
  191. IN UCHAR Link
  192. )
  193. /*++
  194. Routine Description:
  195. This routine calls the individual chipset handler
  196. to set the link to the specified Irq.
  197. Parameters:
  198. Irq - Irq to be set.
  199. Link - Link to be programmed.
  200. Return Value:
  201. Standard Pci Irq Miniport return value.
  202. Notes:
  203. --*/
  204. {
  205. //
  206. // Were we ever initialized?
  207. //
  208. if (rgChipSet == NULL)
  209. {
  210. PCIIRQMPPRINT(("Not initialized yet!"));
  211. return (PCIIRQMP_STATUS_NOT_INITIALIZED);
  212. }
  213. //
  214. // Call the chipset handler.
  215. //
  216. return (rgChipSet->SetIrq(Irq, Link));
  217. }
  218. NTSTATUS
  219. PciirqmpGetTrigger (
  220. OUT PULONG Trigger
  221. )
  222. /*++
  223. Routine Description:
  224. This routine calls the individual chipset handler
  225. to get the interrupt edge\level mask.
  226. Parameters:
  227. Trigger - Variable that receives edge\level mask.
  228. Return Value:
  229. Standard Pci Irq Miniport return value.
  230. Notes:
  231. --*/
  232. {
  233. //
  234. // Were we ever initialized?
  235. //
  236. if (rgChipSet == NULL)
  237. {
  238. PCIIRQMPPRINT(("Not initialized yet!"));
  239. return (PCIIRQMP_STATUS_NOT_INITIALIZED);
  240. }
  241. //
  242. // Call the chipset handler.
  243. //
  244. return (rgChipSet->GetTrigger(Trigger));
  245. }
  246. NTSTATUS
  247. PciirqmpSetTrigger (
  248. IN ULONG Trigger
  249. )
  250. /*++
  251. Routine Description:
  252. This routine calls the individual chipset handler
  253. to set the interrupt edge\level mask.
  254. Parameters:
  255. Trigger - Edge\level mask to be set.
  256. Return Value:
  257. Standard Pci Irq Miniport return value.
  258. Notes:
  259. --*/
  260. {
  261. //
  262. // Were we ever initialized?
  263. //
  264. if (rgChipSet == NULL)
  265. {
  266. PCIIRQMPPRINT(("Not initialized yet!"));
  267. return (PCIIRQMP_STATUS_NOT_INITIALIZED);
  268. }
  269. //
  270. // Call the chipset handler and return the result.
  271. //
  272. return (rgChipSet->SetTrigger(Trigger));
  273. }