Windows NT 4.0 source code leak
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.

551 lines
11 KiB

4 years ago
  1. /*++
  2. Copyright (c) 1993 Digital Equipment Corporation
  3. Module Name:
  4. mkinitnt.c
  5. Abstract:
  6. This module implements the HAL enable/disable system interrupt, and
  7. request interprocessor interrupt routines for the Mikasa system.
  8. Author:
  9. Joe Notarangelo 25-Oct-1993
  10. Environment:
  11. Kernel mode
  12. Revision History:
  13. James Livingston 29-Apr-1994
  14. Adapted from Avanti module for Mikasa.
  15. Janet Schneider (Digital) 27-July-1995
  16. Added support for the Noritake.
  17. --*/
  18. #include "halp.h"
  19. #include "mikasa.h"
  20. #include "axp21064.h"
  21. //
  22. // Function prototype
  23. //
  24. VOID
  25. HalpDisableMikasaPciInterrupt(
  26. IN ULONG Vector
  27. );
  28. VOID
  29. HalpDisableNoritakePciInterrupt(
  30. IN ULONG Vector
  31. );
  32. VOID
  33. HalpEnableMikasaPciInterrupt(
  34. IN ULONG Vector,
  35. IN KINTERRUPT_MODE InterruptMode
  36. );
  37. VOID
  38. HalpEnableNoritakePciInterrupt(
  39. IN ULONG Vector,
  40. IN KINTERRUPT_MODE InterruptMode
  41. );
  42. VOID
  43. HalpSetMachineCheckEnables(
  44. IN BOOLEAN DisableMachineChecks,
  45. IN BOOLEAN DisableProcessorCorrectables,
  46. IN BOOLEAN DisableSystemCorrectables
  47. );
  48. //
  49. // Define reference to the builtin device interrupt enables.
  50. //
  51. extern USHORT HalpBuiltinInterruptEnable;
  52. //
  53. // Define reference to platform identifier
  54. //
  55. extern BOOLEAN HalpNoritakePlatform;
  56. VOID
  57. HalDisableSystemInterrupt (
  58. IN ULONG Vector,
  59. IN KIRQL Irql
  60. )
  61. /*++
  62. Routine Description:
  63. This routine disables the specified system interrupt.
  64. Arguments:
  65. Vector - Supplies the vector of the system interrupt that is disabled.
  66. Irql - Supplies the IRQL of the interrupting source.
  67. Return Value:
  68. None.
  69. --*/
  70. {
  71. KIRQL OldIrql;
  72. //
  73. // Raise IRQL to the highest level.
  74. //
  75. KeRaiseIrql(HIGH_LEVEL, &OldIrql);
  76. //
  77. // If the vector number is within the range of the EISA interrupts, then
  78. // disable the EISA interrrupt.
  79. //
  80. if (Vector >= EISA_VECTORS &&
  81. Vector < MAXIMUM_EISA_VECTOR &&
  82. Irql == EISA_DEVICE_LEVEL) {
  83. HalpDisableEisaInterrupt(Vector);
  84. }
  85. //
  86. // If the vector number is within the range of the PCI interrupts, then
  87. // disable the PCI interrrupt.
  88. //
  89. if (Vector >= PCI_VECTORS &&
  90. Vector < MAXIMUM_PCI_VECTOR &&
  91. Irql == PCI_DEVICE_LEVEL) {
  92. if( HalpNoritakePlatform ) {
  93. HalpDisableNoritakePciInterrupt(Vector);
  94. } else {
  95. HalpDisableMikasaPciInterrupt(Vector);
  96. }
  97. }
  98. //
  99. // If the vector is a performance counter vector or one of the internal
  100. // device vectors then disable the interrupt for the 21064.
  101. //
  102. switch (Vector) {
  103. //
  104. // Performance counter 0 interrupt (internal to 21064)
  105. //
  106. case PC0_VECTOR:
  107. case PC0_SECONDARY_VECTOR:
  108. HalpDisable21064PerformanceInterrupt( PC0_VECTOR );
  109. break;
  110. //
  111. // Performance counter 1 interrupt (internal to 21064)
  112. //
  113. case PC1_VECTOR:
  114. case PC1_SECONDARY_VECTOR:
  115. HalpDisable21064PerformanceInterrupt( PC1_VECTOR );
  116. break;
  117. case CORRECTABLE_VECTOR:
  118. //
  119. // Disable the correctable error interrupt.
  120. //
  121. {
  122. EPIC_ECSR Ecsr;
  123. Ecsr.all = READ_EPIC_REGISTER(
  124. &((PEPIC_CSRS)(APECS_EPIC_BASE_QVA))->EpicControlAndStatusRegister );
  125. Ecsr.Dcei = 0x0;
  126. WRITE_EPIC_REGISTER(
  127. &((PEPIC_CSRS)(APECS_EPIC_BASE_QVA))->EpicControlAndStatusRegister,
  128. Ecsr.all );
  129. HalpSetMachineCheckEnables( FALSE, TRUE, TRUE );
  130. }
  131. break;
  132. } //end switch Vector
  133. //
  134. // Lower IRQL to the previous level.
  135. //
  136. KeLowerIrql(OldIrql);
  137. return;
  138. }
  139. BOOLEAN
  140. HalEnableSystemInterrupt (
  141. IN ULONG Vector,
  142. IN KIRQL Irql,
  143. IN KINTERRUPT_MODE InterruptMode
  144. )
  145. /*++
  146. Routine Description:
  147. This routine enables the specified system interrupt.
  148. Arguments:
  149. Vector - Supplies the vector of the system interrupt that is enabled.
  150. Irql - Supplies the IRQL of the interrupting source.
  151. InterruptMode - Supplies the mode of the interrupt; LevelSensitive or
  152. Latched.
  153. Return Value:
  154. TRUE if the system interrupt was enabled
  155. --*/
  156. {
  157. BOOLEAN Enabled = FALSE;
  158. KIRQL OldIrql;
  159. //
  160. // Raise IRQL to the highest level.
  161. //
  162. KeRaiseIrql(HIGH_LEVEL, &OldIrql);
  163. //
  164. // If the vector number is within the range of the EISA interrupts, then
  165. // enable the EISA interrrupt and set the Level/Edge register.
  166. //
  167. if (Vector >= EISA_VECTORS &&
  168. Vector < MAXIMUM_EISA_VECTOR &&
  169. Irql == EISA_DEVICE_LEVEL) {
  170. HalpEnableEisaInterrupt( Vector, InterruptMode );
  171. Enabled = TRUE;
  172. }
  173. //
  174. // If the vector number is within the range of the PCI interrupts, then
  175. // enable the PCI interrrupt.
  176. //
  177. if (Vector >= PCI_VECTORS &&
  178. Vector < MAXIMUM_PCI_VECTOR &&
  179. Irql == PCI_DEVICE_LEVEL) {
  180. if( HalpNoritakePlatform ) {
  181. HalpEnableNoritakePciInterrupt( Vector, InterruptMode );
  182. } else {
  183. HalpEnableMikasaPciInterrupt( Vector, InterruptMode );
  184. }
  185. Enabled = TRUE;
  186. }
  187. //
  188. // If the vector is a performance counter vector or one of the
  189. // internal device vectors then perform 21064-specific enable.
  190. //
  191. switch (Vector) {
  192. //
  193. // Performance counter 0 (internal to 21064)
  194. //
  195. case PC0_VECTOR:
  196. case PC0_SECONDARY_VECTOR:
  197. HalpEnable21064PerformanceInterrupt( PC0_VECTOR, Irql );
  198. Enabled = TRUE;
  199. break;
  200. //
  201. // Performance counter 1 (internal to 21064)
  202. //
  203. case PC1_VECTOR:
  204. case PC1_SECONDARY_VECTOR:
  205. HalpEnable21064PerformanceInterrupt( PC1_VECTOR, Irql );
  206. Enabled = TRUE;
  207. break;
  208. case CORRECTABLE_VECTOR:
  209. //
  210. // Enable the correctable error interrupt.
  211. //
  212. {
  213. EPIC_ECSR Ecsr;
  214. Ecsr.all = READ_EPIC_REGISTER(
  215. &((PEPIC_CSRS)(APECS_EPIC_BASE_QVA))->EpicControlAndStatusRegister );
  216. Ecsr.Dcei = 0x1;
  217. WRITE_EPIC_REGISTER(
  218. &((PEPIC_CSRS)(APECS_EPIC_BASE_QVA))->EpicControlAndStatusRegister,
  219. Ecsr.all );
  220. HalpSetMachineCheckEnables( FALSE, FALSE, FALSE );
  221. }
  222. Enabled = TRUE;
  223. break;
  224. } //end switch Vector
  225. //
  226. // Lower IRQL to the previous level.
  227. //
  228. KeLowerIrql(OldIrql);
  229. return Enabled;
  230. }
  231. ULONG
  232. HalpGetSystemInterruptVector(
  233. IN PBUS_HANDLER BusHandler,
  234. IN PBUS_HANDLER RootHandler,
  235. IN ULONG BusInterruptLevel,
  236. IN ULONG BusInterruptVector,
  237. OUT PKIRQL Irql,
  238. OUT PKAFFINITY Affinity
  239. )
  240. /*++
  241. Routine Description:
  242. This function returns the system interrupt vector and IRQL level
  243. corresponding to the specified bus interrupt level and/or vector. The
  244. system interrupt vector and IRQL are suitable for use in a subsequent
  245. call to KeInitializeInterrupt.
  246. We only use InterfaceType and BusInterruptLevel. BusInterruptVector
  247. for EISA and ISA are the same as the InterruptLevel, so ignore.
  248. jwlfix - How does the above apply to PCI when it's done as in Mikasa? I've
  249. made the assumption the the same is true, but that must be checked.
  250. Arguments:
  251. BusHandler - Registered BUSHANDLER for the target configuration space
  252. RootHandler - Registered BUSHANDLER for the orginating HalGetBusData
  253. request.
  254. BusInterruptLevel - Supplies the bus-specific interrupt level.
  255. BusInterruptVector - Supplies the bus-specific interrupt vector.
  256. Irql - Returns the system request priority.
  257. Affinity - Returns the affinity for the requested vector
  258. Return Value:
  259. Returns the system interrupt vector corresponding to the specified device.
  260. --*/
  261. {
  262. INTERFACE_TYPE InterfaceType = BusHandler->InterfaceType;
  263. ULONG BusNumber = BusHandler->BusNumber;
  264. ULONG Vector;
  265. *Affinity = 1;
  266. switch (InterfaceType) {
  267. case ProcessorInternal:
  268. //
  269. // Handle the internal defined for the processor itself
  270. // and used to control the performance counters in the 21064.
  271. //
  272. if( (Vector = HalpGet21064PerformanceVector( BusInterruptLevel,
  273. Irql)) != 0 ){
  274. //
  275. // Performance counter was successfully recognized.
  276. //
  277. *Affinity = HalpActiveProcessors;
  278. return Vector;
  279. } else if ((Vector = HalpGet21064CorrectableVector( BusInterruptLevel,
  280. Irql)) != 0 ){
  281. //
  282. // Correctable error interrupt was sucessfully recognized.
  283. //
  284. *Affinity = 1;
  285. return Vector;
  286. } else {
  287. //
  288. // Unrecognized processor interrupt.
  289. //
  290. *Irql = 0;
  291. *Affinity = 0;
  292. return 0;
  293. } //end if Vector
  294. break;
  295. case Internal:
  296. //
  297. // This bus type is for things connected to the processor
  298. // in some way other than a standard bus, e.g., (E)ISA, PCI.
  299. // Since devices on this "bus," apart from the special case of
  300. // the processor, above, interrupt via the 82c59 cascade in the
  301. // ESC, we assign vectors based on (E)ISA_VECTORS - see below.
  302. // Firmware must agree on these vectors, as it puts them in
  303. // the CDS.
  304. //
  305. *Irql = ISA_DEVICE_LEVEL;
  306. return(BusInterruptLevel + ISA_VECTORS);
  307. break;
  308. case Isa:
  309. //
  310. // Assumes all ISA devices coming in on same processor pin
  311. //
  312. *Irql = ISA_DEVICE_LEVEL;
  313. //
  314. // The vector is equal to the specified bus level plus ISA_VECTORS.
  315. // N.B.: this encoding technique uses the notion of defining a
  316. // base interrupt vector in the space defined by the constant,
  317. // ISA_VECTORS, which may or may not differ from EISA_VECTORS or
  318. // PCI_VECTORS.
  319. //
  320. return(BusInterruptLevel + ISA_VECTORS);
  321. break;
  322. case Eisa:
  323. //
  324. // Assumes all EISA devices coming in on same processor pin
  325. //
  326. *Irql = EISA_DEVICE_LEVEL;
  327. //
  328. // The vector is equal to the specified bus level plus the EISA_VECTOR.
  329. //
  330. return(BusInterruptLevel + EISA_VECTORS);
  331. break;
  332. case PCIBus:
  333. //
  334. // Assumes all PCI devices coming in on same processor pin
  335. //
  336. *Irql = PCI_DEVICE_LEVEL;
  337. //
  338. // The vector is equal to the specified bus level plus the PCI_VECTOR
  339. //
  340. return((BusInterruptLevel) + PCI_VECTORS);
  341. break;
  342. default:
  343. //
  344. // Not an interface supported on Mikasa systems.
  345. //
  346. #if defined(HALDBG)
  347. DbgPrint("MKSYSINT: InterfaceType (%d) not supported on Mikasa\r\n",
  348. InterfaceType);
  349. #endif
  350. *Irql = 0;
  351. *Affinity = 0;
  352. return(0);
  353. break;
  354. } //end switch(InterfaceType)
  355. }
  356. VOID
  357. HalRequestIpi (
  358. IN ULONG Mask
  359. )
  360. /*++
  361. Routine Description:
  362. This routine requests an interprocessor interrupt on a set of processors.
  363. This routine performs no function on an Mikasa because it is a
  364. uni-processor system.
  365. Arguments:
  366. Mask - Supplies the set of processors that are sent an interprocessor
  367. interrupt.
  368. Return Value:
  369. None.
  370. --*/
  371. {
  372. return;
  373. }