xref: /csrg-svn/sys/pmax/include/pte.h (revision 52119)
1*52119Smckusick /*
2*52119Smckusick  * Copyright (c) 1988 University of Utah.
3*52119Smckusick  * Copyright (c) 1992 The Regents of the University of California.
4*52119Smckusick  * All rights reserved.
5*52119Smckusick  *
6*52119Smckusick  * This code is derived from software contributed to Berkeley by
7*52119Smckusick  * the Systems Programming Group of the University of Utah Computer
8*52119Smckusick  * Science Department and Ralph Campbell.
9*52119Smckusick  *
10*52119Smckusick  * %sccs.include.redist.c%
11*52119Smckusick  *
12*52119Smckusick  * from: Utah $Hdr: pte.h 1.11 89/09/03$
13*52119Smckusick  *
14*52119Smckusick  *	@(#)pte.h	7.1 (Berkeley) 01/07/92
15*52119Smckusick  */
16*52119Smckusick 
17*52119Smckusick /*
18*52119Smckusick  * R2000 hardware page table entry
19*52119Smckusick  */
20*52119Smckusick 
21*52119Smckusick #ifndef LOCORE
22*52119Smckusick struct pte {
23*52119Smckusick #if BYTE_ORDER == BIG_ENDIAN
24*52119Smckusick unsigned int	pg_pfnum:20,		/* HW: core page frame number or 0 */
25*52119Smckusick 		pg_n:1,			/* HW: non-cacheable bit */
26*52119Smckusick 		pg_m:1,			/* HW: modified (dirty) bit */
27*52119Smckusick 		pg_v:1,			/* HW: valid bit */
28*52119Smckusick 		pg_g:1,			/* HW: ignore pid bit */
29*52119Smckusick 		:4,
30*52119Smckusick 		pg_swapm:1,		/* SW: page must be forced to swap */
31*52119Smckusick 		pg_fod:1,		/* SW: is fill on demand (=0) */
32*52119Smckusick 		pg_prot:2;		/* SW: access control */
33*52119Smckusick #endif
34*52119Smckusick #if BYTE_ORDER == LITTLE_ENDIAN
35*52119Smckusick unsigned int	pg_prot:2,		/* SW: access control */
36*52119Smckusick 		pg_fod:1,		/* SW: is fill on demand (=0) */
37*52119Smckusick 		pg_swapm:1,		/* SW: page must be forced to swap */
38*52119Smckusick 		:4,
39*52119Smckusick 		pg_g:1,			/* HW: ignore pid bit */
40*52119Smckusick 		pg_v:1,			/* HW: valid bit */
41*52119Smckusick 		pg_m:1,			/* HW: modified (dirty) bit */
42*52119Smckusick 		pg_n:1,			/* HW: non-cacheable bit */
43*52119Smckusick 		pg_pfnum:20;		/* HW: core page frame number or 0 */
44*52119Smckusick #endif
45*52119Smckusick };
46*52119Smckusick 
47*52119Smckusick typedef union {
48*52119Smckusick 	unsigned int	pt_entry;	/* for copying, etc. */
49*52119Smckusick 	struct pte	pt_pte;		/* for getting to bits by name */
50*52119Smckusick } pt_entry_t;	/* Mach page table entry */
51*52119Smckusick #endif /* LOCORE */
52*52119Smckusick 
53*52119Smckusick #define	PT_ENTRY_NULL	((pt_entry_t *) 0)
54*52119Smckusick 
55*52119Smckusick #define	PG_PROT		0x00000003
56*52119Smckusick #define PG_RW		0x00000000
57*52119Smckusick #define PG_RO		0x00000001
58*52119Smckusick #define PG_WIRED	0x00000002
59*52119Smckusick #define	PG_G		0x00000100
60*52119Smckusick #define	PG_V		0x00000200
61*52119Smckusick #define	PG_NV		0x00000000
62*52119Smckusick #define	PG_M		0x00000400
63*52119Smckusick #define	PG_N		0x00000800
64*52119Smckusick #define	PG_FRAME	0xfffff000
65*52119Smckusick #define PG_SHIFT	12
66*52119Smckusick #define	PG_PFNUM(x)	(((x) & PG_FRAME) >> PG_SHIFT)
67*52119Smckusick 
68*52119Smckusick /*
69*52119Smckusick  * Kernel virtual address to page table entry and to physical address.
70*52119Smckusick  */
71*52119Smckusick #define	kvtopte(va) \
72*52119Smckusick 	((pt_entry_t *)PMAP_HASH_KADDR + \
73*52119Smckusick 	(((vm_offset_t)(va) - VM_MIN_KERNEL_ADDRESS) >> PGSHIFT))
74*52119Smckusick #define	ptetokv(pte) \
75*52119Smckusick 	((((pt_entry_t *)(pte) - PMAP_HASH_KADDR) << PGSHIFT) + \
76*52119Smckusick 	VM_MIN_KERNEL_ADDRESS)
77*52119Smckusick #define	kvtophys(va) \
78*52119Smckusick 	((kvtopte(va)->pt_entry & PG_FRAME) | ((unsigned)(va) & PGOFSET))
79