示例#1
0
void BSP_printStackTrace(BSP_Exception_frame *excPtr)
{
  LRFrame f;
  int i;
  LRFrame sp;
  void *lr;

  printk("Stack Trace: \n  ");
  if (excPtr) {
    printk("IP: 0x%08x, ", excPtr->EXC_SRR0);
    sp = (LRFrame) GET_GPR(excPtr->GPR1);
    lr = (void *) excPtr->EXC_LR;
  } else {
    /* there's no macro for this */
    __asm__ __volatile__("mr %0, 1":"=r"(sp));
    lr = (LRFrame) ppc_link_register();
  }
  printk("LR: 0x%08x\n", lr);
  for (f = (LRFrame) sp, i = 0; f->frameLink && i < STACK_CLAMP; f = f->frameLink) {
    printk("--^ 0x%08x", (long) (f->frameLink->lr));
    if (!(++i % 5))
      printk("\n");
  }
  if (i >= STACK_CLAMP) {
    printk("Too many stack frames (stack possibly corrupted), giving up...\n");
  } else {
    if (i % 5)
      printk("\n");
  }
}
示例#2
0
文件: isr.c 项目: mambrus/tinker
/*Just loop until watch-dog gets us...*/
void exception_invalid()
{
	GET_GPR(0, exc_id);
	exc_id = exc_id & 0x0000000F;
	assert("Invalid exeption detected" == 0);
	while (1) ;
}
示例#3
0
文件: isr.c 项目: mambrus/tinker
void isr_external()
{
	//PUSHALL;
	extern int __tk_IntFlagCntr;
	__uint32_t stack_ptr;
	__uint32_t cr;
	__tk_IntFlagCntr++;
	//__uint32_t *sipend = &SIPEND;
	idx = *(__int8_t *) (&SIVEC);
	//idx = (idx/4)-1;
	idx = (idx / 4);

	GET_GPR(1, stack_ptr);

	n_isr++;
	if (n_isr > 1)
		possible_starvation();

	if (stack_ptr & 0x00000003)
		alignement_issue();
	else
		isr_table[idx] ();

#ifndef DONT_FECKUP_ON_PURPOSE
//feck up un purpose to check that context is fully saved and resored
	SET_SPR(_CTR, 0xFFFF);
	SET_SPR(_XER, 0xFFFF);
	GET_CR(cr);
	SET_CR(0xFFFFFFFF);
#endif
	if (SIPEND & 0x5555)	//If internal interrupt (i.e. lvl_Intrnl_0 to lvl_Intrnl_7)
		SET_SPR(_EIE, 0xFF);	//permit nested interrupts
	n_isr--;
	__tk_IntFlagCntr--;
	//POPALL;
}
示例#4
0
void C_exception_handler(BSP_Exception_frame *excPtr)
{
  static int nest = 0;

  int recoverable = 0;
  rtems_id id = 0;
  int synch;
  unsigned n;
  rtems_status_code sc;

  /* Catch recursion */
  nest++;

  if (nest > 2) {
    /* maybe printk() or dereferencing excPtr caused an exception;
     * die silently...
     */
    while (1);
  }

  synch = (int) excPtr->_EXC_number >= 0;
  n = excPtr->_EXC_number & 0x7fff;

  printk("Exception handler called for exception %d (0x%x)\n", n, n);
  printk("\t Next PC or Address of fault = %08x\n", excPtr->EXC_SRR0);
  printk("\t Saved MSR = %08x\n", excPtr->EXC_SRR1);

  if (nest > 1) {
    printk("Recursion in the exception handler detected; I'll spin now...\n");
    while (1);
  }

  /* Try to find out more about the context where this happened */
  printk("\t Context: ");
  if (rtems_interrupt_is_in_progress()) {
    printk("ISR");
  } else if (!_Thread_Executing) {
    printk("Initialization (_Thread_Executing not available yet)");
  } else {
    if (RTEMS_SUCCESSFUL != (sc = rtems_task_ident(RTEMS_SELF, RTEMS_LOCAL, &id))) {
      printk("Unable to determine faulting task; rtems_task_ident() returned %u", sc);
      id = 0;
    } else {
      printk("Task ID 0x%08x", id);
    }
  }
  printk("\n");

  /* Dump registers */

  printk("\t R0  = %08x", GET_GPR(excPtr->GPR0));
  if (synch) {
    printk(" R1  = %08x", GET_GPR(excPtr->GPR1));
    printk(" R2  = %08x", GET_GPR(excPtr->GPR2));
  } else {
    printk("               ");
    printk("               ");
  }
  printk(" R3  = %08x\n", GET_GPR(excPtr->GPR3));
  printk("\t R4  = %08x", GET_GPR(excPtr->GPR4));
  printk(" R5  = %08x", GET_GPR(excPtr->GPR5));
  printk(" R6  = %08x", GET_GPR(excPtr->GPR6));
  printk(" R7  = %08x\n", GET_GPR(excPtr->GPR7));
  printk("\t R8  = %08x", GET_GPR(excPtr->GPR8));
  printk(" R9  = %08x", GET_GPR(excPtr->GPR9));
  printk(" R10 = %08x", GET_GPR(excPtr->GPR10));
  printk(" R11 = %08x\n", GET_GPR(excPtr->GPR11));
  printk("\t R12 = %08x", GET_GPR(excPtr->GPR12));
  if (synch) {
    printk(" R13 = %08x", GET_GPR(excPtr->GPR13));
    printk(" R14 = %08x", GET_GPR(excPtr->GPR14));
    printk(" R15 = %08x\n", GET_GPR(excPtr->GPR15));
    printk("\t R16 = %08x", GET_GPR(excPtr->GPR16));
    printk(" R17 = %08x", GET_GPR(excPtr->GPR17));
    printk(" R18 = %08x", GET_GPR(excPtr->GPR18));
    printk(" R19 = %08x\n", GET_GPR(excPtr->GPR19));
    printk("\t R20 = %08x", GET_GPR(excPtr->GPR20));
    printk(" R21 = %08x", GET_GPR(excPtr->GPR21));
    printk(" R22 = %08x", GET_GPR(excPtr->GPR22));
    printk(" R23 = %08x\n", GET_GPR(excPtr->GPR23));
    printk("\t R24 = %08x", GET_GPR(excPtr->GPR24));
    printk(" R25 = %08x", GET_GPR(excPtr->GPR25));
    printk(" R26 = %08x", GET_GPR(excPtr->GPR26));
    printk(" R27 = %08x\n", GET_GPR(excPtr->GPR27));
    printk("\t R28 = %08x", GET_GPR(excPtr->GPR28));
    printk(" R29 = %08x", GET_GPR(excPtr->GPR29));
    printk(" R30 = %08x", GET_GPR(excPtr->GPR30));
    printk(" R31 = %08x\n", GET_GPR(excPtr->GPR31));
  } else {
    printk("\n");
  }
  printk("\t CR  = %08x\n", excPtr->EXC_CR);
  printk("\t CTR = %08x\n", excPtr->EXC_CTR);
  printk("\t XER = %08x\n", excPtr->EXC_XER);
  printk("\t LR  = %08x\n", excPtr->EXC_LR);

  /* Would be great to print DAR but unfortunately,
   * that is not portable across different CPUs.
   * AFAIK on classic PPC DAR is SPR 19, on the
   * 405 we have DEAR = SPR 0x3d5 and booE says
   * DEAR = SPR 61 :-(
   */
  if (ppc_exc_get_DAR) {
    printk("\t DAR = %08x\n", ppc_exc_get_DAR());
  }

  BSP_printStackTrace(excPtr);

  if (excPtr->_EXC_number == ASM_DEC_VECTOR)
    recoverable = 1;
  if (excPtr->_EXC_number == ASM_SYS_VECTOR)
#ifdef TEST_RAW_EXCEPTION_CODE
    recoverable = 1;
#else
    recoverable = 0;
#endif
  if (!recoverable) {
    if (id) {
      printk("Suspending faulting task (0x%08x)\n", id);
      /* Unnest here because rtems_task_suspend() never returns */
      nest--;
      rtems_task_suspend(id);
    } else {
      printk("unrecoverable exception!!! Push reset button\n");
      while (1);
    }
  } else {
    nest--;
  }
}