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.

621 lines
15 KiB

4 years ago
  1. /* #pragma comment(exestr, "@(#) NEC(MIPS) r94anmi.s 1.2 95/10/17 01:19:11" ) */
  2. //
  3. // TITLE("R94A NMI routine")
  4. //++
  5. //
  6. // Copyright (c) 1995 NEC Corporation
  7. //
  8. // Module Name:
  9. //
  10. // r94anmi.s
  11. //
  12. // Abstract:
  13. //
  14. // This routine support for dump switch.
  15. //
  16. // Author:
  17. //
  18. // Akitoshi Kuriyama (NEC Software Kobe,Inc)
  19. //
  20. // Environment:
  21. //
  22. // Kernel mode only.
  23. //
  24. // R4400 based only.
  25. //
  26. // Revision History:
  27. //
  28. // [email protected] Sun Oct 15 20:11:38 JST 1995
  29. // - new code for J94D (!_MRCDUMP_ _MRCPOWER_ compile option need)
  30. //
  31. //--
  32. #include "halmips.h"
  33. SBTTL("NMI dispatch routine")
  34. //++
  35. //
  36. // VOID
  37. // HalpNMIDispatch (
  38. // VOID
  39. // )
  40. //
  41. // Routine Description:
  42. //
  43. // This function was called by firmware when NMI occuerd.
  44. //
  45. // Arguments:
  46. //
  47. // none.
  48. //
  49. // Return Value:
  50. //
  51. // none.
  52. //
  53. //--
  54. LEAF_ENTRY(HalpNMIDispatch)
  55. .set noreorder
  56. .set noat
  57. //
  58. // Save temporary Registers for use.
  59. // save area shoud have for every processros.
  60. //
  61. li k0,0xffffc070 // get processor number.
  62. lw k0,(k0) //
  63. bne k0,zero,10f //
  64. nop // fill
  65. la k1,HalpNMISave0 // set save address.
  66. j 20f //
  67. nop // fill
  68. 10:
  69. la k1,HalpNMISave1 // set save address.
  70. nop // 1 cycle hazzerd
  71. 20:
  72. sw AT,0x0(k1) // register save.
  73. sw v0,0x4(k1) //
  74. sw v1,0x8(k1) //
  75. sw a0,0xc(k1) //
  76. sw a1,0x10(k1) //
  77. sw a2,0x14(k1) //
  78. sw a3,0x18(k1) //
  79. sw t0,0x1c(k1) //
  80. sw t1,0x20(k1) //
  81. sw t2,0x24(k1) //
  82. sw t3,0x28(k1) //
  83. sw t4,0x2c(k1) //
  84. sw t5,0x30(k1) //
  85. sw t6,0x34(k1) //
  86. sw t7,0x38(k1) //
  87. sw t8,0x3c(k1) //
  88. sw t9,0x40(k1) //
  89. sw gp,0x44(k1) //
  90. sw sp,0x48(k1) //
  91. sw s8,0x4c(k1) //
  92. sw ra,0x50(k1) //
  93. mfc0 k0,psr //
  94. nop //
  95. nop //
  96. sw k0,0x54(k1) //
  97. nop //
  98. mfc0 k0,cause //
  99. nop //
  100. nop //
  101. sw k0,0x58(k1) //
  102. nop //
  103. mfc0 k0,epc //
  104. nop //
  105. nop //
  106. sw k0,0x5c(k1) //
  107. nop //
  108. mfc0 k0,errorepc //
  109. nop //
  110. nop //
  111. sw k0,0x60(k1) //
  112. nop //
  113. mfc0 k0,cacheerr //
  114. nop //
  115. nop //
  116. sw k0,0x64(k1) //
  117. sdc1 f0,0x68(k1) //
  118. //
  119. // Set Dump Switch Status register to tlb fixed entry
  120. //
  121. li t0,4 // set index 4(hurricane register)
  122. li t1,0x80012 << 6 // set MRC register
  123. li t2,0x8000e << 6 // set Self-Test address
  124. mfc0 t3,index // save tlb registers
  125. mfc0 t4,entryhi //
  126. mfc0 t5,entrylo0 //
  127. mfc0 t6,entrylo1 //
  128. mfc0 t7,pagemask //
  129. mtc0 t0,index //
  130. nop
  131. nop
  132. nop
  133. tlbr // read index 4 tlb
  134. nop
  135. nop
  136. nop
  137. nop
  138. mfc0 t8,entrylo0 // Get entrylo0
  139. mfc0 t9,entrylo1 // Get entrylo1
  140. nop
  141. nop
  142. nop
  143. or t1,t8,t1 // set MRC address
  144. or t2,t8,t2 // set Self-test address
  145. nop
  146. mtc0 t1,entrylo0 // set MRC to tlb 4 0
  147. mtc0 t2,entrylo1 // set Self-test to tlb 4 1
  148. nop //
  149. nop //
  150. nop //
  151. nop //
  152. tlbwi // write to tlb entry
  153. nop //
  154. nop //
  155. nop //
  156. nop //
  157. //
  158. // read dump status
  159. //
  160. #if defined(_MRCDUMP_)
  161. li t1,0xffffc108 // load MRC Mode value
  162. #else // SELFTEST DUMP
  163. li t1,0xffffd000 // load Self-Test value
  164. li k0,0x1b // set dash
  165. sb k0,(t1) // display led
  166. sync
  167. #endif // _MRCDUMP_
  168. lb k0,(t1) // load Dump switch status.
  169. nop //
  170. lb k0,(t1) // wait
  171. nop //
  172. //
  173. // Check dump status
  174. //
  175. li t1,2 // check for dump switch
  176. and k0,k0,t1 //
  177. #if defined(_MRCDUMP_)
  178. beq k0,zero,30f // if 0 dump swith was not pressed
  179. #else // _MRCDUMP_
  180. bne k0,zero,30f // if 0 dump swith was pressed
  181. #endif // _MRCDUMP_
  182. nop //
  183. #if !defined(_MRCDUMP_)
  184. li t1,0xffffd000 // set dump switch status address
  185. li t2,0x1b // display LED dash
  186. sb t2,(t1) //
  187. sync //
  188. #endif // not _MRCDUMP_
  189. //
  190. // enable powoff NMI
  191. //
  192. #if defined(_MRCPOWER_)
  193. li t1,0xffffc108 //
  194. li t0,0x82 //
  195. nop //
  196. sb t0,(t1) //
  197. nop //
  198. li t0,0x80 //
  199. nop //
  200. sb t0,(t1) //
  201. nop //
  202. li t0,0x02 //
  203. nop //
  204. sb t0,(t1) //
  205. nop //
  206. #endif // _MRCPOWER_
  207. //
  208. // restore tlb 4 entry
  209. //
  210. mtc0 t8,entrylo0 // restore tlb 4 0
  211. mtc0 t9,entrylo1 // restore tlb 4 1
  212. nop //
  213. nop //
  214. nop //
  215. nop //
  216. tlbwi // write to tlb entry
  217. nop //
  218. nop //
  219. nop //
  220. nop //
  221. //
  222. // restore tlb registers
  223. //
  224. mtc0 t3,index //
  225. mtc0 t4,entryhi //
  226. mtc0 t5,entrylo0 //
  227. mtc0 t6,entrylo1 //
  228. mtc0 t7,pagemask //
  229. #if !defined(_MRCDUMP_)
  230. la k0,0xffffc5b8 // get NEC I/O port value
  231. lb t0,(k0) //
  232. nop // 1 cycle hazzerd
  233. li t1,0xfd // clear dump enable bit
  234. and t0,t0,t1
  235. sb t0,(k0) // set NEC I/O port value
  236. #endif // not _MRCDUMP_
  237. //
  238. // set NMI flag 1
  239. //
  240. la t2,HalpNMIFlag // set NMI flag address
  241. li t3,0xa0000000 // set KSEG1_BASE
  242. or t2,t2,t3 //
  243. li t3,1 //
  244. sw t3,(t2) // set NMI flag 1
  245. //
  246. // set dump flag 1
  247. //
  248. la t2,HalpDumpNMIFlag // set Dump NMI flag address
  249. li t3,0xa0000000 // set KSEG1_BASE
  250. or t2,t2,t3 //
  251. li t3,1 //
  252. sw t3,(t2) // set NMI flag 1
  253. //
  254. // clear psr BEV bit
  255. //
  256. mfc0 t0,psr // get psr
  257. li t2,0xffbfffff // clear BEV bit
  258. nop // fill
  259. nop // fill
  260. and t0,t0,t2 //
  261. nop //
  262. mtc0 t0,psr // set psr
  263. lw t0,0x1c(k1) // restore temporary registers
  264. lw t1,0x20(k1) //
  265. lw t2,0x24(k1) //
  266. lw t3,0x28(k1) //
  267. lw t4,0x2c(k1) //
  268. lw t5,0x30(k1) //
  269. lw t6,0x34(k1) //
  270. lw t7,0x38(k1) //
  271. lw t8,0x3c(k1) //
  272. lw t9,0x40(k1) //
  273. lw AT,0x0(k1) //
  274. eret // return to error epc
  275. nop // errata
  276. nop //
  277. nop //
  278. eret //
  279. nop //
  280. 30:
  281. //
  282. // No Dump Switch.
  283. //
  284. // Check Power Switch
  285. #if defined(_MRCPOWER_)
  286. li t1,0xffffc108
  287. nop
  288. li t0,0x02
  289. nop
  290. sb t0,(t1)
  291. nop
  292. #endif // _MRCPOWER_
  293. mtc0 t8,entrylo0 // restore tlb 4
  294. mtc0 t9,entrylo1 // restore tlb 4
  295. nop //
  296. nop //
  297. nop //
  298. nop //
  299. tlbwi // write to tlb entry
  300. nop //
  301. nop //
  302. nop //
  303. nop //
  304. mtc0 t3,index // restore tlb registers
  305. mtc0 t4,entryhi //
  306. mtc0 t5,entrylo0 //
  307. mtc0 t6,entrylo1 //
  308. mtc0 t7,pagemask //
  309. //
  310. // set NMI flag 1
  311. //
  312. la t2,HalpNMIFlag // set NMI flag address
  313. li t3,0xa0000000 // set KSEG1_BASE
  314. or t2,t2,t3 //
  315. li t3,1 //
  316. sw t3,(t2) // set NMI flag 1
  317. // S003 +++
  318. li t1,0xffffc078 // check NMI source
  319. lw t0,(t1) // check NMI source
  320. nop //
  321. beq t0,zero,40f //
  322. nop //
  323. li t1,0xffffc020
  324. nop
  325. ldc1 f0,(t1) // clear processor invalid
  326. nop
  327. sdc1 f0,0x70(k1) // save processor invalid
  328. 40:
  329. // S003 ---
  330. mfc0 t0,psr // get psr
  331. li t2,0xffbfffff // clear BEV bit
  332. nop // fill
  333. nop // fill
  334. and t0,t0,t2 //
  335. nop //
  336. mtc0 t0,psr // set psr
  337. lw t0,0x1c(k1) // restore temporary registers
  338. lw t1,0x20(k1) //
  339. lw t2,0x24(k1) //
  340. lw t3,0x28(k1) //
  341. lw t4,0x2c(k1) //
  342. lw t5,0x30(k1) //
  343. lw t6,0x34(k1) //
  344. lw t7,0x38(k1) //
  345. lw t8,0x3c(k1) //
  346. lw t9,0x40(k1) //
  347. lw AT,0x0(k1) //
  348. ldc1 f0,0x68(k1) //
  349. nop
  350. eret // return to errorepc
  351. nop // errata
  352. nop //
  353. nop //
  354. eret //
  355. nop //
  356. // L001 ---
  357. .set at
  358. .set reorder
  359. .end HalpNMIDispatch
  360. // Start M008
  361. SBTTL("Software Power Off")
  362. //++
  363. //
  364. // VOID
  365. // HalpPowOffNMIDispatch (
  366. // VOID
  367. // )
  368. //
  369. // Routine Description:
  370. //
  371. // This function was called by firmware when NMI occuerd.
  372. //
  373. // Arguments:
  374. //
  375. // none.
  376. //
  377. // Return Value:
  378. //
  379. // none.
  380. //
  381. //--
  382. LEAF_ENTRY(HalpPowOffNMIDispatch)
  383. .set noat
  384. .set noreorder
  385. //
  386. // Save temporary Registers for use.
  387. // save area shoud have for every processros.
  388. //
  389. li k0,0xffffc070 // get processor number.
  390. lw k0,(k0) //
  391. bne k0,zero,60f //
  392. nop // fill
  393. la k1,HalpNMISave0 // set save address.
  394. j 70f //
  395. nop // fill
  396. 60:
  397. la k1,HalpNMISave1 // set save address.
  398. nop // 1 cycle hazzerd
  399. 70:
  400. sw t0,0(k1) // save temporary registers
  401. sw t1,4(k1) //
  402. sw t2,8(k1) //
  403. sw t3,12(k1) //
  404. sw t4,16(k1) //
  405. sw t5,20(k1) //
  406. sw t6,24(k1) //
  407. sw t7,28(k1) //
  408. sw AT,32(k1) //
  409. //
  410. // Set Power Switch Status register to tlb fixed entry
  411. //
  412. li t0,4 // set index 4(hurricane register)
  413. li t1,0x80012 << 6 // set MRC register
  414. mfc0 t3,index // save tlb registers
  415. mfc0 t4,entryhi //
  416. mfc0 t5,entrylo0 //
  417. mfc0 t6,entrylo1 //
  418. mfc0 t7,pagemask //
  419. mtc0 t0,index //
  420. nop
  421. nop
  422. nop
  423. tlbr // read index 4 tlb
  424. nop
  425. nop
  426. nop
  427. nop
  428. mfc0 t2,entrylo0 // set Self-test address to tlb
  429. nop
  430. nop
  431. nop
  432. or t1,t2,t1
  433. nop
  434. mtc0 t1,entrylo0 // set Self-Test to tlb 4
  435. nop //
  436. nop //
  437. nop //
  438. nop //
  439. tlbwi // write to tlb entry
  440. nop //
  441. nop //
  442. nop //
  443. nop //
  444. li t1,0xffffc100 // load MRC Int value
  445. nop
  446. lb k0,(t1) // load Interrupt status.
  447. nop
  448. lb k0,(t1) // wait
  449. nop
  450. li t0,0x01 // set clear value
  451. sb t0,(t1) // clear OffSw bit
  452. li t1,0x4 // check for OffSw switch
  453. nop //
  454. and k0,k0,t1 //
  455. beq k0,zero,80f // 0 means Power switch was not pressed
  456. nop //
  457. li t1,0xffffc130 // load MRC Software PowerOff Register
  458. nop
  459. lb t0,0x1 // set PowerOff Value
  460. 90:
  461. sb t0,(t1) // write PowerOff bit
  462. beq zero,zero,90b
  463. nop
  464. eret
  465. nop
  466. nop
  467. nop
  468. eret
  469. nop
  470. 80:
  471. //
  472. // No Power Switch.
  473. //
  474. mtc0 t2,entrylo0 // restore tlb 4
  475. nop //
  476. nop //
  477. nop //
  478. nop //
  479. tlbwi // write to tlb entry
  480. nop //
  481. nop //
  482. nop //
  483. nop //
  484. mtc0 t3,index // restore tlb registers
  485. mtc0 t4,entryhi //
  486. mtc0 t5,entrylo0 //
  487. mtc0 t6,entrylo1 //
  488. mtc0 t7,pagemask //
  489. la t2,HalpNMIFlag // set NMI flag address
  490. li t3,0xa0000000 // set KSEG1_BASE
  491. or t2,t2,t3 //
  492. li t3,1 //
  493. sw t3,(t2) // set NMI flag 1
  494. lw t0,0xffffc078 // check NMI source
  495. nop //
  496. beq t0,zero,45f //
  497. nop //
  498. lw t0,0xffffc020 // clear processor invalid
  499. 45:
  500. mfc0 t0,psr // get psr
  501. li t2,0xffbfffff // clear BEV bit
  502. nop // fill
  503. nop // fill
  504. and t0,t0,t2 //
  505. nop //
  506. mtc0 t0,psr // set psr
  507. lw t0,0(k1) // restore temporary registers
  508. lw t1,4(k1) //
  509. lw t2,8(k1) //
  510. lw t3,12(k1) //
  511. lw t4,16(k1) //
  512. lw t5,20(k1) //
  513. lw t6,24(k1) //
  514. lw t7,28(k1) //
  515. lw AT,32(k1) //
  516. eret // return to errorepc
  517. nop // errata
  518. nop //
  519. nop //
  520. eret //
  521. nop //
  522. .set reorder
  523. .set at
  524. .end HalpPowOffNMIDispatch
  525. // End M008