Source code of Windows XP (NT5)
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.

173 lines
4.3 KiB

  1. title "Processor State Save Restore"
  2. ;++
  3. ;
  4. ; Copyright (c) 1996 Microsoft Corporation
  5. ;
  6. ; Module Name:
  7. ;
  8. ; procstat.asm
  9. ;
  10. ; Abstract:
  11. ;
  12. ; This module implements procedures for saving and restoring
  13. ; processor control state.
  14. ;
  15. ; Author:
  16. ;
  17. ; Shie-Lin Tzong (shielint) 30-Aug-1990
  18. ;
  19. ; Environment:
  20. ;
  21. ; Kernel mode only.
  22. ;
  23. ; Revision History:
  24. ;
  25. ;--
  26. .486p
  27. .xlist
  28. include ks386.inc
  29. include i386\kimacro.inc
  30. include callconv.inc
  31. .list
  32. page ,132
  33. _TEXT SEGMENT DWORD PUBLIC 'CODE'
  34. ASSUME DS:FLAT, ES:FLAT, SS:NOTHING, FS:NOTHING, GS:NOTHING
  35. page ,132
  36. subttl "Save Processor Control State"
  37. ;++
  38. ;
  39. ; KiSaveProcessorControlState(
  40. ; PKPROCESSOR_STATE ProcessorState
  41. ; );
  42. ;
  43. ; Routine Description:
  44. ;
  45. ; This routine saves the control subset of the processor state.
  46. ; (Saves the same information as KiSaveProcessorState EXCEPT that
  47. ; data in TrapFrame/ExceptionFrame=Context record is NOT saved.)
  48. ; Called by the debug subsystem, and KiSaveProcessorState()
  49. ;
  50. ; N.B. This procedure will save Dr7, and then 0 it. This prevents
  51. ; recursive hardware trace breakpoints and allows debuggers
  52. ; to work.
  53. ;
  54. ; Arguments:
  55. ;
  56. ; ProcessorState - Supplies the address of the processor state.
  57. ; Return Value:
  58. ;
  59. ; None.
  60. ;
  61. ;--
  62. cPublicProc _KiSaveProcessorControlState ,1
  63. mov edx, [esp+4] ; get processor state address
  64. ;
  65. ; Save special registers for debugger
  66. ;
  67. xor ecx,ecx
  68. mov eax, cr0
  69. mov [edx].PsSpecialRegisters.SrCr0, eax
  70. mov eax, cr2
  71. mov [edx].PsSpecialRegisters.SrCr2, eax
  72. mov eax, cr3
  73. mov [edx].PsSpecialRegisters.SrCr3, eax
  74. mov [edx].PsSpecialRegisters.SrCr4, ecx
  75. mov eax,dr0
  76. mov [edx].PsSpecialRegisters.SrKernelDr0,eax
  77. mov eax,dr1
  78. mov [edx].PsSpecialRegisters.SrKernelDr1,eax
  79. mov eax,dr2
  80. mov [edx].PsSpecialRegisters.SrKernelDr2,eax
  81. mov eax,dr3
  82. mov [edx].PsSpecialRegisters.SrKernelDr3,eax
  83. mov eax,dr6
  84. mov [edx].PsSpecialRegisters.SrKernelDr6,eax
  85. mov eax,dr7
  86. mov dr7,ecx
  87. mov [edx].PsSpecialRegisters.SrKernelDr7,eax
  88. sgdt fword ptr [edx].PsSpecialRegisters.SrGdtr
  89. sidt fword ptr [edx].PsSpecialRegisters.SrIdtr
  90. str word ptr [edx].PsSpecialRegisters.SrTr
  91. sldt word ptr [edx].PsSpecialRegisters.SrLdtr
  92. stdRET _KiSaveProcessorControlState
  93. stdENDP _KiSaveProcessorControlState
  94. page ,132
  95. subttl "Restore Processor Control State"
  96. ;++
  97. ;
  98. ; KiRestoreProcessorControlState(
  99. ; PKPROCESSOR_STATE ProcessorState
  100. ; );
  101. ;
  102. ; Routine Description:
  103. ;
  104. ; This routine restores the control subset of the processor state.
  105. ; (Restores the same information as KiRestoreProcessorState EXCEPT that
  106. ; data in TrapFrame/ExceptionFrame=Context record is NOT restored.)
  107. ; Called by the debug subsystem, and KiRestoreProcessorState()
  108. ;
  109. ; Arguments:
  110. ;
  111. ; ProcessorState - Supplies the address of the processor state.
  112. ;
  113. ; Return Value:
  114. ;
  115. ; None.
  116. ;
  117. ;--
  118. cPublicProc _KiRestoreProcessorControlState,1
  119. mov edx, [esp+4] ; (edx)->ProcessorState
  120. ;
  121. ; Restore special registers for debugger
  122. ;
  123. mov eax, [edx].PsSpecialRegisters.SrCr0
  124. mov cr0, eax
  125. mov eax, [edx].PsSpecialRegisters.SrCr2
  126. mov cr2, eax
  127. mov eax, [edx].PsSpecialRegisters.SrCr3
  128. mov cr3, eax
  129. mov eax, [edx].PsSpecialRegisters.SrKernelDr0
  130. mov dr0, eax
  131. mov eax, [edx].PsSpecialRegisters.SrKernelDr1
  132. mov dr1, eax
  133. mov eax, [edx].PsSpecialRegisters.SrKernelDr2
  134. mov dr2, eax
  135. mov eax, [edx].PsSpecialRegisters.SrKernelDr3
  136. mov dr3, eax
  137. mov eax, [edx].PsSpecialRegisters.SrKernelDr6
  138. mov dr6, eax
  139. mov eax, [edx].PsSpecialRegisters.SrKernelDr7
  140. mov dr7, eax
  141. lgdt fword ptr [edx].PsSpecialRegisters.SrGdtr
  142. lidt fword ptr [edx].PsSpecialRegisters.SrIdtr
  143. lldt word ptr [edx].PsSpecialRegisters.SrLdtr
  144. stdRET _KiRestoreProcessorControlState
  145. stdENDP _KiRestoreProcessorControlState
  146. _TEXT ENDS
  147. END