Changeset 84a25d8 in rtems


Ignore:
Timestamp:
Jul 16, 2008, 11:13:24 PM (11 years ago)
Author:
Till Straumann <strauman@…>
Branches:
4.10, 4.11, 4.9, master
Children:
e9c0429
Parents:
0354299
Message:

2008-07-16 Till Straumann <strauman@…>

  • new-exceptions/bspsupport/vectors_init.c: added features to C_exception_handler() (the default global handler):
    • try to catch recursion
    • print info about context where the exception occurred (ISR or task with task ID).
    • suspend offending task rather than spinning forever.
Location:
c/src/lib/libcpu/powerpc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libcpu/powerpc/ChangeLog

    r0354299 r84a25d8  
     12008-07-16      Till Straumann <strauman@slac.stanford.edu>
     2
     3        * new-exceptions/bspsupport/vectors_init.c: added
     4        features to C_exception_handler() (the default global
     5        handler):
     6         - try to catch recursion
     7         - print info about context where the exception occurred
     8           (ISR or task with task ID).
     9         - suspend offending task rather than spinning forever.
     10       
    1112008-07-16      Till Straumann <strauman@slac.stanford.edu>
    212
  • c/src/lib/libcpu/powerpc/new-exceptions/bspsupport/vectors_init.c

    r0354299 r84a25d8  
    108108void C_exception_handler(BSP_Exception_frame* excPtr)
    109109{
    110   int recoverable = 0;
    111   int synch       = (int)excPtr->_EXC_number >= 0 ;
    112   unsigned n      = excPtr->_EXC_number & 0x7fff;
     110static int          nest        = 0;
     111
     112  int               recoverable = 0;
     113  rtems_id          id          = 0;
     114  int               synch;
     115  unsigned          n;
     116  rtems_status_code sc;
     117
     118  /* Catch recursion */
     119  nest++;
     120
     121  if ( nest > 2 ) {
     122        /* maybe printk() or dereferencing excPtr caused an exception;
     123         * die silently...
     124         */
     125        while (1)
     126                ;
     127  }
     128
     129  synch  = (int)excPtr->_EXC_number >= 0 ;
     130  n      = excPtr->_EXC_number & 0x7fff;
    113131
    114132  printk("Exception handler called for exception %d (0x%x)\n", n, n);
    115133  printk("\t Next PC or Address of fault = %08x\n", excPtr->EXC_SRR0);
    116134  printk("\t Saved MSR = %08x\n", excPtr->EXC_SRR1);
     135
     136  if ( nest > 1 ) {
     137    printk("Recursion in the exception handler detected; I'll spin now...\n");
     138        while ( 1 )
     139                ;
     140  }
     141
     142  /* Try to find out more about the context where this happened */
     143  printk("\t Context: ");
     144  if ( rtems_interrupt_is_in_progress() ) {
     145        printk("ISR");
     146  } else if ( !_Thread_Executing ) {
     147        printk("Initialization (_Thread_Executing not available yet)");
     148  } else {
     149        if ( RTEMS_SUCCESSFUL != (sc=rtems_task_ident(RTEMS_SELF, RTEMS_LOCAL, &id)) ) {
     150                printk("Unable to determine faulting task; rtems_task_ident() returned %u", sc);
     151                id = 0;
     152        } else {
     153                printk("Task ID 0x%08x", id);
     154        }
     155  }
     156  printk("\n");
     157
     158  /* Dump registers */
     159
    117160  printk("\t R0  = %08x", excPtr->GPR0);
    118161  if ( synch ) {
     
    181224    recoverable = 0;
    182225#endif
    183     if (!recoverable) {
    184       printk("unrecoverable exception!!! Push reset button\n");
    185       while(1);
    186     }
     226  if (!recoverable) {
     227    if ( id ) {
     228                printk("Suspending faulting task (0x%08x)\n", id);
     229                /* Unnest here because rtems_task_suspend() never returns */
     230                nest--;
     231                rtems_task_suspend(id);
     232        } else {
     233        printk("unrecoverable exception!!! Push reset button\n");
     234        while(1);
     235        }
     236  } else {
     237        nest--;
     238  }
    187239}
    188240
Note: See TracChangeset for help on using the changeset viewer.