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.

126 lines
1.9 KiB

  1. TITLE STACK - Kernel stack switching code
  2. include kernel.inc
  3. ifdef WOW
  4. include vint.inc
  5. endif
  6. ;------------------------------------------------------------------------
  7. ; T M P S T A C K S E G M E N T V A R I A B L E S
  8. ;------------------------------------------------------------------------
  9. sBegin DATA
  10. assumes CS,CODE
  11. assumes DS,NOTHING
  12. assumes ES,NOTHING
  13. assumes SS,NOTHING
  14. EVEN
  15. if KDEBUG
  16. externW gmove_stack_sig
  17. endif
  18. externW gmove_stack
  19. externW prev_gmove_SP
  20. externW prev_gmove_SS
  21. externW ss_sel
  22. sEnd DATA
  23. ;------------------------------------------------------------------------
  24. sBegin CODE
  25. assumes CS,CODE
  26. assumes SS,NOTHING
  27. assumes ds,nothing
  28. assumes es,nothing
  29. cProc Enter_gmove_stack,<PUBLIC,NEAR>
  30. cBegin nogen
  31. mov ax,ds
  32. SetKernelDS
  33. cmp prev_gmove_SS,0
  34. jne gs_fail
  35. FCLI
  36. pop gmove_stack
  37. ;;;if PMODE
  38. ;;; mov ss_sel,ss
  39. ;;;endif
  40. mov prev_gmove_SS,cx
  41. mov prev_gmove_SP,sp
  42. if KDEBUG
  43. mov gmove_stack_sig,STACK_SIGNATURE
  44. endif
  45. smov ss,ds
  46. mov sp,dataOffset gmove_stack
  47. FSTI
  48. mov ds,ax
  49. ret
  50. cEnd nogen
  51. gs_fail:
  52. kerror ERR_GMEM,<gmove_stack usage error>,prev_gmove_SS,prev_gmove_SP
  53. jmp gs_fail
  54. assumes ds,nothing
  55. assumes es,nothing
  56. cProc Leave_gmove_stack,<PUBLIC,NEAR>
  57. cBegin nogen
  58. mov ax,ds
  59. SetKernelDS
  60. cmp prev_gmove_SS,0
  61. je gs_fail
  62. if KDEBUG
  63. push ax
  64. push cx
  65. push es
  66. push di
  67. lea di, gmove_stack_sig
  68. smov es, ss
  69. mov ax, STACK_SIGNATURE
  70. mov cx, 16
  71. cld
  72. repe scasw
  73. pop di
  74. pop es
  75. pop cx
  76. pop ax
  77. jne gs_fail
  78. cmp sp,dataOffset gmove_stack
  79. jne gs_fail
  80. endif
  81. ;;;if PMODE
  82. ;;;externNP get_physical_address
  83. ;;;externNP set_physical_address
  84. ;;; push ax
  85. ;;; push dx
  86. ;;; cCall get_physical_address,<prev_gmove_SS>
  87. ;;; cCall set_physical_address,<ss_sel>
  88. ;;; pop dx
  89. ;;; pop ax
  90. ;;; FCLI
  91. ;;; mov ss,ss_sel
  92. ;;;else
  93. FCLI
  94. mov ss,prev_gmove_SS
  95. ;;;endif
  96. mov sp,prev_gmove_SP
  97. push gmove_stack
  98. mov prev_gmove_SS,0
  99. FSTI
  100. mov ds,ax
  101. ret
  102. cEnd nogen
  103. sEND CODE
  104. end