panic.c
上传用户:qddsws
上传日期:2022-06-22
资源大小:723k
文件大小:3k
- #include <i386/panic.h>
- void int_00(void);
- void LoadExceptions()
- {
- /*
- * Afegim a la IDT tots els handlers de les excepcions.
- *
- */
- AddInt(0, int00, 0);
- AddInt(1, _int01, 0);
- AddInt(2, int02, 0);
- AddInt(3, _int03, 0);
- AddInt(4, int04, 0);
- AddInt(5, int05, 0);
- AddInt(6, int06, 0);
- AddInt(7, int07, 0);
- AddInt(8, int08, 0);
- AddInt(9, int09, 0);
- AddInt(10, int10, 0);
- AddInt(11, int11, 0);
- AddInt(12, int12, 0);
- AddInt(13, int13, 0);
- AddInt(14, int14, 0);
- AddInt(16, int16, 0);
- AddInt(17, int17, 0);
- AddInt(18, int18, 0);
- AddInt(19, int19, 0);
- AddInt(20, 0, 0);
- AddInt(21, 0, 0);
- AddInt(22, 0, 0);
- AddInt(23, 0, 0);
- AddInt(24, 0, 0);
- AddInt(25, 0, 0);
- AddInt(26, 0, 0);
- AddInt(27, 0, 0);
- AddInt(28, 0, 0);
- AddInt(29, 0, 0);
- AddInt(30, 0, 0);
- AddInt(31, 0, 0);
- }
- void panic(char *message, char *code, bool halt)
- {
- clrscr();
- kprint("<SYSTEM ERROR>n");
- if(halt==true)
- {
- kprint("A Fatal ");
- }
- if(halt==false)
- {
- kprint("A Non Fataln");
- }
- kprint("Exception Has Occuredan");
- kprint(message);
- kprint("n");
- while (1>0);
- if(halt==true)
- {
- kprint("n>SYSTEM HALTED<<n");
- asm("clin");
- asm("hltn"); //Parem la m鄎uina
- }
- else if(halt==false)
- {
- kprint("n<Press Any Key To Continue>n");
- }
- }
- /*
- * Exceptions
- */
- void int_00(void)
- {
- kprint("Zarro Division Errorn");
- //panic("Divide By Zero Error","#00", false);
- }
- void int_01(void)
- {
- panic("Debug Error","#DB", false);
- }
- void int_02(void)
- {
- panic("NMI Interrupt","#--", false);
- }
- void int_03(void)
- {
- panic("Breakpoint","#BP", false);
- }
- void int_04(void)
- {
- panic("Overflow","#OF", false);
- }
- void int_05(void)
- {
- panic("BOUND Range Exceeded","#BR", false);
- }
- void int_06(void)
- {
- panic("Invalid Opcode","#UD", false);
- }
- void int_07(void)
- {
- panic("Device Not Available","#NM", false);
- }
- void int_08(void)
- {
- panic("Double Fault","#DF", true);
- }
- void int_09(void)
- {
- panic("Coprocessor Segment Overrun", "#NA", false);
- }
- void int_10(void)
- {
- panic("Invalid TSS","#TS", false);
- }
- void int_11(void)
- {
- panic("Segment Not Present","#NP", false);
- }
- void int_12(void)
- {
- panic("Stack Segment Fault","#SS", false);
- }
- void int_13(void)
- {
- panic("Gneral Protection Fault","#GP", false);
- hangup();
- }
- void int_14(void)
- {
- unsigned long t;
- unsigned long errorcode;
- __asm__ volatile ("" : "=a"(t));
- __asm__ volatile ("" : "=b"(errorcode));
- panic("Page Fault","#PF", false);
- if (errorcode==2) {
- kprint("nWrite a non present pagen");
- allocate_page(t);
- }
- if (errorcode==0) {
- kprint("nRead a non present pagen");
- }
- }
- void int_16(void)
- {
- panic("FPU Floating-Point Error","#MF", false);
- }
- void int_17(void)
- {
- panic("Alignment Check","#AC", false);
- }
- void int_18(void)
- {
- panic("Machine Check","#MC", true);
- }
- void int_19(void)
- {
- panic("SIMD Floating-Point","#XF", false);
- }