- Rearrange reactos.dff according to rosapps rearrange.
[reactos.git] / rosapps / applications / sysutils / utils / pice / module / dblflt.c
1 /*++
2
3 Copyright (c) 1998-2001 Klaus P. Gerlicher
4
5 Module Name:
6
7 dblflt.c
8
9 Abstract:
10
11 handle double faults on x86
12
13 Environment:
14
15 LINUX 2.2.X
16 Kernel mode only
17
18 Author:
19
20 Klaus P. Gerlicher
21
22 Revision History:
23
24 13-Nov-1999: created
25 15-Nov-2000: general cleanup of source files
26
27 Copyright notice:
28
29 This file may be distributed under the terms of the GNU Public License.
30
31 --*/
32
33 ////////////////////////////////////////////////////
34 // INCLUDES
35 ////
36 #include "remods.h"
37 #include "precomp.h"
38
39 ////////////////////////////////////////////////////
40 // GLOBALS
41 ////
42 ULONG OldDblFltHandler = 0;
43
44 ////////////////////////////////////////////////////
45 // FUNCTIONS
46 ////
47
48 //*************************************************************************
49 // HandleDoubleFault()
50 //
51 //*************************************************************************
52 void HandleDoubleFault(FRAME* ptr)
53 {
54 DPRINT((0,"HandleDoubleFault(): ptr = %x\n",ptr));
55 }
56
57
58 //*************************************************************************
59 // NewDblFltHandler()
60 //
61 //*************************************************************************
62 __asm__ (" \
63 NewDblFltHandler:\n\t \
64 pushfl\n\t \
65 cli;\n\t \
66 cld;\n\t \
67 pushal;\n\t \
68 pushl %ds;\n\t \
69 \n\t \
70 // setup default data selectors\n\t \
71 movw %ss,%ax\n\t \
72 movw %ax,%ds\n\t \
73 \n\t \
74 // get frame ptr\n\t \
75 lea 40(%esp),%eax\n\t \
76 pushl %eax\n\t \
77 call _HandleDoubleFault\n\t \
78 addl $4,%esp\n\t \
79 \n\t \
80 popl %ds\n\t \
81 popal\n\t \
82 popfl\n\t \
83 // remove error code from stack and replace with reason code\n\t \
84 movl $" STR(REASON_DOUBLE_FAULT) ",(%esp)\n\t \
85 // call debugger loop\n\t \
86 jmp NewInt31Handler\n\t");
87
88
89 //*************************************************************************
90 // InstallDblFltHook()
91 //
92 //*************************************************************************
93 void InstallDblFltHook(void)
94 {
95 ULONG LocalDblFltHandler;
96
97 ENTER_FUNC();
98
99 MaskIrqs();
100 if(!OldDblFltHandler)
101 {
102 __asm__("mov $NewDblFltHandler,%0"
103 :"=r" (LocalDblFltHandler)
104 :
105 :"eax");
106 OldDblFltHandler=SetGlobalInt(0x08,(ULONG)LocalDblFltHandler);
107 }
108 UnmaskIrqs();
109
110 LEAVE_FUNC();
111 }
112
113 //*************************************************************************
114 // DeInstallDblFltHook()
115 //
116 //*************************************************************************
117 void DeInstallDblFltHook(void)
118 {
119 ENTER_FUNC();
120
121 MaskIrqs();
122 if(OldDblFltHandler)
123 {
124 RemoveAllSWBreakpoints(TRUE);
125 SetGlobalInt(0x08,(ULONG)OldDblFltHandler);
126 OldDblFltHandler=0;
127 }
128 UnmaskIrqs();
129
130 LEAVE_FUNC();
131 }
132
133 // EOF