pte.h revision 1.19.6.2 1 1.19.6.2 nathanw /* $NetBSD: pte.h,v 1.19.6.2 2002/10/18 02:40:31 nathanw Exp $ */
2 1.19.6.2 nathanw
3 1.19.6.2 nathanw /*
4 1.19.6.2 nathanw * Copyright (c) 1994 Ludd, University of Lule}, Sweden.
5 1.19.6.2 nathanw * All rights reserved.
6 1.19.6.2 nathanw *
7 1.19.6.2 nathanw * Redistribution and use in source and binary forms, with or without
8 1.19.6.2 nathanw * modification, are permitted provided that the following conditions
9 1.19.6.2 nathanw * are met:
10 1.19.6.2 nathanw * 1. Redistributions of source code must retain the above copyright
11 1.19.6.2 nathanw * notice, this list of conditions and the following disclaimer.
12 1.19.6.2 nathanw * 2. Redistributions in binary form must reproduce the above copyright
13 1.19.6.2 nathanw * notice, this list of conditions and the following disclaimer in the
14 1.19.6.2 nathanw * documentation and/or other materials provided with the distribution.
15 1.19.6.2 nathanw * 3. All advertising materials mentioning features or use of this software
16 1.19.6.2 nathanw * must display the following acknowledgement:
17 1.19.6.2 nathanw * This product includes software developed at Ludd, University of Lule}.
18 1.19.6.2 nathanw * 4. The name of the author may not be used to endorse or promote products
19 1.19.6.2 nathanw * derived from this software without specific prior written permission
20 1.19.6.2 nathanw *
21 1.19.6.2 nathanw * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 1.19.6.2 nathanw * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 1.19.6.2 nathanw * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 1.19.6.2 nathanw * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 1.19.6.2 nathanw * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 1.19.6.2 nathanw * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 1.19.6.2 nathanw * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 1.19.6.2 nathanw * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 1.19.6.2 nathanw * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 1.19.6.2 nathanw * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 1.19.6.2 nathanw */
32 1.19.6.2 nathanw
33 1.19.6.2 nathanw #ifndef _VAX_PTE_H_
34 1.19.6.2 nathanw #define _VAX_PTE_H_
35 1.19.6.2 nathanw
36 1.19.6.2 nathanw #ifndef _LOCORE
37 1.19.6.2 nathanw /*
38 1.19.6.2 nathanw * VAX page table entries
39 1.19.6.2 nathanw */
40 1.19.6.2 nathanw struct pte {
41 1.19.6.2 nathanw unsigned int pg_pfn:21; /* Page Frame Number or 0 */
42 1.19.6.2 nathanw unsigned int pg_illegal:2; /* Don't use this bits */
43 1.19.6.2 nathanw unsigned int pg_sref:1; /* Help for ref simulation */
44 1.19.6.2 nathanw unsigned int pg_w:1; /* Wired bit */
45 1.19.6.2 nathanw unsigned int pg_z:1; /* Zero DIGITAL = 0 */
46 1.19.6.2 nathanw unsigned int pg_m:1; /* Modify DIGITAL */
47 1.19.6.2 nathanw unsigned int pg_prot:4; /* reserved at zero */
48 1.19.6.2 nathanw unsigned int pg_v:1; /* valid bit */
49 1.19.6.2 nathanw };
50 1.19.6.2 nathanw
51 1.19.6.2 nathanw
52 1.19.6.2 nathanw typedef struct pte pt_entry_t; /* Mach page table entry */
53 1.19.6.2 nathanw
54 1.19.6.2 nathanw #endif /* _LOCORE */
55 1.19.6.2 nathanw
56 1.19.6.2 nathanw #define PG_V 0x80000000
57 1.19.6.2 nathanw #define PG_NV 0x00000000
58 1.19.6.2 nathanw #define PG_PROT 0x78000000
59 1.19.6.2 nathanw #define PG_RW 0x20000000
60 1.19.6.2 nathanw #define PG_KW 0x10000000
61 1.19.6.2 nathanw #define PG_KR 0x18000000
62 1.19.6.2 nathanw #define PG_URKW 0x70000000
63 1.19.6.2 nathanw #define PG_RO 0x78000000
64 1.19.6.2 nathanw #define PG_NONE 0x00000000
65 1.19.6.2 nathanw #define PG_M 0x04000000
66 1.19.6.2 nathanw #define PG_W 0x01000000
67 1.19.6.2 nathanw #define PG_SREF 0x00800000
68 1.19.6.2 nathanw #define PG_ILLEGAL 0x00600000
69 1.19.6.2 nathanw #define PG_FRAME 0x001fffff
70 1.19.6.2 nathanw #define PG_PFNUM(x) (((unsigned long)(x) & 0x3ffffe00) >> VAX_PGSHIFT)
71 1.19.6.2 nathanw
72 1.19.6.2 nathanw #ifndef _LOCORE
73 1.19.6.2 nathanw extern pt_entry_t *Sysmap;
74 1.19.6.2 nathanw /*
75 1.19.6.2 nathanw * Kernel virtual address to page table entry and to physical address.
76 1.19.6.2 nathanw */
77 1.19.6.2 nathanw #endif
78 1.19.6.2 nathanw
79 1.19.6.2 nathanw #ifdef __ELF__
80 1.19.6.2 nathanw #define VAX_SYSMAP "Sysmap"
81 1.19.6.2 nathanw #else
82 1.19.6.2 nathanw #define VAX_SYSMAP "_Sysmap"
83 1.19.6.2 nathanw #endif
84 1.19.6.2 nathanw
85 1.19.6.2 nathanw #ifdef __GNUC__
86 1.19.6.2 nathanw #define kvtopte(va) ({ \
87 1.19.6.2 nathanw struct pte *r; \
88 1.19.6.2 nathanw asm("extzv $9,$21,%1,%0;moval *" VAX_SYSMAP "[%0],%0" : "=r"(r) : "g"(va)); \
89 1.19.6.2 nathanw r; \
90 1.19.6.2 nathanw })
91 1.19.6.2 nathanw #define kvtophys(va) ({ \
92 1.19.6.2 nathanw paddr_t r; \
93 1.19.6.2 nathanw asm("extzv $9,$21,%1,%0;ashl $9,*" VAX_SYSMAP "[%0],%0;insv %1,$0,$9,%0" \
94 1.19.6.2 nathanw : "=&r"(r) : "g"(va) : "cc"); \
95 1.19.6.2 nathanw r; \
96 1.19.6.2 nathanw })
97 1.19.6.2 nathanw #else /* __GNUC__ */
98 1.19.6.2 nathanw #define kvtophys(va) \
99 1.19.6.2 nathanw (((kvtopte(va))->pg_pfn << VAX_PGSHIFT) | ((paddr_t)(va) & VAX_PGOFSET))
100 1.19.6.2 nathanw #define kvtopte(va) (&Sysmap[PG_PFNUM(va)])
101 1.19.6.2 nathanw #endif /* __GNUC__ */
102 1.19.6.2 nathanw #define uvtopte(va, pcb) \
103 1.19.6.2 nathanw (((vaddr_t)va < 0x40000000) ? \
104 1.19.6.2 nathanw &(((pcb)->P0BR)[PG_PFNUM(va)]) : \
105 1.19.6.2 nathanw &(((pcb)->P1BR)[PG_PFNUM(va)]))
106 1.19.6.2 nathanw
107 1.19.6.2 nathanw #endif
108