2 Copyright © 2011, The AROS Development Team. All rights reserved.
5 Desc: Common trap handling routines for x86 CPU
9 #include <exec/execbase.h>
10 #include <exec/tasks.h>
11 #include <proto/exec.h>
13 #include "kernel_base.h"
14 #include "kernel_debug.h"
15 #include "kernel_interrupts.h"
16 #include "kernel_intr.h"
17 #include "cpu_traps.h"
24 static void PrintContext(struct ExceptionContext
*regs
, unsigned long error_code
)
28 struct Task
*t
= SysBase
->ThisTask
;
32 bug("[Kernel] %s %p '%s'\n", t
->tc_Node
.ln_Type
== NT_TASK
?"task":"process", t
, t
->tc_Node
.ln_Name
);
33 bug("[Kernel] SPLower=%p SPUpper=%p\n", t
->tc_SPLower
, t
->tc_SPUpper
);
35 if (((void *)SP(regs
) < t
->tc_SPLower
) || ((void *)SP(regs
) > t
->tc_SPUpper
))
36 bug("[Kernel] Stack out of Bounds!\n");
39 bug("[Kernel] Error 0x%p\n", error_code
);
40 PRINT_CPUCONTEXT(regs
);
42 bug("[Kernel] Stack:\n");
43 ptr
= (unsigned long *)SP(regs
);
44 for (i
=0; i
< 10; i
++)
45 bug("[Kernel] %02x: %p\n", i
* sizeof(unsigned long), ptr
[i
]);
50 #define PrintContext(regs, err)
55 * This table is used to translate x86 trap number
56 * to AmigaOS trap number to be passed to exec exception handler.
58 static const char AmigaTraps
[] =
66 void cpu_Trap(struct ExceptionContext
*regs
, unsigned long error_code
, unsigned long irq_number
)
68 D(bug("[Kernel] Trap exception %u\n", irq_number
));
70 if (krnRunExceptionHandlers(KernelBase
, irq_number
, regs
))
73 D(bug("[Kernel] Passing on to exec, Amiga trap %d\n", AmigaTraps
[irq_number
]));
75 if (AmigaTraps
[irq_number
] != -1)
77 if (core_Trap(AmigaTraps
[irq_number
], regs
))
79 /* If the trap handler returned, we can continue */
80 D(bug("[Kernel] Trap handler returned\n"));
85 bug("[Kernel] UNHANDLED EXCEPTION %lu\n", irq_number
);
86 PrintContext(regs
, error_code
);
88 while (1) asm volatile ("hlt");