1 /* 2 * Copyright (c) 1988 University of Utah. 3 * Copyright (c) 1982, 1986, 1990 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. 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) 12/05/90 15 */ 16 17 /* 18 * HP300 page table entry 19 * 20 * There are two major kinds of pte's: those which have ever existed (and are 21 * thus either now in core or on the swap device), and those which have 22 * never existed, but which will be filled on demand at first reference. 23 * There is a structure describing each. There is also an ancillary 24 * structure used in page clustering. 25 */ 26 27 #ifndef LOCORE 28 struct ste 29 { 30 unsigned int sg_pfnum:20, /* page table frame number */ 31 :8, /* reserved at 0 */ 32 :1, /* reserved at 1 */ 33 sg_prot:1, /* write protect bit */ 34 sg_v:2; /* valid bits */ 35 }; 36 37 struct pte 38 { 39 unsigned int pg_pfnum:20, /* page frame number or 0 */ 40 :3, 41 pg_fod:1, /* is fill on demand (=0) */ 42 :1, /* reserved at zero */ 43 pg_ci:1, /* cache inhibit bit */ 44 :1, /* reserved at zero */ 45 pg_m:1, /* hardware modified (dirty) bit */ 46 pg_u:1, /* hardware used (reference) bit */ 47 pg_prot:1, /* write protect bit */ 48 pg_v:2; /* valid bit */ 49 }; 50 51 /* not used */ 52 struct hpte 53 { 54 unsigned int pg_pfnum:20, 55 pg_high:12; /* special for clustering */ 56 }; 57 58 struct fpte 59 { 60 unsigned int pg_blkno:22, /* file system block number */ 61 pg_fileno:1, /* file mapped from or TEXT or ZERO */ 62 pg_fod:1, /* is fill on demand (=1) */ 63 :6, 64 pg_v:2; 65 }; 66 #endif 67 68 #define SG_V 0x00000002 69 #define SG_NV 0x00000000 70 #define SG_PROT 0x00000004 71 #define SG_RO 0x00000004 72 #define SG_RW 0x00000000 73 #define SG_FRAME 0xfffff000 74 #define SG_IMASK 0xffc00000 75 #define SG_PMASK 0x003ff000 76 #define SG_ISHIFT 22 77 #define SG_PSHIFT 12 78 79 #define PG_V 0x00000001 80 #define PG_NV 0x00000000 81 #define PG_PROT 0x00000004 82 #define PG_U 0x00000008 83 #define PG_M 0x00000010 84 #define PG_FOD 0x00000100 85 #define PG_RO 0x00000004 86 #define PG_RW 0x00000000 87 #define PG_FRAME 0xfffff000 88 #define PG_CI 0x00000040 89 #define PG_PFNUM(x) (((x) & PG_FRAME) >> PGSHIFT) 90 91 /* 92 * Pseudo protections. 93 * Note that PG_URKW is not defined intuitively, but it is currently only 94 * used in vgetu() to initialize the u-area PTEs in the process address 95 * space. Since the kernel never accesses the u-area thru these we are ok. 96 */ 97 #define PG_KW PG_RW 98 #define PG_URKR PG_RO 99 #define PG_URKW PG_RO 100 #define PG_UW PG_RW 101 102 #define PG_FZERO 0 103 #define PG_FTEXT 1 104 #define PG_FMAX (PG_FTEXT) 105 106 /* 107 * Pte related macros 108 */ 109 #define dirty(pte) ((pte)->pg_m) 110 111 /* 112 * Kernel virtual address to page table entry and to physical address. 113 */ 114 #define kvtopte(va) (&Sysmap[((unsigned)(va) &~ KERNBASE) >> PGSHIFT]) 115 #define ptetokv(pt) ((((struct pte *)(pt) - Sysmap) << PGSHIFT) | KERNBASE) 116 #define kvtophys(x) ((kvtopte(x)->pg_pfnum << PGSHIFT) | ((int)(x) & PGOFSET)) 117 118 #if defined(KERNEL) && !defined(LOCORE) 119 /* utilities defined in pmap.c */ 120 extern struct pte *Sysmap; 121 #endif /* defined(KERNEL) && !defined(LOCORE) */ 122