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