summaryrefslogtreecommitdiff
path: root/libcpu/ia32/trap.c
diff options
context:
space:
mode:
Diffstat (limited to 'libcpu/ia32/trap.c')
-rw-r--r--libcpu/ia32/trap.c88
1 files changed, 44 insertions, 44 deletions
diff --git a/libcpu/ia32/trap.c b/libcpu/ia32/trap.c
index 5e9a51d6d2..b3484cfd58 100644
--- a/libcpu/ia32/trap.c
+++ b/libcpu/ia32/trap.c
@@ -22,7 +22,7 @@
struct Gatedesc idt[256] = { {0}, };
struct Pseudodesc idt_pd =
{
- 0, sizeof(idt) - 1, (unsigned long) idt,
+ 0, sizeof(idt) - 1, (unsigned long) idt,
};
/* exception and interrupt handler table */
@@ -40,36 +40,36 @@ extern rt_isr_handler_t hdinterrupt_func[];
*
*/
void rt_hw_idt_init(void)
-{
- extern void Xdefault;
- int i, j, func;
+{
+ extern void Xdefault;
+ int i, j, func;
+
+ // install a default handler
+ for (i = 0; i < sizeof(idt)/sizeof(idt[0]); i++)
+ SETGATE(idt[i], 0, GD_KT, &Xdefault, 0);
+
+ /*install trap handler*/
+ for(i = 0; i < 16; i++)
+ {
+ func = (int)trap_func[i];
+ SETGATE(idt[i], 0, GD_KT, func, 0);
+ }
- // install a default handler
- for (i = 0; i < sizeof(idt)/sizeof(idt[0]); i++)
- SETGATE(idt[i], 0, GD_KT, &Xdefault, 0);
+ func = (int)trap_func[3];
+ SETGATE(idt[3], 0, GD_KT, func, 3);
- /*install trap handler*/
- for(i = 0; i < 16; i++)
- {
- func = (int)trap_func[i];
- SETGATE(idt[i], 0, GD_KT, func, 0);
- }
+ i = 0;
- func = (int)trap_func[3];
- SETGATE(idt[3], 0, GD_KT, func, 3);
+ /*install exteral interrupt handler*/
+ for(j = IRQ_OFFSET; j < IRQ_OFFSET + MAX_HANDLERS; j++)
+ {
+ func = (int)hdinterrupt_func[i];
+ SETGATE(idt[j], 0, GD_KT, func, 0);
+ i++;
+ }
- i = 0;
-
- /*install exteral interrupt handler*/
- for(j = IRQ_OFFSET; j < IRQ_OFFSET + MAX_HANDLERS; j++)
- {
- func = (int)hdinterrupt_func[i];
- SETGATE(idt[j], 0, GD_KT, func, 0);
- i++;
- }
-
- // Load the IDT
- asm volatile("lidt idt_pd + 2");
+ // Load the IDT
+ asm volatile("lidt idt_pd + 2");
}
/**
@@ -80,24 +80,24 @@ void rt_hw_idt_init(void)
*/
void rt_hw_trap_irq(int trapno)
{
- switch(trapno)
- {
- case T_DIVIDE:
- rt_kprintf("Divide error interrupt\n");
- RT_ASSERT(0);
- case T_PGFLT:
- rt_kprintf("Page fault interrupt\n");
- RT_ASSERT(0);
- case T_GPFLT:
- rt_kprintf("General protection interrupt\n");
- RT_ASSERT(0);
- case T_DEFAULT:
- rt_hw_interrupt_handle(T_DEFAULT);
- return;
- }
+ switch(trapno)
+ {
+ case T_DIVIDE:
+ rt_kprintf("Divide error interrupt\n");
+ RT_ASSERT(0);
+ case T_PGFLT:
+ rt_kprintf("Page fault interrupt\n");
+ RT_ASSERT(0);
+ case T_GPFLT:
+ rt_kprintf("General protection interrupt\n");
+ RT_ASSERT(0);
+ case T_DEFAULT:
+ rt_hw_interrupt_handle(T_DEFAULT);
+ return;
+ }
- /*kernel bug if run here*/
- RT_ASSERT(0);
+ /*kernel bug if run here*/
+ RT_ASSERT(0);
}
/*@}*/