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

📄 xtask_rpc.c

📁 Sigma SMP8634 Mrua v. 2.8.2.0
💻 C
📖 第 1 页 / 共 3 页
字号:
					RMDBGPRINT((LOCALDBG,"\n"));				}				RMDBGPRINT(( LOCALDBG, "%02X",  gbus_read_uint8(pgbus, (RMuint32)( ((RMuint32)pB) + sizeof(struct xrpc_block_header)+i)) ));				}			RMDBGPRINT((LOCALDBG,"\n\n\nActual xload binary: \n"));					/* Write out the actual values */			for(i=0; i< xloadSize; i++) {				if(i%32 == 0 && i != 0) {					RMDBGPRINT((LOCALDBG,"\n"));				}				RMDBGPRINT((LOCALDBG, "%02X", ((RMuint8*)pXload)[i]));			}			RMDBGPRINT((ENABLE,"\n\n\n"));		}#endif		RMDBGLOG((ENABLE,"\nxrpc failed --- if a xtask is using a cipher or if you reboot\n"		                     "            --- xrpc will fail with RM_BUSY\n"));		return RM_ERROR;	}		/* Copy back the image number the xtask was loaded to */	context->image = gbus_read_uint32(pgbus,(RMuint32)&pB->param0);		return RM_OK;	}/****************************************************************      Method Name                                             **         xtask_rpc_unloadxtask                                **                                                              **      Description:                                            **         UnLoad the given xtask using the XUNLOAD binary      **         retruns RM_OK for success, RM_ERROR for failure.     **                                                              ****************************************************************/RMstatus xtask_rpc_unloadxtask( struct XtaskAPI* context, RMuint8* pXUnload, RMuint32 xunloadSize, RMuint32 xunloadBinSize){	struct xrpc_block_header *pB = context->pB;	struct gbus *pgbus = context->pgbus;	RMuint32 base_addr = context->base_addr;	RMuint32 image = context->image;	RMstatus err;	/* Make sure that the binary will fit within the buffer */	if( context->size < sizeof(struct xrpc_block_header) + xunloadSize ) {		RMDBGLOG((ENABLE,"xtask_rpc_unloadxtask: ERROR ! xrpc memory area not large enough to unload xtask!\n"));		return RM_ERROR;	}		/** Sanity Checks **/		/* Make sure that the chip is valid type is valid */	if ((gbus_read_uint16(pgbus, REG_BASE_host_interface + PCI_REG0) & ~0xf) != 0x8630) {		RMDBGLOG((ENABLE, "for tango2 only.\n"));		return RM_ERROR;	}		/* Make sure that local RAM is available */	if (gbus_read_uint32(pgbus, REG_BASE_cpu_block + G2L_RESET_CONTROL) == 3) {		RMDBGLOG((ENABLE, "cpu in reset 3, I can't access local ram\n"));		return RM_ERROR;	}		/** Write out the Block Header and Data **/		/* Set the XRPC header */	gbus_write_uint32(pgbus,(RMuint32)&pB->callerid,XRPC_CALLERID_IGNORED);	/* Write XRPC action type */	gbus_write_uint32(pgbus,(RMuint32)&pB->xrpcid,XRPC_ID_XUNLOAD);	/* Write Data, image and size*/	gbus_write_data8(pgbus, (RMuint32)(pB+1),pXUnload, xunloadSize);	gbus_write_uint32(pgbus,(RMuint32)&pB->param1,image);	gbus_write_uint32(pgbus,(RMuint32)&pB->param0,xunloadBinSize);	/* Clear all unused registers */	gbus_write_uint32(pgbus,(RMuint32)&pB->param2, 0);	gbus_write_uint32(pgbus,(RMuint32)&pB->param3, 0);	gbus_write_uint32(pgbus,(RMuint32)&pB->param4, 0);	/* Write out total size of xrpc */	gbus_write_uint32(pgbus,(RMuint32)&pB->headerandblocksize,sizeof(struct xrpc_block_header)+xunloadSize);		RMDBGLOG((LOCALDBG,"base_addr = 0x%08lx, pB = 0x%08lx, xunload: size=%d, image=%d, binSize=%d\n",base_addr, pB, xunloadSize, image, xunloadBinSize ));#ifdef VERBOSE_DEBUG	//DEBUG: Print out header and XLOAD binary:	{		RMuint32 i;		/* write the block header out */		RMDBGLOG((LOCALDBG," block header: "));		for(i=0; i< 8;i++ ) {			RMDBGPRINT(( LOCALDBG, "0x%08lx, ", gbus_read_uint32( pgbus, ((RMuint32)(pB))+(RMuint32)(4*i) ) ));		}				/* Write the rest */		RMDBGPRINT((ENABLE,"\n\ngbus read of the XLOAD binary: \n"));		for(i=0; i<xunloadSize; i++) {			if( i%32 == 0 && i != 0) {				RMDBGPRINT((LOCALDBG,"\n"));			}			RMDBGPRINT(( LOCALDBG, "%02X",  gbus_read_uint8(pgbus, (RMuint32)( ((RMuint32)pB) + sizeof(struct xrpc_block_header)+i)) ));		}		RMDBGPRINT((LOCALDBG,"\n\n\nActual xload binary: \n"));				/* Write out the actual values */		for(i=0; i< xunloadSize; i++) {			if(i%32 == 0 && i != 0) {				RMDBGPRINT((ENABLE,"\n"));			}			RMDBGPRINT((LOCALDBG, "%02X", ((RMuint8*)pXUnload)[i]));		}		RMDBGPRINT((ENABLE,"\n\n\n"));	}#endif		/** Perform XRPC **/	if ( (err=doxrpc(pgbus,base_addr)) == RM_OK ) {		RMDBGLOG((LOCALDBG,"Xunload succeeded\n"));	}	else {		RMDBGLOG((ENABLE,"\nXUNLOAD failed! (%d)", err));#ifdef VERBOSE_DEBUG // PRINT THE block header and XLOAD binary upon failure! 		{			RMuint32 i;					/* write the block header out */			RMDBGLOG((ENABLE," block header: "));			for(i=0; i< 8;i++ ) {				RMDBGPRINT(( ENABLE, "0x%08lx, ", gbus_read_uint32( pgbus, ((RMuint32)(pB))+(RMuint32)(4*i) ) ));			}						/* Write the rest */			RMDBGPRINT((ENABLE,"\n\nthe rest: \n"));			for(i=0; i<xunloadSize; i++) {				if( i%32 == 0 && i != 0) {					RMDBGPRINT((ENABLE,"\n"));				}				RMDBGPRINT(( ENABLE, "%02X",  gbus_read_uint8(pgbus, (RMuint32)( ((RMuint32)pB) + sizeof(struct xrpc_block_header)+i)) ));			}			RMDBGPRINT((ENABLE,"\n\n\nActual Values: "));					/* Write out the actual values */			for(i=0; i< xunloadSize; i++) {				if(i%32 == 0 && i != 0) {					RMDBGPRINT((ENABLE,"\n"));				}				RMDBGPRINT((ENABLE, "%02X", ((RMuint8*)pXUnload)[i]));			}			RMDBGPRINT((ENABLE,"\n\n\n"));		}#endif			return RM_ERROR;			}	return RM_OK;}	/****************************************************************      Method Name                                             **         xtask_rpc_stop                                       **                                                              **      Description:                                            **         Tell the xtask to stop.  This is different than a    **         xrpc -xstop ( ).                                     **                                                              ****************************************************************/RMstatus xtask_rpc_stop( struct XtaskAPI* context ) {	struct gbus *pgbus             =  context->pgbus;	int    xPid                    =  context->xPid;	struct xrpc_block_header *pB   =  context->pB;	RMuint32 base_addr             =  context->base_addr;		RMDBGLOG((LOCALDBG,"Stopping Xtask.\n"));		if (gbus_read_uint32(pgbus, REG_BASE_cpu_block + G2L_RESET_CONTROL) == 3) {		RMDBGLOG((ENABLE, "cpu in reset 3, I can't access local ram\n"));		return RM_ERROR;	}	/* Write out total size of xrpc */	gbus_write_uint32(pgbus, (RMuint32) &pB->callerid, XRPC_CALLERID_IGNORED);	gbus_write_uint32(pgbus, (RMuint32) &pB->headerandblocksize, (sizeof(struct xrpc_block_header) + 63) & ~63);		/* Stop the xtask by the XKILL signal with '-1' as signal */	gbus_write_uint32(pgbus,(RMuint32)&pB->xrpcid,XRPC_ID_XKILL);	gbus_write_uint32(pgbus,(RMuint32)&pB->param0,xPid);	gbus_write_uint32(pgbus,(RMuint32)&pB->param1,XTASK_EVENT_KILL);	gbus_write_uint32(pgbus,(RMuint32)&pB->param2,0);	gbus_write_uint32(pgbus,(RMuint32)&pB->param3,0);	gbus_write_uint32(pgbus,(RMuint32)&pB->param4,0);#ifdef USE_WAIT_FOR_VSYNC	wait_for_vsync(pgbus);#endif	if (doxrpc(pgbus,base_addr) != RM_OK) {			RMDBGLOG((ENABLE,"xrpc failed\n"));		return RM_ERROR;	}	RMDBGLOG((LOCALDBG,"Xtask stopped.\n"));		return RM_OK;}/****************************************************************      Method Name                                             **         xtask_rpc_get_status                                 **                                                              **      Description:                                            **         Retreive the procedure call status.                  **                                                              ****************************************************************/RMstatus xtask_rpc_get_status( struct XtaskAPI* context ){	struct gbus *pgbus = context->pgbus;	RMstatus err;		/* Get status |  */	err = (RMstatus)gbus_read_uint32( pgbus, (RMuint32)&context->fifo->status );	if( err != RM_OK ) {		RMDBGLOG((LOCALDBG,"Error: Status returned %d\n",err));	}		return err;}/****************************************************************      Method Name                                             **         xtask_ioctl                                          **                                                              **      Description:                                            **         Push args, make the call, then return status as well **         as the return arguments.                             **                                                              ****************************************************************/RMstatus xtask_ioctl( struct XtaskAPI* context, RMuint8 procFd, struct XtaskArgs* args){	RMstatus err;	RMuint32 base_addr     =  context->base_addr;	int      xPid          =  context->xPid;	struct   gbus              *pgbus  =  context->pgbus;	struct   xrpc_block_header *pB     =  context->pB;	/* Make sure that procLoc == 0, and !xtaskBusy */		//RMDBGLOG((LOCALDBG,"Pushing ARGS! args.data = 0x%lx, args.size = %ld\n",args->data, args->size));	/* Write args onto the FIFO */	if( (err = xtask_push_args(pgbus, context->fifo, args) ) != RM_OK ) {		return err;	}		/* For new event driven mode we still must set ProcFd, this is required so that we know	 * when the xtask has returned (by setting ProcFd = 0)*/	gbus_write_uint32( pgbus,(RMuint32)&(context->fifo->procedureFd), procFd );		/* Call procedure */	RMDBGLOG((LOCALDBG,"Invoking procedure %d\n",procFd));	if( context->events_enabled ) {		/* Send an event to the xos to wake up the xtask. */				gbus_write_uint32( pgbus, (RMuint32)&pB->xrpcid, XRPC_ID_XKILL);		gbus_write_uint32( pgbus, (RMuint32)&pB->param0, xPid);		gbus_write_uint32( pgbus, (RMuint32)&pB->param1, procFd);		if (doxrpc(pgbus,base_addr) != RM_OK) {						RMDBGLOG((ENABLE,"xrpc failed\n"));			return RM_ERROR;		}	}		RMDBGLOG((LOCALDBG,"complete.\n"));		return err;}/****************************************************************      Method Name                                             **         xtask_rpc_call                                       **                                                              **      Description:                                            **         Make the call specified by proc_index                **                                                              ****************************************************************/RMstatus xtask_rpc_call( struct XtaskAPI* context, RMuint8 procIndex, struct XtaskArgs* args ){	struct gbus *pgbus = context->pgbus;	RMstatus err; 	RMDBGLOG((LOCALDBG,"Xtask RPC Call \'%ld\'\n",procIndex));		/* Get Semaphore */	xtask_semaphore_lock( context );		/* Call procedure */	if( xtask_ioctl(context,procIndex,args) != RM_OK ) {		err = RM_ERROR;		goto safe_exit;	}	#ifdef USE_RPC_TIMEOUT	if( args->timeout_us ) {		err = xtask_rpc_wait_for_completion_wtimeout(context,args->timeout_us);		if( RMFAILED(err) )			goto safe_exit;	}	else {		/* Timeout val of (0) waits forever! */		xtask_rpc_wait_for_completion(context);	}#else	/* Wait for procedure to finish */

⌨️ 快捷键说明

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