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

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

/*
 *      CONSTANTS
 */
/* many constants placed in param.h   */


/*
 *      PopenFileIndex = 0 .. NPopenFiles -1 , -1, -2
 *      -1 = free, -2 = allocated but not set up yet
 */
#define	PopenFileIndex	char

/*
 *      FopenFileIndex = 0 .. NFopenFiles -1
 */
#define	FopenFileIndex	char

/*
 *   pathOps = (po_MKENTRY, po_REMOVE, po_LOCATE, po_CHDIR, po_EXEC, po_CREAT, po_LINK)
 *              note: po_LINK is the same as po_MKENTRY;
 */
#define	pathOps	char

# define po_MKENTRY     0
# define po_REMOVE      1
# define po_LOCATE      2
# define po_CHDIR       3
# define po_EXEC        4
# define po_CREAT       5
# define po_LINK        0       /* link is the same as mkentry: dir */
				/* manager only knows about mkentry */

/*
 *      object_type = (ot_file, ot_device, ot_pipe, ot_port, ot_tty,
 *                     ot_network, ot_dir);
 */
#define	object_type	char

# define ot_file        1
# define ot_device      2
# define ot_pipe        3
# define ot_port        4
# define ot_tty         5
# define ot_network     6
# define ot_dir         7

/*
 *      PopenFileEntry = integer;
 */
#define	PopenFileEntry	int

/*
 *      FopenFileEntry = struct{ ... };
 */
typedef union           /* union (FoF_type : object_type) */
	{
		/* ot_file, ot_device: */
		struct
		{       SHARED                          /* This is the  */
			SEID            FoF_SEID;       /* invariant    */
			KOOD            FoF_KOOD;       /* part of the  */
			open_mode       FoF_mode;       /* union- it    */
			int             FoF_refs;       /* is repeated  */
			object_type     FoF_type;       /* but only     */
							/* allocated    */
							/* once         */
			/* variant part */
			long    FoF_seek;
			long    FoF_leng;
		}   FoFE1;

		/* ot_pipe, ot_port: */
		struct
		{       SHARED
			SEID            FoF_SEID;
			KOOD            FoF_KOOD;
			open_mode       FoF_mode;
			int             FoF_refs;
			object_type     FoF_type;

			open_PipePortEntry      *FoF_GPpointer;
		} FoFE2;

		/* ot_tty:  */
		struct
		{       SHARED
			SEID            FoF_SEID;
			KOOD            FoF_KOOD;
			open_mode       FoF_mode;
			int             FoF_refs;
			object_type     FoF_type;

			TTY_index       FoF_FTTY_index;
		} FoFE3;

		/* ot_network: */
		struct
		{       SHARED
			SEID            FoF_SEID;
			KOOD            FoF_KOOD;
			open_mode       FoF_mode;
			int             FoF_refs;
			object_type     FoF_type;

			/* network portion when defined */
			int		FoF_protocol;
		} FoFE4;
	}   FopenFileEntry;


/*
 * The following three types are defined here in EFI because they
 * are used by several modules whose root is EFI.
 */

/*
 *      Capacity call return type;
 */
typedef union
{       long    longint;
	struct
	{       int     read_count : 15,
			read_eof   :  1;
		int     write_count;
	} long_mask;
} capac_return;

/*
 *      t_set_of_t_fildes  = set of t_fildes
 *              Representation is a one word bit map -- thus no more
 *              than 16 distinct t_fildes may exist.
 */
#define	t_set_of_t_fildes	unsigned


/*
 *      await_return       = word_mask { ... }
 *              Note that the return_event_kind field is subdivided by
 *              EMU_empty, EMU_read, and EMU_write as defined below.
 *              (Several fields of types defined in EPP.h are also
 *              subdivided by them.)
 *              The nulfield must be 0 to guarantee that -1 is never a
 *              legitimate value of await_return.unsign.
 */
typedef union
{       unsigned        unsign;
	struct
	{       unsigned        return_event_kind : 3,
				timedout          : 1,
				nulfield          : 4,  /* MUST be zero */
				fd                : 8;
	} wd_mask0;
} await_return;
#define	EMU_empty	 01
#define	EMU_read	  02
#define	EMU_write	 04


/*
 * UNIX user Inode structure as returned from stat
 *      Comments indicate Ksos information returned
 */
typedef struct
{
	char    minor;          /* SEID.nsp              */
	char    major;          /* SEID.uniq_id0         */
	int     i_ino;          /* SEID.uniq_id1         */
	int     i_mode;         /* Ksos tii.discr_access + ?? */
	char    i_nlink;        /* 0 */
	char    i_uid;          /* low byte of Ksos uid  */
	char    i_gid;          /* low byte of Ksos gid  */
	char    i_size0;        /* low byte of High word of size */
	char    *i_size1;       /* low word of size      */
	int     i_addr[8];      /* 0's                   */
	long    i_atime;        /* 0                     */
	long    i_mtime;        /* time_last_mod         */
} UstatBuf;

/* modes */
#define	IALLOC	  0100000
#define	IFMT	   060000
#define	IFDIR	  040000
#define	IFCHR	  020000
#define	IFBLK	  060000
#define	ILARG	  010000
#define	ISUID	  04000
#define	ISGID	  02000
#define	ISVTX	  01000
#define	IREAD	  0400
#define	IWRITE	 0200
#define	IEXEC	  0100

	/* structure for accessing parts of file size  */
	/* Ksos has long - unix has one word + a char  */

struct
{
	char uf_size0;   /* low byte of the high word                   */
	char uf_size2;   /* high byte of high word  -- not used in unix */
	int  uf_size1;   /* low word                                    */
};
