source: rtems/c/src/lib/libbsp/powerpc/shared/startup/panic.c @ dc6e830

4.115
Last change on this file since dc6e830 was dc6e830, checked in by Sebastian Huber <sebastian.huber@…>, on 11/13/12 at 16:40:33

sapi: Add and use rtems_internal_error_description

  • Property mode set to 100644
File size: 1.8 KB
Line 
1#include <rtems.h>
2#include <bsp.h>
3#include <bsp/bootcard.h>
4#include <bsp/uart.h>
5#include <rtems/bspIo.h>
6#include <rtems/error.h>
7#include <libcpu/stackTrace.h>
8#include <rtems/score/thread.h>
9#include <rtems/score/thread.inl>
10
11static void
12rebootQuestion(void)
13{
14  printk("Press a key to reboot\n");
15  BSP_poll_char_via_serial();
16  bsp_reset();
17}
18
19void BSP_panic(char *s)
20{
21  printk("%s PANIC %s\n",_RTEMS_version, s);
22  rebootQuestion();
23}
24
25#define THESRC _Internal_errors_What_happened.the_source
26#define ISITNL _Internal_errors_What_happened.is_internal
27#define THEERR _Internal_errors_What_happened.the_error
28
29void _BSP_Fatal_error(unsigned int v)
30{
31  unsigned long flags;
32  const char *err = 0;
33
34  rtems_interrupt_disable(flags);
35  printk("%s\n",_RTEMS_version);
36  printk("FATAL ERROR:\n");
37  printk("Internal error: %s\n", ISITNL? "Yes":"No");
38  printk("Environment:");
39  switch (THESRC) {
40    case INTERNAL_ERROR_CORE:
41      printk(" RTEMS Core\n");
42      err = rtems_internal_error_description(THEERR);
43    break;
44
45      case INTERNAL_ERROR_RTEMS_API:
46      printk(" RTEMS API\n");
47      err = rtems_status_text(THEERR);
48    break;
49
50      case INTERNAL_ERROR_POSIX_API:
51      printk(" POSIX API (errno)\n");
52      /* could use strerror but I'd rather avoid using this here */
53    break;
54
55    default:
56      printk("  UNKNOWN (0x%x)\n",THESRC);
57  break;
58  }
59  if ( _Thread_Dispatch_in_critical_section() )
60    printk(
61      "  Error occurred in a Thread Dispatching DISABLED context (level %i)\n",
62      _Thread_Dispatch_get_disable_level());
63  else
64    printk("enabled\n");
65
66  if ( _ISR_Nest_level ) {
67    printk(
68      "  Error occurred from ISR context (ISR nest level %i)\n",
69      _ISR_Nest_level
70    );
71  }
72
73  printk("Error %d",THEERR);
74  if (err) {
75    printk(": %s",err);
76  }
77  printk("\n");
78  printk("Stack Trace:\n");
79  CPU_print_stack();
80
81  rebootQuestion();
82}
Note: See TracBrowser for help on using the repository browser.