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

📄 rpccore.c

📁 vxworks源码源码解读是学习vxworks的最佳途径
💻 C
📖 第 1 页 / 共 5 页
字号:
    WDB_TGT_INFO *	pWdbTgtInfo    )    {    UINT32	status;    /*     * log a message that describe the current action in order to     * inform the user.     */    wpwrLogMsg ("Connecting to target agent... ");    /* clear the memory used by the WDB_TGT_INFO structure */    memset ((void *) pWdbTgtInfo, 0, sizeof (WDB_TGT_INFO));    /*      * call the WDB_TARGET_CONNECT service via the backend client in order     * to connect the WDB target agent.     */    status = rpcCoreClntCall (WDB_TARGET_CONNECT, xdr_void, NULL,			xdr_WDB_TGT_INFO, (char *) pWdbTgtInfo);    /* check if the RPC request succeeded */    if (status != OK)	{	/*	 * the RPC request failed: finish the log message, set the	 * error code in the TGT_INFO structure and set the global variable	 * errno.	 */	wpwrLogRaw ("failed.\n");	}    else	{	/* 	 * the RPC request succeeded: set the local variable rpcCoreMtu	 * with the maximun tranfert unit value returned by the WDB target	 * agent and finish the log message.	 */	pWdbTgtInfo->agentInfo.mtu -= 0x80;	/* save space for RPC header */	rpcCoreMtu = pWdbTgtInfo->agentInfo.mtu;    	wpwrLogRaw ("succeeded.\n");	}    /* return a pointer to the TGT_INFO structure */    return (status);    }/********************************************************************************* rpcCoreMemChecksum - Calculate the checksum of a memory block on the target** This function calculates the checksum of a memory block on the target board.* The memory block description is handled by the MEM_BLOCK structure pointed to* by <pMemBlock>.* The WDB_MEM_CHECKSUM service is called via the backend client. The WDB target* agent replies by a RESULT_STATUS structure. The val field of this structure* handles the checksun value. If the checksun or the RPC request fails the* errCode field will handle the error number.** RETURNS: Always a pointer to a RESULT_STATUS structure.*/LOCAL UINT32 rpcCoreMemChecksum    (    WDB_MEM_REGION *	pWdbMemRegion,		/* memory block to checksum */    UINT32 *		pChecksumValue		/* checksum value */    )    {    /*     * check the easy case: 0 byte to checksum. In this case the function is     * exited immedialtly with the checksun value equal to zero.     */    if (pWdbMemRegion->numBytes == 0)	{	* pChecksumValue = 0;	return (OK);	}    /* clear the memory used to save the checksum value */    *pChecksumValue = 0;    /*     * call the WDB_MEM_CHECKSUM service via the backend client in order     * to compute the checksum of the memory block pointed to by pMemBlock.     */    return (rpcCoreClntCall (WDB_MEM_CHECKSUM,			(xdrproc_t) xdr_WDB_MEM_REGION, (char *) pWdbMemRegion,			(xdrproc_t) xdr_UINT32, (char *) pChecksumValue));    }/********************************************************************************* rpcCoreMemRead - read block of memory from the target* * This function reads a block of memory on the target board. The memory * location is described by the MEM_READ structure pointed to by <pMemRead>.* The WDB_MEM_READ service is called via the backend client. The WDB target* agent replies by returning a MEM_COPY structure.** The copy from the target to the dedicated host memory is performed by the* xdr_MEM_COPY function. This xdr function is called by the backend client when* the MEM_COPY structure is decoded . In addition this xdr function decodes and* saves directly the data in the host memory pointed to by the destination* field of the MEM_COPY structure.  ** When the number of bytes is bigger than the UDP trame, many WDB_MEM_READ* service calls are made to perform the complete memory reading.** If the memory copy or the RPC request fails the errCode field of the returned* structure will handle the error number. ** RETURNS: Always a WDB error code.*/LOCAL UINT32 rpcCoreMemRead    (    WDB_MEM_REGION *	pWdbMemRegion,		/* memory to read description */    WDB_MEM_XFER *	pWdbMemXfer		/* area to save the data read */    )    {    UINT32		status = OK;		/* client call result status */    WDB_MEM_REGION	wdbMemRegion;		/* memory block to read desc.*/    u_int		numBytesRead = 0;	/* number of bytes read */    wdbMemRegion = *pWdbMemRegion;		/* initial region to copy */    while (wdbMemRegion.numBytes > 0)		/* region contain anything? */	{	/*	 * if the number of byte requested to read is bigger that the	 * Maximun Transmit Unit (MTU) allowed by the UDP trame then	 * read only MTU bytes. The others bytes will be read by next	 * requests.  We slim down the region to copy to fit in an	 * MTU.	 */ 	wdbMemRegion.numBytes = min (wdbMemRegion.numBytes, (int)rpcCoreMtu);	/* clear the memory that will be used to save the ouput arguments */	memset ((void *) pWdbMemXfer, 0, sizeof (WDB_MEM_XFER));	/* 	 * call the WDB_MEM_READ service via the backend client in order	 * to read the memory block handled by memReadDesc.	 */	status = rpcCoreClntCall (WDB_MEM_READ, xdr_WDB_MEM_REGION,				       (char *) &wdbMemRegion, xdr_WDB_MEM_XFER,				       (char *) pWdbMemXfer);	/*	 * check the client call status: If the request fails then sets	 * return the error status.	 */	if (status != OK)	    return (status);	/* copy this block out to the caller's destination */	memcpy ((char *) wdbMemRegion.param, (char *) pWdbMemXfer->source,                pWdbMemXfer->numBytes);	/* 	 * Record the number of bytes read.  Prepare the next region to be	 * read by updating the size, source, and destination fields of	 * memRegion.	 */	numBytesRead		+= pWdbMemXfer->numBytes;	wdbMemRegion.numBytes  	 = pWdbMemRegion->numBytes - numBytesRead;	wdbMemRegion.baseAddr	+= pWdbMemXfer->numBytes;	wdbMemRegion.param	+= pWdbMemXfer->numBytes;	/*	 * free the memory used by the backend client to save the structure	 * returned by the WDB target agent.	 */	rpcCoreFreeResultArgs ();	}    /*     * update the structure fields to return with the input value and the     * number of bytes read.     */    pWdbMemXfer->destination = pWdbMemRegion->param;    pWdbMemXfer->numBytes    = numBytesRead;    pWdbMemXfer->source      = (WDB_OPQ_DATA_T) pWdbMemRegion->baseAddr;        return (status);    }    /********************************************************************************* rpcCoreMemWrite - write a memory block to the target.** This function writes a block of memory on the target board. The memory * location is described by the MEM_COPY structure pointed to by <pMemCopy>.* The WDB_MEM_WRITE service is called via the backend client. The WDB target* agent replies by returning a STATUS.** The copy from the host to the dedicated target memory is performed by the* xdr_MEM_COPY function. This xdr function is called by the WDB target agent* to decocde the MEM_COPY structure and data read in the host memory. This data* are saved directly in the target memory pointed to by the MEM_COPY * destination field.** When the number of bytes is bigger than the UDP trame, the WDB_MEM_WRITE* service are called many times to perform the complete memory writing.** If the memory copy or the RPC request fails the errCode field of the returned* structure will handle the error number. ** RETURNS: ERROR if the target memory can't be written or the RPC request*	   fails. In this case the errno global variable handles the error*	   number. Otherwise the OK is returned*/LOCAL UINT32 rpcCoreMemWrite    (    WDB_MEM_XFER * 	pWdbMemXfer	/* memory to write description */    )    {    STATUS		status;			/* client call result status */    WDB_MEM_XFER	memXfer;		/* memory write description */    int			numBytesToWrite;	/* number of bytes to write */    /*     * check the easy case : no byte to write. In this case don't call the      * WDB target agent and leave this backend function by returning OK.     */    if (pWdbMemXfer->numBytes == 0)	return (OK);    /*     * save the input structure to avoid to corrupt input values in case     * memory writing is performed by many transferts.     */    memXfer = * pWdbMemXfer;    /* initialize the number of bytes to write counter */    numBytesToWrite = memXfer.numBytes;    do	{	/*	 * if the number of byte requested to write is bigger that the	 * Maximun Transmit Unit (MTU) allowed by the UDP trame then	 * write only MTU bytes. The others bytes will be written by next	 * requests.	 */         memXfer.numBytes = min (numBytesToWrite, (int)rpcCoreMtu);	/* 	 * call the WDB_MEM_WRITE service via the backend client in order	 * to write the memory block handled by memXfer.	 */	status = rpcCoreClntCall (WDB_MEM_WRITE, xdr_WDB_MEM_XFER, 				     (char *) &memXfer, xdr_void, NULL);	/*	 * check the status returned by the backend client. If the	 * memory writing or the RPC request fails, status will handle ERROR.	 * In this case the do-wile loop is exited.	 */	if (status != OK)	    break;	/*	 * update the remaining number of bytes to write and exit the do-wile	 * loop if no more memory need to be written.	 */	if ((numBytesToWrite -= memXfer.numBytes) <= 0)	    break;	/* 	 * update the source and destination fields in order to	 * perform the next memory reading.	 */	memXfer.source      += memXfer.numBytes;	memXfer.destination += memXfer.numBytes;	}    while (TRUE);    /*     * return the status returned by the backend client. In error case     * the errno global variable will handle the error number.     */    return (status);    }/********************************************************************************* rpcCoreMemFill - fill a memory block with zero.** This function fills a target memory block with a integer value. The memory* region to fill is described by the MEM_REGION structure pointed to by* <pWdbMemRegion>. The WDB_MEM_FILL service is called via the backend client.* The WDB target agent replies by returning a status. This status is ERROR* when the memory region can't be filled or the RPC request fails. Otherwise* OK is returned.** RETURNS: ERROR if the memory region can't be filled or the RPC request fails* 	   In this case the errno global variable handles the error number.* 	   Otherwise OK is returned.*/LOCAL UINT32 rpcCoreMemFill    (    WDB_MEM_REGION *	pWdbMemRegion		/* memory region to fill */    )    {    /*     * check the easy case: no memory to fill. In this case exit the backend     * fonction and return OK.     */    if (pWdbMemRegion->numBytes == 0)	return (OK);    /*      * call the WDB_MEM_FILL service via the backend client in order     * to fill the memory region pointed to by pWdbMemRegion.     */    return (rpcCoreClntCall (WDB_MEM_FILL, xdr_WDB_MEM_REGION,			(char *) pWdbMemRegion, xdr_void, NULL));    }/********************************************************************************* rpcCoreMemProtect - turn protection on or off for a memory region** This function set the protection mode of  a target memory region described * by the MEM_REGION structure pointed to by * <pWdbMemRegion>. ** RETURNS: ERROR if the memory region can't be filled or the RPC request fails* 	   In this case the errno global variable handles the error number.* 	   Otherwise OK is returned.

⌨️ 快捷键说明

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