⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wvlib.c

📁 vxworks5.5.1源代码。完整源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
** If <mode> is INSTRUMENT_ON, instrumentation is turned on; if it is any * other value (including INSTRUMENT_OFF) then instrumentation is turned off* for <objId>.** Call wvObjInstModeSet() with INSTRUMENT_ON if you want to enable* instrumentation for all objects created after a certain place in your code.* Use wvSigInst() if you want to enable instrumentation for all signal activity.** This routine has effect only if INCLUDE_WINDVIEW is defined in* configAll.h.** RETURNS: OK or ERROR.** SEE ALSO: wvSigInst(), wvEventInst(), wvObjInstModeSet()*/STATUS wvObjInst    (    int    objType,			/* object type */    void * objId,			/* object ID or NULL for all objects */    int    mode 			/* instrumentation mode */    )    {    if (objId == NULL)	/* all objects of the same type */        {        if (mode == INSTRUMENT_ON)            {            /* Turn on instrumentation */            switch (objType)                {                case OBJ_TASK:                    taskClassId->instRtn = (FUNCPTR) evtLogOInt;                    break;                case OBJ_SEM:                    semClassId->instRtn = (FUNCPTR) evtLogOInt;                    break;                case OBJ_MSG:                    msgQClassId->instRtn = (FUNCPTR) evtLogOInt;                    break;                case OBJ_WD:                    wdClassId->instRtn = (FUNCPTR) evtLogO;                    break;                case OBJ_MEM:                    memPartClassId->instRtn = (FUNCPTR) evtLogOInt;                    break;                default:                    return(ERROR);                }            }        else            {	    /* Turn off instrumentation */            switch (objType)                {                case OBJ_TASK:                    taskClassId->instRtn = (FUNCPTR) NULL;                    break;                case OBJ_SEM:                    semClassId->instRtn = (FUNCPTR) NULL;                    break;                case OBJ_MSG:                    msgQClassId->instRtn = (FUNCPTR) NULL;                    break;                case OBJ_WD:                    wdClassId->instRtn = (FUNCPTR) NULL;                    break;                case OBJ_MEM:                    memPartClassId->instRtn = (FUNCPTR) NULL;                    break;                default:                    return(ERROR);                }            }	}    else			/* per object basis */        {        /* verify the object */	switch (objType)            {            case OBJ_TASK:                {                if (TASK_ID_VERIFY ((WIND_TCB *) objId) == ERROR)	            return (ERROR);	        break;	        }            case OBJ_SEM:                {                if (OBJ_VERIFY ((SEM_ID) objId, semClassId) == ERROR)	            return (ERROR);		break;		}            case OBJ_MSG:                {                if (OBJ_VERIFY ((MSG_Q_ID) objId, msgQClassId) == ERROR)		    return (ERROR);		break;		}            case OBJ_WD:                {                if (OBJ_VERIFY ((WDOG_ID) objId, wdClassId) == ERROR)		    return (ERROR);		break;		}           case OBJ_MEM:                {                if (OBJ_VERIFY ((PART_ID) objId, memPartClassId) == ERROR)	            return (ERROR);		break;		}            default:                return(ERROR);            }        /* the event logging routine is set/reset in the object's class */        if (mode == INSTRUMENT_ON)            {	    /* change to instrumented class */            if (TASK_ID_VERIFY ((WIND_TCB *) objId) == ERROR)	        {                if (OBJ_EVT_RTN (objId) == (FUNCPTR) NULL)                    {	            (((OBJ_ID)(objId))->pObjClass) =                        (struct obj_class *)                        (((OBJ_ID)(objId))->pObjClass->initRtn);                    }		}	    else		{                if (TASK_EVT_RTN (objId) == (FUNCPTR) NULL)                    {		    ((OBJ_ID)(&((WIND_TCB *)(objId))->objCore))->pObjClass =		        (struct obj_class *) (((OBJ_ID)			(&((WIND_TCB *)(objId))->objCore))->pObjClass)->initRtn;	 	    }		}            }        else            {	    /* change to non-instrumented class */	    /* change to instrumented class */            if (TASK_ID_VERIFY ((WIND_TCB *) objId) == ERROR)	        {                if (OBJ_EVT_RTN (objId) != (FUNCPTR) NULL)                    {	            (((OBJ_ID)(objId))->pObjClass) =                        (struct obj_class *)                        (((OBJ_ID)(objId))->pObjClass->initRtn);                    }		}	    else	        {                if (TASK_EVT_RTN (objId) != (FUNCPTR) NULL)                    {		    ((OBJ_ID)(&((WIND_TCB *)(objId))->objCore))->pObjClass =	                (struct obj_class *) (((OBJ_ID)			(&((WIND_TCB *)(objId))->objCore))->pObjClass)->initRtn;                    }		}            }    	return (OK);        }	    return (ERROR);	/* instrumentation is off */    }/********************************************************************************* wvSigInst - instrument signals (WindView)** This routine instruments all signal activity.** If <mode> is INSTRUMENT_ON, instrumentation for signals is turned on;* if it is any other value (including INSTRUMENT_OFF), instrumentation for* signals is turned off.** This routine has effect only if INCLUDE_WINDVIEW is defined in* configAll.h and event logging has been enabled for system objects.** INTERNAL* Because signals are not implemented as objects, they need their own logging* mechanism.** RETURNS: OK or ERROR.*/STATUS wvSigInst    (    int   mode 		/* instrumentation mode */    )    {    if (mode == INSTRUMENT_ON)        {	/* set signal event routine */        sigEvtRtn = (VOIDFUNCPTR) evtLogOInt;        }    else if (mode == INSTRUMENT_OFF)        {        /* reset signal routine */        sigEvtRtn = NULL;        }    else        return (ERROR);    return (OK);    }/********************************************************************************* wvEventInst - instrument VxWorks Events (WindView)** This routine instruments VxWorks Event activity.** If <mode> is INSTRUMENT_ON, instrumentation for VxWorks events is turned on;* if it is any other value (including INSTRUMENT_OFF), instrumentation for* VxWorks Events is turned off.** This routine has effect only if INCLUDE_WINDVIEW is defined in* configAll.h and event logging has been enabled for system objects.** INTERNAL* Because events are not implemented as objects, they need their own logging* mechanism.** RETURNS: OK or ERROR.*/STATUS wvEventInst    (    int   mode 		/* instrumentation mode */    )    {    if (mode == INSTRUMENT_ON)        {	/* set event logging routine */        eventEvtRtn = (VOIDFUNCPTR) evtLogOInt;        }    else if (mode == INSTRUMENT_OFF)        {        /* reset logging routine */        eventEvtRtn = NULL;        }    else        return (ERROR);    return (OK);    }/********************************************************************************* wvEvent - log a user-defined event (WindView)** This routine logs a user event.  Event logging must have been started with* wvEvtLogEnable() or from the WindView GUI to use this routine.  * The <usrEventId> should be in the* range 0-25535.  A buffer of data can be associated with the event;* <buffer> is a pointer to the start of the data block, and <bufSize> is its* length in bytes.  The size of the event buffer configured with* wvInstInit() should be adjusted when logging large user events.* * RETURNS: OK, or ERROR if the event can not be logged.** SEE ALSO: dbgLib, e()** INTERNAL* This event logging routine stores*       event id        (short )*       timestamp       (int)*       address         (int)   - always NULL*       buffer size     (int)   - if size is ZERO the buffer does not exist.*       buffer          (char)**/STATUS wvEvent    (    event_t    usrEventId,      /* event */    char *     buffer,          /* buffer */    size_t     bufSize          /* buffer size */    )    {    if (WV_ACTION_IS_SET)	return (evtLogPoint (usrEventId, NULL, bufSize, buffer));    else	return (OK);    }/********************************************************************************* uploadPathWrite - write data to upload path** This routine attempts to write the data pointed to by pData to the uplaod* path indicated by pathId.  If the data can not be written due to a blocking* error such as EWOULDBLOCK or EAGAIN, this routine will delay for some time* using taskDelay(), and retry until the data is written.  If the data can* not be written within a reasonable number of attempts, or an error other* than EWOULDBLOCK or EAGAIN is generated while writing, this routine will* give up and return an error.** RETURNS: OK, or ERROR if the data could not be written in a reasonable*          number of attempts, or if invalid pathId** SEE ALSO:* NOMANUAL**/static STATUS uploadPathWrite    (    UPLOAD_ID     pathId,               /* path to write to */    char         *pData,                /* buffer of data to write */    int           nBytes                /* number bytes to write */    )    {    int   trys;                         /* to count the attempts */    int   nToWrite;                     /* number bytes left to write  */    int   nThisTry;                     /* number bytes written this try */    int   nWritten;                     /* total bytes written so far */    char *buf;                          /* local copy of pData */    trys     = 0;    nWritten = 0;    nThisTry = 0;    nToWrite = nBytes;    buf      = pData;    if (pathId == NULL || pathId->writeRtn == NULL)        return (ERROR);    while (nWritten < nBytes && trys < wvUploadMaxAttempts)        {        if ((nThisTry = pathId->writeRtn (pathId, buf, nToWrite)) < 0)            {            /* If write failed because it would have blocked, allow retry. */            if (errno == EWOULDBLOCK || errno == EAGAIN)                taskDelay (wvUploadRetryBackoff);            else                return (ERROR);            }        else            {            nWritten += nThisTry;            nToWrite -= nThisTry;            buf      += nThisTry;            }        ++trys;        }    /* Check if write failed to complete within the max number of tries. */    if (nWritten < nBytes)        return (ERROR);    return (OK);    }/********************************************************************************* wvUpload - transfer events to the host (WindView)** This routine is used to upload events stored in the event buffer to the* host.  Events are read from the buffer using the routines and information* referenced by the BUFFER_ID.  The upload path is accessed using* routines referenced by the UPLOAD_ID.  Information useful for making this* routine exit when desired, and communicating when it has exited is * contained in the WV_UPLOADTASK_ID.** When exitWhenEmpty, within the WV_UPLOADTASK_ID, is set to true, wvUpload* will upload all available events, and then return immediately. If this* value is set to false, wvUpload will never exit, but it will block on the* buffer's semaphore until sufficient data becomes available to upload.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -