/*
 * $Header: /smsa/bsd:include/arm/pte.h:bsd  1.13  $
 * $Source: /smsa/bsd:include/arm/pte.h: $
 *
 * Copyright (c) 1988 Acorn Computers Ltd., Cambridge, England
 *
 */
/*
 * 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.
 *
 *	@(#)pte.h	7.1 (Berkeley) 6/5/86
 */

#ifndef __arm_pte_h
#define	__arm_pte_h
#define __machine_pte_h		"arm"

#ifndef __machine_values_h
#include "values.h"
#endif
#ifndef __machine_vmparam_h
#include "vmparam.h"
#endif

/*
 * Page table entry (software structure only for ARM)
 */

struct pte
{ unsigned int
    pg_pfnum:9,			/* core page frame number or 0 */
    :14,			/* spare */
    pg_m:1,			/* modified bit */
    pg_fileno:2,		/* file mapped from TEXT, ZERO, or SQUEEZED */
    pg_fod:1,			/* is fill on demand (=0) */
    pg_prot:2,			/* access control */
    pg_copywrite:1,		/* copy on write */
    pg_isfod:1,			/* copy of pg_fod */
    pg_v:1;			/* valid bit */
};
/*
 * Masks for pte fields
 */
#define	PG_V		0x80000000
#define PG_ISFOD	0x40000000
#define PG_COPYWRITE	0x20000000
#define	PG_PROT		0x18000000
#define	PG_FOD		0x04000000
#define PG_FILENO	0x03000000
#define	PG_M		0x00800000
#define	PG_PFNUM	0x000001ff

/*
 * Protection modes for MEMC and ptes.
 */
#define	TO_PROT_FLD(prot)	((prot)<<27)	/* pte protection field	*/
#define	APG_MBO			0x03800000	/* must be one bits	*/

#define	APG_URW			0		/* user read-write	*/
#define	APG_UR			1		/* user read-only	*/
#define	APG_OS			2		/* os access		*/
#define	APG_UNOACC		3		/* no user access	*/

/*
 * Page fault types
 */
#define	DATA_FAULT	0
#define	PREFETCH_FAULT	1

/*
 * Fault is read/write argument to pagein
 */

#define	READ_FLT	1
#define	WRITE_FLT	0

/*
 * Demand fetch types
 */
#define	PG_FZERO	0
#define	PG_FTEXT	1
#define	PG_FUNSQUEEZE	2
#define	PG_FMAX		(PG_FUNSQUEEZE)

/*
 * Access testing macros
 */
/*** beware of side effects (currently none) in vtopte when it is the 
 *** source of the pte in the following macros
 ***/
#define	USER_WRITEABLE(pte)	((pte) && ((pte)->pg_prot == APG_URW))
#define USER_READABLE(pte)	((pte) && ((pte)->pg_prot <= APG_UR))

/*
 * Pte related macros
 */
#define	dirty(pte)	((pte)->pg_fod == 0			&& \
			 (pte)->pg_pfnum			&& \
			 (pte)->pg_m)

#ifdef	_KERNEL

/*
 * Table for setting up MEMC's CAM
 */
extern unsigned char ppntab[];

#endif/*_KERNEL*/

#endif/*__arm_pte_h*/

/* EOF pte.h */
