#

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

/*
 *       SCCS File Type - Emulator Source File
 *
 *       What identification string
 */
static char *_S_K02	"@(#)EM_K02.c	3.1";
	/****************************************************************/
	/*
	 *      K_create
	 */


/*
 *      K_create (
 *          1   protoSeid,: seid           : long   (* prototype    *)
 *          2   om,       : open_mode      : char   (* om on create *)
 *          3   da,       : discr_access   : int    (* da allowed   *)
 *          4   stCap,    : openDescriptor : int    (* subtype      *)
 *          5  &fSeid,    : seid           : long   (* result SEID  *)
 *          6  &od        : openDescriptor : int    (* result od    *)
 *              )
 */

K_create( PprotoSeid, Pom, Pda, PstCap, PfSeidP, PodP)
	seid                  PprotoSeid;
	open_mode             Pom;
	discr_access          Pda;
	openDescriptor        PstCap;
	seid                  *PfSeidP;
	openDescriptor        *PodP;
{
	K_err_num       ex;

	struct  {       /* Kcreate_param  */
			seid            proto;          /* const */
			KopenModes      om;             /* const */
			discr_access    da;             /* const */
			openDescriptor  stCap;          /* const */
			/* vars */
			seid            vf_seid;
			openDescriptor  vod;
		}pb;

	pb.proto = PprotoSeid;

	/*  Emulator open_modes == char. Kernel LopenModes == 4 booleans == */
	/* long. Must map between them. In Kernel Non 0 == True.            */

	pb.om.KomRead    = Pom & om_read;
	pb.om.KomWrite   = Pom & om_write;
	pb.om.KomEread   = Pom & om_exclusive_read;
	pb.om.KomEwrite  = Pom & om_exclusive_write;

	pb.da    = Pda;
	pb.stCap = PstCap;

	ex = EMT02(&pb);

	*PfSeidP   = pb.vf_seid;
	*PodP      = pb.vod;

	return(ex);
}
