1 ; MMURTL Operating System Source Code
\r
2 ; Copyright 1991,1992,1993,1994 Richard A. Burgess
\r
3 ; ALL RIGHTS RESERVED
\r
10 EXTRN DbgpTSSSave DD
\r
15 EXTRN dbgOldEFlgs DD
\r
22 ;This file contains Exception Handlers and Debugger Entry
\r
25 ;=============================================================================
\r
26 ; Procedure jumped to by interrupt procedures to enter debugger
\r
27 ;=============================================================================
\r
30 ; This piece of code sets up to enter the debugger. If we get here,
\r
31 ; one of the exceptions has activated and has done a little work based
\r
32 ; on which exception is was, then it jumped here to enter the debugger.
\r
33 ; This code effectively replaces the interrupted task with the debugger
\r
34 ; task (without going through the kernel). First we copy the Page Dir
\r
35 ; entry from the current job into the debuggers job, then copy the CR3
\r
36 ; register from the current TSS into the debugger's TSS. This makes the
\r
37 ; debugger operate in the current tasks memory space. All of the debugger's
\r
38 ; code and data are in OS protected pages (which are shared with all tasks),
\r
39 ; so this is OK to do even if the offending task referenced a bogus address.
\r
40 ; Next, we save the current pRunTSS and place the debugger's TSS in
\r
41 ; pRunTSS, then jump to the debugger's selector. This switches tasks.
\r
44 PUSH EAX ;we MUST save caller's registers
\r
45 PUSH EBX ; and restore them before the
\r
46 PUSH EDX ; task switch into the debugger
\r
48 MOV EAX, pRunTSS ;pRunTSS -> EAX
\r
49 MOV EBX, [EAX+TSS_CR3] ;current CR3 -> EBX
\r
50 MOV EDX, OFFSET DbgTSS ;pDebuggerTSS -> EDX
\r
51 MOV [EDX+TSS_CR3], EBX ;CR3 -> DebuggerTSS
\r
53 MOV EAX, [EAX+TSS_pJCB] ;pCrntJCB -> EAX
\r
54 MOV EDX, [EDX+TSS_pJCB] ;pDebuggerJCB -> EDX
\r
55 MOV EBX, [EAX+JcbPD] ;CrntJob Page Dir -> EBX
\r
56 MOV [EDX+JcbPD], EBX ;Page Dir -> Debugger JCB
\r
58 MOV EAX, pRunTSS ;Save the current pRunTSS
\r
59 MOV DbgpTSSSave, EAX
\r
60 MOV EAX, OFFSET DbgTSS ;Install Debugger's as current
\r
61 MOV pRunTSS, EAX ;Set Dbgr as running task
\r
64 MOV TSS_Sel, BX ;Set up debugger selector
\r
66 POP EDX ;make his registers right!
\r
70 JMP FWORD PTR [TSS] ;Switch tasks to debugger
\r
72 ;When the debugger exits, we come here
\r
74 PUSH dbgOldEFlgs ;Put the stack back the way it was
\r
77 IRETD ;Go back to the caller
\r
79 ;=============================================================================
\r
80 ; INTERRUPT PROCEDURES FOR FAULTS
\r
81 ;=============================================================================
\r
82 ; This is the general purpose "We didn't expect this interrupt" interrupt
\r
83 ; This will place "99" in the upper left corner of the screen so we
\r
84 ; can see there are SPURIOUS interrupts!!!!!
\r
88 MOV EAX,07390739h ;99 - All unassigned ints come here
\r
89 MOV DS:VGATextBase+00h,EAX
\r
93 ;===================== Divide By ZERO (Int 0) ============================
\r
96 ; MOV EAX,07300730h ;00
\r
97 ; MOV DS:VGATextBase+00h,EAX
\r
101 MOV dbgFAULT,00h ; Divide By Zero
\r
102 POP dbgOldEIP ; Get EIP of offender for debugger
\r
105 JMP EnterDebug ;Enter debugger
\r
107 ;===================== Debugger Single Step (Int 1) ======================
\r
111 POP dbgOldEIP ; Get EIP of offender for debugger
\r
114 JMP EnterDebug ;Enter debugger
\r
116 ;===================== Debugger Entry (Int 3) ===========================
\r
120 POP dbgOldEIP ; Get EIP of offender for debugger
\r
121 POP dbgOldCS ; Get CS
\r
122 POP dbgOldEFlgs ; Get Flags
\r
123 JMP EnterDebug ;Enter debugger
\r
125 ;===================== OverFlow (Int 4) ==================================
\r
127 PUBLIC IntOverFlow:
\r
129 MOV EAX,07340730h ;04
\r
130 MOV DS:VGATextBase+00h,EAX
\r
134 ;========================== Bad Opcode (Int 6) ================================
\r
136 ; MOV EAX,07360730h ;06
\r
137 ; MOV DS:VGATextBase+00h,EAX
\r
140 MOV dbgFAULT,06h ; Invalid Opcode
\r
141 POP dbgOldEIP ; Get EIP of offender for debugger
\r
144 JMP EnterDebug ;Enter debugger
\r
146 ;========================== Dbl Exception (Int 08)============================
\r
148 ; MOV EAX,07380730h ;08
\r
149 ; MOV DS:VGATextBase+00h,EAX
\r
153 MOV dbgFAULT,08h ; Double Exception
\r
154 POP dbgFltErc ; Error Code pushed last by processor
\r
159 JMP EnterDebug ;Enter debugger
\r
161 ;========================= Invalid TSS 10 ====================================
\r
163 MOV EAX,07300731h ;10
\r
164 MOV DS:VGATextBase+00h,EAX
\r
168 MOV dbgFAULT,0Ah ; Invalid TSS
\r
169 POP dbgFltErc ; Error code pushed last by processor
\r
173 JMP EnterDebug ;Enter debugger
\r
175 ;========================== Seg Not Present 11 ===============================
\r
178 MOV EAX,07310731h ;11
\r
179 MOV DS:VGATextBase+00h,EAX
\r
183 ;========================== Stack Overflow 12 ================================
\r
185 ; MOV EAX,07320731h ;12
\r
186 ; MOV DS:VGATextBase+00h,EAX
\r
190 MOV dbgFAULT,0Ch ; Stack overflow
\r
195 JMP EnterDebug ;Enter debugger
\r
197 ;========================== GP 13 ===========================================
\r
199 ; MOV EAX,07330731h ;13
\r
200 ; MOV DS:VGATextBase+00h,EAX
\r
204 MOV dbgFAULT,0Dh ; GP Fault
\r
209 JMP EnterDebug ;Enter debugger
\r
211 ;========================== Page Fault 14 ====================================
\r
213 ; MOV EAX,07340731h ;14
\r
214 ; MOV DS:VGATextBase+00h,EAX
\r
218 MOV dbgFAULT,0Eh ; Page Fault
\r
223 JMP EnterDebug ;Enter debugger
\r
225 ;=============================================================================
\r
226 ; ISR for interrupt on PICU1 from Slave
\r
227 ;=============================================================================
\r
229 PUBLIC IntPICU2: ; IRQ Line 2 from Slave 8259 (Int22)
\r
231 MOV EAX,07320750h ; From PICU#2 (P2)
\r
232 MOV DS:VGATextBase+100h,EAX
\r
234 CALL FWORD PTR _EndOfIRQ
\r
238 ;=============== end of module ==================
\r