/* <secdef.h>
 *
 *	Process or global section definitions
 */
#ifndef _SECDEF_H
#define _SECDEF_H

/*
   ***** L_VBN, L_WINDOW, and B_PFC must be the same offset values as the
   ***** equivalently named offsets in $PFLDEF
 */
#define SEC$V_VPX	0
#define SEC$M_VPX	0x003FFFFF
#define SEC$S_VPX	22
#define SEC$V_PFC	24
#define SEC$M_PFC	0xFF000000
#define SEC$S_PFC	8
#define SEC$V_GBL	0
#define SEC$V_CRF	1
#define SEC$V_DZRO	2
#define SEC$V_WRT	3
#define SEC$V_SHMGS	4
#define SEC$V_WRTMOD	6
#define SEC$S_WRTMOD	2
#define SEC$V_AMOD	8
#define SEC$S_AMOD	8
#define SEC$V_RESIDENT	13
#define SEC$V_PERM	14
#define SEC$V_SYSGBL	15
#define SEC$V_PFNMAP	16
#define SEC$V_EXPREG	17
#define SEC$V_PROTECT	18
#define SEC$V_PAGFIL	19
#define SEC$V_EXECUTE	20
#define SEC$V_NOPROTCHK 21
#define SEC$V_NO_OVERMAP 22
#define SEC$V_INPROG	23
#define SEC$V_PARANOID	24
#define SEC$M_GBL	(1<<SEC$V_GBL)		/* 0x01 */
#define SEC$M_CRF	(1<<SEC$V_CRF)		/* 0x02 */
#define SEC$M_DZRO	(1<<SEC$V_DZRO)		/* 0x04 */
#define SEC$M_WRT	(1<<SEC$V_WRT)		/* 0x08 */
#define SEC$M_SHMGS	(1<<SEC$V_SHMGS)	/* 0x10 */
#define SEC$M_WRTMOD	(3<<SEC$V_WRTMOD)	/* 0xC0 */
#define SEC$M_AMOD	(3<<SEC$V_AMOD)		/* 0x0300 */
#define SEC$M_RESIDENT	(1<<SEC$V_RESIDENT)	/* 0x2000 */
#define SEC$M_PERM	(1<<SEC$V_PERM)		/* 0x4000 */
#define SEC$M_SYSGBL	(1<<SEC$V_SYSGBL)	/* 0x8000 */
#define SEC$M_PFNMAP	(1<<SEC$V_PFNMAP)	/* 0x010000 */
#define SEC$M_EXPREG	(1<<SEC$V_EXPREG)	/* 0x020000 */
#define SEC$M_PROTECT	(1<<SEC$V_PROTECT)	/* 0x040000 */
#define SEC$M_PAGFIL	(1<<SEC$V_PAGFIL)	/* 0x080000 */
#define SEC$M_EXECUTE	(1<<SEC$V_EXECUTE)	/* 0x100000 */
#define SEC$M_NOPROTCHK (1<<SEC$V_NOPROTCHK)	/* 0x200000 */
#define SEC$M_NO_OVERMAP (1<<SEC$V_NO_OVERMAP)	/* 0x400000 */
#define SEC$M_INPROG	(1<<SEC$V_INPROG)	/* 0x800000 */
#define SEC$M_PARANOID	(1<<SEC$V_PARANOID)	/* 0x01000000 */
struct secdef {
    union {
	unsigned long sec$l_gsd;	/* global section descriptor address */
	unsigned long sec$l_ccb;	/* channel control block address if process section */
    } sec$r_gsd_overlay;
    unsigned short sec$w_secxfl;	/* section index forward link */
    unsigned short sec$w_secxbl;	/* section index backward link */
    union {
	unsigned long sec$l_vpxpfc;	/* start virt page index & PFC */
	struct {
	    unsigned sec$v_vpx : 22;	/* starting virtual page index */
	    unsigned	       : 2;	/* unused */
	    unsigned sec$v_pfc : 8;	/* page fault cluster */
	} sec$r_vpxpfc_bits;
	struct {
	    unsigned	: 8, : 8, : 8;	/* char fill[3]; */
	    unsigned char sec$b_pfc;	/* page fault cluster */
	} sec$r_vpxpfc_fields;
    } sec$r_vpxpfc_overlay;
    unsigned long sec$l_window;		/* window control block */
    unsigned long sec$l_vbn;		/* base virtual block number */
    union {
	unsigned short sec$w_flags;	/* various control flags */
	struct {
	    unsigned sec$v_gbl	    : 1; /* global section */
	    unsigned sec$v_crf	    : 1; /* copy on reference */
	    unsigned sec$v_dzro     : 1; /* demand zero */
	    unsigned sec$v_wrt	    : 1; /* writable */
	    unsigned sec$v_shmgs    : 1; /* shared memory global section */
	    unsigned		    : 1; /* spare */
	    unsigned sec$v_wrtmod   : 2; /* write access mode for section */
	    unsigned sec$v_amod     : 2; /* access mode of section */
	    unsigned		    : 3; /* spare */
	    unsigned sec$v_resident : 1; /* resident global */
	    unsigned sec$v_perm     : 1; /* permanent section */
	    unsigned sec$v_sysgbl   : 1; /* 1 = system global, 0 = group global */
/* The following flags are indicators for $MGBLSC and $CRMPSC system */
/* service requests and are not stored in the flags word field.      */
	    unsigned sec$v_pfnmap   : 1; /* map to specific PFN's */
	    unsigned sec$v_expreg   : 1; /* map into first free address space */
	    unsigned sec$v_protect  : 1; /* check write access mode (wrtmod) */
	    unsigned sec$v_pagfil   : 1; /* global section has page file backing store */
	    unsigned sec$v_execute  : 1; /* check for execute access */
	    unsigned sec$v_noprotchk: 1; /* inhibit protection check */
	    unsigned sec$v_no_overmap : 1; /* don't overmap address space */
	    unsigned sec$v_inprog   : 1; /* section creation in progress */
	    unsigned sec$v_paranoid : 1; /* go into paranoia mode */
	    unsigned		    : 7;
	} sec$r_flags_bits;
    } sec$r_flags_overlay;
};
#define SEC$K_LENGTH	32	/* size of pste/gste */
#define SEC$C_LENGTH	32

/* match control vield values */
#define SEC$K_MATALL	0	/* match always, use global section */
#define SEC$K_MATEQU	1	/* match if ISD$L_IDENT EQU GBL ID */
#define SEC$K_MATLEQ	2	/* match if ISD$L_IDENT LEQ GBL ID */
struct secdef1 {
    char secdef1_fill[21];
    unsigned char sec$b_amod;	/* access mode of section */
    unsigned	: 16;		/* short fill; spare */
    unsigned long sec$l_refcnt; /* count of PTE's referencing this section */
    unsigned long sec$l_pagcnt; /* no. of pages in the section */
};

/* definitions for $GETSECI service */
#define SECI$_CHAIN	1	/* chained item block */
#define SECI$_GSMODE	2	/* access mode of section */
#define SECI$_GSFLAGS	3	/* flags */
#define SECI$_GSNAME	4	/* global section name */
#define SECI$_GSIDENT	5	/* global section ident */
#define SECI$_GSRELPAG	6	/* relative page number */

#endif	/*_SECDEF_H*/
