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

/*
 *      CONSTANTS
 */



/*
 *      TYPES
 */

/*
 *      EventType = 0 .. 255
 */
#include  "EventType.h"

/*
 *      EventKind = (EK_Call, EK_Wait, EK_Mesg )
 */
#define EventKind char
#define EK_Call 0
#define EK_Wait 1
#define EK_Mesg 2

typedef char EventData[11];
typedef int  (*EventISP)();

typedef EventType EventTypeList[256];
typedef EventTypeList *EventTypeListp;

typedef char EventMessageBody[12];

typedef union {
		struct {
			SEID EM_Sendee_er;
			EventMessageBody EM_Body;
		}EM1;
		struct {
			SEID EM_Sendee_er;
			EventType EM_Type;
			EventData EM_Data;
		}EM2;
		struct {        /* structure of io completion event message  */
			SEID EM_Sendee_er;
			EventType EM_Type;      /* char                      */
			char      EM_hole;      /* comiler does this any way */
			ioStatus  EM_ioStatus;  /* long                      */
			unsigned  EM_byteCount;
			asyncId   EM_asyncId;   /* int                       */
		}EM3;
#ifdef	EMULATOR
		struct {        /* structure of ETTY  event messages         */
			SEID EM_Sendee_er;
			EventType EM_Type;          /* char                  */
			char      EM_proc_index;    /* process table index   */
			KOOD      EM_kood;          /* integer               */
			char      EM_tty_index;     /* TTY table index       */
		}EM4;
		struct {        /* structure of signal event message         */
			SEID EM_Sendee_er;
			EventType EM_Type;          /* char                  */
			char      EM_proc_index;    /* process table index   */
			int       EM_signal_number; /* signal being sent     */
		}EM5;
		struct          /* structure of pipe/port await notification */
		{       SEID EM_Sendee_er;
			EventType EM_type;      /* i.e.: EPP_wake_up_event  */
			char      ev_type;      /* EMU_empty, _read, _write */
			SEID      PP_subject;   /* identifies the pipe or   */
					/* port on which the event occurred */
		} EM6;
		struct          /* structure of child stopped notification */
		{       SEID EM_Sendee_er;
			EventType EM_type;      /* ET_ChildStopped          */
			int       EM_Cpid;      /* process id of child      */
			int       EM_Sstatus;   /* Stopped status           */
			char      EM_CPindex;   /* Proc table index of child*/
		} EM7;
		struct          /* structure of child times   notification */
		{       SEID EM_Sendee_er;
			EventType EM_type;      /* ET_ChildStopped          */
			int       EM_Cpid;      /* process id of child      */
			long      EM_CUtimes;   /* Child User times         */
			long      EM_CStimes;   /* Child Supervisor times   */
		} EM8;
		struct          /* structure of fork completion notification*/
		{       SEID EM_Sendee_er;
			EventType EM_type;      /* ET_ForkStat              */
			int       EM_Cpid;      /* process id of child      */
			boolean   EM_Fstatus;   /* Fork status              */
                } EM9;
                struct          /* structure for the TUC_wake_up channel    */
                {       SEID EM_Sendee_er;
                        EventType EM_type;      /* char                     */
                        char      EM_fd;        /* network connection fd    */
                } EM10;
#endif	EMULATOR
	} EventMessage;

	/* structure for accessing parts of the asyncId used in events for */
	/* io completion in ETTY and the IO completion (not done yet)      */
	/* maybe it should be placed elsewhere                             */

#ifdef	EMULATOR
	struct{
		int
			AID_tty_index   : 6,   /* index into TTY structure */
			AID_io_Type     : 2,   /* read/write/echo          */
			AID_Event_Type  : 8;   /* event type               */
	};
#endif	EMULATOR

/*
 * Event Channel Table -- Maintained in User Supplied Area
 */

typedef struct ECTbuffer {
		EventMessage      ECT_Mesg;
		struct ECTbuffer *ECT_NxtB;
	} ECTbuffer;

/*
 *      ECTrange = 0 .. ECTmax;       ECTmax determined at runtime but < 255
 */
#define ECTrange char

typedef struct {
		EventType ECT_Type;
		EventKind ECT_Kind;
		EventISP  ECT_ISP;      /* Ev Int Serv Proc */
		Boolean   ECT_IntE;     /* Interrupt Enable */
		ECTbuffer *ECT_Blst;    /* Buffer list head */
		ECTbuffer *ECT_Tlst;    /* Buffer list tail */
	} ECTentry;

/*
 *      VARIABLES
 */

ECTentry        *ECT;
char            *ECTend;
ECTentry        *ECTtabend;
ECTbuffer       *ECTbufend;
ECTbuffer       *ECTfrLow;
ECTbuffer       ECTfrHigh;
int             ECTnfree;
int             (*ECTnospace)(), (*ECTnoevent)();

EventTypeListp  EventWaitListp;
EventType       EventShortList[2];      /* for EEV_Wait1 */

/* ECCcallQueue used to queue call channel events when one is in progress */
ECTentry        ECCcallQueue;

/*****************************************************************/

ECTentry        *ECTT;
char            *ECTEND;
ECTentry        *ECTTABEND;
ECTbuffer       *ECTBUFEND;
ECTbuffer       *ECTFRLOW;
ECTbuffer       ECTFRHIGH;
int             ECTNFREE;
int             (*ECTNOSPACE)(), (*ECTNOEVENT)();

EventTypeListp  EVTWTLP;
EventType       EVTSHTL[2];      /* for EEV_Wait1 */

#define ECT (ECTT)
#define ECTend (ECTEND)
#define ECTtabend (ECTTABEND)
#define ECTbufend (ECTBUFEND)
#define ECTfrLow (ECTFRLOW)
#define ECTfrHigh (ECTFRHIGH)
#define ECTnfree (ECTNFREE)
#define ECTnospace (ECTNOSPACE)
#define ECTnoevent (ECTNOEVENT)
#define EventWaitListp (EVTWTLP)

#define EventShortList (EVTSHTL)
