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

📄 wvlib.c

📁 vxworks5.5.1源代码。完整源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
Unfortunately, when either windview or triggering is on, three tests,rather than just two, have to be performed.All three global variables, evtAction, wvEvtClass trgEvtClass are managedthrough the macro interface defined in eventP.h.  The variables themselvesnever need to be referenced explicitly.The event buffer and upload paths provide a fairly simple interface that allows wvLib to use them.  Other buffers and upload paths can beeasily added by follwing the same interface.  The buffer ID passed to many of wvLib's routines is actually a pointer toa structure defined in wvBufferP.h.  This structure contains function pointers for reading and writing, and communicates threshold information fromthe buffering library.  evtLogLib also uses this ID to write to the buffers.The buffer library usually considers the ID as a pointer to a structure whose first members are like the structure defined in wvBufferP.h, butwhose other members are used to store its own private information.Upload paths are accessed in a similar way to the event buffers,  but are much simpler.  The structure that defines their interface is defined inwvUploadPathP.h.A hash table is implemented within wvLib to maintain task name events forpost mortem log generation, as described above.  This was done because itis possible for a tid to be reused, leaving more than one taskname for a single tid.  In this case one of the names has to be chosen, and in ourcase it is the last.  The hash table provides near constant time lookup ofevents as they are logged, in order to ensure that there is only ever onename per tid in the table at any time.  The hash tables were rewritten here,rather than using the vxWorks' hashLib, because the storage has to relocatable to other memory partitions than the system partition.  This hash table is complete overkill however, because the WindView parsercan accept any number of taskname events with a single tid.  It always updates the name to the last name it received for a tid.  Given this, itis not necessary to ensure there are no duplicate names per tid in thetaskname buffer.  With no lookup facility necessary, a simple linked listwould suffice for this data structure.  Well, the hash table works.*/#include "vxWorks.h"#include "intLib.h"#include "logLib.h"#include "msgQLib.h"#include "semLib.h"#include "private/memPartLibP.h"#include "string.h"#include "taskLib.h"#include "wdLib.h"#include "sysLib.h"#include "errnoLib.h"#include "wvLib.h"#include "private/eventP.h"#include "private/objLibP.h"#include "private/sigLibP.h"#include "private/eventLibP.h"#include "private/taskLibP.h"#include "private/kernelLibP.h"#include "private/workQLibP.h"#include "private/semLibP.h"#include "private/evtLogLibP.h"#include "private/wvBufferP.h"#include "private/wvUploadPathP.h"#include "private/wvLibP.h"/* global */int wvUploadTaskPriority      = 150;	        /* upload task priority */int wvUploadTaskStackSize     = 5000;	        /* upload task stack size */int wvUploadTaskOptions       = VX_UNBREAKABLE; /* upload task options */int wvUploadMaxAttempts       = 200;            /* upload write retries */int wvUploadRetryBackoff      = 6;              /* upload retry delay - ticks */PART_ID	pmPartId ;				/* post mortem partition id */BOOL    wvEvtBufferFullNotify = FALSE;	/* notify the host that the evt buff */					/* is full. Will be reset by the */					/* when seen (handshake) or when */					/* wvEvtLogStart is called *//* local */static BUFFER_ID    wvEvtBufferId;	/* a local copy for access by the host					   through wvEvtBufferGet */static TN_HASH_TBL *tnHashTbl;		/* Local copy of post-mortem taskname					   event hash table.  This is required					   for adding events, because events 					   are added directly from event points					   and this info isn't known at the					   event point. *//* extern */extern CLASS_ID msgQClassId;extern CLASS_ID wdClassId;/* forward declarations */static STATUS       uploadPathWrite        (UPLOAD_ID pathId, char *pData,					    int nBytes);static STATUS 	    wvUpload		   (WV_UPLOADTASK_ID upTaskId);static TASKBUF_ID   tnHashTblCreate        (PART_ID memPart, int tblSize);static STATUS       tnHashTblDestroy       (TN_HASH_TBL *pTbl);static int 	    tnHash 	           (TN_HASH_TBL *tbl, int key);static TN_ITER_KEY *tnHashTblIterInit      (TN_HASH_TBL *pTbl);static void         tnHashTblIterDone      (TN_ITER_KEY *pIterKey, 					    TN_HASH_TBL *pTbl);static TN_NODE     *tnHashTblIterNext      (TN_HASH_TBL *pTbl, 					    TN_ITER_KEY *pIterKey);static TN_EVENT    *tnHashTblIterNextEvent (TN_HASH_TBL *pTbl, 					    TN_ITER_KEY *pIterKey);static STATUS       tnHashTblInsert        (TN_HASH_TBL *pTbl, 					    TN_EVENT *pEvent, int key, 					    TN_EVENT *pReplacedEvent);/********************************************************************************* wvLibInit - initialize wvLib - first step (WindView)** This routine starts initializing wvLib.  Its actions should be performed * before object creation, so it is called from usrKernelInit() in usrKernel.c.** RETURNS: N/A*/void wvLibInit (void)    {    evtObjLogFuncBind ();    }/********************************************************************************* wvLibInit2 - initialize wvLib - final step (WindView)** This routine is called after wvLibInit() to complete the initialization of* wvLib.  It should be called before starting any event logging.** RETURNS: N/A*/void wvLibInit2 (void)    {    evtLogFuncBind ();    }/********************************************************************************* wvEvtLogInit - initialize an event log (WindView)** This routine initializes event logging by associating a particular event* buffer with the logging functions.  It must be called before event logging* is turned on.** RETURNS: N/A*/void wvEvtLogInit     (    BUFFER_ID 	evtBufId		/* event-buffer id */    )    {    /* Bind the buffer identified by evtBufId to the logging functions. */    evtBufferBind (evtBufId);    /* Stash a private copy of the id to return from wvEvtBufferGet. */    wvEvtBufferId = evtBufId;    }/******************************************************************************** wvEvtLogStart - start logging events to the buffer (WindView)** This routine starts event logging.  It also resets the timestamp* mechanism so that it can be called more than once without stopping event* logging.** RETURNS: N/A*/void wvEvtLogStart (void)     {    /*      * Initialize the time-stamp facility.  If event-logging is already     * enabled then we must disable the time-stamp facility before re-     * enabling it.     */    if (_func_tmrDisable != NULL && !WV_ACTION_IS_SET)	(* _func_tmrDisable)();    if (_func_tmrEnable != NULL)        (* _func_tmrEnable) ();    /* Turn on event logging. */    wvEvtBufferFullNotify = FALSE;    WV_ACTION_SET;    }/********************************************************************************* wvEvtLogStop - stop logging events to the buffer (WindView)** This routine turns off all event logging, including event-logging of* objects and signals specifically requested by the user.  In addition,* it disables the timestamp facility.** RETURNS: N/A*/void wvEvtLogStop (void)    {    /* Disable all event logging. */    WV_ACTION_UNSET;    /* Turn off any user-requested event logging within objects and signals. */    if (wvObjInstModeSet (INSTRUMENT_OFF) == INSTRUMENT_ON)        {        wvObjInst (OBJ_TASK, 0, INSTRUMENT_OFF);        wvObjInst (OBJ_SEM,  0, INSTRUMENT_OFF);        wvObjInst (OBJ_MSG,  0, INSTRUMENT_OFF);        wvObjInst (OBJ_WD,   0, INSTRUMENT_OFF);        wvObjInst (OBJ_MEM,  0, INSTRUMENT_OFF);        }    wvSigInst (INSTRUMENT_OFF);    wvEventInst (INSTRUMENT_OFF);    /* Disable the time-stamp facility. */    if (_func_tmrDisable != NULL)        (* _func_tmrDisable) ();    }/********************************************************************************* wvEvtClassSet - set the class of events to log (WindView)** This routine sets the class of events which are logged when event* logging is started.  <classDescription> can take the following values:** .CS*      WV_CLASS_1      /@ Events causing context switches @/*      WV_CLASS_2      /@ Events causing task-state transitions @/*      WV_CLASS_3      /@ Events from object and system libraries @/* .CE** See wvLib for more information about these classes, particularly Class 3.** RETURNS: N/A** SEE ALSO:* wvObjInst(), wvObjInstModeSet(), wvSigInst(), wvEventInst()**/void wvEvtClassSet    (    UINT32 classDescription		/* description of evt classes to set */    )    {    WV_EVTCLASS_SET (classDescription);    }/********************************************************************************* wvEvtClassGet - get the current set of classes being logged (WindView)** This routine returns the set of classes currently being logged.** RETURNS: The class description.*/UINT32 wvEvtClassGet (void)    {    return (wvEvtClass);    }/********************************************************************************* wvEvtClassClear - clear the specified class of events from those being logged (WindView)** This routine clears the class or classes described by <classDescription>* from the set of classes currently being logged.** RETURNS: N/A*/void wvEvtClassClear    (    UINT32 classDescription	/* description of evt classes to clear */    )    {    WV_EVTCLASS_UNSET (classDescription);    }/********************************************************************************* wvEvtClassClearAll - clear all classes of events from those logged (WindView)** This routine clears all classes of events so that no classes are logged* if event logging is started.** RETURNS: N/A*/void wvEvtClassClearAll (void)    {    WV_EVTCLASS_EMPTY;    }/********************************************************************************* wvObjInstModeSet - set object instrumentation on/off  (WindView)** This routine causes objects to be created either instrumented or not* depending on the value of <mode>, which can be INSTRUMENT_ON or * INSTRUMENT_OFF.  All objects created after wvObjInstModeSet() is called* with INSTRUMENT_ON and before it is called with INSTRUMENT_OFF are* created as instrumented objects.** Use wvObjInst() if you want to enable instrumentation for a specific* object or set of objects.  Use wvSigInst() if you want to enable * instrumentation for all signal activity, and wvEventInst() to * enable instrumentation for VxWorks Event activity.** This routine has effect only if INCLUDE_WINDVIEW is defined in* configAll.h.** RETURNS: The previous value of <mode> or ERROR.** SEE ALSO: wvObjInst(), wvSigInst(), wvEventInst()*/STATUS wvObjInstModeSet     (    int mode			/* object instrumentation on/off */    )    {    if (mode == INSTRUMENT_ON)		/* turn instrumentation on */	{	if (wvObjIsEnabled == TRUE)	    return (INSTRUMENT_ON);	wvObjIsEnabled = TRUE;	return (INSTRUMENT_OFF);	}    else if (mode == INSTRUMENT_OFF)	/* turn instrumentation off */        {        if (wvObjIsEnabled == FALSE)            return (INSTRUMENT_OFF);        wvObjIsEnabled = FALSE;        return (INSTRUMENT_ON);        }    else        return (ERROR);    }/********************************************************************************* wvObjInst - instrument objects (WindView)** This routine instruments a specified object or set of objects and has* effect when system objects have been enabled for event logging.** <objType> can be set to one of the following: OBJ_TASK (tasks), OBJ_SEM * (semaphores), OBJ_MSG (message queues), or OBJ_WD (watchdogs).* <objId> specifies the identifier of the particular object to be instrumented.* If <objId> is NULL, then all objects of <objType> have instrumentation* turned on or off depending on the value of <mode>. 

⌨️ 快捷键说明

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