/*-=-=-=-=-=-=-=-=-=-=-=- 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.		    *
 *									    *
 *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/

#include <signal.h>

#include "../h/rci.h"
#include "../rci/rciCheck.h"

doStartup(td, arg)
RCI_DESC *td;
int arg;
{
	char *fxnName = "doStartup() --";
	COMBLK *cb;

	if ((cb = (COMBLK*)getMemByAddr((char*)arg)) == NULL)
	 { rciAbort (0, "%s can't reference control memory\n");
	   return;
	 }
	cb->startupCnt++;
}

doControl(td, arg)
RCI_DESC *td;
int arg;
{
	char *fxnName = "doControl() --";
	COMBLK *cb;

	if ((cb = (COMBLK*)getMemByAddr((char*)arg)) == NULL)
	 { rciAbort (0, "%s can't reference control memory\n");
	   return;
	 }
	cb->controlCnt++;

	if (cb->cmd == DO_SIGNAL)
	 { cb->cmd = 0;
	   rciSignal (SIGIO);
	 }
	else if (cb->cmd == DO_ABORT)
	 { cb->cmd = 0;
	   rciAbort (1234, "test abort");
	 }	
	else if (cb->cmd == DO_CRASH)
	 { cb->cmd = 0;
#if defined(vax)
	   *(char*)-1 = 0;
#else
#if defined(VXWORKS_CFG)
#define BADADDR 0x80000000
	   *(short*)BADADDR = 0xfeda;
	   rciPrintf ("hey!! address 0x%x is valid?\n", BADADDR);
#else
	   *(char*)0 = 0;
#endif
#endif
	 }
}

doRelease(td, arg, code)
RCI_DESC *td;
int arg;
int code;
{
	char *fxnName = "doRelease() --";
	COMBLK *cb;

	if ((cb = (COMBLK*)getMemByAddr((char*)arg)) == NULL)
	 { rciAbort (0, "%s can't reference control memory\n", fxnName);
	   return;
	 }
	cb->releaseCnt++;
}
