2 * Copyright (c) 1997 Berkeley Software Design, Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * 3. Berkeley Software Design Inc's name may not be used to endorse or
13 * promote products derived from this software without specific prior
16 * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN INC ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN INC BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * from: BSDI: pmap.v9.h,v 1.10.2.6 1999/08/23 22:18:44 cp Exp
32 #ifndef _MACHINE_TTE_H_
33 #define _MACHINE_TTE_H_
37 #define TD_SIZE_SHIFT (61)
38 #define TD_SOFT2_SHIFT (50)
39 #define TD_RSVD2_SHIFT (49)
40 #define TD_SIZE2_SHIFT (48)
41 #define TD_DIAG_SF_SHIFT (41)
42 #define TD_RSVD_CH_SHIFT (43)
43 #define TD_RSVD_OC_SHIFT (47)
44 #define TD_RSVD_PT_SHIFT TD_RSVD_CH_SHIFT
45 #define TD_RSVD_VE_SHIFT (41)
46 #define TD_PA_SHIFT (13)
47 #define TD_SOFT_SHIFT (7)
49 #define TD_SIZE_BITS (2)
50 #define TD_SOFT2_BITS (9)
51 #define TD_RSVD2_BITS (1) /* US-IV+, SPARC64 VI, VII, VIIIfx */
52 #define TD_SIZE2_BITS (1) /* US-IV+, SPARC64 VI, VII, VIIIfx */
53 #define TD_DIAG_SF_BITS (9) /* US-I, II{,e,i} */
54 #define TD_RSVD_CH_BITS (7) /* US-III{,i,+}, US-IV, SPARC64 V */
55 #define TD_RSVD_OC_BITS (1) /* SPARC64 VI, VII */
56 #define TD_RSVD_PT_BITS (5) /* US-IV+, SPARC64 VI, VII */
57 #define TD_RSVD_VE_BITS (7) /* SPARC64 VIIIfx */
58 #define TD_PA_CH_BITS (30) /* US-III{,i,+}, US-IV{,+}, SPARC64 V */
59 #define TD_PA_OC_BITS (34) /* SPARC64 VI, VII */
60 #define TD_PA_SF_BITS (28) /* US-I, II{,e,i}, SPARC64 VIIIfx */
61 #define TD_PA_BITS TD_PA_CH_BITS
62 #define TD_SOFT_BITS (6)
64 #define TD_SIZE_MASK ((1UL << TD_SIZE_BITS) - 1)
65 #define TD_SOFT2_MASK ((1UL << TD_SOFT2_BITS) - 1)
66 #define TD_RSVD2_MASK ((1UL << TD_RSVD2_BITS) - 1)
67 #define TD_SIZE2_MASK ((1UL << TD_SIZE2_BITS) - 1)
68 #define TD_DIAG_SF_MASK ((1UL << TD_DIAG_SF_BITS) - 1)
69 #define TD_RSVD_CH_MASK ((1UL << TD_RSVD_CH_BITS) - 1)
70 #define TD_RSVD_OC_MASK ((1UL << TD_RSVD_OC_BITS) - 1)
71 #define TD_RSVD_PT_MASK ((1UL << TD_RSVD_PT_BITS) - 1)
72 #define TD_RSVD_VE_MASK ((1UL << TD_RSVD_VE_BITS) - 1)
73 #define TD_PA_CH_MASK ((1UL << TD_PA_CH_BITS) - 1)
74 #define TD_PA_OC_MASK ((1UL << TD_PA_OC_BITS) - 1)
75 #define TD_PA_SF_MASK ((1UL << TD_PA_SF_BITS) - 1)
76 #define TD_PA_MASK ((1UL << TD_PA_BITS) - 1)
77 #define TD_SOFT_MASK ((1UL << TD_SOFT_BITS) - 1)
83 #define TS_32M (4UL) /* US-IV+, SPARC64 VI, VII only */
84 #define TS_256M (5UL) /* US-IV+, SPARC64 VI, VII only */
85 #define TS_2G (6UL) /* SPARC64 VIIIfx only */
90 #define TD_V (1UL << 63)
91 #define TD_8K (TS_8K << TD_SIZE_SHIFT)
92 #define TD_64K (TS_64K << TD_SIZE_SHIFT)
93 #define TD_512K (TS_512K << TD_SIZE_SHIFT)
94 #define TD_4M (TS_4M << TD_SIZE_SHIFT)
96 (((TS_32M & TD_SIZE_MASK) << TD_SIZE_SHIFT) | \
97 (TD_SIZE2_MASK << TD_SIZE2_SHIFT))
99 (((TS_256M & TD_SIZE_MASK) << TD_SIZE_SHIFT) | \
100 (TD_SIZE2_MASK << TD_SIZE2_SHIFT))
102 (((TS_2G & TD_SIZE_MASK) << TD_SIZE_SHIFT) | \
103 (TD_SIZE2_MASK << TD_SIZE2_SHIFT))
104 #define TD_NFO (1UL << 60)
105 #define TD_IE (1UL << 59)
106 #define TD_PA(pa) ((pa) & (TD_PA_MASK << TD_PA_SHIFT))
107 /* NOTE: bit 6 of TD_SOFT will be sign-extended if used as an immediate. */
108 #define TD_FAKE ((1UL << 5) << TD_SOFT_SHIFT)
109 #define TD_EXEC ((1UL << 4) << TD_SOFT_SHIFT)
110 #define TD_REF ((1UL << 3) << TD_SOFT_SHIFT)
111 #define TD_PV ((1UL << 2) << TD_SOFT_SHIFT)
112 #define TD_SW ((1UL << 1) << TD_SOFT_SHIFT)
113 #define TD_WIRED ((1UL << 0) << TD_SOFT_SHIFT)
114 #define TD_L (1UL << 6)
115 #define TD_CP (1UL << 5)
116 #define TD_CV (1UL << 4)
117 #define TD_E (1UL << 3)
118 #define TD_P (1UL << 2)
119 #define TD_W (1UL << 1)
120 #define TD_G (1UL << 0)
122 #define TV_SIZE_BITS (TD_SIZE_BITS)
123 #define TV_VPN(va, sz) ((((va) >> TTE_PAGE_SHIFT(sz)) << TV_SIZE_BITS) | sz)
125 #define TTE_SIZE_SPREAD (3)
126 #define TTE_PAGE_SHIFT(sz) \
127 (PAGE_SHIFT + ((sz) * TTE_SIZE_SPREAD))
129 #define TTE_GET_SIZE(tp) \
130 (((tp)->tte_data >> TD_SIZE_SHIFT) & TD_SIZE_MASK)
131 #define TTE_GET_PAGE_SHIFT(tp) \
132 TTE_PAGE_SHIFT(TTE_GET_SIZE(tp))
133 #define TTE_GET_PAGE_SIZE(tp) \
134 (1 << TTE_GET_PAGE_SHIFT(tp))
135 #define TTE_GET_PAGE_MASK(tp) \
136 (TTE_GET_PAGE_SIZE(tp) - 1)
138 #define TTE_GET_PA(tp) \
139 ((tp)->tte_data & (TD_PA_MASK << TD_PA_SHIFT))
140 #define TTE_GET_VPN(tp) \
141 ((tp)->tte_vpn >> TV_SIZE_BITS)
142 #define TTE_GET_VA(tp) \
143 (TTE_GET_VPN(tp) << TTE_GET_PAGE_SHIFT(tp))
144 #define TTE_GET_PMAP(tp) \
145 (((tp)->tte_data & TD_P) != 0 ? (kernel_pmap) : \
146 (PHYS_TO_VM_PAGE(pmap_kextract((vm_offset_t)(tp)))->md.pmap))
147 #define TTE_ZERO(tp) \
148 memset(tp, 0, sizeof(*tp))
155 TAILQ_ENTRY(tte
) tte_link
;
159 tte_match(struct tte
*tp
, vm_offset_t va
)
162 return (((tp
->tte_data
& TD_V
) != 0) &&
163 (tp
->tte_vpn
== TV_VPN(va
, TTE_GET_SIZE(tp
))));
166 #endif /* !_MACHINE_TTE_H_ */