mips3_pte.h revision 1.17 1 1.17 tsutsui /* $NetBSD: mips3_pte.h,v 1.17 2005/09/08 15:11:43 tsutsui Exp $ */
2 1.2 thorpej
3 1.1 jonathan /*
4 1.1 jonathan * Copyright (c) 1992, 1993
5 1.1 jonathan * The Regents of the University of California. All rights reserved.
6 1.16 agc *
7 1.16 agc * This code is derived from software contributed to Berkeley by
8 1.16 agc * the Systems Programming Group of the University of Utah Computer
9 1.16 agc * Science Department and Ralph Campbell.
10 1.16 agc *
11 1.16 agc * Redistribution and use in source and binary forms, with or without
12 1.16 agc * modification, are permitted provided that the following conditions
13 1.16 agc * are met:
14 1.16 agc * 1. Redistributions of source code must retain the above copyright
15 1.16 agc * notice, this list of conditions and the following disclaimer.
16 1.16 agc * 2. Redistributions in binary form must reproduce the above copyright
17 1.16 agc * notice, this list of conditions and the following disclaimer in the
18 1.16 agc * documentation and/or other materials provided with the distribution.
19 1.16 agc * 3. Neither the name of the University nor the names of its contributors
20 1.16 agc * may be used to endorse or promote products derived from this software
21 1.16 agc * without specific prior written permission.
22 1.16 agc *
23 1.16 agc * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 1.16 agc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 1.16 agc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 1.16 agc * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 1.16 agc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 1.16 agc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 1.16 agc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 1.16 agc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 1.16 agc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 1.16 agc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 1.16 agc * SUCH DAMAGE.
34 1.16 agc *
35 1.16 agc * from: Utah Hdr: pte.h 1.11 89/09/03
36 1.16 agc *
37 1.16 agc * from: @(#)pte.h 8.1 (Berkeley) 6/10/93
38 1.16 agc */
39 1.16 agc /*
40 1.16 agc * Copyright (c) 1988 University of Utah.
41 1.1 jonathan *
42 1.1 jonathan * This code is derived from software contributed to Berkeley by
43 1.1 jonathan * the Systems Programming Group of the University of Utah Computer
44 1.1 jonathan * Science Department and Ralph Campbell.
45 1.1 jonathan *
46 1.1 jonathan * Redistribution and use in source and binary forms, with or without
47 1.1 jonathan * modification, are permitted provided that the following conditions
48 1.1 jonathan * are met:
49 1.1 jonathan * 1. Redistributions of source code must retain the above copyright
50 1.1 jonathan * notice, this list of conditions and the following disclaimer.
51 1.1 jonathan * 2. Redistributions in binary form must reproduce the above copyright
52 1.1 jonathan * notice, this list of conditions and the following disclaimer in the
53 1.1 jonathan * documentation and/or other materials provided with the distribution.
54 1.1 jonathan * 3. All advertising materials mentioning features or use of this software
55 1.1 jonathan * must display the following acknowledgement:
56 1.1 jonathan * This product includes software developed by the University of
57 1.1 jonathan * California, Berkeley and its contributors.
58 1.1 jonathan * 4. Neither the name of the University nor the names of its contributors
59 1.1 jonathan * may be used to endorse or promote products derived from this software
60 1.1 jonathan * without specific prior written permission.
61 1.1 jonathan *
62 1.1 jonathan * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
63 1.1 jonathan * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
64 1.1 jonathan * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
65 1.1 jonathan * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
66 1.1 jonathan * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
67 1.1 jonathan * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
68 1.1 jonathan * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
69 1.1 jonathan * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
70 1.1 jonathan * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
71 1.1 jonathan * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
72 1.1 jonathan * SUCH DAMAGE.
73 1.1 jonathan *
74 1.1 jonathan * from: Utah Hdr: pte.h 1.11 89/09/03
75 1.1 jonathan *
76 1.1 jonathan * from: @(#)pte.h 8.1 (Berkeley) 6/10/93
77 1.1 jonathan */
78 1.1 jonathan
79 1.1 jonathan /*
80 1.1 jonathan * R4000 hardware page table entry
81 1.1 jonathan */
82 1.1 jonathan
83 1.3 jonathan #ifndef _LOCORE
84 1.7 jonathan struct mips3_pte {
85 1.1 jonathan #if BYTE_ORDER == BIG_ENDIAN
86 1.1 jonathan unsigned int pg_prot:2, /* SW: access control */
87 1.1 jonathan pg_pfnum:24, /* HW: core page frame number or 0 */
88 1.1 jonathan pg_attr:3, /* HW: cache attribute */
89 1.9 nisimura pg_m:1, /* HW: dirty bit */
90 1.1 jonathan pg_v:1, /* HW: valid bit */
91 1.9 nisimura pg_g:1; /* HW: ignore asid bit */
92 1.1 jonathan #endif
93 1.1 jonathan #if BYTE_ORDER == LITTLE_ENDIAN
94 1.9 nisimura unsigned int pg_g:1, /* HW: ignore asid bit */
95 1.1 jonathan pg_v:1, /* HW: valid bit */
96 1.9 nisimura pg_m:1, /* HW: dirty bit */
97 1.9 nisimura pg_attr:3, /* HW: cache attribute */
98 1.1 jonathan pg_pfnum:24, /* HW: core page frame number or 0 */
99 1.1 jonathan pg_prot:2; /* SW: access control */
100 1.1 jonathan #endif
101 1.1 jonathan };
102 1.1 jonathan
103 1.1 jonathan /*
104 1.1 jonathan * Structure defining an tlb entry data set.
105 1.1 jonathan */
106 1.1 jonathan
107 1.1 jonathan struct tlb {
108 1.1 jonathan int tlb_mask;
109 1.14 simonb int tlb_hi; /* XXX should be 64 bits */
110 1.14 simonb int tlb_lo0; /* XXX maybe 64 bits (only 32 really used) */
111 1.14 simonb int tlb_lo1; /* XXX maybe 64 bits (only 32 really used) */
112 1.1 jonathan };
113 1.3 jonathan #endif /* _LOCORE */
114 1.1 jonathan
115 1.7 jonathan #define MIPS3_PG_WIRED 0x80000000 /* SW */
116 1.7 jonathan #define MIPS3_PG_RO 0x40000000 /* SW */
117 1.1 jonathan
118 1.7 jonathan #define MIPS3_PG_SVPN 0xfffff000 /* Software page no mask */
119 1.7 jonathan #define MIPS3_PG_HVPN 0xffffe000 /* Hardware page no mask */
120 1.7 jonathan #define MIPS3_PG_ODDPG 0x00001000 /* Odd even pte entry */
121 1.7 jonathan #define MIPS3_PG_ASID 0x000000ff /* Address space ID */
122 1.7 jonathan #define MIPS3_PG_G 0x00000001 /* Global; ignore ASID if in lo0 & lo1 */
123 1.7 jonathan #define MIPS3_PG_V 0x00000002 /* Valid */
124 1.7 jonathan #define MIPS3_PG_NV 0x00000000
125 1.9 nisimura #define MIPS3_PG_D 0x00000004 /* Dirty */
126 1.7 jonathan #define MIPS3_PG_ATTR 0x0000003f
127 1.14 simonb
128 1.14 simonb #define MIPS3_CCA_TO_PG(cca) ((cca) << 3)
129 1.14 simonb
130 1.14 simonb #define MIPS3_PG_UNCACHED MIPS3_CCA_TO_PG(2)
131 1.10 shin #ifdef HPCMIPS_L1CACHE_DISABLE /* MIPS3_L1CACHE_DISABLE */
132 1.14 simonb #define MIPS3_PG_CACHED MIPS3_PG_UNCACHED /* XXX: brain damaged!!! */
133 1.10 shin #else /* HPCMIPS_L1CACHE_DISABLE */
134 1.14 simonb #define MIPS3_PG_CACHED mips3_pg_cached
135 1.14 simonb #define MIPS3_DEFAULT_PG_CACHED MIPS3_CCA_TO_PG(3)
136 1.10 shin #endif /* ! HPCMIPS_L1CACHE_DISABLE */
137 1.14 simonb #define MIPS3_PG_CACHEMODE MIPS3_CCA_TO_PG(7)
138 1.14 simonb
139 1.7 jonathan /* Write protected */
140 1.7 jonathan #define MIPS3_PG_ROPAGE (MIPS3_PG_V | MIPS3_PG_RO | MIPS3_PG_CACHED)
141 1.7 jonathan
142 1.7 jonathan /* Not wr-prot not clean */
143 1.9 nisimura #define MIPS3_PG_RWPAGE (MIPS3_PG_V | MIPS3_PG_D | MIPS3_PG_CACHED)
144 1.7 jonathan
145 1.7 jonathan /* Not wr-prot but clean */
146 1.7 jonathan #define MIPS3_PG_CWPAGE (MIPS3_PG_V | MIPS3_PG_CACHED)
147 1.14 simonb #define MIPS3_PG_IOPAGE(cca) \
148 1.14 simonb (MIPS3_PG_G | MIPS3_PG_V | MIPS3_PG_D | MIPS3_CCA_TO_PG(cca))
149 1.7 jonathan #define MIPS3_PG_FRAME 0x3fffffc0
150 1.10 shin #ifdef MIPS3_4100 /* VR4100 core */
151 1.10 shin #define MIPS3_PG_SHIFT 4
152 1.10 shin #else
153 1.7 jonathan #define MIPS3_PG_SHIFT 6
154 1.10 shin #endif
155 1.4 jonathan
156 1.4 jonathan /* pte accessor macros */
157 1.4 jonathan
158 1.8 jonathan #define mips3_pfn_is_ext(x) ((x) & 0x3c000000)
159 1.13 soda #define mips3_paddr_to_tlbpfn(x) \
160 1.13 soda (((paddr_t)(x) >> MIPS3_PG_SHIFT) & MIPS3_PG_FRAME)
161 1.13 soda #define mips3_tlbpfn_to_paddr(x) \
162 1.13 soda ((paddr_t)((x) & MIPS3_PG_FRAME) << MIPS3_PG_SHIFT)
163 1.12 soda #define mips3_vad_to_vpn(x) ((vaddr_t)(x) & MIPS3_PG_SVPN)
164 1.7 jonathan #define mips3_vpn_to_vad(x) ((x) & MIPS3_PG_SVPN)
165 1.4 jonathan
166 1.13 soda #define MIPS3_PTE_TO_PADDR(pte) (mips3_tlbpfn_to_paddr(pte))
167 1.7 jonathan #define MIPS3_PAGE_IS_RDONLY(pte,va) \
168 1.5 jonathan (pmap_is_page_ro(pmap_kernel(), mips_trunc_page(va), (pte)))
169 1.5 jonathan
170 1.4 jonathan
171 1.7 jonathan #define MIPS3_PG_SIZE_4K 0x00000000
172 1.7 jonathan #define MIPS3_PG_SIZE_16K 0x00006000
173 1.7 jonathan #define MIPS3_PG_SIZE_64K 0x0001e000
174 1.7 jonathan #define MIPS3_PG_SIZE_256K 0x0007e000
175 1.7 jonathan #define MIPS3_PG_SIZE_1M 0x001fe000
176 1.7 jonathan #define MIPS3_PG_SIZE_4M 0x007fe000
177 1.7 jonathan #define MIPS3_PG_SIZE_16M 0x01ffe000
178 1.15 simonb #define MIPS3_PG_SIZE_64M 0x07ffe000
179 1.15 simonb #define MIPS3_PG_SIZE_256M 0x1fffe000
180 1.17 tsutsui
181 1.17 tsutsui /* NEC Vr41xx uses different pagemask values. */
182 1.17 tsutsui #define MIPS4100_PG_SIZE_1K 0x00000000
183 1.17 tsutsui #define MIPS4100_PG_SIZE_4K 0x00001800
184 1.17 tsutsui #define MIPS4100_PG_SIZE_16K 0x00007800
185 1.17 tsutsui #define MIPS4100_PG_SIZE_64K 0x0001f800
186 1.17 tsutsui #define MIPS4100_PG_SIZE_256K 0x0007f800
187