/* <lkidef.h>
 *
 *	Get Lock Information Data Identifier Definitions
 */
#ifndef _LKIDEF_H
#define _LKIDEF_H

/* item list blocks */
#define LKI$K_LENGTH	24	/* length of list block without byte range info */
#define LKI$C_LENGTH	24
#define LKI$K_BR_LENGTH 56	/* length of list block with byte range info */
#define LKI$C_BR_LENGTH 56
struct lkidef {
    union {
	unsigned long lki$l_mstlkid;	/* lock ID on master */
	unsigned long lki$l_lockid;	/* old symbol */
    } lki$r_u1;
    unsigned long lki$l_pid;		/* process ID */
    union {
	unsigned long lki$l_mstcsid;	/* CSID of master */
	unsigned long lki$l_sysid;	/* old symbol */
    } lki$r_u2;
    unsigned char lki$b_rqmode;		/* request mode */
    unsigned char lki$b_grmode;		/* granted mode */
    char lki$b_queue;			/* lock queue */
    char lki$$$_spare;			/* spare byte */
    union {
	unsigned long lki$l_lkid;	/* lock ID on process node */
	unsigned long lki$l_remlkid;	/* old symbol */
    } lki$r_u3;
    union {
	unsigned long lki$l_csid;	/* CSID of process node */
	unsigned long lki$l_remsysid;	/* old symbol */
    } lki$r_u4;
    unsigned long lki$q_rqstart[2];	/* request range start */
    unsigned long lki$q_rqlength[2];	/* request range length */
    unsigned long lki$q_grstart[2];	/* granted range start */
    unsigned long lki$q_grlength[2];	/* granted range length */
};

/* define namspace fields */
#define LKI$V_SYSNAM	28
#define LKI$M_SYSNAM	(1<<LKI$V_SYSNAM)	/* 0x80000000 */
struct lki$namspace {
    union {
	struct {
	    unsigned short lki$w_group; /* group of owner UIC */
	    unsigned char lki$b_rmod;	/* access mode of request */
	    unsigned char lki$b_status; /* status of resource */
	} lki$r_namspace_fields;
	struct {
	    unsigned		  : 31; /* spare */
	    unsigned lki$v_sysnam : 1;	/* system wide RSB */
	} lki$r_status_bits;
    } lki$r_namspace_union;
};

/* define state fields */
struct lki$statef {
    unsigned char lki$b_state_rqmode;	/* request mode */
    unsigned char lki$b_state_grmode;	/* granted mode */
    char lki$b_state_queue;		/* lock state code */
};

#define LKIUSR$K_LENGTH 20
#define LKIUSR$C_LENGTH 20
#define LKIUSR$K_BLOCKER_START	20	/* offset to the start of the returned information */
struct lkiusrdef {
    unsigned long lkiusr$q_start[2];	/* start of the requested range */
    unsigned long lkiusr$q_length[2];	/* length of the requested range */
    unsigned char lkiusr$b_rqmode;	/* requested mode */
    unsigned char lkiusr$b_ignore_own;	/* flag to ignore locks owned by the calling process */
    unsigned	: 16;			/* short fill; reserved */
};
struct rngdef {
    unsigned long lki$_rng_q_rqstart[2];  /* request range start */
    unsigned long lki$_rng_q_rqlength[2]; /* request range length */
    unsigned long lki$_rng_q_grstart[2];  /* granted range start */
    unsigned long lki$_rng_q_grlength[2]; /* granted range length */
};

/*lock state code values */
#define LKI$C_GRANTED	1	/* granted */
#define LKI$C_CONVERT	0	/* conversion */
#define LKI$C_WAITING	(-1)	/* waiting */
#define LKI$C_RETRY	(-2)	/* retry request */
#define LKI$C_SCSWAIT	(-3)	/* SCS wait */
#define LKI$C_RSPNOTQED (-4)	/* response not queued */
#define LKI$C_RSPQUEUED (-5)	/* response queued */
#define LKI$C_RSPGRANTD (-6)	/* response granted */
#define LKI$C_RSPDOLOCL (-7)	/* response do locally */
#define LKI$C_RSPRESEND (-8)	/* response resend */

/* define table numbers */
#define LKI$C_LKBTYPE	1	/* item in LKB */
#define LKI$C_RSBTYPE	2	/* item in RSB */
#define LKI$C_LISTEND	0	/* define itmlst terminator */

/* item identifiers for LKB */
#define LKI$_PID	256	/* process ID */
#define LKI$_STATE	257	/* current lock state */
#define LKI$_PARENT	258	/* ID of parent lock */
#define LKI$_LCKREFCNT	259	/* sub-lock reference count */
#define LKI$_LOCKID	260	/* lock ID */
#define LKI$_REMLKID	261	/* remote lock ID */
#define LKI$_MSTLKID	262	/* lock ID on resource master */
#define LKI$_LKID	263	/* lock ID on process node */
#define LKI$_CSID	264	/* CSID of process node */
#define LKI$_BRL	265	/* is the lock a byte range lock */
#define LKI$_RANGE	266	/* range of request */
#define LKI$_LASTLKB	267	/* max index in LKB table */

/* item identifiers for RSB */
#define LKI$_NAMSPACE	512	/* resource name space */
#define LKI$_RESNAM	513	/* resource name */
#define LKI$_RSBREFCNT	514	/* sub-resource reference count */
#define LKI$_VALBLK	515	/* value block */
#define LKI$_SYSTEM	516	/* system id of system with resource */
#define LKI$_LCKCOUNT	517	/* count of locks on resource */
#define LKI$_BLOCKEDBY	518	/* list of locks blocked by current lock */
#define LKI$_BLOCKING	519	/* list of locks blocking current lock */
#define LKI$_LOCKS	520	/* list of all locks on resource */
#define LKI$_CVTCOUNT	521	/* count of locks on conversion queue */
#define LKI$_WAITCOUNT	522	/* count of locks on wait queue */
#define LKI$_GRANTCOUNT 523	/* count of locks on grant queue */
#define LKI$_MSTCSID	524	/* CSID of resource master */
#define LKI$_VALBLKST	525	/* value block status */
#define LKI$_BLOCKEDBY_BR 526	/* list of locks blocked by current lock with byte ranges */
#define LKI$_BLOCKING_BR 527	/* list of locks blocking the current lock with byte ranges */
#define LKI$_LOCKS_BR	528	/* list of locks all locks on a resource with byte ranges */
#define LKI$_BLOCKER_BR 529	/* lock that will block the requested range and mode */
#define LKI$_LASTRSB	530	/* max index in RSB */
#define LKISND$K_HDRLEN 16	/* length of header */
#define LKISND$C_HDRLEN 16
/* Format for local system buffer header when sending an information request */
/* to a remote system.							     */
struct lkisnddef {
    unsigned short lkisnd$w_retsize;	/* size of return info */
    unsigned short lkisnd$w_status;	/* status of operation */
    unsigned short lkisnd$w_flags;	/* flags */
    unsigned short lkisnd$w_seqnum;	/* rebuild seqnm */
    unsigned short lkisnd$w_size;	/* size of structure */
    unsigned char lkisnd$b_type;	/* type of stucture */
    unsigned	: 8;			/* unsigned char fill; */
    unsigned char lkisnd$b_item_length; /* len of item info */
    unsigned	: 8;			/* unsigned char fill; */
    unsigned	: 16;			/* unsigned short fill; */
};

#endif	/*_LKIDEF_H*/
