00001
00002 #ifndef _CORE_ARCH_X86_EXCEPT_C_HPP
00003 #define _CORE_ARCH_X86_EXCEPT_C_HPP
00004
00005 #include "src/arch/x86/interr.hpp"
00006
00007 extern void (*exc)();
00008 extern void (*irq_h)();
00009
00010 namespace Arch {
00011 namespace x86 {
00012 namespace Interr {
00013
00018 bool isInInterruptHandler();
00019
00022 const uint32 CHAINHANDLERSTACKCOPY = sizeof(uint32) * 10 +
00023 sizeof(struct reg_dump);
00024 const uint32 CHAINREGCOPY = sizeof(uint32) * 3;
00025
00026 const uint32 STACKSZ = 0x4000;
00027 const uint32 STACKCNT = 16;
00028
00029 extern char *stackPtr[STACKCNT];
00030 extern uint32 volatile stackVac;
00031
00032
00033
00034 struct except2_t
00035 {
00036 uint32 ebp;
00037 struct reg_dump r;
00038 uint32 c1, c2;
00039 uint32 cr2;
00040 uint32 eip,cs,eflags,esp,ss;
00041 char *stack;
00042 char *reta;
00043 };
00044
00045 struct except_t
00046 {
00047 uint32 cr3, cr2, cr0;
00048 union
00049 {
00050 uint32 thread_esp;
00051
00052 struct {
00053 uint32 thread_ebp;
00054 reg_dump regs;
00055 uint32 code;
00056 uint32 val;
00057 uint32 thread_eip;
00058 uint32 thread_cs;
00059 uint32 thread_eflags;
00060 union
00061 {
00062 uint32 thread_3_esp;
00063 uint32 *stack;
00064 } uu;
00065 uint32 thread_3_ss;
00066 } *iret;
00067
00068 uint32 *stack;
00069 } uu;
00070 uint32 interrupt_stack_offset;
00071 };
00072
00073
00074 extern const char *except_names[0x20];
00075
00076
00077 const uint32 INT_DIV0 = 0x00;
00078 const uint32 INT_OPCODE = 0x06;
00079 const uint32 INT_GPF = 0x0d;
00080 const uint32 INT_PF = 0x0e;
00081 const uint32 SYSENT = 0x30;
00082
00083
00084 struct list_t
00085 {
00086 list_t *next;
00087 int (*proc)(except2_t*);
00088 };
00089
00090
00091 extern list_t* int_lists[0x31];
00092 extern int (*first_routine[0x31])(except2_t*);
00093
00094
00095 int Exception(except2_t *code);
00096 int PageFault(except2_t *code);
00097 void double_fault() __attribute__ ((noreturn));
00098 void stack_fault() __attribute__ ((noreturn));
00099 int Irq_H(except2_t *code);
00100
00101
00102 struct chh_t
00103 {
00104 uint32 ebp;
00105 struct reg_dump r;
00106 uint32 c1,c2;
00107 uint32 eip;
00108 uint32 cs;
00109 uint32 eflags;
00110 };
00111
00112 void chain_handler(struct chh_t code);
00113 extern uint32 add2interr_chain(uint32,int (*proc)(except2_t*));
00114 void install_first_routine(uint32 n, uint32 (*proc)(except2_t*));
00115 uint32 del_chainHdl(uint32 intno, uint32 ptr);
00116 void init_int_chains(idt_service *ptr);
00117 void done_int_chains();
00118
00119
00120
00121 extern uint32 free_stacks[];
00122 extern uint32 free_stacks_ptr;
00123
00124 extern void intr0x00() asm ("intr0x00");
00125 extern void intr0x01() asm ("intr0x01");
00126 extern void intr0x02() asm ("intr0x02");
00127 extern void intr0x03() asm ("intr0x03");
00128 extern void intr0x04() asm ("intr0x04");
00129 extern void intr0x05() asm ("intr0x05");
00130 extern void intr0x06() asm ("intr0x06");
00131 extern void intr0x07() asm ("intr0x07");
00132 extern void intr0x08() asm ("intr0x08");
00133 extern void intr0x09() asm ("intr0x09");
00134 extern void intr0x0a() asm ("intr0x0a");
00135 extern void intr0x0b() asm ("intr0x0b");
00136 extern void intr0x0c() asm ("intr0x0c");
00137 extern void intr0x0d() asm ("intr0x0d");
00138 extern void intr0x0e() asm ("intr0x0e");
00139 extern void intr0x0f() asm ("intr0x0f");
00140 extern void intr0x10() asm ("intr0x10");
00141 extern void intr0x11() asm ("intr0x11");
00142 extern void intr0x12() asm ("intr0x12");
00143 extern void intr0x13() asm ("intr0x13");
00144 extern void intr0x14() asm ("intr0x14");
00145 extern void intr0x15() asm ("intr0x15");
00146 extern void intr0x16() asm ("intr0x16");
00147 extern void intr0x17() asm ("intr0x17");
00148 extern void intr0x18() asm ("intr0x18");
00149 extern void intr0x19() asm ("intr0x19");
00150 extern void intr0x1a() asm ("intr0x1a");
00151 extern void intr0x1b() asm ("intr0x1b");
00152 extern void intr0x1c() asm ("intr0x1c");
00153 extern void intr0x1d() asm ("intr0x1d");
00154 extern void intr0x1e() asm ("intr0x1e");
00155 extern void intr0x1f() asm ("intr0x1f");
00156
00157 extern void intr0x20() asm ("intr0x20");
00158 extern void intr0x21() asm ("intr0x21");
00159 extern void intr0x22() asm ("intr0x22");
00160 extern void intr0x23() asm ("intr0x23");
00161 extern void intr0x24() asm ("intr0x24");
00162 extern void intr0x25() asm ("intr0x25");
00163 extern void intr0x26() asm ("intr0x26");
00164 extern void intr0x27() asm ("intr0x27");
00165 extern void intr0x28() asm ("intr0x28");
00166 extern void intr0x29() asm ("intr0x29");
00167 extern void intr0x2a() asm ("intr0x2a");
00168 extern void intr0x2b() asm ("intr0x2b");
00169 extern void intr0x2c() asm ("intr0x2c");
00170 extern void intr0x2d() asm ("intr0x2d");
00171 extern void intr0x2e() asm ("intr0x2e");
00172 extern void intr0x2f() asm ("intr0x2f");
00173
00174
00175 };
00176 };
00177 };
00178
00179 #endif