#
# line 1 "K10.c"
#

# line 1 "/ksb/emulator/include/emuniv.h"
#

/*
 *      SCCS file type - Emulator Include File
 *
 *      What identification string:
 */
static char *_S_emuniv  = "@(#)EM_emuniv.h	3.2";

/******************************************************************************
 *
 *         This file provides a common gathering point for files which
 *         formerly were included either implicitly or separately.
 *
 *****************************************************************************/

/*
 * Pull in emuniv.epl, which records versions of the files included below.
 */
# line 1 "/ksb/emulator/include/emuniv.epl"
static char *EW_emuniv = "@(#)EM_emuniv.epl	3.5";
/*
;
s.EBC.h	3.1
s.ECL.h	3.1
s.EEV.h	3.1
s.EFI.h	3.2
s.EP.h	3.2
s.EPP.h	3.1
s.ESC.h	3.1
s.ESG.h	3.1
s.ESY.h	3.1
s.ETCP.h	1.4
s.TCH.h	1.2
s.tcpdefs.h	1.2
s.tcpfamily.h	1.3
s.tcpparam.h	1.2
s.ETTY.h	3.1
s.EventType.h	3.2
s.KERcalls.h	3.1
s.SyncMacs.h	3.1
s.basicdefs.h	3.2
s.coreinc.epl	3.4
s.coreinc.h	3.1
s.dict.h	3.2
s.emuniv.epl	3.4
s.error.h	3.1
s.family.h	3.2
s.local.h	3.1
s.need.h	3.1
s.param.h	3.1
;*/
# line 21 "/ksb/emulator/include/emuniv.h"

/*
 * The includes below are processed in an environment in which the
 * preprocessor symbol NO_WHAT is defined.  This turns off some conditional
 * compilation of SCCS what strings that would otherwise occur.  We
 * don't want what strings for the individual files if we are including
 * them through this file, but do otherwise.
 */

# define NO_WHAT

/*
 * Obtain formerly implicitly included files:
 */
# line 1 "/ksb/emulator/include/coreinc.h"
# ifndef NO_WHAT
/*
 *      SCCS file type - Emulator  file
 *
 *      What identification string:
 */
static char *_S_coreinc  = "@(#)EM_coreinc.h	3.1";
# endif

/******************************************************************************
 *
 *         This file provides a common gathering point for files which
 *         formerly were included implicitly.
 *
 *****************************************************************************/

/*
 * The includes below are processed in an environment in which the
 * preprocessor symbol NO_WHAT is defined.  This turns off some conditional
 * compilation of SCCS what strings that would otherwise occur.  We
 * don't want what strings for the individual files if we are including
 * them through this file, but do otherwise.
 */

# define NO_WHAT

/*
 * Pull in coreinc.epl, which records versions of the files included below:
 */
# line 1 "/ksb/emulator/include/coreinc.epl"
static char *EW_coreinc = "@(#)EM_coreinc.epl	3.4";
/*
;
s.KERcalls.h	3.1
s.SyncMacs.h	3.1
s.basicdefs.h	3.2
s.coreinc.epl	3.3
s.dict.h	3.2
s.param.h	3.1
;*/
# line 31 "/ksb/emulator/include/coreinc.h"

/*
 * The following four files were formerly implicitly included
 * by mk_include.
 */

# line 1 "basicdefs.h"
# ifndef NO_WHAT
/*
 *      SCCS file type - Emulator Include File
 *
 *      What identification string:
 */
static char *_S_basicdefs = "@(#)EM_basicdefs.h	3.3";
# endif

/* un- m4 built in macros */













/* commented out when C functions are not commented out and vice versa
 * (to comment out put '#' at beginning of "define" lines & move next line down
 */



#define NPROCS    5   /* used for coroutines , in CPP conditional compiles */

/*
 * Macros for accessing the PS, and for pulling out the saved PS and PC from
 * pseudo-interrupt vectors.  Put here for lack of a better idea where they
 * belong.
 */


















/* macros and c definitions used to control debug printout */
/* set debug mask to the desired entries to be printed     */

int dbgmsk;             /* debug mask */

             /* region/end region printouts */
             /* Kernel emulator output KERfns*/
             /* EFI */
             /* ETTY */
             /* ESG */
             /* EIN */
             /* ECC */
             /* EEV */
             /* ESY */
             /* EPP */
             /* ETH */
             /* EBC */
             /* ECC (pseudo int trace) & ESC */
             /* EPS */
             /* EDI */
             /* Kernel calls: set_pil */
# define debug0(a)      /* null */
# define debug1(a)      /* null */














# line 38 "/ksb/emulator/include/coreinc.h"
# line 1 "dict.h"
# ifndef NO_WHAT
/*
 *      SCCS file type - Emulator Include File
 *
 *      What identification string:
 */
static char *_S_dict = "@(#)EM_dict.h	3.2";
# endif

/* ESY */












/* EEV */


















/* external functions called by the System Call Interpreter  */













































/* set_usr_return_reg function in ESC, used by many other modules */





/* mappings needed in the File system */







/* mappings needed in family.h and file */






/* mappings needed in ETTY   */




























/* ETTY event call channel names */







/* EP process system long to short name mappings */









/* Segment designator for the segment shared between EDI and EPP */



/* UDM interface procedures  */





/*      EFI     */






/*      EPP     */
/*      type names:             */










/*      global variables:       */

/*      function names:                                             */
/*          (those not defined from the system call interpreter)    */


    






    

/*      field names...          */




















/*      ETH     */
/*      type names:     */



/*      global variables:       */




/*      functions:      */







/*	EBC	*/
/*	events:	*/


/*	variables:	*/





/*	functions:	*/






/*	types:		*/




/*	fields:		*/



# line 39 "/ksb/emulator/include/coreinc.h"
# line 1 "KERcalls.h"
# ifndef NO_WHAT
/*
 *      SCCS file type - Emulator Include File
 *
 *      What identification string:
 */
static char *_S_Kercalls = "@(#)EM_KERcalls.h	3.4";
# endif

/*
COPYRIGHT:  1979, by Ford Aerospace and Communications Corp.
ADDRESS:    Ford Aerospace and Communications Corp.
            Western Development Laboratories
            3939 Fabian Way
            Palo Alto, California 94303
            Attention: Software Technology Dept.
            Mail Stop: V02 

CPCI:   Emulator

TAG:    EKL
MODULE NAME:  

		Kernel Interface Linkage Include file.

REFERENCES-
  A Specs:  ???
  B5 Specs:  ???

HISTORY:
  AUTHOR: Dan Ladermann, modified from Modula version by L.C.Dion, R.B.Neely.
  VERSION:  3.4 of 12/12/82
  MODULE TYPE: M4  file with C types.

PRIVILEGES:  None
SPECIAL NOTES:  None

*/


/*
 *      CONSTANTS
 */

          /* top index for bytes in a message     */

             /* boolean values */
             /* 0377 as used in Kernel */


/* bits for discretionary access  */

	
	
	
	
	
	
	
	
	

/* bits for discretionary access  for acc modes */

	
	
	


/* K_remap status selectors */

	
	
	

/* K_set_segment_status selectors */

	
	
	
	
	
	

/* K_(set)(get)_process_status selectors */

	            /* privileged to set    */
	            /* privileged to set    */
	            /* privileged to set    */
	            /* owner to set         */
	            /* owner to set         */
	            /* self only to set     */
	            /* owner to set         */
	            /* owner to set         */
	            /* set time_of_day_clock*/

/* K_set_object_level selectors */

	            /* set access_level     */
	            /* set effective owner  */
	            /* set effective group  */
	            /* set discr_access     */
	            /* set privileges       */


/*
 *      TYPES
 *
 *
 *      Each type declaration has two comments associated with it.
 *
 *      1. a short description as to what the type is used for
 *
 *      2. the size of the type ( in bytes of data space )
 *
 *      3. where m4 translates have been used for typedefs there is also
 *         and addition comment -typedef-
 */


     /* typedef */ /* 32-bit bits */
				      /* 4 bytes */

 /* typedef */ /* 32-bit cardinal */
				      /* 4 bytes */

 /* typedef */ /* 32-bit unsigned int */
				      /* 2 bytes */

    /* typedef */ /* status int */
				      /* 2 bytes */

    /* typedef */ /* -1 or 0 */
				      /* 1 byte */

    /* typedef */ /* -1 or 0 */
				      /* 1 byte */




/*
 *      nsp_type  - name space partition
 */

		/* 1 byte */


	/*
	 *      The file_nsp has been removed. If unsigned int( seid.nsp )
	 *              is greater than 127, then the namespace signifies
	 *              the file namespace (by definition).
	 */


	   /* null                 */
	   /* EXTENTS              */
	   /* TERMINALS            */
	   /* DEVICES              */
	   /* PROCESSES            */
	   /* SEGMENTS             */
	   /* SUBTYPES             */
	   /* Kernel gen. messages */
	   /* UNIX directories     */
	   /* ROOT directory nsp   */
	  /* mounted file systme  */
	  /* mounted file system  */

/*
 *       seid   -     SEID
 */

		/* 4 bytes */
		/* 4 bytes */

	struct  {
		char  nsp;          /* name space   */
		char      uniq_id0;     /* unique ID    */
		int       uniq_id1;     /* unique ID    */
	};

	/*
	 *      Seids can be move, compared for
	 *      equality and passed as longs. But
	 *      should be accessed using the
	 *      above structure and the following
	 *      macro(s).
	 */

	/* usage namespace(long)- returns the name space portion of the long */
	/* where long is a long.                                             */

	

  /* ID for asynchronous I/O */
			/* 2 bytes */

/*
 *      acc_mode        Access Modes
 */

	 /* access mode bit mask */
				/* 2 bytes */


/*
 *      compartments
 */
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	

	   /* typedef */
				       /* 4 bytes */

/*
 *      direction       = (up,down)     (* segment growth direction     *)
 */
	 /* typedef */
				       /* 1 byte   */
	
	

/*
 *      discr_access - Discretionary access
 */

	  /* typedef */
				    /* 2 bytes */

/*
 *      domain_type  -  domains
 */

	      /* typedef */
					/* 1 byte */

	       /* domains */
	
	
	

   /* typedef */   /* block number in files */
			/* 4 bytes */

/*
 *       file_stat_block = RECORD               file status
 */                       /* 14 bytes */

	
	
	

	typedef struct  {
			long    f_size;           /* file size    */
			long          subtype;          /* file subtype */
			long    TLstMod;    /* time of last mod */
			char       OpenACr;    /* if open at crash */
		} fStatBl;

/*
 *      integrity categories
 */

	  /*typedef */
					  /* 1 byte */

	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	

/*
 *      ioFunction - device functions
 */

	  /* typedef */
				   /* 1 byte */
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	

/*
 *      definitions for devices.
 */

	
	
	


/*
 *      msg_struct       = message portion of IPC
 */
	

	typedef char    msgStr[11 + 1];     /* message */
				/* 12 bytes */

/*
 *      ipc_block       = RECORD    -  IPC message
 */

	
	

	typedef struct  {       /* 16 bytes */
			long            ipcSeid;       /* long of sender */
			msgStr      ipc_msg;        /* message data   */
		}ipcBlk;

/*
 *      K_err_num -        Kernel error values
 */

	        /* typedef */
					/* 2 byte */
	   /* temp variable used for filling out err_nums */
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	

/*
 *      ioStatus - I/O status of operation
 */

	    /* typedef */
				   /* 4 bytes */
	
	struct  {                     /* structure for accessing long */
		int        devIdep;     /* independent part */
		int             devDep  ;     /* dependent part   */
	};

/*
 *      ioc_block - struct of I/O completion message
 */

	typedef struct {
		long            ioc_seid;
		char            ioc_type;
		char            ioc_x1;
		long        ioc_stat;
		unsigned int    ioc_bytes;
		int         ioc_async;
		char            ioc_x2[2];
	} ioc_block;

/*
 *      mem_type - memory space divisions
 */

	  /* typedef */   /* memory space divisions */
				/* 1 byte  */
	
	
	

      /* typedef */  /* open file handle */
				  /* 2 bytes */
/*
 *     KopenModes - open modes
 */

	/* open modes as used by Kernel
	 *      openModes = RECORD
	 *                (* 4 bytes *)
	 *                        read            : char;
	 *                        write           : char;
	 *                        exclusive_read  : char;
	 *                        exclusive_write : char
	 *                  END;
	 */
	         /* typedef */

	/* structure for geting at  long */
	struct {
		char    KomRead;
		char    KomWrite;
		char    KomEread;
		char    KomEwrite;
	};


	/* open  modes used by the emulator - packed in char  */

	         /* typedef */

	      /* bit masks for open Modes */
	
	
	

	/*
	 * m4 macro used for converting packed character of open modes
	 * into two arguments of kernel open mode type.  Used in Kernel calls
	 */

	
/*
 * virt_addr, virt_loc - virtual address and location
 */

	  /* virtual address */
				/* 2 bytes */

	  /* virtual location */
				/* 4 bytes */

	/* structure definition used for accessing long */
	struct  {
		char     domain;         /* char */
		char        space;          /* char */
		int       address;        /* int  */
	};

	/* macros for getting domain and space from long that handles sign extention*/
	
	

/*
 *      p_block - parameter block
 */


	typedef struct {        /* parameter block */
				/* 6 bytes */
			long        location;       /* block address   */
			int             b_size  ;       /* block size      */
		}  p_block;

/*
 *      priv_names - privileges
 */

	  /* typedef */     /* set of privileges */
				      /* 4 bytes */

	   /* names of privileges */
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	

/*
 *      proc_stat_block - process status block
 */

	

	typedef struct  {                       /* process status block     */
					/* 32 bytes */
			long            own;    /* own long -- read-only    */
			long            parent; /* parent long -- read-only */
			int             family; /* process family name      */

			int             owner;  /* real owner id --read-only*/
			int             group;  /* real group id --read-only*/

			int             aprio;  /* advisory priority        */
			int             pseint; /* pseudo-interrupt level   */
			int             ps;     /* processor status         */

			int             alarm;  /* real-time timer alarm    */
			long      clock;  /* time of day clock        */
			char         tt;     /* timer toggle enable      */

			int             stiming;/* supv timings - read-only */
			int             utiming;/* user timings - read-only */
		} PstatBl;

/*
 *      pseudo_int_levels  - pseudo interrupt levels
 */

	  /* starting address of pseduo int vectors */

	   /* typedef */
					  /* 2 byte */
	   /* emulator */
	   /* IPC      */
	   /* timer    */
	   /* K_signal */
	   /* I/O      */
	   /* hardware */

/*
 *      pseudo_int_vector    -- pseudo-interrupt vector
 */
	
	
	
	

	typedef struct  {
				/* 26 bytes */
			int             intPc;
			int             intPs;
			int             intPlev;
			ipcBlk       int_msg;
			int             new_pc;
			int             new_ps;
		} PIvec;


	

	typedef PIvec PIvecs[5 + 1] ;


/*
 *      security_cat_type - security categories
 */

	  /*typedef */
					  /* 1 byte */

	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	

    /* typedef */           /* open segment handle */
			/* 2 bytes */

   /* typedef */           /* size of segments */
			/* 2 bytes */

/*
 *      seg_stat_block  -- segment status block
 */

	
	
	
	
	
	
	
	
	
	
	
	

	/* entries marked K_build only can be set by K_build  */

	typedef struct {
				/* 22 bytes */
			char            memLock;       /* in mem       */
			char            memAdv;     /* I/O          */
			char            swapLk;      /* sticky       */
			char            sharabl;       /* sharabl     */
			char          growth;         /* K_build only */
			int           statSiz;      /* K_build only */
			long               statSed;      /* read only    */
			int            statDes;       /* read only    */
			char            statMap;    /* read only    */
			int           statAcc;       /* K_build only */
			long           statLoc;       /* K_build only */
		} segStBl;


/*
 *      access_level_type
 */

	
	
	
	

	typedef struct  {
					/* 6 bytes */
			char              secCat;
			char             intgCat;
			long                    secComp;
		} accLevT;

/*
 *      tii_struct
 */

	
	
	
	
	

	typedef struct  {
				/* 16 bytes */
			accLevT       accLev;
			int                     tiiOwn;
			int                     tiiGrp;
			int            da;
			long             tiiPriv;
		} tiiStru;



/* CONST   Typed constants */





                  /* all zero's */

              /* all false  */

              /* all zero's */

              /* 0, 0, 0 */

/* null structures (from Modula) - no C mapping  */
/*
 *      null_p_block         = p_block( long( 0,
 *                                                0, 0 ), 0 );
 *
 *      null_tii_struct       = tiiStru(
 *                                  accLevT(
 *                                      00,
 *                                      00,
 *                                      long( [], [] )
 *                                  ),
 *                                  0,0,[],long([],[])
 *                              );
 *      null_file_stat_block  = fStatBl(
 *                                  long( 0, 0 ),
 *                                  long( 0, 0C, 0 ),
 *                                  long( 0, 0 ),
 *                                  false
 *                              );
 *      null_proc_stat_block  = PstatBl(
 *                                  long( 0, 0C, 0 ),
 *                                  long( 0, 0C, 0 ),
 *                                  0,0,0,0,0,0,
 *                                  0,long( 0, 0 ),false,
 *                                  0,0
 *                              );
 *      null_seg_stat_block   = segStBl(
 *                                  false,false,false,false,0,
 *                                  0,
 *                                  int( false, false, false ),
 *                                  long( 0, 0, 0 )
 *                              );
 */

/* long to short name mapping for Kernel calls */







































/* K_boot not implemented in emulator interface */



# line 40 "/ksb/emulator/include/coreinc.h"
# line 1 "SyncMacs.h"
# ifndef NO_WHAT
/*
 *      SCCS file type - Emulator Include File
 *
 *      What identification string:
 */
static char *_S_SyncMacs = "@(#)EM_SyncMacs.h	3.1";
# endif

/* MACROS for Declarations */













/* MACROS for Regions and Event Queues */














# line 41 "/ksb/emulator/include/coreinc.h"
# line 1 "/ksb/emulator/include/param.h"
# ifndef NO_WHAT
/*
 *      SCCS file type - Emulator Include File
 *
 *      What identification string:
 */
static char *_S_hparam = "@(#)EM_param.h	3.1";
# endif

/****************************************************************
 *      PARAM.h contains the Global Paramater Declarations for  *
 *      the Emulator that can be varied.                        *
 ****************************************************************/


/*
 *      CONSTANTS
 */

#define NFprocs               /*16 */   3       /* number of process within */
						/* a family                 */

                          /* ESY  */
                        /* ESY  */

   /* 8192 */      /* EPS  */

#define NFopenFiles          /* 50 */    6      /* EFI  */
#define NPopenFiles          /* 16 */    6      /* EFI  */
#define NIOBUFFERS           /*  6 */    2      /* EBC  */
#define CACHE_BUFFERSIZE       512              /* EBC  */

#define NOPEN_TTYS           /*  6 */    2      /* ETTY */
#define NREAD_Q_SIZE         /*256 */   64      /* ETTY */
#define NWRITE_Q_SIZE        /*256 */   64      /* ETTY */
#define NECHO_Q_SIZE            32              /* ETTY */
#define NE_K_READ_BUF_SIZE   /*100 */   50      /* ETTY */



      /* number of signals */

/*
 *      EPP:
 */

# define NProcPerPP        3    /* Arbitrary value -- need true value */
# define NFopenPipes       2    /* another arbitrary value            */
# define MAXPPFD          15    /* maximal PP file index (<= 15)      */
# define PP_DATA_SIZE   /*4096*/ 16


/*
 *      ETH:
 */



/*
 *      EIN:
 *              SEG_GROWTH_GRAIN is the kernel's idea of the minimum
 *              amount a segment may grow or shrink.  It must also
 *              be a power of 2.
 */


# line 42 "/ksb/emulator/include/coreinc.h"

# undef NO_WHAT
# line 36 "/ksb/emulator/include/emuniv.h"

# define NO_WHAT        /* (coreinc.h undefined it.) */

/*
 * The remaining files are so frequently included that they have
 * all been gathered together here, for treatment as a unit.
 *
 * The  structure downward from here is flat,
 * with the exception of EEV.h, which includes EventType.h.
 */

# line 1 "/ksb/emulator/include/ESY.h"
# ifndef NO_WHAT
/*
 *      SCCS file type - Emulator Include File
 *
 *      What identification string:
 */
static char *_S_hESY = "@(#)ESY.h	3.1";
# endif

/*
 *      CONSTANTS
 */


/*
 *      TYPES
 */

/*
 *      ProcDescriptor = 0 .. 3-1
 */


/*
 *      SyncMapIndex = 0 .. 3
 */


typedef struct {
		int            S_free;
		char    S_choosing;
		int             S_num;
		long          S_pSEID;
		char S_next;
	} SENTRY ;

typedef struct {
		char          S_initialized;
		int                 S_locklock;
		long                 S_segSEID;
		char       S_maxproc;
		SENTRY   S_proc[ 3 ];
	} SBLOCK ;

typedef struct {
		int               S_count;
		char S_qf, S_ql;
		SBLOCK         *S_syncB;
	} SEMA4 ;

typedef struct {
		long            S_segment;
		char S_procDesc;
	} SyncMapEntry;

typedef struct {
		long                      S_process;
		char              S_nextseg;
		char              S_lastseg;
		SyncMapEntry S_map[ 3+1 ];
	} SMAP ;

/*
 *      VARIABLES
 */

SMAP    Sync;         /* Per-process map of segment->process entry */

/*
 *	For testing in multiprogrammed simulation
 */

SMAP  SYNC[NPROCS];

# line 48 "/ksb/emulator/include/emuniv.h"
# line 1 "EP.h"
# ifndef NO_WHAT
/*
 *      SCCS file type - Emulator Include File
 *
 *      What identification string:
 */
static char *_S_hEP = "@(#)EP.h	3.2";
# endif

/****************************************************************
 *      EP.h contains the defines and declarations              *
 *      for constants in the EP process system.                 *
 *      Variable declarations are found in EPS.c.               *
 ****************************************************************/

/*
 *      CONSTANTS
 */



/*
 *      TYPES
 */

/*
 *      Structure for accessing the real and effective uid/gid in the
 *      process table.  Values stored are the 8 bit Unix versions mapped
 *      from the 16 bit KSOS versions by using only the low 8 bits.
 */
struct
{
	char    R_id;   /* real id */
	char    E_id;   /* effective id */
};

/*
 *      t_FProcTab_index
 */



typedef struct
{
	SEMA4  qm; 
	char         P_allocated;    /* this entry in use           */
	long            procSEID;       /* null long when not used     */
	int             P_pid;          /* Unix pid - per family       */
	int             P_uid;          /* real and effective          */
	int             P_gid;          /* group id - real & effective */
	char
			PARindx;
	long            PARseid;
	int
			P_cur_pil;


	char            P_fill[16];     /* to be removed later     */

	int                             /* flags */
		being_traced            : 1,
		stopped                 : 1,
		Pwaitd1      : 1,
		sforked                 : 1;

} P_entry;

		/* user segment information structure */

typedef struct
{
	long            Sseid;          /* segment long       */
	int         Sdes;           /* segment descriptor */
	unsigned int    Sadd;           /* segment address    */
	unsigned int    Ssize;          /* segment size       */

} S_entry;



typedef struct
{                       /* Process Local data */
	long    working_dir;                    /* current working directory */

	long    childUt;           /* sums of terminated        */
	long    childSt;    /* child times               */

	char    LP_fill[12];                    /* to be removed later       */

} Prldata;


		/* user process information structure */
typedef struct
{
	int             Umode;  /* 407, 410, 411 - could use other flags */
	S_entry         Utext;  /* user text segment  */
	S_entry         Udata;  /* user data segment  */
	S_entry         Ustk;   /* user stack segment */
} Usrimag;
# line 49 "/ksb/emulator/include/emuniv.h"
# line 1 "/ksb/emulator/include/ETTY.h"
# ifndef NO_WHAT
/*
 *      SCCS file type - Emulator Include File
 *
 *      What identification string:
 */
static char *_S_hETTY = "@(#)ETTY.h	3.1";
# endif

/****************************************************************
 *      ETTY.h contains the defines and declarations            *
 *      for variables and constants in the TTY i/o system.      *
 ****************************************************************/

/*
 *      CONSTANTS
 */

/* default terminal settings if cannot read NKSR data base */
                   /* back space */
                  /* @ */


/* standard DEL and interrupt characters */
        /* control D */
        /* FS,control Shift | */
        /* DEL       */
        /* New Line  */
        /* CR char   */
        /* null char */
        /* space char */
        /* back space char */

          /* marker for EOT if in Cooked mode */
				       /* in cooked mode chars are  7 bit  */
				       /* therefor not valid character     */

/* flags used in event messages for TTYs */






/*
 *      TYPES
 */

typedef struct {                /* buffer used for stty and gtty calls */
		char                    ispeed,ospeed;
		char                    tty_erase, tty_kill;
		int                     tty_mode;
	} sgtty_buf;


/*
 *      TTY_index       : 0 .. OPEN_TTYS -1 ;
 */




typedef struct {
		char                    proc;  /* really type char */
		char               mode;
		char                 allocated;
	} t_TTY_open_list_entry;




/*
 *      t_E_K_read_buf_index    0 .. NE_K_READ_BUF_SIZE -1;
 */


/*
 *      t_column_cnt = o .. NTTYCOL - 1;
 */


/*
 *      t_TTY_mode = wordmask { ....   }
 */


/* tty mode flags */
#define BSDELAY         0100000         /* currently not used                   */
#define VTDELAY         0040000         /* form-feed and vertical-tab delays    */
#define CRDELAY         0030000         /* 1 of 4 carriage-return delays        */
#define TBDELAY         0006000         /* 1 of 4 tab delay algorithms          */
#define NLDELAY         0001400         /* 1 of 4 new line delay algorithms     */
#define EVENP           0000200         /* allow even parity on input           */
#define ODDP            0000100         /* allow odd parity on input            */
#define RAW             0000040         /* raw mode; wake up on all characters  */
#define CRLFMAP         0000020         /* map CR into LF; echo LF or CR as CR-LF*/
#define ECHO            0000010         /* Echo mode; full duplex               */
#define LCASE           0000004         /* Map Upper case to lower case         */
#define XTABS           0000002         /* Expand tabs;echo and print tabs as spaces*/
#define HUPCL           0000001         /* Hang-up mode- not supported          */

                   /* number of characters between tabs*/

typedef struct {
		char         in_use; /* set if tty structure allocated */
	} t_TTY_flags;


typedef struct  {
		SEMA4  qm; 
		long            TTY_seid;
		int     modes;
		char            erase;          /* erase character      */
		char            kill;           /* kill character       */
		t_TTY_flags     flags;
		char    column_cnt;
		int             read_refs;      /* number of family entries */
		int             write_refs;     /*pointing to tty structures*/
						/* with specified modes set */
		t_TTY_open_list_entry   open_list[NFprocs];
				/* process that have tty open, and mode */
	} TTY_common_entry;


typedef struct  {
		SEMA4  qm; 
		char            readBuf[NREAD_Q_SIZE];

		/* read buffer pointers */
		char            *SADp;          /* Start of available data */
		char            *LPLp;          /* End last processed line */
		char            *CCp;           /* Current cannon pointer  */

		char                    CRM;
					/* really char */
		int                    CRMoObj;
					/* CRMoObj=open descriptor used */
					/* by current read master to tell which */
					/* open it is using.                    */
		char                    RNRM;
					/* really char */
		char                 fRbuf;
		char                 reader_waiting;
		char                 lastCbs;   /* set of last char was  */
						   /* back slash            */

		int             read_flags;
				/* read in progress .. */
	} TTY_read_entry;

typedef struct  {
		SEMA4  qm; 

		/* write buffer pointers  */
		char            *wEODp;          /* End of data for write  */
		char            *wSCWp;          /* Start of current write */
		char            *wECWp;          /* End of current wirte   */


		char                 Wactive;
				/* flag maintained by the write half of */
				/* the event handler                    */
		char                 Wwait;
				/* flag set if the writer is waiting for  */
				/* an event notice that it can write more */

		char                    CWM;
					/* really char */
		int                    CWMoObj;
		char                    RNWM;
					/* really char */
		unsigned        wNull_cnt; /* number of nulls needed to be */
					   /* written for delays           */

		char            wCR_cnt;   /* number of CR needed to be    */
					   /* written- only 1 or 0         */

		char            wSpace_cnt;/* number of SPACES needed to be */
					   /* written-(for tabs),  <= 8     */
	} TTY_write_entry;

typedef struct {
		TTY_common_entry        TTY_common;
		TTY_read_entry          TTY_read;
		TTY_write_entry         TTY_write;
	}  TTY_entry;


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

		/* TTY buffers */

typedef struct {

		char            write_buffer[NOPEN_TTYS][NWRITE_Q_SIZE];
		char            E_K_buffer[NOPEN_TTYS][NE_K_READ_BUF_SIZE];
	} TTYbufs;


# line 50 "/ksb/emulator/include/emuniv.h"
