コード例 #1
0
ファイル: scheduler.c プロジェクト: 634351070/rt-thread
static void _rt_scheduler_stack_check(struct rt_thread *thread)
{
    RT_ASSERT(thread != RT_NULL);

    if ((rt_uint32_t)thread->sp <= (rt_uint32_t)thread->stack_addr ||
        (rt_uint32_t)thread->sp >
        (rt_uint32_t)thread->stack_addr + (rt_uint32_t)thread->stack_size)
    {
        rt_uint32_t level;

        rt_kprintf("thread:%s stack overflow\n", thread->name);
        #ifdef RT_USING_FINSH
        {
            extern long list_thread(void);
            list_thread();
        }
        #endif
        level = rt_hw_interrupt_disable();
        while (level);
    }
    else if ((rt_uint32_t)thread->sp <= ((rt_uint32_t)thread->stack_addr + 32))
    {
        rt_kprintf("warning: %s stack is close to end of stack address.\n",
                   thread->name);
    }
}
コード例 #2
0
ファイル: msh_cmd.c プロジェクト: 1847123212/EasyFlash
int cmd_ps(int argc, char** argv)
{
    extern long list_thread(void);

    list_thread();
    return 0;
}
コード例 #3
0
void rt_hw_hard_fault_exception(struct exception_stack_frame *exception_stack)
{
    extern long list_thread(void);

    if (rt_exception_hook != RT_NULL)
    {
        rt_err_t result;

        result = rt_exception_hook(exception_stack);
        if (result == RT_EOK) return;
    }

    rt_kprintf("psr: 0x%08x\n", exception_stack->psr);
    rt_kprintf(" pc: 0x%08x\n", exception_stack->pc);
    rt_kprintf(" lr: 0x%08x\n", exception_stack->lr);
    rt_kprintf("r12: 0x%08x\n", exception_stack->r12);
    rt_kprintf("r03: 0x%08x\n", exception_stack->r3);
    rt_kprintf("r02: 0x%08x\n", exception_stack->r2);
    rt_kprintf("r01: 0x%08x\n", exception_stack->r1);
    rt_kprintf("r00: 0x%08x\n", exception_stack->r0);

    rt_kprintf("hard fault on thread: %s\n", rt_thread_self()->name);

#ifdef RT_USING_FINSH
    list_thread();
#endif

    while (1);
}
コード例 #4
0
/**
 * deal exception 
 * 
 * @author LXZ (2014/11/8)
 * 
 * @param struct stack_frame* exception_contex 
 */
void rt_hw_hard_fault_exception(struct stack_frame* exception_contex)
{
    if (exception_contex != RT_NULL) {
        rt_kprintf("psw: 0x%08x\n", exception_contex->PSW); 
        rt_kprintf("pc: 0x%08x\n", exception_contex->PC);
        rt_kprintf("r0: 0x%08x\n", exception_contex->R1);
        rt_kprintf("r0: 0x%08x\n", exception_contex->R2);
        rt_kprintf("r0: 0x%08x\n", exception_contex->R3);
        rt_kprintf("r0: 0x%08x\n", exception_contex->R4);
        rt_kprintf("r0: 0x%08x\n", exception_contex->R5);
        rt_kprintf("r0: 0x%08x\n", exception_contex->R6);
        rt_kprintf("r0: 0x%08x\n", exception_contex->R7);
        rt_kprintf("r0: 0x%08x\n", exception_contex->R8);
        rt_kprintf("r0: 0x%08x\n", exception_contex->R9);
        rt_kprintf("r0: 0x%08x\n", exception_contex->R10);
        rt_kprintf("r0: 0x%08x\n", exception_contex->R11);
        rt_kprintf("r0: 0x%08x\n", exception_contex->R12);
        rt_kprintf("r0: 0x%08x\n", exception_contex->R13);
        rt_kprintf("r0: 0x%08x\n", exception_contex->R14);
        rt_kprintf("r0: 0x%08x\n", exception_contex->R15);
        rt_kprintf("fpsw: 0x%08x\n", exception_contex->FPSW);
        rt_kprintf("acchi: 0x%08x\n", exception_contex->ACCHI);
        rt_kprintf("acclo: 0x%08x\n", exception_contex->ACCLO);
    }
        rt_kprintf("hard fault on thread: %s\n", rt_current_thread->name);
    #ifdef RT_USING_FINSH
        list_thread();
    #endif
        while (1);
    
}
コード例 #5
0
/**
 * An abort indicates that the current memory access cannot be completed,
 * which occurs during an instruction prefetch.
 *
 * @param regs system registers
 *
 * @note never invoke this function in application
 */
void rt_hw_trap_pabt(struct rt_hw_exp_stack *regs)
{
    rt_kprintf("prefetch abort:\n");
    rt_hw_show_register(regs);
#ifdef RT_USING_FINSH
    list_thread();
#endif
    rt_hw_cpu_shutdown();
}
コード例 #6
0
/**
 * The software interrupt instruction (SWI) is used for entering
 * Supervisor mode, usually to request a particular supervisor
 * function.
 *
 * @param regs system registers
 *
 * @note never invoke this function in application
 */
void rt_hw_trap_swi(struct rt_hw_exp_stack *regs)
{
    rt_kprintf("software interrupt:\n");
    rt_hw_show_register(regs);
#ifdef RT_USING_FINSH
    list_thread();
#endif
    rt_hw_cpu_shutdown();
}
コード例 #7
0
/**
 * When comes across an instruction which it cannot handle,
 * it takes the undefined instruction trap.
 *
 * @param regs system registers
 *
 * @note never invoke this function in application
 */
void rt_hw_trap_undef(struct rt_hw_exp_stack *regs)
{
    rt_kprintf("undefined instruction:\n");
    rt_hw_show_register(regs);
#ifdef RT_USING_FINSH
    list_thread();
#endif
    rt_hw_cpu_shutdown();
}
コード例 #8
0
/**
 * Normally, system will never reach here
 *
 * @param regs system registers
 *
 * @note never invoke this function in application
 */
void rt_hw_trap_resv(struct rt_hw_exp_stack *regs)
{
    rt_kprintf("reserved trap:\n");
    rt_hw_show_register(regs);
#ifdef RT_USING_FINSH
    list_thread();
#endif
    rt_hw_cpu_shutdown();
}
コード例 #9
0
ファイル: trap.c プロジェクト: BernardXiong/porting
/**
 * An abort indicates that the current memory access cannot be completed,
 * which occurs during a data access.
 *
 * @param regs system registers
 *
 * @note never invoke this function in application
 */
void rt_hw_trap_dabt(struct rt_hw_register *regs)
{
	rt_hw_show_register(regs);

	rt_kprintf("data abort\n");
	rt_kprintf("thread - %s stack:\n", rt_current_thread->name);

#ifdef RT_USING_FINSH
	list_thread();
#endif
	rt_hw_cpu_shutdown();
}
コード例 #10
0
ファイル: trap.c プロジェクト: BernardXiong/porting
/**
 * When ARM7TDMI comes across an instruction which it cannot handle,
 * it takes the undefined instruction trap.
 *
 * @param regs system registers
 *
 * @note never invoke this function in application
 */
void rt_hw_trap_udef(struct rt_hw_register *regs)
{
	rt_hw_show_register(regs);

	rt_kprintf("undefined instruction\n");
	rt_kprintf("thread - %s stack:\n", rt_current_thread->name);

#ifdef RT_USING_FINSH
	list_thread();
#endif
	rt_hw_cpu_shutdown();
}
コード例 #11
0
/**
 * An abort indicates that the current memory access cannot be completed,
 * which occurs during an instruction prefetch.
 *
 * @param regs system registers
 *
 * @note never invoke this function in application
 */
void rt_hw_trap_pabt(struct rt_hw_register *regs)
{
	rt_hw_show_register(regs);

	rt_kprintf("prefetch abort\n");
	rt_kprintf("thread %.*s stack:\n", RT_NAME_MAX, rt_current_thread->name);

#ifdef RT_USING_FINSH
	list_thread();
#endif
	rt_hw_cpu_shutdown();
}
コード例 #12
0
ファイル: cpuport.c プロジェクト: zhuhuijia0001/eload
/*
 * fault exception handler
 */
void rt_hw_hard_fault_exception(struct exception_info * exception_info)
{
    extern long list_thread(void);
    struct stack_frame* context = &exception_info->stack_frame;

    if (rt_exception_hook != RT_NULL)
    {
        rt_err_t result;

        result = rt_exception_hook(exception_info);
        if (result == RT_EOK)
            return;
    }

    rt_kprintf("psr: 0x%08x\n", context->exception_stack_frame.psr);

    rt_kprintf("r00: 0x%08x\n", context->exception_stack_frame.r0);
    rt_kprintf("r01: 0x%08x\n", context->exception_stack_frame.r1);
    rt_kprintf("r02: 0x%08x\n", context->exception_stack_frame.r2);
    rt_kprintf("r03: 0x%08x\n", context->exception_stack_frame.r3);
    rt_kprintf("r04: 0x%08x\n", context->r4);
    rt_kprintf("r05: 0x%08x\n", context->r5);
    rt_kprintf("r06: 0x%08x\n", context->r6);
    rt_kprintf("r07: 0x%08x\n", context->r7);
    rt_kprintf("r08: 0x%08x\n", context->r8);
    rt_kprintf("r09: 0x%08x\n", context->r9);
    rt_kprintf("r10: 0x%08x\n", context->r10);
    rt_kprintf("r11: 0x%08x\n", context->r11);
    rt_kprintf("r12: 0x%08x\n", context->exception_stack_frame.r12);
    rt_kprintf(" lr: 0x%08x\n", context->exception_stack_frame.lr);
    rt_kprintf(" pc: 0x%08x\n", context->exception_stack_frame.pc);

    if(exception_info->exc_return & (1 << 2) )
    {
        rt_kprintf("hard fault on thread: %s\r\n\r\n", rt_thread_self()->name);

#ifdef RT_USING_FINSH
        list_thread();
#endif /* RT_USING_FINSH */
    }
    else
    {
        rt_kprintf("hard fault on handler\r\n\r\n");
    }

#ifdef RT_USING_FINSH
    hard_fault_track();
#endif /* RT_USING_FINSH */

    while (1);
}
コード例 #13
0
void alarm_handler(int sig){

  gtthread_blk_t *cur, *next;

  DEBUG_MSG("alarm_handler\n");

  cur = (gtthread_blk_t *)steque_front(&thread_queue);
  if(cur->state == RUNNING){                                       // avoid update state when it's already done
    cur->state = READY;
    steque_cycle(&thread_queue);
  }

  /*if((cur->state == TERMINATED) && (cur->tID == 1)){

    while(!steque_isempty(&thread_queue)){
      steque_pop(&thread_queue);
    }

    return;

  } */

  while((next = (gtthread_blk_t *)steque_front(&thread_queue))){ 
  
    if(next->state == READY){
      next->state = RUNNING;
      DEBUG_MSG("Schedule #%ld thread\n", next->tID);
      break;
    }
    else if(next->state == JOINED){
      steque_pop(&thread_queue);
      DEBUG_MSG("POP #%ld thread\n", next->tID);
    }
    else if(next->state == TERMINATED)
      steque_cycle(&thread_queue);
    else{
      steque_pop(&thread_queue);
      DEBUG_MSG("ERROR! RUNNING thread?\n");
    }
  } 

  DEBUG_MSG("swap: cur thread: # %ld, next thread: # %ld\n", cur->tID, next->tID);
  reset_timer();

  if (swapcontext(&cur->uctx, &next->uctx) != 0)
    DEBUG_MSG("ERROR! Swap failed?\n");
  DEBUG_MSG("GOOD! Swap SUCCESS!\n");

  list_thread();

}
コード例 #14
0
void rt_hw_hard_fault_exception(struct stack_contex* contex)
{
	rt_kprintf("psr: 0x%08x\n", contex->psr);
	rt_kprintf(" pc: 0x%08x\n", contex->pc);
	rt_kprintf(" lr: 0x%08x\n", contex->lr);
	rt_kprintf("r12: 0x%08x\n", contex->r12);
	rt_kprintf("r03: 0x%08x\n", contex->r3);
	rt_kprintf("r02: 0x%08x\n", contex->r2);
	rt_kprintf("r01: 0x%08x\n", contex->r1);
	rt_kprintf("r00: 0x%08x\n", contex->r0);

	rt_kprintf("hard fault on thread: %s\n", rt_current_thread->name);
#ifdef RT_USING_FINSH
	list_thread();
#endif
	while (1);
}
コード例 #15
0
/**
 * When ARM7TDMI comes across an instruction which it cannot handle,
 * it takes the undefined instruction trap.
 *
 * @param regs system registers
 *
 * @note never invoke this function in application
 */
void rt_hw_trap_udef(struct rt_hw_register *regs)
{

#ifdef RT_USING_GDB
    regs->pc -= 4; //lr in undef is pc + 4
    if (gdb_undef_hook(regs))
        return;
#endif

	rt_hw_show_register(regs);

	rt_kprintf("undefined instruction\n");
	rt_kprintf("thread %.*s stack:\n", RT_NAME_MAX, rt_current_thread->name);

#ifdef RT_USING_FINSH
	list_thread();
#endif
	rt_hw_cpu_shutdown();
}
コード例 #16
0
/**
 * An abort indicates that the current memory access cannot be completed,
 * which occurs during a data access.
 *
 * @param regs system registers
 *
 * @note never invoke this function in application
 */
void rt_hw_trap_dabt(struct rt_hw_register *regs)
{

#ifdef RT_USING_GDB
    if (gdb_mem_fault_handler) {
        regs->pc = (unsigned long)gdb_mem_fault_handler; 
        return;
    }
#endif
	rt_hw_show_register(regs);

	rt_kprintf("data abort\n");
	rt_kprintf("thread %.*s stack:\n", RT_NAME_MAX, rt_current_thread->name);

#ifdef RT_USING_FINSH
	list_thread();
#endif
	rt_hw_cpu_shutdown();
}
コード例 #17
0
ファイル: cpuport.c プロジェクト: mildrock/705_1
/***********************************************************
* Function:
* Description:
* Input:
* Input:
* Output:
* Return:
* Others:
***********************************************************/
void rt_hw_hard_fault_exception( struct exception_stack_frame * exception_stack )
{
	rt_kprintf( "psr: 0x%08x\n", exception_stack->psr );
	rt_kprintf( " pc: 0x%08x\n", exception_stack->pc );
	rt_kprintf( " lr: 0x%08x\n", exception_stack->lr );
	rt_kprintf( "r12: 0x%08x\n", exception_stack->r12 );
	rt_kprintf( "r03: 0x%08x\n", exception_stack->r3 );
	rt_kprintf( "r02: 0x%08x\n", exception_stack->r2 );
	rt_kprintf( "r01: 0x%08x\n", exception_stack->r1 );
	rt_kprintf( "r00: 0x%08x\n", exception_stack->r0 );

	rt_kprintf( "hard fault on thread: %s\n", rt_current_thread->name );
#ifdef RT_USING_FINSH
	list_thread( );
#endif

	rt_kprintf("\nsys_tick=%d",rt_tick_get());

/*о┤ллопкЗ*/
	{
		reset( 0xFFFFFFFF );
	}
}
コード例 #18
0
ファイル: cpuport.c プロジェクト: malooei/yeejoin-workspace
/**
 * fault exception handling
 */
void rt_hw_hard_fault_exception(struct stack_context* contex)
{
	rt_kprintf("psr: 0x%08x\n", contex->psr);
	rt_kprintf(" pc: 0x%08x\n", contex->pc);
	rt_kprintf(" lr: 0x%08x\n", contex->lr);
	rt_kprintf("r12: 0x%08x\n", contex->r12);
	rt_kprintf("r03: 0x%08x\n", contex->r3);
	rt_kprintf("r02: 0x%08x\n", contex->r2);
	rt_kprintf("r01: 0x%08x\n", contex->r1);
	rt_kprintf("r00: 0x%08x\n", contex->r0);

    rt_kprintf("CFSR = 0x%08x\n", (*((volatile unsigned long *)(0xE000ED28))));  
    rt_kprintf("HFSR = 0x%08x\n", (*((volatile unsigned long *)(0xE000ED2C))));  
    rt_kprintf("DFSR = 0x%08x\n", (*((volatile unsigned long *)(0xE000ED30))));  
    rt_kprintf("AFSR = 0x%08x\n", (*((volatile unsigned long *)(0xE000ED3C))));
    rt_kprintf("MMAR = 0x%08x\n", (*((volatile unsigned long *)(0xE000ED34))));  
    rt_kprintf("BFAR = 0x%08x\n", (*((volatile unsigned long *)(0xE000ED38))));  

	rt_kprintf("hard fault on thread: %s\n", rt_current_thread->name);
#ifdef RT_USING_FINSH
	list_thread();
#endif
	while (1);
}