2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
6 #include <asm/segments.h>
7 #include <asm/linkage.h>
8 #include <asm/ptrace.h>
9 #include <exec/alerts.h>
10 #include <proto/exec.h>
11 #include <aros/debug.h>
15 #define __text __attribute__((section(".text")))
20 return address of these exceptions is the address of faulting instr
22 return address is address of instruction followed by trapping instr
23 (1 can be FAULT and TRAP)
25 ABORT = ??? (no information = no return address)
49 const void (*traps
[0x14])(void) __text
=
73 static const struct { long long a
; } *idt_base
= (struct { long long a
; } *)0x100;
75 #define _set_gate(gate_addr,type,dpl,addr) \
78 __asm__ __volatile__ ("movw %%dx,%%ax\n\t" \
82 :"=m" (*((long *) (gate_addr))), \
83 "=m" (*(1+(long *) (gate_addr))), "=&a" (__d0), "=&d" (__d1) \
84 :"i" ((short) (0x8000+(dpl<<13)+(type<<8))), \
85 "3" ((char *) (addr)),"2" (KERNEL_CS << 16)); \
89 void set_intr_gate(unsigned int n
, void *addr
)
91 _set_gate(idt_base
+n
,14,0,addr
);
94 void set_system_gate(unsigned int n
, void *addr
)
96 _set_gate(idt_base
+n
,14,3,addr
);
99 void do_TRAP(struct pt_regs regs
)
103 kprintf("*** trap: eip = %x eflags = %x ds = %x sp ~= %x\n",
104 regs
.eip
, regs
.eflags
, regs
.xds
, ®s
);
106 switch (regs
.orig_eax
)
109 alert
= ACPU_DivZero
;
112 alert
= ACPU_InstErr
;
115 alert
= AT_DeadEnd
| 0x100 | regs
.orig_eax
;
120 void Init_Traps(void) {
125 _set_gate(idt_base
+i
,14,0,traps
[i
]);