1 | #include <rtems/system.h> |
---|
2 | /* |
---|
3 | #include <rtems/score/isr.h> |
---|
4 | */ |
---|
5 | |
---|
6 | /* |
---|
7 | * User exception handlers |
---|
8 | */ |
---|
9 | proc_ptr M68040FPSPUserExceptionHandlers[9]; |
---|
10 | |
---|
11 | /* |
---|
12 | * Intercept requests to install an exception handler. |
---|
13 | * FPSP exceptions get special treatment. |
---|
14 | */ |
---|
15 | static int |
---|
16 | FPSP_install_raw_handler (uint32_t vector, proc_ptr new_handler, proc_ptr *old_handler) |
---|
17 | { |
---|
18 | int fpspVector; |
---|
19 | |
---|
20 | switch (vector) { |
---|
21 | default: return 0; /* Non-FPSP vector */ |
---|
22 | case 11: fpspVector = 0; break; /* F-line */ |
---|
23 | case 48: fpspVector = 1; break; /* BSUN */ |
---|
24 | case 49: fpspVector = 2; break; /* INEXACT */ |
---|
25 | case 50: fpspVector = 3; break; /* DIVIDE-BY-ZERO */ |
---|
26 | case 51: fpspVector = 4; break; /* UNDERFLOW */ |
---|
27 | case 52: fpspVector = 5; break; /* OPERAND ERROR */ |
---|
28 | case 53: fpspVector = 6; break; /* OVERFLOW */ |
---|
29 | case 54: fpspVector = 7; break; /* SIGNALLING NAN */ |
---|
30 | case 55: fpspVector = 8; break; /* UNIMPLEMENTED DATA TYPE */ |
---|
31 | } |
---|
32 | *old_handler = M68040FPSPUserExceptionHandlers[fpspVector]; |
---|
33 | M68040FPSPUserExceptionHandlers[fpspVector] = new_handler; |
---|
34 | return 1; |
---|
35 | } |
---|
36 | |
---|
37 | /* |
---|
38 | * Exception handlers provided by FPSP package. |
---|
39 | */ |
---|
40 | extern void _fpspEntry_fline(void); |
---|
41 | extern void _fpspEntry_bsun(void); |
---|
42 | extern void _fpspEntry_inex(void); |
---|
43 | extern void _fpspEntry_dz(void); |
---|
44 | extern void _fpspEntry_unfl(void); |
---|
45 | extern void _fpspEntry_ovfl(void); |
---|
46 | extern void _fpspEntry_operr(void); |
---|
47 | extern void _fpspEntry_snan(void); |
---|
48 | extern void _fpspEntry_unsupp(void); |
---|
49 | |
---|
50 | /* |
---|
51 | * Attach floating point exception vectors to M68040FPSP entry points |
---|
52 | * |
---|
53 | * NOTE: Uses M68K rather than M68040 in the name so all CPUs having |
---|
54 | * an FPSP can share the same code in RTEMS proper. |
---|
55 | */ |
---|
56 | void |
---|
57 | M68KFPSPInstallExceptionHandlers (void) |
---|
58 | { |
---|
59 | static struct { |
---|
60 | int vector_number; |
---|
61 | void (*handler)(void); |
---|
62 | } fpspHandlers[] = { |
---|
63 | { 11, _fpspEntry_fline }, |
---|
64 | { 48, _fpspEntry_bsun }, |
---|
65 | { 49, _fpspEntry_inex }, |
---|
66 | { 50, _fpspEntry_dz }, |
---|
67 | { 51, _fpspEntry_unfl }, |
---|
68 | { 52, _fpspEntry_operr }, |
---|
69 | { 53, _fpspEntry_ovfl }, |
---|
70 | { 54, _fpspEntry_snan }, |
---|
71 | { 55, _fpspEntry_unsupp }, |
---|
72 | }; |
---|
73 | int i; |
---|
74 | proc_ptr oldHandler; |
---|
75 | |
---|
76 | for (i = 0 ; i < sizeof fpspHandlers / sizeof fpspHandlers[0] ; i++) { |
---|
77 | _CPU_ISR_install_raw_handler(fpspHandlers[i].vector_number, fpspHandlers[i].handler, &oldHandler); |
---|
78 | M68040FPSPUserExceptionHandlers[i] = oldHandler; |
---|
79 | } |
---|
80 | _FPSP_install_raw_handler = FPSP_install_raw_handler; |
---|
81 | } |
---|