1 | /* fatal.c |
---|
2 | * |
---|
3 | * User-define fatal error handler. |
---|
4 | * |
---|
5 | * Copyright (c) 1998, National Research Council of Canada |
---|
6 | * |
---|
7 | * The license and distribution terms for this file may be |
---|
8 | * found in the file LICENSE in this distribution or at |
---|
9 | * http://www.rtems.com/license/LICENSE. |
---|
10 | */ |
---|
11 | |
---|
12 | #include <bsp.h> |
---|
13 | #include <fatal.h> |
---|
14 | #include <string.h> |
---|
15 | |
---|
16 | /* |
---|
17 | * bsp_fatal_error_occurred |
---|
18 | * |
---|
19 | * Called when rtems_fatal_error_occurred() is called. Returns control to |
---|
20 | * 167Bug. The _Internal_error_Occurred() function has already saved the |
---|
21 | * parameters in Internal_errors_What_happened. If the function returns, |
---|
22 | * RTEMS will halt the CPU. |
---|
23 | * |
---|
24 | * Make sure the CPU is |
---|
25 | * |
---|
26 | * Input parameters: |
---|
27 | * the_source - what subsystem the error originated in |
---|
28 | * is_internal - if the error was internally generated |
---|
29 | * the_error - fatal error status code |
---|
30 | * |
---|
31 | * Output parameters: |
---|
32 | * output to the 167Bug console |
---|
33 | * |
---|
34 | * Return values: NONE. |
---|
35 | */ |
---|
36 | User_extensions_routine bsp_fatal_error_occurred( |
---|
37 | Internal_errors_Source the_source, |
---|
38 | bool is_internal, |
---|
39 | uint32_t the_error |
---|
40 | ) |
---|
41 | { |
---|
42 | struct { |
---|
43 | char index; /* First byte is number of chars in strbuf */ |
---|
44 | char strbuf[254]; /* In case count is bumped up by one by 167Bug */ |
---|
45 | } my_p_str; |
---|
46 | |
---|
47 | strcat(my_p_str.strbuf, |
---|
48 | "\r\nRTEMS Fatal Error Occurred:\r\n the_source = " ); |
---|
49 | |
---|
50 | switch ( the_source ) { |
---|
51 | case INTERNAL_ERROR_CORE: |
---|
52 | strcat(my_p_str.strbuf, |
---|
53 | "INTERNAL_ERROR_CORE\r\n is_internal = " ); |
---|
54 | break; |
---|
55 | |
---|
56 | case INTERNAL_ERROR_RTEMS_API: |
---|
57 | strcat(my_p_str.strbuf, |
---|
58 | "INTERNAL_ERROR_RTEMS_API\r\n is_internal = " ); |
---|
59 | break; |
---|
60 | |
---|
61 | case INTERNAL_ERROR_POSIX_API: |
---|
62 | strcat(my_p_str.strbuf, |
---|
63 | "INTERNAL_ERROR_POSIX_API\r\n is_internal = " ); |
---|
64 | break; |
---|
65 | |
---|
66 | default: |
---|
67 | strcat(my_p_str.strbuf, |
---|
68 | "UNKNOWN\r\n is_internal = " ); |
---|
69 | break; |
---|
70 | } |
---|
71 | |
---|
72 | if ( is_internal ) |
---|
73 | strcat(my_p_str.strbuf, |
---|
74 | "TRUE\r\n the_error = 0x|10,8|\r\n" ); |
---|
75 | else |
---|
76 | strcat(my_p_str.strbuf, |
---|
77 | "FALSE\r\n the_error = 0x|10,8|\r\n" ); |
---|
78 | |
---|
79 | my_p_str.index = strlen(my_p_str.strbuf); |
---|
80 | lcsr->intr_ena = 0; /* disable interrupts */ |
---|
81 | m68k_set_vbr(0xFFE00000); /* restore 167Bug vectors */ |
---|
82 | |
---|
83 | __asm__ volatile( "movel %0, -(%%a7)\n\t" |
---|
84 | "pea (%%a7)\n\t" |
---|
85 | "pea (%1)\n\t" |
---|
86 | "trap #15\n\t" /* trap to 167Bug (.WRITDLN) */ |
---|
87 | ".short 0x25\n\t" |
---|
88 | "trap #15\n\t" |
---|
89 | ".short 0x63" |
---|
90 | :: "d" (the_error), "a" (&my_p_str) ); |
---|
91 | } |
---|