source: trunk/hal/i386/__do_exception.c @ 30

Last change on this file since 30 was 1, checked in by alain, 8 years ago

First import

File size: 2.6 KB
Line 
1/*
2 * __do_exception.c - first stage exception handler
3 *
4 * Copyright (c) 2008,2009,2010,2011,2012 Ghassan Almaless
5 * Copyright (c) 2011,2012 UPMC Sorbonne Universites
6 *
7 * This file is part of ALMOS-kernel.
8 *
9 * ALMOS-kernel is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 2.0 of the License.
12 *
13 * ALMOS-kernel is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with ALMOS-kernel; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23#include <types.h>
24#include <kdmsg.h>
25#include <cpu.h>
26#include <cpu-internal.h>
27
28static char *exception_name[32] = {"Division By Zero Exception",
29                                   "Debug Exception",
30                                   "Non Maskable Interrupt Exception",
31                                   "Breakpoint Exception",
32                                   "Into Detected Overflow Exception",
33                                   "Out of Bounds Exception",
34                                   "Invalid Opcode Exception",
35                                   "Coprocessor Exception",
36                                   "Double Fault Exception",
37                                   "Coprocessor Segment Overrun Exception",
38                                   "Bad TSS Exception",
39                                   "Segment Not Present Exception",
40                                   "Stack Fault Exception",
41                                   "General Protection Fault Exception",
42                                   "Page Fault Exception",
43                                   "Unknown Interrupt Exception",
44                                   "Coprocessor Fault Exception",
45                                   "Alignment Check Exception (486+)",
46                                   "Machine Check Exception (Pentium/586+)",
47                                   "Resrved Exception",
48                                   "Resrved Exception",
49                                   "Resrved Exception",
50                                   "Resrved Exception",
51                                   "Resrved Exception",
52                                   "Resrved Exception",
53                                   "Resrved Exception",
54                                   "Resrved Exception",
55                                   "Resrved Exception",
56                                   "Resrved Exception",
57                                   "Resrved Exception",
58                                   "Resrved Exception",
59                                   "Resrved Exception"};
60
61void __do_exception(struct cpu_regs_s *regs)
62{ 
63
64        cpu_spinlock_lock(&exception_lock.val);
65 
66        except_dmsg("Exception has occured [ %s ]\n", exception_name[regs->int_nr]);
67        except_dmsg("ret_cs %x\tret_eip %x\teflags %x\told_ss %x\told_esp %x\t err_code %x\n",
68                    regs->ret_cs,regs->ret_eip,regs->eflags, regs->old_ss, regs->old_esp, regs->err_code);
69 
70        except_dmsg("gs %x\tfs %x\tes %x\tds %x\n", regs->gs, regs->es, regs->ds);
71
72        except_dmsg("ebp %x\tebx %x\tedx %x\tecx %x\teax %x\n",
73                    regs->ebx, regs->edx, regs->ecx, regs->eax);
74
75        cpu_spinlock_unlock(&exception_lock.val);
76 
77        while(1);
78}
Note: See TracBrowser for help on using the repository browser.