/*
 * $Header: /smsa/bsd:include/sys/text.h:bsd  1.16  $
 * $Source: /smsa/bsd:include/sys/text.h: $
 *
 * Copyright (c) 1988 Acorn Computers Ltd., Cambridge, England
 * 
 */
/* @(#)text.h	1.5 87/06/30 3.2/4.3NFSSRC */
/*
 * Copyright (c) 1982, 1986 Regents of the University of California.
 * All rights reserved.  The Berkeley software License Agreement
 * specifies the terms and conditions for redistribution.
 *
 *	@(#)text.h	7.1 (Berkeley) 6/4/86
 */

#ifndef	__sys_text_h
#define	__sys_text_h

#ifndef __sys_types_h
#include "types.h"
#endif

/*
 * Text structure.
 * One allocated per program image and per shared library.
 * Manipulated by vm_text.c
 */

struct proto
{
    struct vnode  *pr_dvp;	/* vnode of device blocks are mapped on */
    unsigned char  pr_nbppg;	/* number of fs blocks per page */
    unsigned char  pr_fileno;	/* PG_FUNSQUEEZE or PG_FTEXT */
    unsigned short pr_dpages;	/* data size in pages */
    daddr_t 	  *pr_tmap;	/* -> blocks of prototype text */
    daddr_t 	  *pr_dmap;	/* -> blocks of prototype data */
};

struct text
{
	struct	text *x_forw;	/* forward link in free list */
	struct	text **x_back;	/* backward link in free list */
	swblk_t	*x_daddr;	/* swap area addrs of dmtext-block segments */
	struct proto *x_proto;  /* -> prototype disk block map */
	short	x_size;		/* text size (pages) */
	short   x_offset;	/* offset (pages) in process text segment */
	struct proc *x_caddr;	/* ptr to linked proc, if loaded */
	struct vnode *x_vptr;	/* vnode of prototype */
	short	x_rssize;
	short	x_swrss;
	short	x_count;	/* reference count. For main program texts */
				/* this is the number of processes sharing */
				/* this text. For libraries, it is the     */
				/* number of references from other text    */
				/* structs (through x_shlptr).             */
	short	x_ccount;	/* number of loaded references (not used */
				/* for shared library texts).            */
	u_char	x_flag;		/* traced, written flags */
	char	x_slptime;
	u_char	x_poip;		/* page out in progress count */
	u_char	x_liblevel;	/* level of shared library: 0 for most      */
				/* deeply nested. Main text is always given */
				/* level MAXSHLIBS.                         */
	struct text *x_shlptr;	/* pointer to next shared library segment */
	int	x_pginiorate;	/* moving avg of pages/sec in from disc */
};

#ifdef	_KERNEL
struct	text *text, *textNTEXT;
int	ntext;
#endif

#define	XTRC	0x01		/* Text may be written, exclusive use */
#define	XWRIT	0x02		/* Text written into, must swap out */
#define	XLOAD	0x04		/* Currently being read from file */
#define	XLOCK	0x08		/* Being swapped in or out */
#define	XWANT	0x10		/* Wanted for swapping */
#define	XPAGV	0x20		/* Page in on demand from vnode */
#define	XUNUSED	0x40		/* unused since swapped out for cache */
#define XUNSQUEEZE 0x80		/* Text needs unsqueezing after paging in */

/*
 * Text table statistics
 */
struct xstats {
	u_long	alloc;			/* calls to xalloc */
	u_long	alloc_inuse;		/*	found in use/sticky */
	u_long	alloc_cachehit;		/*	found in cache */
	u_long	alloc_cacheflush;	/*	flushed cached text */
	u_long	alloc_unused;		/*	flushed unused cached text */
	u_long	free;			/* calls to xfree */
	u_long	free_inuse;		/*	still in use/sticky */
	u_long	free_cache;		/*	placed in cache */
	u_long	free_cacheswap;		/*	swapped out to place in cache */
};

#endif/*__sys_text_h*/

/* EOF text.h */
