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.
27 #define SCREEN_ATTR 0x1f /* Bright white on blue background */
82 i386ExceptionHandlerText:
83 .ascii "An error occured in FreeLoader\n"
86 .asciz "Report this error to the ReactOS Development mailing list <ros-dev@reactos.org>\n\n"
89 .asciz "Exception 00: DIVIDE BY ZERO\n\n"
90 i386DebugExceptionText:
91 .asciz "Exception 01: DEBUG EXCEPTION\n\n"
93 .asciz "Exception 02: NON-MASKABLE INTERRUPT EXCEPTION\n\n"
95 .asciz "Exception 03: BREAKPOINT (INT 3)\n\n"
97 .asciz "Exception 04: OVERFLOW\n\n"
98 i386BoundExceptionText:
99 .asciz "Exception 05: BOUND EXCEPTION\n\n"
100 i386InvalidOpcodeText:
101 .asciz "Exception 06: INVALID OPCODE\n\n"
102 i386FPUNotAvailableText:
103 .asciz "Exception 07: FPU NOT AVAILABLE\n\n"
105 .asciz "Exception 08: DOUBLE FAULT\n\n"
106 i386CoprocessorSegmentText:
107 .asciz "Exception 09: COPROCESSOR SEGMENT OVERRUN\n\n"
109 .asciz "Exception 0A: INVALID TSS\n\n"
110 i386SegmentNotPresentText:
111 .asciz "Exception 0B: SEGMENT NOT PRESENT\n\n"
112 i386StackExceptionText:
113 .asciz "Exception 0C: STACK EXCEPTION\n\n"
114 i386GeneralProtectionFaultText:
115 .asciz "Exception 0D: GENERAL PROTECTION FAULT\n\n"
117 .asciz "Exception 0E: PAGE FAULT\n\n"
118 i386CoprocessorErrorText:
119 .asciz "Exception 10: COPROCESSOR ERROR\n\n"
120 i386AlignmentCheckText:
121 .asciz "Exception 11: ALIGNMENT CHECK\n\n"
122 i386MachineCheckText:
123 .asciz "Exception 12: MACHINE CHECK\n\n"
157 i386_ERROR_CODE_Text:
158 .asciz " ERROR CODE: "
180 .asciz " GDTR Base: "
182 .asciz " IDTR Base: "
193 /* Set by each exception handler to the address of the description text */
194 i386ExceptionDescriptionText:
197 /* Used to store the contents of all the registers when an exception occurs */
263 /* Used to store the current X and Y position on the screen */
269 /************************************************************************/
270 i386CommonExceptionHandler:
276 call MachVideoClearScreen
279 movl $i386ExceptionHandlerText,%esi
282 movl i386ExceptionDescriptionText,%esi
285 movl $i386_EAX_Text,%esi
288 call i386PrintHexDword // Display EAX
289 movl $i386_ESP_Text,%esi
292 call i386PrintHexDword // Display ESP
293 movl $i386_CR0_Text,%esi
296 call i386PrintHexDword // Display CR0
297 movl $i386_DR0_Text,%esi
300 call i386PrintHexDword // Display DR0
301 movl $0,i386_ScreenPosX
303 movl $i386_EBX_Text,%esi
306 call i386PrintHexDword // Display EBX
307 movl $i386_EBP_Text,%esi
310 call i386PrintHexDword // Display EBP
311 movl $i386_CR1_Text,%esi
314 call i386PrintHexDword // Display CR1
315 movl $i386_DR1_Text,%esi
318 call i386PrintHexDword // Display DR1
319 movl $0,i386_ScreenPosX
321 movl $i386_ECX_Text,%esi
324 call i386PrintHexDword // Display ECX
325 movl $i386_ESI_Text,%esi
328 call i386PrintHexDword // Display ESI
329 movl $i386_CR2_Text,%esi
332 call i386PrintHexDword // Display CR2
333 movl $i386_DR2_Text,%esi
336 call i386PrintHexDword // Display DR2
337 movl $0,i386_ScreenPosX
339 movl $i386_EDX_Text,%esi
342 call i386PrintHexDword // Display EDX
343 movl $i386_EDI_Text,%esi
346 call i386PrintHexDword // Display EDI
347 movl $i386_CR3_Text,%esi
350 call i386PrintHexDword // Display CR3
351 movl $i386_DR3_Text,%esi
354 call i386PrintHexDword // Display DR3
356 movl $55,i386_ScreenPosX
357 movl $i386_DR6_Text,%esi
360 call i386PrintHexDword // Display DR6
362 movl $55,i386_ScreenPosX
363 movl $i386_DR7_Text,%esi
366 call i386PrintHexDword // Display DR7
367 movl $0,i386_ScreenPosX
370 movl $i386_CS_Text,%esi
373 call i386PrintHexWord // Display CS
374 movl $i386_EIP_Text,%esi
377 call i386PrintHexDword // Display EIP
378 movl $0,i386_ScreenPosX
380 movl $i386_DS_Text,%esi
383 call i386PrintHexWord // Display DS
384 movl $i386_ERROR_CODE_Text,%esi
386 movl i386_ERROR_CODE,%eax
387 call i386PrintHexDword // Display ERROR CODE
388 movl $0,i386_ScreenPosX
390 movl $i386_ES_Text,%esi
393 call i386PrintHexWord // Display ES
394 movl $i386_EFLAGS_Text,%esi
396 movl i386_EFLAGS,%eax
397 call i386PrintHexDword // Display EFLAGS
398 movl $0,i386_ScreenPosX
400 movl $i386_FS_Text,%esi
403 call i386PrintHexWord // Display FS
404 movl $i386_GDTR_Text,%esi
406 movl i386_GDTR+2,%eax
407 call i386PrintHexDword // Display GDTR Base
408 movl $i386_Limit_Text,%esi
411 call i386PrintHexWord // Display GDTR Limit
412 movl $0,i386_ScreenPosX
414 movl $i386_GS_Text,%esi
417 call i386PrintHexWord // Display GS
418 movl $i386_IDTR_Text,%esi
420 movl i386_IDTR+2,%eax
421 call i386PrintHexDword // Display IDTR Base
422 movl $i386_Limit_Text,%esi
425 call i386PrintHexWord // Display IDTR Limit
426 movl $0,i386_ScreenPosX
428 movl $i386_SS_Text,%esi
431 call i386PrintHexWord // Display SS
432 movl $i386_LDTR_Text,%esi
435 call i386PrintHexWord // Display LDTR
436 movl $i386_TR_Text,%esi
439 call i386PrintHexWord // Display TR
440 movl $0,i386_ScreenPosX
443 call i386PrintFrames // Display frames
448 i386ExceptionHandlerHang:
450 jmp i386ExceptionHandlerHang
455 movl $0,i386_ScreenPosX
456 movl $i386FramesText,%esi
463 movl $STACK32ADDR,%eax
468 call i386PrintHexDword // Display frame
477 /************************************************************************/
478 /* AL = Char to display */
479 /************************************************************************/
483 pushl i386_ScreenPosY
484 pushl i386_ScreenPosX
488 call MachVideoPutChar
493 /************************************************************************/
494 /* ESI = Address of text to display */
495 /************************************************************************/
502 // Check for end of string char
506 // Check for newline char
508 jne i386PrintTextLoop2
510 movl $0,i386_ScreenPosX
511 jmp i386PrintTextLoop
517 jmp i386PrintTextLoop
523 /************************************************************************/
524 /* Prints the value in EAX on the screen in hex */
525 /************************************************************************/
540 movl $i386PrintHexTable,%ebx
541 xlat /*$i386PrintHexTable*/
549 .ascii "0123456789ABCDEF"
551 /************************************************************************/
552 /* Prints the value in AX on the screen in hex */
553 /************************************************************************/
557 call i386PrintHexWord1
559 call i386PrintHexWord2
565 movl $i386PrintHexTable,%ebx
566 xlat /*$i386PrintHexTable*/
573 /************************************************************************/
574 /* Prints the value in AL on the screen in hex */
575 /************************************************************************/
579 call i386PrintHexByte1
585 movl $i386PrintHexTable,%ebx
586 xlat /*$i386PrintHexTable*/
593 /************************************************************************/
594 EXTERN(i386DivideByZero)
597 movl $i386DivideByZeroText,i386ExceptionDescriptionText
598 jmp i386CommonExceptionHandler
600 /************************************************************************/
601 EXTERN(i386DebugException)
604 movl $i386DebugExceptionText,i386ExceptionDescriptionText
605 jmp i386CommonExceptionHandler
607 /************************************************************************/
608 EXTERN(i386NMIException)
611 movl $i386NMIExceptionText,i386ExceptionDescriptionText
612 jmp i386CommonExceptionHandler
614 /************************************************************************/
615 EXTERN(i386Breakpoint)
618 movl $i386BreakpointText,i386ExceptionDescriptionText
619 jmp i386CommonExceptionHandler
621 /************************************************************************/
625 movl $i386OverflowText,i386ExceptionDescriptionText
626 jmp i386CommonExceptionHandler
628 /************************************************************************/
629 EXTERN(i386BoundException)
632 movl $i386BoundExceptionText,i386ExceptionDescriptionText
633 jmp i386CommonExceptionHandler
635 /************************************************************************/
636 EXTERN(i386InvalidOpcode)
639 movl $i386InvalidOpcodeText,i386ExceptionDescriptionText
640 jmp i386CommonExceptionHandler
642 /************************************************************************/
643 EXTERN(i386FPUNotAvailable)
646 movl $i386FPUNotAvailableText,i386ExceptionDescriptionText
647 jmp i386CommonExceptionHandler
649 /************************************************************************/
650 EXTERN(i386DoubleFault)
654 movl %eax,i386_ERROR_CODE
656 movl $i386DoubleFaultText,i386ExceptionDescriptionText
657 jmp i386CommonExceptionHandler
659 /************************************************************************/
660 EXTERN(i386CoprocessorSegment)
663 movl $i386CoprocessorSegmentText,i386ExceptionDescriptionText
664 jmp i386CommonExceptionHandler
666 /************************************************************************/
667 EXTERN(i386InvalidTSS)
671 movl %eax,i386_ERROR_CODE
673 movl $i386InvalidTSSText,i386ExceptionDescriptionText
674 jmp i386CommonExceptionHandler
676 /************************************************************************/
677 EXTERN(i386SegmentNotPresent)
681 movl %eax,i386_ERROR_CODE
683 movl $i386SegmentNotPresentText,i386ExceptionDescriptionText
684 jmp i386CommonExceptionHandler
686 /************************************************************************/
687 EXTERN(i386StackException)
691 movl %eax,i386_ERROR_CODE
693 movl $i386StackExceptionText,i386ExceptionDescriptionText
694 jmp i386CommonExceptionHandler
696 /************************************************************************/
697 EXTERN(i386GeneralProtectionFault)
701 movl %eax,i386_ERROR_CODE
703 movl $i386GeneralProtectionFaultText,i386ExceptionDescriptionText
704 jmp i386CommonExceptionHandler
706 /************************************************************************/
707 EXTERN(i386PageFault)
711 movl %eax,i386_ERROR_CODE
713 movl $i386PageFaultText,i386ExceptionDescriptionText
714 jmp i386CommonExceptionHandler
716 /************************************************************************/
717 EXTERN(i386CoprocessorError)
720 movl $i386CoprocessorErrorText,i386ExceptionDescriptionText
721 jmp i386CommonExceptionHandler
723 /************************************************************************/
724 EXTERN(i386AlignmentCheck)
727 movl $i386AlignmentCheckText,i386ExceptionDescriptionText
728 jmp i386CommonExceptionHandler
730 /************************************************************************/
731 EXTERN(i386MachineCheck)
734 movl $i386MachineCheckText,i386ExceptionDescriptionText
735 jmp i386CommonExceptionHandler
737 /************************************************************************
738 * DEBUGGING SUPPORT FUNCTIONS
739 ************************************************************************/
740 EXTERN(_INSTRUCTION_BREAKPOINT1)
749 andl $0xfff0ffff,%eax
757 EXTERN(_MEMORY_READWRITE_BREAKPOINT1)
766 andl $0xfff0ffff,%eax
774 EXTERN(_MEMORY_WRITE_BREAKPOINT1)
783 andl $0xfff0ffff,%eax
791 EXTERN(_INSTRUCTION_BREAKPOINT2)
800 andl $0xff0fffff,%eax
808 EXTERN(_MEMORY_READWRITE_BREAKPOINT2)
817 andl $0xff0fffff,%eax
825 EXTERN(_MEMORY_WRITE_BREAKPOINT2)
834 andl $0xff0fffff,%eax
842 EXTERN(_INSTRUCTION_BREAKPOINT3)
851 andl $0xf0ffffff,%eax
859 EXTERN(_MEMORY_READWRITE_BREAKPOINT3)
868 andl $0xf0ffffff,%eax
876 EXTERN(_MEMORY_WRITE_BREAKPOINT3)
885 andl $0xf0ffffff,%eax
893 EXTERN(_INSTRUCTION_BREAKPOINT4)
902 andl $0x0fffffff,%eax
910 EXTERN(_MEMORY_READWRITE_BREAKPOINT4)
919 andl $0x0fffffff,%eax
927 EXTERN(_MEMORY_WRITE_BREAKPOINT4)
936 andl $0x0fffffff,%eax