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