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.

128 lines
3.9 KiB

  1. PAGE ,132
  2. TITLE NTNPXEM.ASM -- Support for fielding exceptions from npx em
  3. ; Copyright (c) Microsoft Corporation 1988-1991. All Rights Reserved.
  4. ;****************************************************************
  5. ;* *
  6. ;* NTNPXEM.ASM - Exception handler for npx emulation *
  7. ;* *
  8. ;****************************************************************
  9. ;* *
  10. ;* Module Description: *
  11. ;* This module contains code to field exceptions from the *
  12. ;* Nt NPX emulator. These exceptions will only be *
  13. ;* received on machines without 387's, on which the app *
  14. ;* has set the EM bit. *
  15. ;****************************************************************
  16. .286p
  17. .287
  18. ; -------------------------------------------------------
  19. ; INCLUDE FILE DEFINITIONS
  20. ; -------------------------------------------------------
  21. .xlist
  22. .sall
  23. include segdefs.inc
  24. include gendefs.inc
  25. include pmdefs.inc
  26. include ks386.inc
  27. include intmac.inc
  28. .list
  29. ; -------------------------------------------------------
  30. ; GENERAL SYMBOL DEFINITIONS
  31. ; -------------------------------------------------------
  32. ; -------------------------------------------------------
  33. ; EXTERNAL SYMBOL DEFINITIONS
  34. ; -------------------------------------------------------
  35. extrn PmFaultEntryVector:near
  36. ; -------------------------------------------------------
  37. ; DATA SEGMENT DEFINITIONS
  38. ; -------------------------------------------------------
  39. DXDATA segment
  40. extrn rgw0stack:word
  41. DXDATA ends
  42. ; -------------------------------------------------------
  43. ; Exception Handler
  44. ; -------------------------------------------------------
  45. DXPMCODE segment
  46. assume cs:DXPMCODE
  47. .386p
  48. ;
  49. ; N.B. The following routine will be executed on a special
  50. ; code selector. The following routine must ALWAYS
  51. ; appear at offset zero in this code selector.
  52. ;
  53. ; -------------------------------------------------------
  54. ; NpxExceptionHandler -- This function switches to the
  55. ; exception handler stack, pushes an exception frame,
  56. ; and restores the registers. It then transfers control
  57. ; the trap 7 fault handler.
  58. ;
  59. ; Input: ss:esp -> an NT CONTEXT record
  60. ; Output: all registers restored to fault time
  61. ; values, and exception frame pushed.
  62. ; Errors: none
  63. ; Uses: all
  64. assume ds:NOTHING,es:NOTHING,ss:NOTHING,fs:NOTHING
  65. public NpxExceptionHandler,EndNpxExceptionHandler
  66. NpxExceptionHandler proc far
  67. FCLI
  68. mov ax,ss
  69. mov ds,ax
  70. mov ebx,esp ; ds:ebx->CONTEXT
  71. mov ax,SEL_DXDATA OR STD_RING
  72. mov ss,ax
  73. mov esp,offset DXDATA:rgw0Stack ; ss:esp->exception stack
  74. ;
  75. ; Push exception frame on exception stack
  76. ;
  77. movzx eax,word ptr [ebx].CsSegSs
  78. push eax
  79. push dword ptr [ebx].CsEsp
  80. push dword ptr [ebx].CsEFlags
  81. movzx eax,word ptr [ebx].CsSegCs
  82. push eax
  83. push dword ptr [ebx].CsEip
  84. ;
  85. ; Restore registers
  86. ;
  87. mov gs,[ebx].CsSegGs
  88. mov fs,[ebx].CsSegFs
  89. mov es,[ebx].CsSegEs
  90. mov ebp,[ebx].CsEbp
  91. mov edi,[ebx].CsEdi
  92. mov esi,[ebx].CsEsi
  93. mov edx,[ebx].CsEdx
  94. mov ecx,[ebx].CsEcx
  95. mov ax,[ebx].CsSegDs
  96. push ax
  97. push dword ptr [ebx].CsEbx
  98. mov eax,[ebx].CsEax
  99. pop ebx
  100. pop ds
  101. db 0eah
  102. dw (offset PmFaultEntryVector + 21)
  103. dw SEL_DXPMCODE OR STD_RING
  104. EndNpxExceptionHandler:
  105. NpxExceptionHandler endp
  106. DXPMCODE ends
  107. end