/*-=-=-=-=-=-=-=-=-=-=-=- RCCL/RCI Notice of Copyright -=-=-=-=-=-=-=-=-=-=-*
 *									    *
 *	Copyright (C) 1991 by John E. Lloyd.				    *
 *									    *
 *	Information on copyright permissions, as well as a complete	    *
 *	disclaimer of warranty, is given in the file COPYRIGHT.		    *
 *									    *
 *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
#ifdef VXWORKS_CFG

#include "../rci/vxwCtrlTask.h"
#include "../h/errorCodes.h"

static char *timeoutMsg		= "%s -- fxn did not execute; timed out\n";

rciTaskExec (fxn, arg)
int (*fxn)();
int arg;
{
	char *fxnName = "rciTaskExec()";
	int timeoutTick;

	extern EXEC_REQ taskExr;

	taskExr.fxn = fxn;
	taskExr.arg = arg;
	placeExecuteRequest (&taskExr);
	timeoutTick = tickGet() + sysClkRateGet()*5/*seconds*/;
	while (taskExr.request && (tickGet() <= timeoutTick))
	   ;
	if (taskExr.request)
	 { errorMsg (EInternal, timeoutMsg, fxnName);
	   return (-1);
	 }
	return(1);
}

rciKrnlExec (fxn, arg0, arg1, arg2, arg3)
int (*fxn)();
int arg0, arg1, arg2, arg3;
{
	return((*fxn)(arg0, arg1, arg2, arg3));
}

rciKutExec (fxn, arg0, arg1, arg2, arg3)
int (*fxn)();
int arg0, arg1, arg2, arg3;
{
	int s, rval;

	/* XXX need to see if traps will still happen OK */

	s = VXINT_LOCK();
	rval = (*fxn)(arg0, arg1, arg2, arg3);
	VXINT_UNLOCK(s);
	return(rval);
}

#endif
