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

📄 usrwdb.c

📁 ppc 8245 可编译bsp 包括 uart
💻 C
📖 第 1 页 / 共 3 页
字号:
	(*wdbCreateHook) (&createdCtx, &creationCtx);	}    return (OK);    }/******************************************************************************** vxTaskCreateHookAdd - install WDB task create hook.** This routine installs or remove the WDB task create hook. ** RETURNS : OK always.*/ LOCAL STATUS vxTaskCreateHookAdd    (    void	(*hook)()    )    {    static int initialized = FALSE;    wdbCreateHook = hook;    if ((hook == NULL) && initialized)	/* remove task creation hook */	{	taskCreateHookDelete (__wdbTaskCreateHook);	initialized = FALSE;	}    else if (!initialized)		/* install task creation hook */	{	taskCreateHookAdd (__wdbTaskCreateHook);	initialized = TRUE;	}    return (OK);    }/******************************************************************************** wdbRtIfInit - Initialize pointers to the VxWorks routines.*/LOCAL void wdbRtIfInit ()    {    int 	ix = 0;    WDB_RT_IF *	pRtIf = &wdbRtIf;    bzero ((char *)pRtIf, sizeof (WDB_RT_IF));    pRtIf->rtInfoGet	= wdbRtInfoGet;    pRtIf->reboot	= vxReboot;    pRtIf->cacheTextUpdate = (void (*)())cacheLib.textUpdateRtn;    pRtIf->memProtect   = vxMemProtect;    pRtIf->memProbe	= (STATUS (*)())vxMemProbe;    pRtIf->excHookAdd	= vxExcHookAdd;#ifdef	INCLUDE_VXWORKS_KERNEL    pRtIf->taskCreate	= vxTaskCreate;    pRtIf->taskResume	= vxTaskResume;    pRtIf->taskSuspend	= vxTaskSuspend;    pRtIf->taskDelete	= vxTaskDelete;    pRtIf->taskLock	= (VOIDFUNCPTR) taskLock;    pRtIf->taskUnlock	= (VOIDFUNCPTR) taskUnlock;    pRtIf->taskRegsSet	= vxTaskRegsSet;    pRtIf->taskRegsGet  = vxTaskRegsGet;    pRtIf->malloc	= malloc;    pRtIf->free		= free;    pRtIf->semCreate	= vxSemCreate;    pRtIf->semGive	= vxSemGive;    pRtIf->semTake	= vxSemTake;    pRtIf->taskDeleteHookAdd	= vxTaskDeleteHookAdd;    pRtIf->taskSwitchHookAdd	= (STATUS (*)())taskSwitchHookAdd;    pRtIf->taskCreateHookAdd	= vxTaskCreateHookAdd;#endif	/* INCLUDE_VXWORKS_KERNEL */    /* first check if boot line is empty (eg : no network) */    if (*sysBootLine != EOS)	{	for (ix = 0; ix < MAX_LEN; ix ++)	    {	    if (*(sysBootLine + ix) == ')')		{		ix++;		break;		}	    }	bcopy (sysBootLine + ix, vxBootFile, MAX_LEN - ix);	for (ix = 0; ix < MAX_LEN - 1; ix ++)	    {	    if (*(vxBootFile + ix) == ' ')		break;	    }	}    *(vxBootFile + ix) = '\0';    wdbInstallRtIf (pRtIf);    }/******************************************************************************** wdbCommIfInit - Initialize the agent's communction interface** RETURNS : OK or error if we can't initialize the communication interface.** NOMANUAL*/LOCAL STATUS wdbCommIfInit ()    {    static uint_t	wdbInBuf	  [WDB_MTU/4];    static uint_t	wdbOutBuf	  [WDB_MTU/4];    static WDB_XPORT	wdbXport;    static WDB_COMM_IF	wdbCommIf;    WDB_COMM_IF * pCommIf = &wdbCommIf;    wdbMbufInit ();#if	(WDB_COMM_TYPE == WDB_COMM_NETWORK)    /* UDP sockets - supports a task agent */    if (wdbUdpSockIfInit (pCommIf) == ERROR)	return (ERROR);#endif	/* (WDB_COMM_TYPE == WDB_COMM_NETWORK) */#if	(WDB_COMM_TYPE == WDB_COMM_TYCODRV_5_2)    {    /* SLIP lite built on a VxWorks serial driver - supports a task agent */    static WDB_TYCO_SIO_CHAN tyCoSioChan;	/* serial I/O device */    static WDB_SLIP_PKT_DEV  wdbSlipPktDev;	/* SLIP packet device */    if (wdbTyCoDevInit	(&tyCoSioChan, WDB_TTY_DEV_NAME, WDB_TTY_BAUD))	return (ERROR);#ifdef	INCLUDE_WDB_TTY_TEST    wdbSioTest ((SIO_CHAN *)&tyCoSioChan, SIO_MODE_INT, 0);#endif	/* INCLUDE_WDB_TTY_TEST */    wdbSlipPktDevInit	(&wdbSlipPktDev, (SIO_CHAN *)&tyCoSioChan, udpRcv);    if (udpCommIfInit (pCommIf, &wdbSlipPktDev.wdbDrvIf))	return (ERROR);    }#endif	/* (WDB_COMM_TYPE == WDB_COMM_TYCODRV_5_2) */#if	(WDB_COMM_TYPE == WDB_COMM_ULIP)    {    /* ULIP packet driver (VxSim only) - supports task or external agent */    static WDB_ULIP_PKT_DEV	wdbUlipPktDev;	/* ULIP packet device */    wdbUlipPktDevInit (&wdbUlipPktDev, WDB_ULIP_DEV, udpRcv);    if (udpCommIfInit (pCommIf, &wdbUlipPktDev.wdbDrvIf))	return (ERROR);    }#endif	/* (WDB_COMM_TYPE == WDB_COMM_ULIP) */#if	(WDB_COMM_TYPE == WDB_COMM_SERIAL)    {    /* SLIP-lite over a raw serial channel - supports task or external agent */    SIO_CHAN *			pSioChan;	/* serial I/O channel */    static WDB_SLIP_PKT_DEV	wdbSlipPktDev;	/* SLIP packet device */    if ((pSioChan = sysSerialChanGet (WDB_TTY_CHANNEL)) == (SIO_CHAN *)ERROR)	return (ERROR);    sioIoctl (pSioChan, SIO_BAUD_SET, (void *)WDB_TTY_BAUD);#ifdef	INCLUDE_WDB_TTY_TEST    /* test in polled mode if the kernel hasn't started */    if (taskIdCurrent == 0)	wdbSioTest (pSioChan, SIO_MODE_POLL, 0);    else	wdbSioTest (pSioChan, SIO_MODE_INT, 0);#endif	/* INCLUDE_WDB_TTY_TEST */    wdbSlipPktDevInit (&wdbSlipPktDev, pSioChan, udpRcv);    if (udpCommIfInit (pCommIf, &wdbSlipPktDev.wdbDrvIf))	return (ERROR);#if (CPU==SIMHPPA)    sysSerialWDBSetup ();#endif /* CPU==SIMHPPA */    }#endif	/* (WDB_COMM_TYPE == WDB_COMM_SERIAL) */#if     (WDB_COMM_TYPE == WDB_COMM_NETROM)    {    /* netrom packet driver - supports task or external agent */    int dpOffset;				/* offset of dualport RAM */    static WDB_NETROM_PKT_DEV	wdbNetromPktDev; /* NETROM packet device */    dpOffset = (WDB_NETROM_ROMSIZE - DUALPORT_SIZE) * WDB_NETROM_WIDTH;    wdbNetromPktDevInit (&wdbNetromPktDev, (caddr_t)ROM_BASE_ADRS + dpOffset,			 WDB_NETROM_WIDTH, WDB_NETROM_INDEX,			 WDB_NETROM_NUM_ACCESS, udpRcv,			 WDB_NETROM_POLL_DELAY);    if (udpCommIfInit (pCommIf, &wdbNetromPktDev.wdbDrvIf))	return (ERROR);    }#endif  /* (WDB_COMM_TYPE == WDB_COMM_NETROM) */#if     (WDB_COMM_TYPE == WDB_COMM_CUSTOM)    {    /* custom packet driver - supports task or external agent */    static WDB_CUSTOM_PKT_DEV	wdbCustomPktDev; /* custom packet device */    wdbCustomPktDevInit (&wdbCustomPktDev, udpRcv);    if (udpCommIfInit (pCommIf, &wdbCustomPktDev.wdbDrvIf) == ERROR)	return (ERROR);    }#endif  /* (WDB_COMM_TYPE == WDB_COMM_CUSTOM) */#if	(WDB_COMM_TYPE == WDB_COMM_END)    {#ifndef WDB_COMM_END_ENTRY#define WDB_COMM_END_ENTRY 0#endif /* WDB_COMM_END_ENTRY */    /* END agent - supports a network MUX/END agent */    static WDB_END_PKT_DEV wdbEndPktDev; /* END packet device */    END_TBL_ENTRY* pDevTbl = endDevTbl;    END_OBJ* pEnd = NULL;    char devName[END_NAME_MAX];        netLibInit();    muxMaxBinds = MUX_MAX_BINDS;    if (muxLibInit() == ERROR)	return (ERROR);    /* Add in mux functionality. */    if (!pDevTbl->processed)        {	void *pCookie=0;        pCookie = muxDevLoad(pDevTbl->unit,                             pDevTbl->endLoadFunc,                             pDevTbl->endLoadString,                             pDevTbl->endLoan, pDevTbl->pBSP);        if (pCookie == NULL)            {            if (_func_logMsg != NULL)                _func_logMsg ("muxLoad failed!\n", 0, 0, 0, 0, 0, 0);            return (ERROR);            }        else            {            pDevTbl->processed = TRUE;            if (muxDevStart(pCookie) != OK)                {                if (_func_logMsg != NULL)                    _func_logMsg ("muxDevStart failed!\n", 0, 0, 0, 0, 0, 0);                return (ERROR);                }            }        }    /* get the name for the END */    bzero ((char *)&devName, END_NAME_MAX);    if (pDevTbl->endLoadFunc((char *)&devName, NULL) != 0)	{	if (_func_logMsg != NULL)	    _func_logMsg ("could not get device name!\n", 0, 0, 0, 0, 0, 0);            return (ERROR);	}    pEnd = endFindByName (devName, pDevTbl->unit);            if (pEnd == NULL)	{	if (_func_logMsg != NULL)	    _func_logMsg ("Could not find device %s unit 0!\n",			  devName, 0, 0, 0, 0, 0);            return (ERROR);	}        wdbEndPktDevInit(&wdbEndPktDev, udpRcv,                     (char *)pEnd->devObject.name,                     pEnd->devObject.unit);    if (udpCommIfInit(pCommIf, &wdbEndPktDev.wdbDrvIf) == ERROR)	return (ERROR);    }#endif	/* (WDB_COMM_TYPE == WDB_COMM_END) */#if     (WDB_COMM_TYPE == WDB_COMM_PIPE)    {    static WDB_PIPE_PKT_DEV wdbPipePktDev; /* Pipe packet device */    if (wdbPipePktDevInit(&wdbPipePktDev, udpRcv) == ERROR)	return (ERROR);    if (udpCommIfInit(pCommIf, &wdbPipePktDev.wdbDrvIf) == ERROR)	return (ERROR);    }#endif  /* (WDB_COMM_TYPE == WDB_COMM_PIPE) */    /*     * Install the agents communication interface and RPC transport handle.     * Currently only one agent will be active at a time, so both     * agents can share the same communication interface and XPORT handle.     */    wdbRpcXportInit  (&wdbXport, pCommIf, (char *)wdbInBuf,		      (char *)wdbOutBuf, WDB_MTU);    wdbInstallCommIf (pCommIf, &wdbXport);#if (CPU==SIMHPPA) && defined(INCLUDE_SLIP) && \			(WDB_COMM_TYPE == WDB_COMM_NETWORK)    {    UNIX_CHAN *pChan = (UNIX_CHAN *) sysSerialChanGet (SLIP_TTY);    /*     * Begin polling for connection request from tgtsvr.  This is necessary     * because an earlier connection may have left the pipe in a state in     * which SIGIO will not be generated until pipe is read.     */    wdSlipConnect = wdCreate ();    usrWdbPollForConnect (FD_TO_IVEC (pChan->u_fd));    }#endif	/* (CPU==SIMHPPA) && defined(INCLUDE_SLIP) ... */    return (OK);    }/******************************************************************************** wdbMbufInit - initialize the agent's mbuf memory allocator.** wdbMbufLib manages I/O buffers for the agent since the agent* can't use malloc().** If the agent is ever hooked up to a network driver that uses standard* MGET/MFREE for mbuf managment, then the routines wdbMBufAlloc()* and wdbMBufFree() below should be changed accordingly.*/ LOCAL void wdbMbufInit (void)    {    static struct mbuf mbufs[NUM_MBUFS];    static CL_BLK      wdbClBlks [WDB_NUM_CL_BLKS];    bufPoolInit (&wdbMbufPool, (char *)mbufs, NUM_MBUFS, sizeof (struct mbuf));    bufPoolInit (&wdbClBlkPool, (char *)wdbClBlks, WDB_NUM_CL_BLKS,                 sizeof (CL_BLK));    }/******************************************************************************** wdbMbufAlloc - allocate an mbuf** RETURNS: a pointer to an mbuf, or NULL on error.*/ struct mbuf *	wdbMbufAlloc (void)    {    struct mbuf * pMbuf;    CL_BLK_ID	  pClBlk;    pMbuf = (struct mbuf *)bufAlloc (&wdbMbufPool);    if (pMbuf == NULL)        return (NULL);     pClBlk = (CL_BLK_ID) bufAlloc (&wdbClBlkPool);        if (pClBlk == NULL)        {        wdbMbufFree (pMbuf);	return (NULL);        }    pMbuf->m_next	= NULL;    pMbuf->m_nextpkt	= NULL;    pMbuf->m_flags	= 0;    pMbuf->pClBlk 	= pClBlk;    return (pMbuf);    }/******************************************************************************** wdbMbufFree - free an mbuf*/ void wdbMbufFree    (    struct mbuf *	pMbuf		/* mbuf chain to free */    )    {    /* if it is a cluster, see if we need to perform a callback */    if (pMbuf->m_flags & M_EXT)	{	if (--(pMbuf->m_extRefCnt) <= 0)            {            if (pMbuf->m_extFreeRtn != NULL)                {                (*pMbuf->m_extFreeRtn) (pMbuf->m_extArg1, pMbuf->m_extArg2,                                         pMbuf->m_extArg3);                }            /* free the cluster blk */            bufFree (&wdbClBlkPool, (char *) pMbuf->pClBlk);            }	}    bufFree (&wdbMbufPool, (char *)pMbuf);    }#if (CPU==SIMHPPA) && defined(INCLUDE_SLIP) && \				(WDB_COMM_TYPE == WDB_COMM_NETWORK)/********************************************************************************  usrWdbPollForConnect - poll SLIP input pipe** INTERNAL* This routine is not normally part of a BSP.** RETURNS: N/A** NOMANUAL*/LOCAL void usrWdbPollForConnect    (    int slipIntr                                /* SLIP interrupt number */    )    {    intCatch (slipIntr);                        /* fake I/O interrupt */    if (wdbTargetIsConnected ())	{	wdDelete (wdSlipConnect);               /* stop polling */	s_asyncio (0);	s_asyncio (1);	}    else	wdStart (wdSlipConnect, sysClkRateGet() * 3,			(FUNCPTR) usrWdbPollForConnect, slipIntr);    }#endif /* (CPU==SIMHPPA) && defined(INCLUDE_SLIP) */

⌨️ 快捷键说明

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