3 * Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include <arch/pc/x86common.h>
24 #define SCREEN_ATTR 0x1f /* Bright white on blue background */
26 EXTERN _i386PrintExceptionText@12:PROC
31 /* push the rest of the KTRAP_FRAME */
37 push 0 // ExceptionList
38 push 0 // PreviousPreviousMode
59 /* push KSPECIAL_REGISTERS */
60 /* Gdtr, Idtr, Tr, Ldtr, Reserved */
64 str word ptr [esp + 16]
65 sldt word ptr [esp + 18]
88 /* Set by each exception handler to the address of the description text */
92 /************************************************************************/
93 i386CommonExceptionHandler:
97 lea eax, [esp + (21 * 4)] // KTRAP_FRAME
98 push esp // KSPECIAL_REGISTERS
100 push i386ExceptionIndex
101 call _i386PrintExceptionText@12
104 i386ExceptionHandlerHang:
106 jmp i386ExceptionHandlerHang
110 MACRO(TRAP_STUB, function, index)
117 push 0 // Fake error code
118 mov dword ptr i386ExceptionIndex, VAL(index)
119 jmp i386CommonExceptionHandler
122 MACRO(TRAP_STUB2, function, index)
129 mov dword ptr i386ExceptionIndex, VAL(index)
130 jmp i386CommonExceptionHandler
133 /************************************************************************/
134 TRAP_STUB _i386DivideByZero, 0
136 TRAP_STUB _i386DebugException, 1
137 TRAP_STUB _i386NMIException, 2
138 TRAP_STUB _i386Breakpoint, 3
139 TRAP_STUB _i386Overflow, 4
140 TRAP_STUB _i386BoundException, 5
141 TRAP_STUB _i386InvalidOpcode, 6
142 TRAP_STUB _i386FPUNotAvailable, 7
143 TRAP_STUB2 _i386DoubleFault, 8
144 TRAP_STUB _i386CoprocessorSegment, 9
145 TRAP_STUB2 _i386InvalidTSS, 10
146 TRAP_STUB2 _i386SegmentNotPresent, 11
147 TRAP_STUB2 _i386StackException, 12
148 TRAP_STUB2 _i386GeneralProtectionFault, 13
149 TRAP_STUB2 _i386PageFault, 14
151 TRAP_STUB _i386CoprocessorError, 16
152 TRAP_STUB _i386AlignmentCheck, 17
153 TRAP_STUB _i386MachineCheck, 18
154 TRAP_STUB _i386SimdFloatError, 19
156 /************************************************************************
157 * DEBUGGING SUPPORT FUNCTIONS
158 ************************************************************************/
160 MACRO(BREAKPOINT_TEPLATE, functionname, mask1, mask2)
161 PUBLIC VAL(functionname)
178 BREAKPOINT_TEPLATE _INSTRUCTION_BREAKPOINT1, HEX(0fff0ffff), HEX(000000303)
179 BREAKPOINT_TEPLATE _MEMORY_READWRITE_BREAKPOINT1, HEX(0fff0ffff), HEX(000030303)
180 BREAKPOINT_TEPLATE _MEMORY_WRITE_BREAKPOINT1, HEX(0fff0ffff), HEX(000010303)
181 BREAKPOINT_TEPLATE _INSTRUCTION_BREAKPOINT2, HEX(0ff0fffff), HEX(00000030c)
182 BREAKPOINT_TEPLATE _MEMORY_READWRITE_BREAKPOINT2, HEX(0ff0fffff), HEX(00030030c)
183 BREAKPOINT_TEPLATE _MEMORY_WRITE_BREAKPOINT2, HEX(0ff0fffff), HEX(00010030c)
184 BREAKPOINT_TEPLATE _INSTRUCTION_BREAKPOINT3, HEX(0f0ffffff), HEX(000000330)
185 BREAKPOINT_TEPLATE _MEMORY_READWRITE_BREAKPOINT3, HEX(0f0ffffff), HEX(003000330)
186 BREAKPOINT_TEPLATE _MEMORY_WRITE_BREAKPOINT3, HEX(0f0ffffff), HEX(001000330)
187 BREAKPOINT_TEPLATE _INSTRUCTION_BREAKPOINT4, HEX(00fffffff), HEX(0000003c0)
188 BREAKPOINT_TEPLATE _MEMORY_READWRITE_BREAKPOINT4, HEX(00fffffff), HEX(0300003c0)
189 BREAKPOINT_TEPLATE _MEMORY_WRITE_BREAKPOINT4, HEX(00fffffff), HEX(0100003c0)