# ifndef NO_WHAT
/*
 *      SCCS file type - Emulator Include File
 *
 *      What identification string:
 */
static char *_S_hEPP = "@(#)EPP.h	3.1";
# endif

/****************************************************************
 *      EPP.h contains  the defines and declarations            *
 *      for variables and constants in the Pipe and Port        *
 *      system that are not on the family of I/O segments.      *
 ****************************************************************/


/*
 *      CONSTANTS
 *              These now live in param.h.
 */


/*
 *      TYPES
 *              Word_mask types are represented as unions of an
 *              unsigned and a struct with the desired bit fields.
 *              The unsigned part allows them to be passed as arguments
 *              and returned as results.
 *              We use a similar technique for two word types.
 *              These are unioned with longs.
 */


/*
 *      PP_open_list_index = 0 .. NProcPerPP-1
 */
#define PP_open_list_index char


/*
 *      openPipeIndex      = 0 .. NFopenPipes-1
 */
#define openPipeIndex char


/*
 *      PP_ptr_index       = 0 .. PP_DATA_SIZE-1
 */
#define PP_ptr_index int


/*
 *      PP_conditions_d    = word_mask { ... }
 *              The event_kind and WU_kind fields are subdivided by
 *              EMU_read, EMU_write, and EMU_empty (which are defined
 *              in EFI.h).
 */
typedef union
{       unsigned        unsign;
	struct
	{       unsigned        event_kind  :  3,       /* Event notices    */
				bit12_3     : 10,       /* filler           */
				WU_kind     :  3;       /* Wake-up requests */
	} wd_mask1;
} PP_conditions_d;


/*
 *      PP_flags_d         = word_mask { ... }
 *              H_GID, H_UID, and H_PID are bit masks for subdividing
 *              the Header field.  They are also used in the Header
 *              field of Port_mode.
 */
typedef union
{       unsigned        unsign;
	struct
	{       unsigned        Allocated :  1,
				bit11_1   : 11, /* filler */
				Header    :  3, /* Same as in Port_mode */
				Eofp_flag :  1;
	} wd_mask2;
} PP_flags_d;
#define H_GID  01
#define H_UID  02
#define H_PID  04


/*
 *      PP_open_list_entry = struct { ... }
 */
typedef struct
{       SEID            P_SEID;
	PP_conditions_d PP_conditions;
} PP_open_list_entry;


/*
 *      User_pathname      = struct { ... }
 *              (This is not necessarily final.)
 */
typedef struct
{       SEID    dir_seid;
	char    entry_name [14];    /* 14 should be replaced symbolically */
} User_pathname;


/*
 *      open_PipePortEntry = struct { ... }
 */
typedef struct
{       SHARED
	EVENT           eofp_read,
			read,
			write;
	User_pathname   Port_name;
	int             PP_write_refs,
			PP_read_refs;
	PP_ptr_index    PP_write_ptr,
			PP_read_ptr;
	PP_flags_d      PP_flags;
	PP_open_list_entry
			PP_open_list [ NProcPerPP /* PP_open_list_index */ ];
} open_PipePortEntry;


/*
 *      Port_mode          = word_mask { ... }
 */
typedef union
{       unsigned        unsign;
	struct
	{       unsigned        DA      : 9,
				bit11_9 : 3,    /* filler                   */
				Header  : 3,    /* same as in PP_flags_d    */
				OFRO    : 1;
	} wd_mask3;
} Port_mode;


/*
 *      Port segment layout:
 *              Note that the pipe data segment is embedded in it.
 */
typedef struct
{       SyncBlock               P_SyncBlock;
	open_PipePortEntry      P_openPort;
	char                    PP_data_segment [PP_DATA_SIZE];
} Port_segment;


/*
 *      Port header layout:
 *              Not all fields need be in use.
 */
typedef struct
{       unsigned        H_pid,
			H_uid,
			H_pgid;
	union
	{       unsigned        unsign;
		struct
		{
			int     H_wcnt   : 15,
				H_msgend :  1;
		} wd_mask4;
	} H_status;
} Port_header;


/*
 *      Bit masks for use in resource control in PP_pipe and EPP_port:
 */
#define GOTrfdes  0001
#define GOTwfdes  0002
#define GOTrfs    0004
#define GOTwfs    0010
#define GOTFopi   0020
#define GOTports  0040
#define GOTsync   0100


/*
 *      TEMPORARY (maybe)
 *      segdes   = seg_des      (this rectifies a small confusion of names)
 *      t_fildes = ???
 */
#define segdes    seg_des
#define t_fildes  int
