1 | #include <rtems.h> |
---|
2 | #include <bsp.h> |
---|
3 | #include <bsp/uart.h> |
---|
4 | #include <rtems/bspIo.h> |
---|
5 | #include <rtems/error.h> |
---|
6 | #include <libcpu/stackTrace.h> |
---|
7 | |
---|
8 | static void |
---|
9 | rebootQuestion() |
---|
10 | { |
---|
11 | printk("Press a key to reboot\n"); |
---|
12 | BSP_poll_char_via_serial(); |
---|
13 | rtemsReboot(); |
---|
14 | } |
---|
15 | |
---|
16 | void BSP_panic(char *s) |
---|
17 | { |
---|
18 | printk("%s PANIC %s\n",_RTEMS_version, s); |
---|
19 | rebootQuestion(); |
---|
20 | } |
---|
21 | |
---|
22 | #define THESRC Internal_errors_What_happened.the_source |
---|
23 | #define ISITNL Internal_errors_What_happened.is_internal |
---|
24 | #define THEERR Internal_errors_What_happened.the_error |
---|
25 | |
---|
26 | char *score_status_text(rtems_status_code sc) |
---|
27 | { |
---|
28 | switch (sc) { |
---|
29 | case INTERNAL_ERROR_NO_CONFIGURATION_TABLE: |
---|
30 | return "INTERNAL_ERROR_NO_CONFIGURATION_TABLE"; |
---|
31 | case INTERNAL_ERROR_NO_CPU_TABLE: |
---|
32 | return "INTERNAL_ERROR_NO_CPU_TABLE"; |
---|
33 | case INTERNAL_ERROR_INVALID_WORKSPACE_ADDRESS: |
---|
34 | return "INTERNAL_ERROR_INVALID_WORKSPACE_ADDRESS"; |
---|
35 | case INTERNAL_ERROR_TOO_LITTLE_WORKSPACE: |
---|
36 | return "INTERNAL_ERROR_TOO_LITTLE_WORKSPACE"; |
---|
37 | case INTERNAL_ERROR_WORKSPACE_ALLOCATION: |
---|
38 | return "INTERNAL_ERROR_WORKSPACE_ALLOCATION"; |
---|
39 | case INTERNAL_ERROR_INTERRUPT_STACK_TOO_SMALL: |
---|
40 | return "INTERNAL_ERROR_INTERRUPT_STACK_TOO_SMALL"; |
---|
41 | case INTERNAL_ERROR_THREAD_EXITTED: |
---|
42 | return "INTERNAL_ERROR_THREAD_EXITTED"; |
---|
43 | case INTERNAL_ERROR_INCONSISTENT_MP_INFORMATION: |
---|
44 | return "INTERNAL_ERROR_INCONSISTENT_MP_INFORMATION"; |
---|
45 | case INTERNAL_ERROR_INVALID_NODE: |
---|
46 | return "INTERNAL_ERROR_INVALID_NODE"; |
---|
47 | case INTERNAL_ERROR_NO_MPCI: |
---|
48 | return "INTERNAL_ERROR_NO_MPCI"; |
---|
49 | case INTERNAL_ERROR_BAD_PACKET: |
---|
50 | return "INTERNAL_ERROR_BAD_PACKET"; |
---|
51 | case INTERNAL_ERROR_OUT_OF_PACKETS: |
---|
52 | return "INTERNAL_ERROR_OUT_OF_PACKETS"; |
---|
53 | case INTERNAL_ERROR_OUT_OF_GLOBAL_OBJECTS: |
---|
54 | return "INTERNAL_ERROR_OUT_OF_GLOBAL_OBJECTS"; |
---|
55 | case INTERNAL_ERROR_OUT_OF_PROXIES: |
---|
56 | return "INTERNAL_ERROR_OUT_OF_PROXIES"; |
---|
57 | case INTERNAL_ERROR_INVALID_GLOBAL_ID: |
---|
58 | return "INTERNAL_ERROR_INVALID_GLOBAL_ID"; |
---|
59 | case INTERNAL_ERROR_BAD_STACK_HOOK: |
---|
60 | return "INTERNAL_ERROR_BAD_STACK_HOOK"; |
---|
61 | case INTERNAL_ERROR_BAD_ATTRIBUTES: |
---|
62 | return "INTERNAL_ERROR_BAD_ATTRIBUTES"; |
---|
63 | case 18: /* not in header (yet) :-( */ |
---|
64 | return "INTERNAL_ERROR_CALLED_FROM_WRONG_ENVIRONMENT"; |
---|
65 | default: |
---|
66 | break; |
---|
67 | } |
---|
68 | return 0; |
---|
69 | } |
---|
70 | |
---|
71 | void _BSP_Fatal_error(unsigned int v) |
---|
72 | { |
---|
73 | unsigned long flags; |
---|
74 | const char *err = 0; |
---|
75 | |
---|
76 | rtems_interrupt_disable(flags); |
---|
77 | printk("%s\n",_RTEMS_version); |
---|
78 | printk("FATAL ERROR:\n"); |
---|
79 | printk("Internal error: %s\n", ISITNL? "Yes":"No"); |
---|
80 | printk("Environment:"); |
---|
81 | switch (THESRC) { |
---|
82 | case INTERNAL_ERROR_CORE: |
---|
83 | printk(" RTEMS Core\n"); |
---|
84 | err = score_status_text(THEERR); |
---|
85 | break; |
---|
86 | |
---|
87 | case INTERNAL_ERROR_RTEMS_API: |
---|
88 | printk(" RTEMS API\n"); |
---|
89 | err = rtems_status_text(THEERR); |
---|
90 | break; |
---|
91 | |
---|
92 | case INTERNAL_ERROR_POSIX_API: |
---|
93 | printk(" POSIX API (errno)\n"); |
---|
94 | /* could use strerror but I'd rather avoid using this here */ |
---|
95 | break; |
---|
96 | |
---|
97 | case INTERNAL_ERROR_ITRON_API: |
---|
98 | printk(" ITRON API\n"); |
---|
99 | /* conversion to string not implemented */ |
---|
100 | break; |
---|
101 | |
---|
102 | default: |
---|
103 | printk(" UNKNOWN (0x%x)\n",THESRC); |
---|
104 | break; |
---|
105 | } |
---|
106 | if ( _Thread_Dispatch_disable_level ) |
---|
107 | printk(" Error occurred in a Thread Dispatching DISABLED context (level %i)\n", |
---|
108 | _Thread_Dispatch_disable_level); |
---|
109 | else |
---|
110 | printk("enabled\n"); |
---|
111 | if ( _ISR_Nest_level ) |
---|
112 | printk(" Error occurred from ISR context (ISR nest level %i)\n", _ISR_Nest_level); |
---|
113 | |
---|
114 | printk("Error %d",THEERR); |
---|
115 | if (err) { |
---|
116 | printk(": %s",err); |
---|
117 | } |
---|
118 | printk("\n"); |
---|
119 | printk("Stack Trace:\n"); |
---|
120 | CPU_print_stack(); |
---|
121 | |
---|
122 | rebootQuestion(); |
---|
123 | } |
---|