#

include(`dict.h')
include(`KERcalls.h')

/*
 *       SCCS File Type - Emulator Source File
 *
 *       What identification string
 */
static char *_S_K03	"@(#)EM_K03.c	3.1";
	/****************************************************************/
	/*
	 *      K_device_function
	 */


/*
 *      K_device_function (
 *          1   od,       : openDescriptor: int    (* of the device    *)
 *          2   funct,    : ioFunction    : char   (* function         *)
 *          3   fblkno,   : fBlockNumber  : long   (* file block no.   *)
 *          4  &inP,      : p_block       : struct (* argument block   *)
 *          5  &outP,     : p_block       : struct (* status block     *)
 *          6   id,       : asyncId       : int    (* asynchronous ID  *)
 *          7  &stat,     : ioStatus      : long   (* status (synch)   *)
 *          8  &byteCount : cardinal      : int    (* # bytes read     *)
 *              )
 */

K_device_function(Pod,Pfunct,Pfblkno, PinPP, PoutPP, Pid, PstatP, PbyteCountP)
	openDescriptor  Pod;
	ioFunction      Pfunct;
	fBlockNumber    Pfblkno;
	p_block         *PinPP;
	p_block         *PoutPP;
	asyncId         Pid;
	ioStatus        *PstatP;
	cardinal        *PbyteCountP;

{
	K_err_num       ex;
	struct  {       /* Kdevfun_param        */
			openDescriptor  od;             /* const */
			ioFunction      funct;          /* const */
			fBlockNumber    fblkno;         /* const */
			p_block         inP;            /* const */
			p_block         outP;           /* const */
			asyncId         id;             /* const */
			/* vars */
			ioStatus        vstat;
			cardinal        vcount;
		}pb;

	pb.od = Pod;
	pb.funct = Pfunct;
	pb.fblkno = Pfblkno;
	st_copy(PinPP, &pb.inP, sizeof(p_block) );
	st_copy(PoutPP, &pb.outP, sizeof(p_block) );
	pb.id = Pid;

	ex = EMT03(&pb);

	*PstatP         = pb.vstat;
	*PbyteCountP    = pb.vcount;

	return( ex );
}

