Exemplo n.º 1
0
/* Initialize for programs not started with os_procCreate*/
void
os_procInitialize()
{
    os_procContextData process_procContextData;
    os_int32 status = os_resultSuccess;
    os_int32 taskid;

    if ( readTLSVarSelf(procContextData) == NULL) {
        taskid = taskIdSelf();
        process_procContextData = (os_procContextData )os_malloc((size_t)OS_SIZEOF(os_procContextData));
        if (process_procContextData == (os_procContextData) NULL) {
            OS_REPORT(OS_WARNING, "os_procCreate", 1,
                        "malloc failed with error %d (%s)",
                        os_getErrno(), taskName(taskIdSelf()));
        } else {
            os_procInit(process_procContextData, taskName((int)taskid), "program" , "none");
            os_procSetTaskId(process_procContextData, (int)taskid);
            process_procContextData->procAttrPrio = VXWORKS_PRIORITY_DEFAULT;
            /* create & set context variable for the task */
            status = os_procAddTaskVar((int)taskid, "none", process_procContextData, 0);
            if (status == os_resultSuccess) {
                status = os_threadNew(process_procContextData->procName);
            } else {
                printf("os_procApplAddContext os_threadNew ERROR\n");
            }
            process_procContextData->procStartWithProcCreate = 1; /* not started with procCreate*/
       }
    }

}
Exemplo n.º 2
0
static int __wind_taskinfo_name(struct task_struct *curr, struct pt_regs *regs)
{
	xnhandle_t handle = __xn_reg_arg1(regs);
	const char *name;
	WIND_TCB *pTcb;

	if (!__xn_access_ok
	    (curr, VERIFY_WRITE, __xn_reg_arg2(regs), XNOBJECT_NAME_LEN))
		return -EFAULT;

	pTcb = (WIND_TCB *)xnregistry_fetch(handle);

	if (!pTcb)
		return S_objLib_OBJ_ID_ERROR;

	name = taskName((TASK_ID) pTcb);

	if (!name)
		return S_objLib_OBJ_ID_ERROR;

	/* We assume that a VxWorks task name fits in XNOBJECT_NAME_LEN
	   bytes, including the trailing \0. */
	__xn_copy_to_user(curr, (void __user *)__xn_reg_arg2(regs), name,
			  strlen(name) + 1);

	return 0;
}
Exemplo n.º 3
0
void UtlRscTrace::addAllocCnt(int addr,
                                                          int taskId)
{
        if (mTaskId && (mTaskId != taskId))
                return;

    mpResourceStoreLock->acquire();
        int traceFlag = sTraceFlag;
        sTraceFlag = 0;
        
        char buf[512];
    long  ts;
#ifdef _VXWORKS
    ts = *osTimerCtr - sStartTime;
        sprintf(buf, "0x%08x 0x%08x %12d %s", taskId, addr, ts, taskName(taskId));

#else 
        time( (time_t*)&ts );
        sprintf(buf, "0x%08x 0x%08x %12d", taskId, addr, ts);
#endif

        if (OS_SUCCESS != mUtlRscStore.insert(addr, buf))
        {
//              printf("\nUtlRscStore.insert returned error.\n");
        }
        sTraceFlag = traceFlag;
        mpResourceStoreLock->release();
}
Exemplo n.º 4
0
Arquivo: dbgLib.c Projeto: phoboz/vmx
LOCAL void dbgTaskTyAbort(
    void
    )
{
    /* Temprary remove abort function */
    tyAbortFuncSet((FUNCPTR) NULL);

    /* Flush standard I/O */
    ioctl(STDIN_FILENO, FIOFLUSH, 0);
    ioctl(STDOUT_FILENO, FIOFLUSH, 0);
    ioctl(STDERR_FILENO, FIOFLUSH, 0);

    /* If shell restart fails */
    if (taskRestart(shellTaskId) != OK)
    {
        fprintf(stderr, "spawning new shell.\n");

        /* Start a new shell */
        if (shellSpawn(0, (ARG) TRUE) != OK)
        {
            fprintf(stderr, "shell spawn failed.\n");
        }
    }
    else
    {
        fprintf(stderr, "%s restarted.\n", taskName(shellTaskId) );
    }

    /* Restore shell abort function */
    tyAbortFuncSet((FUNCPTR) dbgTyAbort);
}
Exemplo n.º 5
0
void
os_procListTask(
    os_threadContextData this_threadContextData,
    os_int32 tid)
{
    printf("  %x %s \n",this_threadContextData->threadTaskId,taskName(this_threadContextData->threadTaskId));
}
Exemplo n.º 6
0
int msgQInfoPrint(MSG_Q_ID pMsgQ)
{
  int i,pPendTasks[4];
  char *pStr;

  memset(&MsgQinfo,0,sizeof(MsgQinfo));
  MsgQinfo.taskIdListMax = 4;
  MsgQinfo.taskIdList = &pPendTasks[0];
  MsgQinfo.msgListMax = 4;
  MsgQinfo.msgPtrList = &msgList[0];
  MsgQinfo.msgLenList = &msgLenList[0];

  msgQInfoGet(pMsgQ,&MsgQinfo);
  printf("%d Msge Queued, %d Limit, %d (bytes) Msge Size Limit\n",
	  MsgQinfo.numMsgs,MsgQinfo.maxMsgs,MsgQinfo.maxMsgLength);

  if (MsgQinfo.numMsgs == 0)
      pStr = "Pending to get from MsgQ";
  else if (MsgQinfo.numMsgs == MsgQinfo.maxMsgs) 
      pStr = "Pending to put into MsgQ";

  if (MsgQinfo.numTasks > 0)
  {
    for(i=0;i < MsgQinfo.numTasks; i++)
    {
      printf("Task: '%s' - 0x%lx is %s \n",taskName(pPendTasks[i]),pPendTasks[i],pStr);
    }
  }
  else
  {
      printf("No Task(s) Pending on this msgQ\n");
  }
  
  return(0);
}
Exemplo n.º 7
0
QStringList MainWindow::taskNamesList()
{
    QStringList list;
    for (int i = 0; i < taskCount(); i++)
        list.append(taskName(static_cast<Task>(i)));

    return list;
}
Exemplo n.º 8
0
void
os_procDDSHook(
    WIND_TCB *pNewTcb)
{

    os_procContextData process_procContextData;
    os_int32 status = os_resultSuccess;
    os_int32 taskid;
    os_int32 init_process = 0;

    if (getenv("SPLICE_NEW_PROCESS") != NULL) {
        if (strncmp(getenv("SPLICE_NEW_PROCESS"),"no",2) == 0) {
            init_process = 1;
        }
    }

    if (init_process == 1)  {
        /* task Started with os_proCreate  */
    } else {
        if (readTLSVarSelf(procContextData) == NULL) { /* main thread */
            taskid = (int)pNewTcb;
            process_procContextData = (os_procContextData )os_malloc((size_t)OS_SIZEOF(os_procContextData));
            if (process_procContextData == (os_procContextData) NULL) {
                OS_REPORT(OS_WARNING, "os_procCreate", 1,
                            "malloc failed with error %d (%s)",
                            os_getErrno(), taskName(taskid));
            } else {
                os_procInit(process_procContextData, taskName((int)taskid), "program" , "none");
                os_procSetTaskId(process_procContextData, (int)taskid);
                process_procContextData->procAttrPrio = VXWORKS_PRIORITY_DEFAULT;
                /* create & set context variable for the task */
                status = os_procAddTaskVar((int)taskid, "none", process_procContextData, 0);
                if (status == os_resultSuccess) {
                    status = os_hookthreadNew(process_procContextData->procName, process_procContextData, taskid);
                } else {
                    printf("os_procApplAddContext os_threadNew ERROR\n");
                }
                /*
                process_procContextData->procStartWithProcCreate = 1; not started with procCreate*/
           }
        } else { /* extra threads */
            os_threadHookThreadInit(readTLSVarSelf(procContextData), pNewTcb);
        }
    }

}
Exemplo n.º 9
0
void taskCreateCallback(WIND_TCB *pNewTcb) {	
	char * self = (char *)taskName(taskIdSelf());	
	// spare1: accumulated execution time
	pNewTcb->spare1 = 0;
	// spare2: start/resume time
	pNewTcb->spare2 = sysTimestamp();
	// spare3: number of premptions on this task
	pNewTcb->spare3 = 0;
	// spare4: absolute start time
	pNewTcb->spare4 = sysTimestamp();
}
char * OS_GetTaskName(VOS_UINT32 ulTaskId)
{
    char                   *pucTaskName = VOS_NULL_PTR;

#if ((VOS_VXWORKS == VOS_OS_VER) || (VOS_NUCLEUS == VOS_OS_VER) || (VOS_WIN32 == VOS_OS_VER))
    pucTaskName = taskName((int)ulTaskId);
#elif (VOS_RTOSCK == VOS_OS_VER)
    if (SRE_OK != SRE_TaskNameGet((TSK_HANDLE_T)ulTaskId, &pucTaskName))
    {
        return VOS_NULL_PTR;
    }
#else
    return VOS_NULL_PTR;
#endif

    return pucTaskName;
}
Exemplo n.º 11
0
printSemInfo(SEM_ID pSemId,char *msge,int level)
{
   int npend,pAry[6],i;

   npend = semInfo(pSemId,pAry,6);
   if ( npend > 0 )
   {
     for(i=0;i < npend; i++)
     {
       printf("Task: '%s' - 0x%lx Pending on %s\n",taskName(pAry[i]),pAry[i],msge);
     }
     semShow(pSemId,0);
   }
   else
   {
      printf("No Tasks Pending on %s\n",msge);
   }
}
Exemplo n.º 12
0
/*
** Name: CFE_PSP_ExceptionHook
**
** Purpose: Make the proper call to CFE_ES_ProcessCoreException
**
** Notes:   pEsf - pointer to exception stack frame.
**          fppSave - When it makes this call, it captures the last floating
**                      point context - which may not be valid.  If a floating
**                      point exception occurs you can be almost 100% sure
**                      that this will reflect the proper context.  But if another
**                      type of exception occurred then this has the possibility
**                      of not being valid.  Specifically if a task that is not
**                      enabled for floating point causes a non-floating point
**                      exception, then the meaning of the floating point context
**                      will not be valid.  If the task is enabled for floating
**                      point, then it will be valid.
**
*/
void CFE_PSP_ExceptionHook (int task_id, int vector, ESFPPC* pEsf )
{

    char *TaskName;

    /*
    ** Get the vxWorks task name
    */
    TaskName = taskName(task_id);

    if ( TaskName == NULL )
    {
       sprintf(CFE_PSP_ExceptionReasonString, "Exception: Vector=0x%06X, vxWorks Task Name=NULL, Task ID=0x%08X", vector,task_id);
    }
    else
    {
       sprintf(CFE_PSP_ExceptionReasonString, "Exception: Vector=0x%06X, vxWorks Task Name=%s, Task ID=0x%08X", vector, TaskName, task_id);
    }

    /*
    ** Save Exception Stack frame
    */
    memcpy(&(CFE_PSP_ExceptionContext.esf), pEsf, sizeof(ESFPPC));

    /*
    ** Save floating point registers
    */
    speSave(&CFE_PSP_ExceptionContext.fp);

    /*
    ** Call the Generic cFE routine to finish processing the exception and
    ** restart the cFE
    */
    CFE_ES_ProcessCoreException((uint32 )task_id,
            (uint8*)CFE_PSP_ExceptionReasonString,
            (uint32 *)&CFE_PSP_ExceptionContext,
            sizeof(CFE_PSP_ExceptionContext_t));

    /*
    ** No return to here
    */

} /* end function */
Exemplo n.º 13
0
void user_defined_trap_rtn( ESFPPC *esf, REG_SET regs, int a, int b)
{
	  FP_CONTEXT fpContext;
	  long           my_task_id;
	  CFE_EVS_LogFileCmd_t Cmd;

	  my_task_id  = taskIdSelf();

	  CFE_EVS_SendEvent(24, CFE_EVS_ERROR, "Exception: task %s: vector: 0x%.08X",taskName(my_task_id),(int)esf->vecOffset);

	  speSave(&fpContext);
	  fpContext.fpcsr &= 0x000000ff;
	  speRestore(&fpContext);

	  strcpy((char *) Cmd.Payload.LogFilename,"\/cf\/log\/nvlog");
	  CFE_EVS_WriteLogFileCmd(&Cmd);

	  taskSuspend(my_task_id);
}
Exemplo n.º 14
0
static int __wind_taskinfo_name(struct pt_regs *regs)
{
	xnhandle_t handle = __xn_reg_arg1(regs);
	const char *name;
	WIND_TCB *pTcb;

	pTcb = __wind_lookup_task(handle);

	if (!pTcb)
		return S_objLib_OBJ_ID_ERROR;

	name = taskName((TASK_ID) pTcb);

	if (!name)
		return S_objLib_OBJ_ID_ERROR;

	/* We assume that a VxWorks task name fits in XNOBJECT_NAME_LEN
	   bytes, including the trailing \0. */
	return __xn_safe_copy_to_user((void __user *)__xn_reg_arg2(regs), name,
				      strlen(name) + 1);
}
Exemplo n.º 15
0
void GenericFunctionInterval::priv_instant()
   {
   check_stopped(get_class_type(), "priv_instant");
   // Evaluate the function
   if(m_functionPtr != NULL)
      {
      // Note: the following code would deadlock when trying to access data from another
      //       running interval (such as in the Boxing-Robots tutorial, i.e. checkPunch
      //       accessing resetHead). I'm guessing it is because the running thread1 is
      //       asking data from thread2 who is waiting for thread1 to finish...
      //
      //       (*m_functionPtr)(m_dataPtr);
      //
      //       The truth is I did not try to figure it out, but I rather looked for a
      //       workaround to indirectly ask data to thread2 using an AsyncTask.
      string taskName("GenericFunctionIntervalTask");
      taskName += InstanceCounter;
      AsyncTaskManager::get_global_ptr()->add(new GenericAsyncTask(taskName, wrapper, this));
      }
   _state = S_final;
   }
/* 如果在中断中,则返回0 */
u32 icc_taskid_get(void)
{
	
#ifdef __KERNEL__
	if (in_interrupt()) /*lint !e737 */
	{
		return 0;
	}
	else
	{
		icc_print_debug("%s\n", current->comm);
		return (u32)(current->pid);
	}

#elif defined(__VXWORKS__)
	if (intCnt)
	{
		return 0;
	}
	else
	{
		icc_print_debug("%s\n", taskName(taskIdSelf()));
		return (u32)(taskIdSelf());
	}

#elif defined(__CMSIS_RTOS)
	if (in_interrupt())
	{
		return 0;
	}
	else
	{
		osThreadId task = osThreadGetId();
		return (u32)(task->task_id);
	}

#endif
}
void cpu_view_report_init(void)
{
    u32     i;
    WIND_TCB     *tempPtr;
    u32         startslice = 0;
    /*establish  map between task and stat info */
    g_task_num = (u32)taskIdListGet( vxworks_tid_list, BSP_OM_MAX_TASK_NUM );
    if (0 == g_task_num)
    {
        return;
    }

    for ( i=0; i<g_task_num; i++ )
    {
        tempPtr = (WIND_TCB *)((u32)vxworks_tid_list[i]);
        tempPtr->spare4 = (int)i;
        strncpy((char *)g_om_cpu_trace[i].task_name, (const char *)taskName(vxworks_tid_list[i]), BSP_SYSVIEW_TASK_NAME_LEN);
        g_om_cpu_trace[i].slices = 0;
        g_om_cpu_trace[i].max_slice = 0;
        g_om_cpu_trace[i].min_slice = 0xffffffff;
    }

    /*Init Task/interrupt Switch Hook*/
    if ( ERROR == taskSwitchHookAdd( (FUNCPTR)cpu_task_swt_hook ) )
    {
        printf("CPU_utilization_Init fail.\r\n");
        return;
    }

    startslice = om_timer_get();

    old_slice = startslice;

    cpu_state = 1;

    return;
}
Exemplo n.º 18
0
void taskDeleteCallback(WIND_TCB *pTcb) {	
	long curTime = sysTimestamp();
	char * self = (char *)taskName(taskIdSelf());
	long execTime = pTcb->spare1 + curTime - pTcb->spare2;
	long microsecExecTime = 1000000 * (double)execTime / sysTimestampFreq();
	
	if (strcmp(self, mqs) == 0 ||
			strcmp(self, mbs) == 0 ||
			strcmp(self, mns) == 0 ||
			strcmp(self, sup) == 0) {
		printf("Task %s: no. of premptions: %d ---  Execution time (microsec): %d.\n",
				self, pTcb->spare3, microsecExecTime);
	}
	
	if (strcmp(self, sup) == 0) {		
		long elapsed = curTime - pTcb->spare4;
		long totalTime = 1000000 * (double)elapsed / sysTimestampFreq();
		
		printf("Absolute execution time (microsec): %d.\n", totalTime);
		printf("System-wide total number of premptions: %d\n", premptionCounter);
	}
	
	return;	
}
Exemplo n.º 19
0
STATUS msgQShow(
    MSG_Q_ID msgQId,
    int mode
    )
{
    STATUS status;
    MSG_Q_INFO info;
    TCB_ID tcbId;
    char tmpString[15];
    int level;
    int taskIdList[20], taskDList[20];
    char *msgPtrList[20];
    int msgLengthList[20];
    int i, j, len;
    char *pMsg;

    /* Clear info */
    memset(&info, 0, sizeof(info));

    /* If mode ge. 1 */
    if (mode >= 1)
    {
        /* Get info for each message, task pending */
        info.taskIdList = taskIdList;
        info.taskIdListMax = NELEMENTS(taskIdList);
        info.msgPtrList = msgPtrList;
        info.msgLengthList = msgLengthList;
        info.msgListMax = NELEMENTS(msgPtrList);
    }

    /* Lock interrupts */
    INT_LOCK(level);

    /* Get message queue info structure */
    status = msgQInfoGet(msgQId, &info);
    if (status != OK)
    {
        INT_UNLOCK(level);
        printf("Invalid message queue id: %#x\n", (int) msgQId);
    }
    else
    {
        /* If show tasks pending */
        if ((info.numTask > 0) && (mode >= 1))
        {
            /* For all in id list */
            for (i = 0;
                 i < min(info.numTask, NELEMENTS(taskIdList));
                 i++)
            {
                /* Get tcb */
                tcbId = (TCB_ID) taskIdList[i];
                if (tcbId->status & TASK_DELAY)
                {
                    taskDList[i]  = Q_KEY(&tickQHead, &tcbId->tickNode, 1);
                }
                else
                {
                    taskDList[i] = 0;
                }
            }
        }

        /* Unlock interrupts */
        INT_UNLOCK(level);

        /* Get options string */
        if ((info.options & MSG_Q_TYPE_MASK) == MSG_Q_FIFO)
        {
            strcpy(tmpString, "MSG_Q_FIFO");
        }
        else
        {
            strcpy(tmpString, "MSG_Q_PRIORITY");
        }

        /* Print summary */
        printf("\n");

        printf("Message Queue Id    : 0x%-10x\n", (int) msgQId);

        if ((info.options & MSG_Q_TYPE_MASK) == MSG_Q_FIFO)
        {
            printf("Task Queuing        : %-10s\n", "FIFO");
        }
        else
        {
            printf("Task Queuing        : %-10s\n", "PRIORITY");
        }

        printf("Message Byte Len    : %-10d\n", info.maxMsgLength);
        printf("Messages Max        : %-10d\n", info.maxMsg);
        printf("Messages Queued     : %-10d\n", info.numMsg);

        if (info.numMsg == info.maxMsg)
        {
            printf("Senders Blocked     : %-10d\n", info.numTask);
        }
        else
        {
            printf("Receivers Blocked   : %-10d\n", info.numTask);
        }

        printf("Send timeouts       : %-10d\n", info.sendTimeouts);
        printf("Receive timeouts    : %-10d\n", info.reciveTimeouts);
        printf("Options             : 0x%x\t%s\n", info.options, tmpString);

        /* If detailed info requested */
        if (mode >= 1)
        {
            /* If tasks pending */
            if (info.numTask > 0)
            {
                /* Get sender/receiver string */
                if (info.numMsg == info.maxMsg)
                {
                    strcpy(tmpString, "Senders");
                }
                else
                {
                    strcpy(tmpString, "Receivers");
                }

                printf("\n%s Blocked:\n", tmpString);
                printf("   NAME      TID    PRI TIMEOUT\n");
                printf("---------- -------- --- -------\n");

                /* For all tasks */
                for (i = 0; i < min(info.numTask, NELEMENTS(taskIdList)); i++)
                {
                    printf(
                        "%-11.11s%8x %3d %7u\n",
                        taskName(taskIdList[i]),
                        taskIdList[i],
                        ((TCB_ID) taskIdList[i])->priority,
                        taskDList[i]
                        );
                }
            }

            /* If messages pending */
            if (info.numMsg > 0)
            {
                printf(
                    "\nMessages queued:\n"
                    "  #   address length value\n"
                    );

                /* For all messages */
                for (i = 0; i < min(info.numMsg, NELEMENTS(msgPtrList)); i++)
                {
                    /* Get message and length */
                    pMsg = msgPtrList[i];
                    len  = msgLengthList[i];

                    printf("%3d %#10x %4d ", i + 1, (int) pMsg, len);

                    /* For length */
                    for (j = 0; j < min(len, 20); j++)
                    {
                        if ((j % 4) == 0)
                        {
                            printf(" 0x");
                        }

                        printf("%02x", pMsg[j] & 0xff);
                    }

                    if (len > 20)
                    {
                        printf(" ...");
                    }

                    printf("\n");
                }
            }
        }

        printf("\n");
    }

    return status;
}
Exemplo n.º 20
0
const char* Name()
{
  return taskName(taskIdSelf());
}
Exemplo n.º 21
0
const char* Name(Id* id)
{
	assert(id);
	return taskName(id->TaskId);
}
Exemplo n.º 22
0
void UtlRscTrace::addAllocCnt(int size,
                                                          int addr,
                                                          const char* name, 
                                                          int pArg, 
                                                          int priority, 
                                                          int options,
                                                          int taskId) 
{
        if (mTaskId && (mTaskId != taskId))
                return;

    mpResourceStoreLock->acquire();
        int traceFlag = sTraceFlag;
        sTraceFlag = 0;
        
        char buf[1024];
    long  ts;
#ifdef _VXWORKS
    ts = *osTimerCtr - sStartTime;
        sprintf(buf, "0x%08x 0x%08x %6d %12d %s %s %6d %6d %6d", taskId, addr, size, ts, taskName(taskId), 
                                                                                        name, pArg, priority, options);

#else 
        time( (time_t*)&ts );
        sprintf(buf, "0x%08x 0x%08x %6d %12d %s %6d %6d %6d", taskId, addr, size, ts, 
                                                                                        name, pArg, priority, options);
#endif

        if (OS_SUCCESS != mUtlRscStore.insert(addr, buf))
        {
//              printf("\nUtlRscStore.insert returned error.\n");
        }
        sTraceFlag = traceFlag;
        mpResourceStoreLock->release();
}
Exemplo n.º 23
0
// Return the number of memory allocations (monotonically increasing)
int UtlRscTrace::allocCnt(int taskId)
{
        unsigned int size;
        char** activeRscs;
        int i;

    mpResourceStoreLock->acquire();
        int traceFlag = sTraceFlag;
        sTraceFlag = 0;
        size = mUtlRscStore.numEntries();

        activeRscs = (char**) new long[size];
        for (i = 0; i < size; i++)
        {
                activeRscs[i] = new char[256];
        }
        mUtlRscStore.getActiveRscs(activeRscs, size);
        sTraceFlag = traceFlag;
        mpResourceStoreLock->release();

        int id;
        unsigned long cnt = 0;
        printf("        total current alloc's: %d\n", size);
        switch (traceFlag)
        {
        case MEMORY:
                printf("  taskId     address     size    time   taskName\n");
                break;

        case OSSOCKET:
                printf("  taskId     address     time     taskName\n");
                break;
       
        case OSMSGQ:
                printf("  taskId     address     time     taskName           qName\n");
                break;
  
        case OSBSEM:
                printf("  taskId     address  options  time     taskName     state\n");
                break;

        case OSCSEM:
                printf("  taskId     address    queueOptions  time   taskName    maxCount   initCount  \n");
                break;

        case OSMUTEX:
        case OSRWMUTEX:
                printf("  taskId     address     options   time   taskName\n");
                break;

        case OSTIMER:
                printf("  taskId     address     state   time   taskName    timerId   type  \n");
                break;

        case OSTASK:
                printf("  taskId     address     size    time  taskName   taskName  pArg priority options\n");
                break;

        case NONE:
        default:
                break;
        }
        printf("============================================================================\n");
        if (taskId == 0)
        {
                for (i = 0; i < size; i++)
                {
                        cnt++;
                        printf("%s\n", activeRscs[i]);
                }
                printf("============================================================================\n");
                printf("        total current alloc's: %d\n", size);
        }
        else
        {
                for (i = 0; i < size; i++)
                {
                        sscanf(activeRscs[i], "0x%08x", &id);
                        if (id == taskId)
                        {
                                cnt++;
                                printf("%s\n", activeRscs[i]);
                        }
                }
                printf("============================================================================\n");
#ifdef _VXWORKS
                printf("current alloc's for %s 0x%08x: %d\n", taskName(taskId), taskId, cnt);
#else
                printf("current alloc's for 0x%08x: %d\n", taskId, cnt);
#endif
        }

        return cnt;
}
Exemplo n.º 24
0
/**
 ******************************************************************************
 * @brief    interrupt level handling of exceptions
 * @param[in]  pRegs    : 发生异常时寄存器值
 * @param[in]  excNo    : 异常中断号
 *
 * @retval None
 ******************************************************************************
 */
void
excExcHandle(void* pRegs, uint32_t excNo)
{
    uint32_t regs[16];
    uint32_t hfsr = *(uint32_t*)HARD_FALUT_FSR;
    uint8_t mfsr = *(uint8_t*)MEM_FALUT_FSR;
    uint8_t bfsr = *(uint8_t*)BUS_FALUT_FSR;
    uint16_t ufsr = *(uint16_t*)USGE_FALUT_FSR;

    memcpy(regs, pRegs, 64);
    uint32_t sp = (uint32_t)pRegs;

    intCnt++;
    printf("\r\n");
    switch (excNo)
    {
        case 3:
            /* 输出hfsr信息 */
            printf("=====硬fault=====\r\n");
            if (hfsr & 0x00000002) printf("取向量时发生硬fault\r\n");
            if (hfsr & 0x40000000) printf("上访产生硬fault\r\n");
            if (hfsr & 0x80000000) printf("调试产生硬fault\r\n");
            break;
        case 4:
            /* 输出mfsr信息 */
            printf("=====存储器fault=====\r\n");
            if (mfsr & 0x01) printf("取指令访问违规\r\n");
            if (mfsr & 0x02) printf("数据访问违规\r\n");
            if (mfsr & 0x08) printf("出栈错误\r\n");
            if (mfsr & 0x10) printf("入栈错误\r\n");
            if (mfsr & 0x80) printf("由0x%08x处的指令引起\r\n", *(uint32_t*)(MEM_FALUT_FAR));
            break;
        case 5:
            /* 输出bsfr信息 */
            printf("=====总线fault=====\r\n");
            if (bfsr & 0x01) printf("取指令访问违规\r\n");
            if (bfsr & 0x02) printf("精确的数据访问违规\r\n");
            if (bfsr & 0x04) printf("不精确的数据访问违规\r\n");
            if (bfsr & 0x08) printf("出栈错误\r\n");
            if (bfsr & 0x10) printf("入栈错误\r\n");
            if (bfsr & 0x80) printf("由0x%08x处的指令引起\r\n", *(uint32_t*)(BUS_FALUT_FAR));
            else printf("无法追踪违规指令\r\n");
            break;
        case 6:
            /* 输出ufsr信息 */
            printf("=====用法fault=====\r\n");
            if (ufsr & 0x0001) printf("指令解码错误\r\n");
            if (ufsr & 0x0002) printf("程序视图切入ARM状态\r\n");
            if (ufsr & 0x0008) printf("异常返回时视图非法的加载EXC_RETURN到PC\r\n");
            if (ufsr & 0x0010) printf("程序视图执行协处理器相关指令\r\n");
            if (ufsr & 0x0100) printf("未对齐\r\n");
            if (ufsr & 0x0200) printf("除数为零\r\n");
            break;
        default:
            printf("=====无效的错误中断:%d=====\r\n", excNo);
            intCnt--;
            return;
    }

    printf("exception occur regs : \r\n");
    printf("    r0  =%08x    r1  =%08x    r2  =%08x    r3  =%08x \r\n",
            regs[8], regs[9], regs[10], regs[11]);
    printf("    r4  =%08x    r5  =%08x    r6  =%08x    r7  =%08x \r\n",
            regs[0], regs[1], regs[2], regs[3]);
    printf("    r8  =%08x    r9  =%08x    r10 =%08x    r11 =%08x \r\n",
            regs[4], regs[5], regs[6], regs[7]);
    printf("    sp  =%08x    lr  =%08x    pc  =%08x    xpsr=%08x \r\n",
            sp, regs[13], regs[14], regs[15]);

    TASK_ID taskid = taskIdSelf();
    printf("exception occur in task: 0x%x \n\r", (uint32_t)taskid);
    printf("exception task name: %-16s \n\r", taskName(taskid));
    taskSuspend(taskid);    /* 挂起产生异常的任务 */

    time_t curtm = time(NULL);
    struct tm daytime;
    (void)localtime_r(&curtm, &daytime);
    printf("exception occur time: %04d-%02d-%02d %02d:%02d:%02d\r\n",
            daytime.tm_year + 1900, daytime.tm_mon + 1, daytime.tm_mday,
            daytime.tm_hour, daytime.tm_min, daytime.tm_sec);
    /* 若此时调度器关闭,则打开调度器 */
    if (xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED)
    {
        xTaskResumeAll();
    }
    intCnt--;
}
Exemplo n.º 25
0
Arquivo: logLib.c Projeto: phoboz/vmx
LOCAL void logTask(
    void
    )
{
    LOG_MSG logMsg;
    char *tName;
    int newMsgsLost;

    /* Initialize locals */
    newMsgsLost = oldMsgsLost;

    /* Endless loop */
    while (1)
    {
        /* If failed to get message */
        if (msgQReceive(logMsgQId, &logMsg, sizeof(logMsg), WAIT_FOREVER) !=
            sizeof(logMsg))
        {
            /* Error */
            lprintf(
                "logTask: error reading log messages.\n",
                (ARG) 0,
                (ARG) 0,
                (ARG) 0,
                (ARG) 0,
                (ARG) 0,
                (ARG) 0
                );
        }
        else
        {
            if (logMsg.id == -1)
            {
                lprintf(
                    "interrupt: ",
                    (ARG) 0,
                    (ARG) 0,
                    (ARG) 0,
                    (ARG) 0,
                    (ARG) 0,
                    (ARG) 0
                    );
            }
            else
            {
                /* Get name from task */
                tName = taskName(logMsg.id);
                if (tName == NULL)
                {
                    lprintf(
                        "%#x (): task dead",
                        (ARG) logMsg.id,
                        (ARG) 0,
                        (ARG) 0,
                        (ARG) 0,
                        (ARG) 0,
                        (ARG) 0
                        );
                }
                else
                {
                    lprintf(
                        "%#x (%s): ",
                        (ARG) logMsg.id,
                        (ARG) tName,
                        (ARG) 0,
                        (ARG) 0,
                        (ARG) 0,
                        (ARG) 0
                        );
                }
            }

            /* If message format null */
            if (logMsg.fmt == NULL)
            {
                lprintf(
                    "<null \"fmt\" parameter>\n",
                    (ARG) 0,
                    (ARG) 0,
                    (ARG) 0,
                    (ARG) 0,
                    (ARG) 0,
                    (ARG) 0
                    );
            }
            else
            {
                lprintf(
                    logMsg.fmt,
                    logMsg.arg[0],
                    logMsg.arg[1],
                    logMsg.arg[2],
                    logMsg.arg[3],
                    logMsg.arg[4],
                    logMsg.arg[5]
                    );
            }
        }

        /* If lost messages changed */
        if (newMsgsLost != oldMsgsLost)
        {
            lprintf(
                "logTask: %d log messages lost.\n",
                (ARG) newMsgsLost - oldMsgsLost,
                (ARG) 0,
                (ARG) 0,
                (ARG) 0,
                (ARG) 0,
                (ARG) 0
                );

            oldMsgsLost = newMsgsLost;
        }
    }
}