/* <vms/lib/uncdef.h>
 *
 *	LIB - universal context definitions	[not in Starlet]
 */
#ifndef _UNCDEF_H
#define _UNCDEF_H

/*
   UNCHDRDEF - Universal Context Segment Header definition
 */
#define UNC$C_JPI		1	/* JPI context segment */
#define UNC$C_UAI		2	/* UAI context segment */
#define UNC$C_AUDIT_EVENT	3	/* AUDIT_EVENT context segment */
#define UNC$C_OBJECT		4	/* object management context segment */
#define UNC$C_ORB_FIXUP		5	/* writeback ORB after boot fixup */
#define UNC$C_OBJECT_SERVICE	6	/* object service request context */
#define UNC$C_HDR_LENGTH 16
#define UNC$K_HDR_LENGTH 16	/* size of context segment header */
#define UNC$C_LIST	 16
#define UNC$K_LIST	 16	/* offset to first context block */
#define UNC$S_UNCHDRDEF  16
struct unchdrdef {
    unsigned long unc$l_flink;		/* forward link to next context segment */
    unsigned long unc$l_blink;		/* back link to prev context segment */
    unsigned short unc$w_size;		/* total size of context segment */
    unsigned char unc$b_type;		/* VMS type of block (DYN$C_UNC) */
    unsigned char unc$b_subtype;	/* type of context segment */
    unsigned short unc$w_count;		/* number of context blocks in segment */
    unsigned short unc$w_free_count;	/* number of entries free for use */
#define unc$w_unused_w1 unc$w_free_count
};

/*
   Universal Context Block definition
 */
#ifndef NO_VMS_V6
#define UNC$V_ENTRY_INUSE	0
#define UNC$V_NEW_ENTRY		1
#define UNC$M_ENTRY_INUSE	(1<<UNC$V_ENTRY_INUSE)	/* 0x01 */
#define UNC$M_NEW_ENTRY		(1<<UNC$V_NEW_ENTRY)	/* 0x02 */
#define UNC$C_LENGTH	84	/* size of largest context block */
#define UNC$K_LENGTH	84
#define UNC$C_SEGMENTS	5	/* natural number of segments/page */
#define UNC$K_SEGMENTS	5
#define UNC$S_UNCDEF	84
#define UNC$S_SO_OSR_CONTEXT 16
#define UNC$S_OS_IOSB	8
#else
#define UNC$C_LENGTH	16	/* size of context block */
#define UNC$C_SEGMENTS	31	/* natural number of blocks/segment */
#define UNC$S_UNCDEF	16
#endif
struct uncdef {
    union {
	unsigned short unc$w_flags;	/* context cell flags */
	struct {
	    unsigned unc$v_entry_inuse	: 1;	/* context entry inuse */
	    unsigned unc$v_new_entry	: 1;	/* newly created entry */
	    unsigned			: 14;	/* padding */
	} unc$r_flags_bits;
    } unc$r_flags_overlay;
    unsigned char unc$b_access_mode;	/* access mode of context cell */
    unsigned char unc$b_unused_b1;	/* padding for alignment */
    unsigned long unc$l_image_count;	/* imgcnt when context cell assigned */
    union {
	struct {
	    unsigned long  unc$l_target_pid;	/* target process PID */
	    unsigned short unc$w_segidx;	/* rights segment index */
	    unsigned short unc$w_rights;	/* rights list index */
	} unc$r_jpi_context;
	struct {
	    unsigned short unc$w_uai_ifi;	/* FAB$W_IFI */
	    unsigned short unc$w_uai_isi;	/* RAB$W_ISI */
	    unsigned short unc$w_uai_channel;	/* UAF channel */
	    unsigned	: 16;			/* padding */
	} unc$r_uai_context;
#ifndef NO_VMS_V6
	struct {
	    unsigned long  unc$l_ae_iosb;	/* IOSB address */
	    unsigned long  unc$l_ae_astadr;	/* AST address */
	    unsigned long  unc$l_ae_astprm;	/* AST parameter */
	    unsigned short unc$w_ae_efn;	/* EFN number */
	    unsigned short unc$w_ae_channel;	/* reply mailbox channel */
	    unsigned long  unc$l_ae_flags;	/* $AUDIT_EVENT flags */
	    unsigned long  unc$l_ae_reply;	/* audit server reply status */
	    unsigned short unc$w_ae_qio_status; /* status from $AUDIT_EVENT's $QIO to reply mailbox */
	    unsigned char  unc$b_ae_prvmod;	/* mode to deliver completion AST */
	    unsigned	: 8;			/* padding */
	} unc$r_ae_context;
	struct {
	    unsigned long  unc$l_so_context;	 /* Value of this context block */
	    unsigned long  unc$l_so_context_ptr; /* Address of user's context cell */
	    unsigned long  unc$l_so_acl_position;	/* position in the ACL */
	    unsigned long  unc$l_so_lockid;		/* lock ID for write lock on ORB */
	    unsigned long  unc$l_so_parent_id;		/* parent lock ID for SO_LOCKID */
	    unsigned long  unc$l_so_osr_flags;		/* OSR processing flags (see $OSRDEF) */
	    unsigned long  unc$l_so_ocb;		/* Object Class Block address */
	    unsigned long  unc$l_so_orb;		/* address of the ORB */
	    unsigned long  unc$l_so_object_handle;	/* object handle address */
	    unsigned short unc$w_so_objnam_length;	/* size of object name */
	    unsigned short unc$w_so_reserved_1;		/* reserved (MBZ) [descriptor padding] */
	    unsigned long  unc$l_so_objnam;		/* object name buffer address */
	    unsigned short unc$w_so_objnam_bufsiz;	/* size of objnam buffer alloc */
	    unsigned char  unc$b_so_acmode;		/* access mode */
	    unsigned char  unc$b_so_reserved_2;		/* reserved for Digital use */
	    unsigned long  unc$l_so_aclctx_ptr;		/* context return address */
	    unsigned long  unc$l_so_macctx_ptr;		/* address of MAC context area */
	    unsigned long  unc$l_so_tranquility_count;	/* tranquility count (MAC) */
	    char	   unc$t_so_osr_context[16];	/* object support routine context area */
	} unc$r_so_context;
	struct {
	    unsigned long  unc$l_of_astadr;	/* AST address */
	    unsigned long  unc$l_of_astprm;	/* AST parameter */
	    unsigned long  unc$l_of_flags;	/* flags (object specific) */
	    unsigned short unc$w_of_status;	/* completion status */
	    unsigned char  unc$b_of_prvmod;	/* mode to deliver completion AST */
	    unsigned long  unc$l_of_object;	/* context for locating the */
	    unsigned long  unc$l_of_object1;	/* next object profile */
	    unsigned long  unc$l_of_object2;	/* (object specific) */
	    unsigned long  unc$l_of_object3;
	} unc$r_of_context;
	struct {
	    unsigned long  unc$l_os_astadr;	/* AST address */
	    unsigned long  unc$l_os_astprm;	/* AST parameter */
	    unsigned long  unc$l_os_flags;	/* flags (object specific) */
	    unsigned short unc$w_os_repl_chan;	/* mailbox channel for reply */
	    unsigned short unc$w_os_rqst_chan;	/* mailbox channel for request */
	    unsigned short unc$q_os_iosb[4];	/* IOSB for $QIO */
	    unsigned short unc$w_os_status;	/* completion status */
	    unsigned char  unc$b_os_prvmod;	/* mode to deliver completion AST */
	    unsigned long  unc$l_os_object;	/* context for locating the */
	    unsigned long  unc$l_os_object1;	/* next object profile */
	    unsigned long  unc$l_os_object2;	/* (object specific) */
	    unsigned long  unc$l_os_object3;
	} unc$r_os_context;
#endif
    } unc$r_context_overlay;
};

#ifndef NO_VMS_V6
/* object management context cell layout */
#define OBJCTX$S_CTXDEF 4
struct objctxdef {
    unsigned short objctx$w_index;	/* index in table */
    unsigned short objctx$w_seq;	/* sequence number */
};
#endif

#endif	/*_UNCDEF_H*/
