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.

210 lines
6.2 KiB

4 years ago
  1. #if defined(R4000)
  2. // TITLE("Interval and Profile Clock Interrupts")
  3. //++
  4. //
  5. // Copyright (c) 1991 Microsoft Corporation
  6. //
  7. // Module Name:
  8. //
  9. // x4clock.s
  10. //
  11. // Abstract:
  12. //
  13. // This module implements the code necessary to field and process the
  14. // interval and profile clock interrupts on a MIPS R4000 system.
  15. //
  16. // Author:
  17. //
  18. // David N. Cutler (davec) 26-Apr-1991
  19. //
  20. // Environment:
  21. //
  22. // Kernel mode only.
  23. //
  24. // Revision History:
  25. //
  26. //--
  27. #include "halmips.h"
  28. SBTTL("System Clock Interrupt")
  29. //++
  30. //
  31. // Routine Description:
  32. //
  33. // This routine is entered as the result of an interrupt generated by
  34. // the interval timer. Its function is to acknowledge the interrupt and
  35. // transfer control to the standard system routine to update the system
  36. // time and the execution time of the current thread and process.
  37. //
  38. // Arguments:
  39. //
  40. // s8 - Supplies a pointer to a trap frame.
  41. //
  42. // Return Value:
  43. //
  44. // None.
  45. //
  46. //--
  47. .struct 0
  48. CiArgs: .space 4 * 4 // saved arguments
  49. .space 3 * 4 // fill
  50. CiRa: .space 4 // saved return address
  51. CiFrameLength: //
  52. NESTED_ENTRY(HalpClockInterrupt, CiFrameLength, zero)
  53. subu sp,sp,CiFrameLength // allocate stack frame
  54. sw ra,CiRa(sp) // save return address
  55. PROLOGUE_END
  56. move a0,s8 // set address of trap frame
  57. lw a1,HalpCurrentTimeIncrement // Get current time increment
  58. jal KeUpdateSystemTime // update system time
  59. lw t0,HalpNextTimeIncrement // Get NextTimeIncrement
  60. sw t0,HalpCurrentTimeIncrement // Set CurrentTimeIncrement to NextTimeIncrement
  61. lw a0,HalpNextIntervalCount // Get Next Interval Count. If 0, then no change required
  62. beq zero,a0,5f // See if time increment is to be changed
  63. jal HalpProgramIntervalTimer // Program timer with new interval count value
  64. lw t0,HalpNewTimeIncrement // Get HalpNewTimeIncrement
  65. sw t0,HalpNextTimeIncrement // Set HalpNextTimeIncrement to HalpNewTimeIncrement
  66. sw zero,HalpNextIntervalCount // Set HalpNextIntervalCount to 0
  67. 5:
  68. lw t0,KdDebuggerEnabled // check if debugger enabled
  69. lbu t0,0(t0) //
  70. beq zero,t0,10f // if eq, debugger not enabled
  71. jal KdPollBreakIn // check if breakin is requested
  72. beq zero,v0,10f // if eq, no breakin requested
  73. li a0,DBG_STATUS_CONTROL_C // break in and send
  74. jal DbgBreakPointWithStatus // status to debugger
  75. 10: lw ra,CiRa(sp) // restore return address
  76. addu sp,sp,CiFrameLength // deallocate stack frame
  77. j ra // return
  78. .end HalpClockInterrupt
  79. SBTTL("Profile Clock Interrupt")
  80. //++
  81. //
  82. // Routine Description:
  83. //
  84. // This routine is entered as the result of an interrupt generated by the
  85. // profile clock. Its function is to acknowledge the profile interrupt,
  86. // compute the next compare value, update the performance counter, and
  87. // transfer control to the standard system routine to process any active
  88. // profiles.
  89. //
  90. // Arguments:
  91. //
  92. // s8 - Supplies a pointer to a trap frame.
  93. //
  94. // Return Value:
  95. //
  96. // None.
  97. //
  98. //--
  99. LEAF_ENTRY(HalpProfileInterrupt)
  100. .set noreorder
  101. .set noat
  102. mfc0 t1,count // get current count value
  103. mfc0 t0,compare // get current comparison value
  104. addu t1,t1,8 // factor in lost cycles
  105. subu t1,t1,t0 // compute initial count value
  106. mtc0 t0,compare // dismiss interrupt
  107. mtc0 t1,count // set new count register value
  108. .set at
  109. .set reorder
  110. la t1,HalpPerformanceCounter // get performance counter address
  111. lw t2,LiLowPart(t1) // get low part of performance count
  112. lw t3,LiHighPart(t1) // get high part of performance count
  113. addu t2,t2,t0 // update low part of performance count
  114. sw t2,LiLowPart(t1) // store low part of performance count
  115. sltu t4,t2,t0 // generate carry into high part
  116. addu t3,t3,t4 // update high part of performance count
  117. sw t3,LiHighPart(t1) // store high part of performance count
  118. move a0,s8 // set address of trap frame
  119. j KeProfileInterrupt // process profile entries
  120. .end HalpProfileInterrupt
  121. SBTTL("Read Count Register")
  122. //++
  123. //
  124. // ULONG
  125. // HalpReadCountRegister (
  126. // VOID
  127. // );
  128. //
  129. // Routine Description:
  130. //
  131. // This routine reads the current value of the count register and
  132. // returns the value.
  133. //
  134. // Arguments:
  135. //
  136. // None.
  137. //
  138. // Return Value:
  139. //
  140. // Current value of the count register.
  141. //
  142. //--
  143. LEAF_ENTRY(HalpReadCountRegister)
  144. .set noreorder
  145. .set noat
  146. mfc0 v0,count // get count register value
  147. .set at
  148. .set reorder
  149. j ra // return
  150. .end HalpReadCountRegister
  151. SBTTL("Write Compare Register And Clear")
  152. //++
  153. //
  154. // ULONG
  155. // HalpWriteCompareRegisterAndClear (
  156. // IN ULONG Value
  157. // );
  158. //
  159. // Routine Description:
  160. //
  161. // This routine reads the current value of the count register, writes
  162. // the value of the compare register, clears the count register, and
  163. // returns the previous value of the count register.
  164. //
  165. // Arguments:
  166. //
  167. // Value - Supplies the value written to the compare register.
  168. //
  169. // Return Value:
  170. //
  171. // Previous value of the count register.
  172. //
  173. //--
  174. LEAF_ENTRY(HalpWriteCompareRegisterAndClear)
  175. .set noreorder
  176. .set noat
  177. mfc0 v0,count // get count register value
  178. mtc0 a0,compare // set compare register value
  179. li t0,7 // set lost cycle count
  180. mtc0 t0,count // set count register to zero
  181. .set at
  182. .set reorder
  183. j ra // return
  184. .end HalpWriteCompareRegisterAndClear
  185. #endif