2 Copyright © 1995-2009, 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 typedef asmlinkage
void (*trap_type
)(void);
51 const trap_type traps
[0x14] __text
=
75 typedef struct { long long a
; } dummy_double
;
76 static const dummy_double
*idt_base
= (const dummy_double
*)0x100;
78 #define _set_gate(gate_addr,type,dpl,addr) \
81 __asm__ __volatile__ ("movw %%dx,%%ax\n\t" \
85 :"=m" (*((long *) (gate_addr))), \
86 "=m" (*(1+(long *) (gate_addr))), "=&a" (__d0), "=&d" (__d1) \
87 :"i" ((short) (0x8000+(dpl<<13)+(type<<8))), \
88 "3" ((char *) (addr)),"2" (KERNEL_CS << 16)); \
92 void set_intr_gate(unsigned int n
, void *addr
)
94 _set_gate(idt_base
+n
,14,0,addr
);
97 void set_system_gate(unsigned int n
, void *addr
)
99 _set_gate(idt_base
+n
,14,3,addr
);
102 void printException(struct pt_regs regs
)
104 kprintf("*** trap: eip = %x eflags = %x ds = %x sp ~= %x\n",
105 regs
.eip
, regs
.eflags
, regs
.xds
, ®s
.esp
);
108 void handleException(ULONG exceptionNo
)
112 VOID (*trapHandler
)(ULONG
, void *);
114 // Determine alert number
118 alert
= ACPU_DivZero
;
121 alert
= ACPU_InstErr
;
124 alert
= AT_DeadEnd
| 0x100 | exceptionNo
;
127 // Call task's trap handler
128 task
= FindTask(NULL
);
129 trapHandler
= task
->tc_TrapCode
;
130 trapHandler(alert
, NULL
);
133 void Init_Traps(void) {
138 _set_gate(idt_base
+i
,14,0,traps
[i
]);