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.
20 .intel_syntax noprefix
28 #define SCREEN_ATTR 0x1f /* Bright white on blue background */
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 */
88 /* Set by each exception handler to the address of the description text */
93 /************************************************************************/
94 i386CommonExceptionHandler:
99 lea eax, [esp + (21 * 4)] // KTRAP_FRAME
100 push esp // KSPECIAL_REGISTERS
102 push i386ExceptionIndex
103 call _i386PrintExceptionText@12
106 i386ExceptionHandlerHang:
108 jmp i386ExceptionHandlerHang
112 .macro TRAP_STUB function, index
114 push 0 // Fake error code
115 mov dword ptr i386ExceptionIndex, \index
116 jmp i386CommonExceptionHandler
119 .macro TRAP_STUB2 function, index
121 mov dword ptr i386ExceptionIndex, \index
122 jmp i386CommonExceptionHandler
125 /************************************************************************/
126 TRAP_STUB i386DivideByZero, 0
127 TRAP_STUB i386DebugException, 1
128 TRAP_STUB i386NMIException, 2
129 TRAP_STUB i386Breakpoint, 3
130 TRAP_STUB i386Overflow, 4
131 TRAP_STUB i386BoundException, 5
132 TRAP_STUB i386InvalidOpcode, 6
133 TRAP_STUB i386FPUNotAvailable, 7
134 TRAP_STUB2 i386DoubleFault, 8
135 TRAP_STUB i386CoprocessorSegment, 9
136 TRAP_STUB2 i386InvalidTSS, 10
137 TRAP_STUB2 i386SegmentNotPresent, 11
138 TRAP_STUB2 i386StackException, 12
139 TRAP_STUB2 i386GeneralProtectionFault, 13
140 TRAP_STUB2 i386PageFault, 14
142 TRAP_STUB i386CoprocessorError, 16
143 TRAP_STUB i386AlignmentCheck, 17
144 TRAP_STUB i386MachineCheck, 18
145 TRAP_STUB i386SimdFloatError, 19
147 /************************************************************************
148 * DEBUGGING SUPPORT FUNCTIONS
149 ************************************************************************/
151 .macro BREAKPOINT_TEPLATE functionname, mask1, mask2
152 EXTERN(\functionname)
164 BREAKPOINT_TEPLATE _INSTRUCTION_BREAKPOINT1, 0xfff0ffff, 0x00000303
165 BREAKPOINT_TEPLATE _MEMORY_READWRITE_BREAKPOINT1, 0xfff0ffff, 0x00030303
166 BREAKPOINT_TEPLATE _MEMORY_WRITE_BREAKPOINT1, 0xfff0ffff, 0x00010303
167 BREAKPOINT_TEPLATE _INSTRUCTION_BREAKPOINT2, 0xff0fffff, 0x0000030c
168 BREAKPOINT_TEPLATE _MEMORY_READWRITE_BREAKPOINT2, 0xff0fffff, 0x0030030c
169 BREAKPOINT_TEPLATE _MEMORY_WRITE_BREAKPOINT2, 0xff0fffff, 0x0010030c
170 BREAKPOINT_TEPLATE _INSTRUCTION_BREAKPOINT3, 0xf0ffffff, 0x00000330
171 BREAKPOINT_TEPLATE _MEMORY_READWRITE_BREAKPOINT3, 0xf0ffffff, 0x03000330
172 BREAKPOINT_TEPLATE _MEMORY_WRITE_BREAKPOINT3, 0xf0ffffff, 0x01000330
173 BREAKPOINT_TEPLATE _INSTRUCTION_BREAKPOINT4, 0x0fffffff, 0x000003c0
174 BREAKPOINT_TEPLATE _MEMORY_READWRITE_BREAKPOINT4, 0x0fffffff, 0x300003c0
175 BREAKPOINT_TEPLATE _MEMORY_WRITE_BREAKPOINT4, 0x0fffffff, 0x100003c0