Print this page
de-linting of .s files
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/sfmmu/ml/sfmmu_kdi.s
+++ new/usr/src/uts/sfmmu/ml/sfmmu_kdi.s
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
↓ open down ↓ |
16 lines elided |
↑ open up ↑ |
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 */
26 26
27 -#if !defined(lint)
28 27 #include <sys/asm_linkage.h>
29 28 #include "assym.h"
30 -#endif
31 29
32 30 #include <sys/sun4asi.h>
33 31 #include <sys/machparam.h>
34 32 #include <vm/hat_sfmmu.h>
35 33
36 34 /*
37 35 * This file contains a kmdb-support function which retrieves the TTE for a
38 36 * given VA/context pair, and returns it to the caller if the TTE is valid.
39 37 * The code here is essentially an assembly implementation of the unix-tte
40 38 * word used to allow OBP to do the same thing.
41 39 *
42 40 * Depending on the invocation context, the translator may be invoked either
43 41 * as a normal function (kdi_vatotte) or as a trap handler fragment
44 42 * (kdi_trap_vatotte).
45 43 */
46 44
47 45 /*
48 46 * uint64_t
49 47 * kdi_hme_hash_function(sfmmu_t *sfmmup, uintptr_t va, uint_t hmeshift)
50 48 * {
51 49 * uintptr_t hash = (uintptr_t)sfmmup ^ (va >> hmeshift);
52 50 *
53 51 * if (sfmmup == KHATID) {
54 52 * return (khme_hash_pa + (hash & KHMEHASH_SZ) *
55 53 * sizeof (struct hmehash_bucket));
56 54 * } else {
57 55 * return (uhme_hash_pa + (hash & UHMEHASH_SZ) *
58 56 * sizeof (struct hmehash_bucket));
59 57 * }
60 58 * }
61 59 */
62 60
63 61 /*
64 62 * Parameters: %g1: VA, %g2: sfmmup, %g4: hmeshift
65 63 * Scratch: %g4, %g5, %g6 available
66 64 * Return: Hash value in %g4
67 65 */
68 66
69 67 #define KDI_HME_HASH_FUNCTION \
70 68 srlx %g1, %g4, %g4; /* va >> hmeshift */ \
71 69 xor %g4, %g2, %g4; /* hash in g4 */ \
72 70 set KHATID, %g5; \
73 71 ldx [%g5], %g5; \
74 72 cmp %g2, %g5; \
75 73 be %xcc, is_khat; \
76 74 nop; \
77 75 \
78 76 /* sfmmup != KHATID */ \
79 77 set UHMEHASH_SZ, %g5; \
80 78 ld [%g5], %g5; \
81 79 and %g4, %g5, %g4; \
82 80 mulx %g4, HMEBUCK_SIZE, %g4; /* g4 = off from hash_pa */ \
83 81 set uhme_hash_pa, %g5; \
84 82 ldx [%g5], %g5; \
85 83 ba hash_done; \
86 84 add %g4, %g5, %g4; \
87 85 \
88 86 is_khat: /* sfmmup == KHATID */ \
89 87 set KHMEHASH_SZ, %g5; \
90 88 ld [%g5], %g5; \
91 89 and %g4, %g5, %g4; \
92 90 mulx %g4, HMEBUCK_SIZE, %g4; /* g4 = off from hash_pa */ \
93 91 set khme_hash_pa, %g5; \
94 92 ldx [%g5], %g5; \
95 93 add %g4, %g5, %g4; \
96 94 \
97 95 hash_done:
98 96
99 97 /*
100 98 * uint64_t
101 99 * kdi_hme_hash_tag(uint64_t rehash, uintptr_t va)
102 100 * {
103 101 * uint_t hmeshift = HME_HASH_SHIFT(rehash);
104 102 * uint64_t bspage = HME_HASH_BSPAGE(va, hmeshift);
105 103 * return (rehash | (bspage << HTAG_BSPAGE_SHIFT));
106 104 * }
107 105 */
108 106
109 107 /*
110 108 * Parameters: %g1: VA, %g3: rehash
111 109 * Scratch: %g5, %g6 available
112 110 * Return: hmeblk tag in %g5
113 111 */
114 112
115 113 #define KDI_HME_HASH_TAG \
116 114 cmp %g3, TTE8K; \
117 115 be,a %xcc, bspage; \
118 116 mov HBLK_RANGE_SHIFT, %g5; \
119 117 mulx %g3, 3, %g5; \
120 118 add %g5, MMU_PAGESHIFT, %g5; \
121 119 \
122 120 bspage: /* TTE_PAGE_SHIFT in %g5 */ \
123 121 srlx %g1, %g5, %g6; \
124 122 sub %g5, MMU_PAGESHIFT, %g5; \
125 123 sllx %g6, %g5, %g5; \
126 124 \
127 125 /* BSPAGE in %g5 */ \
128 126 sllx %g5, HTAG_BSPAGE_SHIFT, %g5; \
129 127 sllx %g3, HTAG_REHASH_SHIFT, %g6; \
130 128 or %g6, SFMMU_INVALID_SHMERID, %g6; \
131 129 or %g5, %g6, %g5
132 130
133 131 /*
134 132 * uint64_t
135 133 * kdi_hme_hash_table_search(sfmmu_t *sfmmup, uint64_t hmebpa, uint64_t hblktag)
136 134 * {
137 135 * struct hme_blk *hblkp;
138 136 * uint64_t blkpap = hmebpa + HMEBP_HBLK;
139 137 * uint64_t blkpa;
140 138 *
141 139 * while ((blkpa = lddphys(blkpap)) != HMEBLK_ENDPA) {
142 140 * if (lddphys(blkpa + HMEBLK_TAG) == hblktag) {
143 141 * if ((sfmmu_t *)lddphys(blkpa + HMEBLK_TAG + 8) ==
144 142 * sfmmup)
145 143 * return (blkpa);
146 144 * }
147 145 *
148 146 * blkpap = blkpa + HMEBLK_NEXTPA;
149 147 * }
150 148 *
151 149 * return (NULL);
152 150 * }
153 151 */
154 152
155 153 /*
156 154 * Parameters: %g2: sfmmup, %g4: hmebp PA, %g5: hmeblk tag
157 155 * Scratch: %g4, %g5, %g6 available
158 156 * Return: hmeblk PA in %g4
159 157 */
160 158
161 159 #define KDI_HME_HASH_TABLE_SEARCH \
162 160 add %g4, HMEBUCK_NEXTPA, %g4; /* %g4 is hmebucket PA */ \
163 161 search_loop: \
164 162 ldxa [%g4]ASI_MEM, %g4; \
165 163 cmp %g4, HMEBLK_ENDPA; \
166 164 be,a,pn %xcc, search_done; \
167 165 clr %g4; \
168 166 \
169 167 add %g4, HMEBLK_TAG, %g4; /* %g4 is now hmeblk PA */ \
170 168 ldxa [%g4]ASI_MEM, %g6; \
171 169 sub %g4, HMEBLK_TAG, %g4; \
172 170 cmp %g5, %g6; \
173 171 bne,a %xcc, search_loop; \
174 172 add %g4, HMEBLK_NEXTPA, %g4; \
175 173 \
176 174 /* Found a match. Is it in the right address space? */ \
177 175 add %g4, (HMEBLK_TAG + 8), %g4; \
178 176 ldxa [%g4]ASI_MEM, %g6; \
179 177 sub %g4, (HMEBLK_TAG + 8), %g4; \
180 178 cmp %g6, %g2; \
181 179 bne,a %xcc, search_loop; \
182 180 add %g4, HMEBLK_NEXTPA, %g4; \
183 181 \
184 182 search_done:
185 183
186 184 /*
187 185 * uint64_t
188 186 * kdi_hblk_to_ttep(uint64_t hmeblkpa, uintptr_t va)
189 187 * {
190 188 * size_t ttesz = ldphys(hmeblkpa + HMEBLK_MISC) & HBLK_SZMASK;
191 189 * uint_t idx;
192 190 *
193 191 * if (ttesz == TTE8K)
194 192 * idx = (va >> MMU_PAGESHIFT) & (NHMENTS - 1);
195 193 * else
196 194 * idx = 0;
197 195 *
198 196 * return (hmeblkpa + (idx * sizeof (struct sf_hment)) +
199 197 * HMEBLK_HME + SFHME_TTE);
200 198 * }
201 199 */
202 200
203 201 /*
204 202 * Parameters: %g1: VA, %g4: hmeblk PA
205 203 * Scratch: %g1, %g2, %g3, %g4, %g5, %g6 available
206 204 * Return: TTE PA in %g2
207 205 */
208 206
209 207 #define KDI_HBLK_TO_TTEP \
210 208 add %g4, HMEBLK_MISC, %g3; \
211 209 lda [%g3]ASI_MEM, %g3; \
212 210 and %g3, HBLK_SZMASK, %g3; /* ttesz in %g3 */ \
213 211 \
214 212 cmp %g3, TTE8K; \
215 213 bne,a ttep_calc; \
216 214 clr %g1; \
217 215 srlx %g1, MMU_PAGESHIFT, %g1; \
218 216 and %g1, NHMENTS - 1, %g1; \
219 217 \
220 218 ttep_calc: /* idx in %g1 */ \
221 219 mulx %g1, SFHME_SIZE, %g2; \
222 220 add %g2, %g4, %g2; \
223 221 add %g2, (HMEBLK_HME1 + SFHME_TTE), %g2;
224 222
225 223 /*
226 224 * uint64_t
227 225 * kdi_vatotte(uintptr_t va, int cnum)
228 226 * {
229 227 * sfmmu_t *sfmmup = ksfmmup;
230 228 * uint64_t hmebpa, hmetag, hmeblkpa;
231 229 * int i;
232 230 *
233 231 * for (i = 1; i < DEFAULT_MAX_HASHCNT + 1; i++) {
234 232 * hmebpa = kdi_c_hme_hash_function(sfmmup, va, HME_HASH_SHIFT(i));
235 233 * hmetag = kdi_c_hme_hash_tag(i, va);
236 234 * hmeblkpa = kdi_c_hme_hash_table_search(sfmmup, hmebpa, hmetag);
237 235 *
238 236 * if (hmeblkpa != NULL) {
239 237 * uint64_t tte = lddphys(kdi_c_hblk_to_ttep(hmeblkpa,
240 238 * va));
241 239 *
242 240 * if ((int64_t)tte < 0)
↓ open down ↓ |
202 lines elided |
↑ open up ↑ |
243 241 * return (tte);
244 242 * else
245 243 * return (0);
246 244 * }
247 245 * }
248 246 *
249 247 * return (0);
250 248 * }
251 249 */
252 250
253 -#if defined(lint)
254 -/*ARGSUSED*/
255 -int
256 -kdi_vatotte(uintptr_t va, int cnum, tte_t *ttep)
257 -{
258 - return (0);
259 -}
260 -
261 -void
262 -kdi_trap_vatotte(void)
263 -{
264 -}
265 -
266 -#else
267 -
268 251 /*
269 252 * Invocation in normal context as a VA-to-TTE translator
270 253 * for kernel context only. This routine returns 0 on
271 254 * success and -1 on error.
272 255 *
273 256 * %o0 = VA, input register
274 257 * %o1 = KCONTEXT
275 258 * %o2 = ttep, output register
276 259 */
277 260 ENTRY_NP(kdi_vatotte)
278 261 mov %o0, %g1 /* VA in %g1 */
279 262 mov %o1, %g2 /* cnum in %g2 */
280 263
281 264 set kdi_trap_vatotte, %g3
282 265 jmpl %g3, %g7 /* => %g1: TTE or 0 */
283 266 add %g7, 8, %g7
284 267
285 268 brz %g1, 1f
286 269 nop
287 270
288 271 /* Got a valid TTE */
289 272 stx %g1, [%o2]
290 273 retl
291 274 clr %o0
292 275
293 276 /* Failed translation */
294 277 1: retl
295 278 mov -1, %o0
296 279 SET_SIZE(kdi_vatotte)
297 280
298 281 /*
299 282 * %g1 = vaddr passed in, tte or 0 (error) when return
300 283 * %g2 = KCONTEXT
301 284 * %g7 = return address
302 285 */
303 286 ENTRY_NP(kdi_trap_vatotte)
304 287
305 288 cmp %g2, KCONTEXT /* make sure called in kernel ctx */
306 289 bne,a,pn %icc, 6f
307 290 clr %g1
308 291
309 292 sethi %hi(ksfmmup), %g2
310 293 ldx [%g2 + %lo(ksfmmup)], %g2
311 294
312 295 mov 1, %g3 /* VA %g1, ksfmmup %g2, idx %g3 */
313 296 mov HBLK_RANGE_SHIFT, %g4
314 297 ba 3f
315 298 nop
316 299
317 300 1: mulx %g3, 3, %g4 /* 3: see TTE_BSZS_SHIFT */
318 301 add %g4, MMU_PAGESHIFT, %g4
319 302
320 303 3: KDI_HME_HASH_FUNCTION /* %g1, %g2, %g4 => hash in %g4 */
321 304 KDI_HME_HASH_TAG /* %g1, %g3 => tag in %g5 */
322 305 KDI_HME_HASH_TABLE_SEARCH /* %g2, %g4, %g5 => hmeblk PA in %g4 */
323 306
324 307 brz %g4, 5f
325 308 nop
326 309
327 310 KDI_HBLK_TO_TTEP /* %g1, %g4 => TTE PA in %g2 */
328 311 ldxa [%g2]ASI_MEM, %g1
329 312 brgez,a %g1, 4f
330 313 clr %g1
331 314 4: ba,a 6f
332 315
333 316 5: add %g3, 1, %g3
334 317 set mmu_hashcnt, %g4
335 318 lduw [%g4], %g4
↓ open down ↓ |
58 lines elided |
↑ open up ↑ |
336 319 cmp %g3, %g4
337 320 ble 1b
338 321 nop
339 322
340 323 clr %g1
341 324
342 325 6: jmp %g7
343 326 nop
344 327 SET_SIZE(kdi_trap_vatotte)
345 328
346 -#endif /* lint */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX