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

📄 wtx.c

📁 vxworks源码源码解读是学习vxworks的最佳途径
💻 C
📖 第 1 页 / 共 5 页
字号:
    callStat = exchange (hWtx, WTX_COMMAND_SEND, &in, &out);    if (callStat == WTX_ERR_NONE)	wtxExchangeFree (hWtx->server, WTX_COMMAND_SEND, &out);    /* Free the event list and stop the async. notif. mechanism */    wtxAsyncStop ();    /* Reset all global variables */    hWtxForAsyncNotify = NULL;    userNotifyFunc = NULL;    /* Tchao */#endif    return (WTX_OK);    }/********************************************************************************* wtxBreakpointAdd - create a new WTX eventpoint of type breakpoint** This routine creates a new eventpoint on the target to represent a* breakpoint at the address <tgtAddr> for the target context <contextId>.* The target server maintains a list of eventpoints created on the target* and this can be queried using wtxEventpointList().  When a context is* destroyed on the target or the target is reset, eventpoints are deleted* automatically without intervention from the creator.** The context types are given by:** EXPAND ../../../include/wtxtypes.h WTX_CONTEXT_TYPE** When <contextType> is set to WTX_CONTEXT_SYSTEM, then only breakpoints* in system mode can be added. When <contextType> is set to WTX_CONTEXT_TASK,* then only breakpoints in context task can be added.** RETURNS: The ID of the new breakpoint or WTX_ERROR if the add fails.** SEE ALSO: WTX_EVENTPOINT_ADD, wtxEventpointAdd(), wtxEventpointDelete(), * wtxEventpointList()*/UINT32 wtxBreakpointAdd     (    HWTX		hWtx,		/* WTX API handle */    WTX_CONTEXT_TYPE	contextType,	/* type of context to put bp in */    WTX_CONTEXT_ID_T	contextId,	/* associated context */    TGT_ADDR_T		tgtAddr		/* breakpoint address */    )    {    WTX_MSG_RESULT	out;    WTX_MSG_EVTPT_DESC	in;    WTX_ERROR_T		callStat;    UINT32		bpId;        WTX_CHECK_CONNECTED (hWtx, WTX_ERROR);    memset (&out, 0, sizeof (out));    memset (&in, 0, sizeof (in));    in.wtxEvtpt.event.eventType = WTX_EVENT_TEXT_ACCESS;    in.wtxEvtpt.event.eventArg = (TGT_ARG_T) tgtAddr;    in.wtxEvtpt.context.contextType = contextType;    in.wtxEvtpt.context.contextId = contextId;    /* ??? Not used by target agent */    in.wtxEvtpt.action.actionType = WTX_ACTION_STOP | WTX_ACTION_NOTIFY;     in.wtxEvtpt.action.actionArg = 0;	/* ??? Not used by target agent */    in.wtxEvtpt.action.callRtn = 0;	/* ??? Not used by target agent */    in.wtxEvtpt.action.callArg = 0;	/* ??? Not used by target agent */    callStat = exchange (hWtx, WTX_EVENTPOINT_ADD, &in, &out);    if (callStat != WTX_ERR_NONE)	WTX_ERROR_RETURN (hWtx, callStat, WTX_ERROR);    bpId = out.val.value_u.v_uint32;     wtxExchangeFree (hWtx->server, WTX_EVENTPOINT_ADD, &out);    return bpId;    }/********************************************************************************* wtxCacheTextUpdate - synchronize the instruction and data caches.** This function flushes the data chache, then invalidates the instruction cache.* This operation forces the instruction cache to fetch code that may have been * created via the data path.** ERRORS:* .iP WTX_ERR_API_INVALID_ARG 12* <nBytes> is invalid.** RETURNS: WTX_OK or WTX_ERROR if exchange failed.** SEE ALSO: WTX_CACHE_TEXT_UPDATE, wtxMemRead(), wtxMemWrite()*/STATUS wtxCacheTextUpdate    (    HWTX        hWtx,                   /* WTX API handle            */    TGT_ADDR_T  addr,                   /* remote addr to update     */    UINT32      nBytes                  /* number of bytes to update */    )    {    WTX_ERROR_T                 callStat;    WTX_MSG_MEM_BLOCK_DESC      in;    WTX_MSG_RESULT              out;    WTX_CHECK_CONNECTED (hWtx, WTX_ERROR);    if (nBytes == 0)        WTX_ERROR_RETURN (hWtx, WTX_ERR_API_INVALID_ARG, WTX_ERROR);    memset (&in, 0, sizeof (in));    memset (&out, 0, sizeof (out));    in.startAddr = addr;    in.numBytes = nBytes;    callStat = exchange (hWtx, WTX_CACHE_TEXT_UPDATE, &in, &out);    if (callStat != WTX_ERR_NONE)        WTX_ERROR_RETURN (hWtx, callStat, WTX_ERROR);    wtxExchangeFree (hWtx->server, WTX_CACHE_TEXT_UPDATE, &out);    return (WTX_OK);    }/******************************************************************************** wtxCommandSend - Pass a string to be interpreted by the target server** This function is used to control the target server behavior.* Services availables are: wtxTsKill(), wtxTsRestart(), wtxLogging (),* wtxTsLock(), wtxTsUnlock(), wtxTargetReset(), wtxAsyncNotifyEnable(),* wtxAsyncNotifyDisable().** This service sends a string to the target server which interprets it.* If the requested service is not known by tsWtxCommandSend(), then* the string is sent back to the client.** EXAMPLE* The following is a sample of string** .CS*    commandString = "wtxTsLock_30";    /@ lock the target server for 30s @/*    commandString = "wtxTsUnlock";     /@ Unlock the target server @/*    commandString = "wtxLoggingOn_/folk/pascal/wtx.txt"; /@ wtx log started @/* .CE** NOTE:* A separator is used ("_") and only some command strings can be * recognized by the target server (plus options if needed):* .iP "wdbLoggingOn"* Open the file and log all WDB requests.* .iP "wdbLoggingOff"* Close the file and stop the log.* .iP "wtxLoggingOn"* Open the file and log all WTX requests.* .iP "wtxLoggingOff"* Close the file and stop the log.* .iP "allLoggingOff"* Stop WDB and WTX log.* .iP "wtxAsyncNotifyEnable"* Start the asynchronous notification of events.* .iP "wtxAsyncNotifyDisable"* Stop the asynchronous notification of events.* .iP "wtxObjKillDestroy"* Kill the target server.* .iP "wtxObjKillRestart"* Restart the target server.* .iP "wtxTsLock"* Lock the target server.* .iP "wtxTsUnlock"* Unlock the target server.* .iP "wtxTargetReset"* Reset the target.* .iP "wtxTargetIpAddressGet"* Get the target's IP address (if applicable) in a.b.c.d form.** RETURNS: string containing the command's result.* * SEE ALSO: wtxTsKill(), wtxTsRestart(), wtxLogging(), wtxTsLock(), * wtxTsUnlock(), wtxTargetReset(), wtxAsyncNotifyEnable(),* wtxAsyncNotifyDisable()*/char * wtxCommandSend    (    HWTX    hWtx,                          /* WTX API handle           */    char *  commandString                  /* String to be interpreted */    )    {    WTX_MSG_RESULT  out;    WTX_MSG_PARAM   in;    WTX_ERROR_T     callStat;    WTX_CHECK_CONNECTED (hWtx, NULL);    memset (&out, 0, sizeof (out));    memset (&in, 0, sizeof (in));    in.param.valueType = V_PCHAR;    in.param.value_u.v_pchar = commandString;    callStat = exchange (hWtx, WTX_COMMAND_SEND, &in, &out);    if (callStat != WTX_ERR_NONE)        WTX_ERROR_RETURN (hWtx, callStat, NULL);    return (out.val.value_u.v_pchar);    }/********************************************************************************* wtxTargetIpAddressGet - gets target IP address.** This routine returns the target's IP address in network byte order. The* returned address is the one used by the target server to connect the target.** On error (the target have no IP address), this value will be (UINT32) 0.** RETURNS: the target's IP address in network byte order or 0 on error.*/UINT32 wtxTargetIpAddressGet     (    HWTX    hWtx                          /* WTX API handle           */    )    {    WTX_MSG_RESULT  out;    WTX_MSG_PARAM   in;    WTX_ERROR_T     callStat;    WTX_CHECK_CONNECTED (hWtx, 0);    memset (&out, 0, sizeof (out));    memset (&in, 0, sizeof (in));    in.param.valueType = V_PCHAR;    in.param.value_u.v_pchar = WTX_TARGET_IP_ADDRESS_CMD;    callStat = exchange (hWtx, WTX_COMMAND_SEND, &in, &out);    if (callStat != WTX_ERR_NONE)        WTX_ERROR_RETURN (hWtx, callStat, 0);    return (inet_addr (out.val.value_u.v_pchar));    }/********************************************************************************* wtxCpuInfoGet - gets cpu related information from architecturedb file** This function allows to get target CPU related informations. <cpuNum>* specifies the CPU number in data base, while <cpuInfoType> specifies which* parameter to get.** <cpuInfoType> can be from the following type** EXPAND ../../../include/wtx.h CPU_INFO** NOTE:* returned value if not NULL should be freed by caller** RETURNS: a string containing parameter in string format or NULL.** SEE ALSO: wtxTsInfoGet()*/char * wtxCpuInfoGet    (    int		cpuNum,			/* cpu number to get info on       */    CPU_INFO	cpuInfoType		/* cpu info type to get            */    )    {    char *	cpuInfo = NULL;		/* returned target cpu information */#ifdef HOST    char *	windBase = NULL;	/* win base directory name         */    char *	cpuFamilyName = NULL;	/* family name of CPU num <cpuNum> */    char	section [100];		/* section number e.g. CPU ID      */    char	paramBuf [100];		/* receiving parameter buffer      */    char	configFile [PATH_MAX];	/* configuration file name         */    int		ix = 0;			/* loop counter                    */    int		nChar = 0;		/* # of chars in returned value    */    CPU_INFO_TYPE	targetCpuInfo[] =	/* cpu data initialization */	{	/* param,	string,				section */	{CPU_INFO_NONE,	"none",				NULL},	{ARCH_DIR,	"Architecture Directory",	NULL},	{LEADING_CHAR,	"Leading Character",		NULL},	{DEMANGLER,	"demangler",			NULL},	{CPU_NAME,	"cpuname",			NULL}	};    sprintf (section, "CPU_%d", cpuNum);    /* setting architecture data base file name */    windBase = wpwrGetEnv ("WIND_BASE");    if (windBase == NULL)        {	goto error1;	}    strcpy (configFile, windBase);    strcat (configFile, "/host/resource/target/architecturedb");#ifdef WIN32    wpwrBackslashToSlash (configFile);#endif /* WIN32 */    /* get CPU family name */    nChar = GetPrivateProfileString (section, "cpuFamilyName", "unknown",				     paramBuf, sizeof (paramBuf), configFile);    if ( (! strcmp (paramBuf, "unknown")) ||	 ( (cpuFamilyName = strdup (paramBuf)) == NULL))	{	goto error1;	}    /* section assignement for parameters */    targetCpuInfo[1].section = cpuFamilyName;    targetCpuInfo[2].section = cpuFamilyName;    targetCpuInfo[3].section = "misc";    targetCpuInfo[4].section = (char *) section;    /* set searched string */    for (ix = 1 ; ix < (int) NELEMENTS (targetCpuInfo) ; ix++)	{	if (targetCpuInfo[ix].param == cpuInfoType)	    {	    if ( (targetCpuInfo[ix].section != NULL) &&		 (targetCpuInfo[ix].string != NULL))		{		nChar = GetPrivateProfileString (targetCpuInfo[ix].section,						 targetCpuInfo[ix].string,						 "unknown", paramBuf,						 sizeof (paramBuf), configFile);		}	    else		{		goto error2;		}	    break;	    }	}    /* allocate and verify returned value */    if ( (! strcmp (paramBuf, "unknown")) ||	 ( (cpuInfo = strdup (paramBuf)) == NULL))	{	goto error2;	}error2:    free (cpuFamilyName);error1:#endif /* HOST */    return cpuInfo;    }/********************************************************************************* wtxEventpointAdd - create a new WTX eventpoint** This routine creates a new eventpoint on the target. This routine is a* generic facility for setting breakpoints. An eventpoint specifies the* context to which it applies, the type of event to detect (for example * breakpoint, context exit), and the action to be taken upon detection of * the event (for example, notify the target server of the event).** The target server maintains a list of eventpoints created on the target* and this can be queried using wtxEventpointList().  When a context is* destroyed on the target or the target is reset, eventpoints are deleted* automatically without intervention from the creator.** When <pEvtpt->context.contextType> is set to WTX_CONTEXT_SYSTEM, then * only eventpoints in system mode can be added. * When <pEvtpt->context.contextType> is set to WTX_CONTEXT_TASK, then only * eventpoints in context task can be added.** The eventpoint parameters are grouped into the structure:** EXPAND ../../../include/wtxmsg.h WTX_EVTPT_2** where WTX_EVENT_2 is:** EXPAND ../../../include/wtxmsg.h WTX_EVENT_2* * where WTX_CONTEXT is:** EXPAND ../../../include/wtxmsg.h WTX_CONTEXT* * The context types are given by:** EXPAND ../../../include/wtxtypes.h WTX_CONTEXT_TYPE** If contextType is set to WTX_CONTEXT_TASK and contextId set to 0, * then it is equivalent to contextType set to WTX_CONTEXT_ANY_TASK.** where WTX_ACTION is:** EXPAND ../../../include/wtxmsg.h WTX_ACTION** The action types are given by WTX_ACTION_TYPE and can be or'ed * together if multiple actions are needed:** EXPAND ../../../include/wtxtypes.h WTX_ACTION_TYPE** RETURNS: The ID of the new eventpoint or WTX_ERROR if the add fails.** SEE ALSO: WTX_EVENTPOINT_ADD_2, wtxEventpointDelete(

⌨️ 快捷键说明

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