📄 usrwdb.c
字号:
wdbBpInstall ();#endif }/******************************************************************************** wdbTgtHasFpp - TRUE if target has floating point support.*/LOCAL bool_t wdbTgtHasFpp (void) {#ifdef INCLUDE_HW_FP if (fppProbe() == OK) return (TRUE); return (FALSE);#else return (FALSE);#endif }/******************************************************************************** wdbRtInfoGet - get info on the VxWorks run time system.*/LOCAL void wdbRtInfoGet ( WDB_RT_INFO * pRtInfo ) { pRtInfo->rtType = WDB_RT_VXWORKS; pRtInfo->rtVersion = vxWorksVersion; pRtInfo->cpuType = CPU; pRtInfo->hasFpp = wdbTgtHasFpp();#ifdef INCLUDE_PROTECT_TEXT pRtInfo->hasWriteProtect = (vmLibInfo.pVmTextProtectRtn != NULL);#else /* !INCLUDE_PROTECT_TEXT */ pRtInfo->hasWriteProtect = FALSE;#endif /* !INCLUDE_PROTECT_TEXT */ pRtInfo->pageSize = VM_PAGE_SIZE_GET(); pRtInfo->endian = _BYTE_ORDER; pRtInfo->bspName = sysModel(); pRtInfo->bootline = vxBootFile; pRtInfo->memBase = (TGT_ADDR_T)(LOCAL_MEM_LOCAL_ADRS); pRtInfo->memSize = (int)sysMemTop() - (int)LOCAL_MEM_LOCAL_ADRS; pRtInfo->numRegions = wdbNumMemRegions; pRtInfo->memRegion = pWdbMemRegions; pRtInfo->hostPoolBase = (TGT_ADDR_T)WDB_POOL_BASE; pRtInfo->hostPoolSize = WDB_POOL_SIZE; }/******************************************************************************** vxReboot - reboot the system.*/LOCAL void vxReboot (void) { reboot (0); }/******************************************************************************** vxMemProtect - protect a region of memory.*/LOCAL STATUS vxMemProtect ( char * addr, u_int nBytes, bool_t protect /* TRUE = protect, FALSE = unprotect */ ) { return (VM_STATE_SET (NULL, addr, nBytes, VM_STATE_MASK_WRITABLE, (protect ? VM_STATE_WRITABLE_NOT : VM_STATE_WRITABLE))); }#ifdef INCLUDE_VXWORKS_KERNEL/******************************************************************************** wdbSp - spawn a task with default params*/ #define PRIORITY 100#define OPTIONS VX_FP_TASKvoid wdbSp ( int (*func)(), int arg0, int arg1, int arg2, int arg3, int arg4 ) { taskSpawn (NULL, PRIORITY, OPTIONS, WDB_SPAWN_STACK_SIZE, func, arg0, arg1, arg2, arg3, arg4, 0, 0, 0, 0, 0); }/******************************************************************************** vxTaskCreate - WDB callout to create a task (and leave suspended).** RETURNS : Task ID or ERROR if unable to create a task** NOMANUAL*/LOCAL int vxTaskCreate ( char * name, /* name of new task (stored at pStackBase) */ int priority, /* priority of new task */ int options, /* task option word */ caddr_t stackBase, /* base of stack. ignored by VxWorks */ int stackSize, /* size (bytes) of stack needed plus name */ caddr_t entryPt, /* entry point of new task */ int arg[10], /* 1st of 10 req'd task args to pass to func */ int fdIn, /* fd for input redirection */ int fdOut, /* fd for output redirection */ int fdErr /* fd for error output redirection */ ) { int tid; if (stackSize == 0) stackSize = WDB_SPAWN_STACK_SIZE; tid = taskCreat (name, priority, options, stackSize, (int (*)())entryPt, arg[0], arg[1], arg[2], arg[3], arg[4], arg[5], arg[6], arg[7], arg[8], arg[9]); if (tid == NULL) /* create failed */ return (ERROR);#ifdef INCLUDE_IO_SYSTEM if (fdIn != 0) ioTaskStdSet (tid, 0, fdIn); if (fdOut != 0) ioTaskStdSet (tid, 1, fdOut); if (fdErr != 0) ioTaskStdSet (tid, 2, fdErr);#endif /* INCLUDE_IO_SYSTEM */ return (tid); }/******************************************************************************** vxTaskResume - WDB callout to resume a suspended task.*/LOCAL STATUS vxTaskResume ( WDB_CTX * pContext ) { if (pContext->contextType != WDB_CTX_TASK) return (ERROR); return (taskResume (pContext->contextId)); }/******************************************************************************** vxTaskSuspend - WDB callout to suspend a task.*/LOCAL STATUS vxTaskSuspend ( WDB_CTX * pContext ) { if (pContext->contextType != WDB_CTX_TASK) return (ERROR); return (taskSuspend (pContext->contextId)); }/******************************************************************************** vxTaskDelete - WDB callout to delete a task.*/LOCAL STATUS vxTaskDelete ( WDB_CTX * pContext ) { if (pContext->contextType != WDB_CTX_TASK) return (ERROR); return (taskDelete (pContext->contextId)); }/******************************************************************************** vxTaskRegsSet - WDB callout to get a task register set.*/LOCAL STATUS vxTaskRegsSet ( WDB_CTX * pContext, WDB_REG_SET_TYPE regSetType, char * pRegSet ) { STATUS status; if (pContext->contextType != WDB_CTX_TASK) return (ERROR); switch (regSetType) { case WDB_REG_SET_IU: status = taskRegsSet (pContext->contextId, (REG_SET *)pRegSet); break;#ifdef INCLUDE_HW_FP case WDB_REG_SET_FPU: { WIND_TCB * pTcb = taskTcb (pContext->contextId); if ((pTcb == NULL) || (pTcb->pFpContext == NULL)) return (ERROR); bcopy (pRegSet, (char *)(pTcb->pFpContext), sizeof (FP_CONTEXT)); return (OK); }#endif /* INCLUDE_HW_FP */ default: status = ERROR; } return (status); }/******************************************************************************** vxTaskRegsGet - WDB callout to get a tasks register set.** This routine is not reentrant, but it it only called by one thread (the* WDB agent).*/LOCAL STATUS vxTaskRegsGet ( WDB_CTX * pContext, WDB_REG_SET_TYPE regSetType, char ** ppRegSet ) { WIND_TCB * pTcb; if (pContext->contextType != WDB_CTX_TASK) return (ERROR); pTcb = taskTcb (pContext->contextId); if (pTcb == NULL) return (ERROR); switch (regSetType) { case WDB_REG_SET_IU: { REG_SET dummy; taskRegsGet (pContext->contextId, &dummy); *ppRegSet = (char *) &pTcb->regs; return (OK); }#ifdef INCLUDE_HW_FP case WDB_REG_SET_FPU: if (pTcb->pFpContext == NULL) return (ERROR); /* no coprocessor support */ *ppRegSet = (char *) pTcb->pFpContext; return (OK);#endif /* INCLUDE_HW_FP */ default: return (ERROR); } }/******************************************************************************** vxSemCreate - create a SEMAPHORE*/LOCAL void * vxSemCreate (void) { return ((void *)semBCreate (0, 0)); }/******************************************************************************** vxSemGive - give a semaphore*/LOCAL STATUS vxSemGive ( void * semId ) { return (semGive ((SEM_ID)semId)); }/******************************************************************************** vxSemTake - take a semaphore*/LOCAL STATUS vxSemTake ( void * semId, struct timeval * tv ) { return (semTake ((SEM_ID) semId, (tv == NULL ? WAIT_FOREVER : tv->tv_sec * sysClkRateGet() + (tv->tv_usec * sysClkRateGet()) / MILLION))); }#endif /* INCLUDE_VXWORKS_KERNEL *//******************************************************************************** vxExcHookAdd -*/LOCAL void (*vxExcHook)();LOCAL int vxExcHookWrapper (int vec, char *pESF, WDB_IU_REGS *pRegs) { WDB_CTX context; static int restartCnt; extern int wdbTaskId; if (INT_CONTEXT() || wdbIsNowExternal() || (taskIdCurrent == 0)) context.contextType = WDB_CTX_SYSTEM; else context.contextType = WDB_CTX_TASK; context.contextId = (int)taskIdCurrent; (*vxExcHook)(context, vec, pESF, pRegs); /* * if the exception is in the agent task, restart the agent * after a delay. */ if (((int)taskIdCurrent == wdbTaskId) && (restartCnt < WDB_MAX_RESTARTS)) { restartCnt++; if (_func_logMsg != NULL) _func_logMsg ("WDB exception. restarting agent in %d seconds...\n", WDB_RESTART_TIME, 0,0,0,0,0); taskDelay (sysClkRateGet() * WDB_RESTART_TIME); taskRestart (0); } return (FALSE); }LOCAL void vxExcHookAdd ( void (*hook)() ) { vxExcHook = hook; _func_excBaseHook = vxExcHookWrapper; }/******************************************************************************** __wdbTaskDeleteHook -*/ LOCAL int __wdbTaskDeleteHook ( WIND_TCB *pTcb ) { WDB_CTX ctx; void (*hook)(); hook = pTcb->wdbExitHook; if (hook != NULL) { ctx.contextType = WDB_CTX_TASK; ctx.contextId = (UINT32)pTcb; (*hook) (ctx, pTcb->exitCode, pTcb->errorStatus); } return (OK); }/******************************************************************************** vxTaskDeleteHookAdd - task-specific delete hook (one per task).** currently only one hook per task.*/ LOCAL STATUS vxTaskDeleteHookAdd ( UINT32 tid, void (*hook)() ) { static int initialized = FALSE; if (taskIdVerify ((int)tid) == ERROR) return (ERROR); taskTcb (tid)->wdbExitHook = hook; if (!initialized) { taskDeleteHookAdd (__wdbTaskDeleteHook); initialized = TRUE; } return (OK); }/******************************************************************************** __wdbTaskCreateHook - task create hook** This hook is called each time a task is created.** RETURNS : OK always*/ LOCAL int __wdbTaskCreateHook ( WIND_TCB * pTcb ) { WDB_CTX createdCtx; WDB_CTX creationCtx; if (wdbCreateHook != NULL) { /* fill createdCtx structure */ createdCtx.contextType = WDB_CTX_TASK; createdCtx.contextId = (UINT32)pTcb; /* fill creationCtx structure */ creationCtx.contextType = WDB_CTX_TASK; creationCtx.contextId = (UINT32)taskIdCurrent;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -