/*
 * $Header: /smsa/bsd:include/sys/cmap.h:bsd  1.16  $
 * $Source: /smsa/bsd:include/sys/cmap.h: $
 *
 * Copyright (c) 1988 Acorn Computers Ltd., Cambridge, England
 *
 */
/* @(#)cmap.h	1.5 87/07/09 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.
 *
 *	@(#)cmap.h	7.1 (Berkeley) 6/4/86
 */

#ifndef	__sys_cmap_h
#define	__sys_cmap_h

#ifndef	__machine_vmparam_h
#include "../machine/vmparam.h"
#endif

/*
 * core map entry
 *
 * Limits imposed by this structure:
 *
 *		limit		     cur. size		fields
 *	Physical memory			16   Mb 	c_next, c_prev, c_hlink
 *	size of a process segment	32   Mb		c_page
 *	filesystem size			2048 Gb		c_blkno
 *	proc, text table size		255		c_ndx
 *
 * Note: memory can be expanded by converting first three entries
 *	to larger bit fields. Pte's in <arm/pte.h> also need changing.
 *      Proc structure limit can be enlarged, reduce packing to byte boundary.
 */

struct cmap
{
unsigned int 	c_next:9,	/* index of next free list entry */
		c_prev:9,	/* index of previous free list entry */
		c_hlink:9,	/* hash link for <blkno,mdev> */
		c_lock:1,	/* locked for raw i/o or pagein */
		c_want:1,	/* wanted */
		c_intrans:1,	/* intransit bit */
		c_free:1,	/* on the free list */
		c_gone:1;	/* associated page has been released */
unsigned int	c_page:10,	/* virtual page number in segment */
		:6,		/* to byte boundary */
		c_ndx:8,	/* index of owner proc or text */
		:5,		/* padding to align end of c_type */
		c_type:3;	/* type CSYS, CTEXT, CSTACK, CDATA or CSHM */
daddr_t		c_blkno;	/* disk block this is a copy of */
struct vnode	*c_vp;          /* vnode to which c_blkno refers */
};

#ifdef	_KERNEL
extern struct cmap *cmap, *ecmap;
extern struct cmap *mfind();
extern int munhash(), munhashany();
#endif	_KERNEL

/* bits defined in c_type */

#define	CSYS		0		/* none of below */
#define	CTEXT		1		/* belongs to shared text segment */
#define	CDATA		2		/* belongs to data segment */
#define	CSTACK		3		/* belongs to stack segment */
#define CSHM		4		/* belongs to shared memory segment */

/*
 * Core map handling is now complicated a little because of the way
 * DMA memory is allocated.  Note that in the following macros CLSIZE
 * has been omitted from the calculation and is assumed to equal 1.
 */
extern int lowfreepgoffset, highfreepgoffset, highfreepgcount;

#define	pgtocm(x)	((x) < DMA_PAGES ? (x) + lowfreepgoffset \
			 		 : (x) + highfreepgoffset)
#define	cmtopg(x)	((x) <= highfreepgcount ? (x) - highfreepgoffset \
						: (x) - lowfreepgoffset)
#endif/*__sys_cmap_h*/

/* EOF cmap.h */
