Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | \ ========== Copyright Header Begin ========================================== |
2 | \ | |
3 | \ Hypervisor Software File: tte-lookup.fth | |
4 | \ | |
5 | \ Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. | |
6 | \ | |
7 | \ - Do no alter or remove copyright notices | |
8 | \ | |
9 | \ - Redistribution and use of this software in source and binary forms, with | |
10 | \ or without modification, are permitted provided that the following | |
11 | \ conditions are met: | |
12 | \ | |
13 | \ - Redistribution of source code must retain the above copyright notice, | |
14 | \ this list of conditions and the following disclaimer. | |
15 | \ | |
16 | \ - Redistribution in binary form must reproduce the above copyright notice, | |
17 | \ this list of conditions and the following disclaimer in the | |
18 | \ documentation and/or other materials provided with the distribution. | |
19 | \ | |
20 | \ Neither the name of Sun Microsystems, Inc. or the names of contributors | |
21 | \ may be used to endorse or promote products derived from this software | |
22 | \ without specific prior written permission. | |
23 | \ | |
24 | \ This software is provided "AS IS," without a warranty of any kind. | |
25 | \ ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, | |
26 | \ INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A | |
27 | \ PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN | |
28 | \ MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR | |
29 | \ ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR | |
30 | \ DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN | |
31 | \ OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR | |
32 | \ FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE | |
33 | \ DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, | |
34 | \ ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF | |
35 | \ SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. | |
36 | \ | |
37 | \ You acknowledge that this software is not designed, licensed or | |
38 | \ intended for use in the design, construction, operation or maintenance of | |
39 | \ any nuclear facility. | |
40 | \ | |
41 | \ ========== Copyright Header End ============================================ | |
42 | id: @(#)tte-lookup.fth 1.2 06/10/13 | |
43 | purpose: | |
44 | copyright: Copyright 2006 Sun Microsystems, Inc. All Rights Reserved | |
45 | copyright: Use is subject to license terms. | |
46 | ||
47 | headerless | |
48 | ||
49 | \ tte-lookup | |
50 | \ | |
51 | \ You *MUST* preserve %o7 before calling this routine. | |
52 | \ You have %g5 available for this purpose. | |
53 | \ | |
54 | \ before calling this routine you *MUST* patch the first 4 nops | |
55 | \ with instructions that result in %g7 having the PA of the VPT root. | |
56 | \ | |
57 | \ In: | |
58 | \ %g4 = VA to resolve | |
59 | \ Out: | |
60 | \ %g3 = tte or 0. | |
61 | \ all other registers are trashed, except %g5 | |
62 | \ | |
63 | 0 value vpt-patch-pt | |
64 | label tte-lookup | |
65 | nop nop nop nop nop nop | |
66 | %g0 1 %g1 sub | |
67 | %g1 d# 64 pageshift - %g2 srlx \ page mask | |
68 | %g0 %g3 move | |
69 | %g1 #vabits pageshift - tteshift + %g1 sllx \ %g1 = vpt-base | |
70 | %g4 %g1 %g0 subcc | |
71 | u< if | |
72 | %g1 pageshift tteshift - %g6 srax \ %g6 = vpt | |
73 | %g4 pageshift tteshift - 3 * tteshift + %g1 srlx | |
74 | %g1 tteshift %g1 sllx | |
75 | %g1 %g2 %g6 and \ root VPT offset | |
76 | %g7 %g6 memory-asi %g3 ldxa \ L2 vpt tte | |
77 | %g3 %g0 %g0 subcc | |
78 | 0< if | |
79 | %g4 pageshift tteshift - 2 * tteshift + %g1 srlx | |
80 | %g1 tteshift %g1 sllx | |
81 | %g1 %g2 %g6 and \ L2 VPT offset | |
82 | %g3 d# 64 #vabits - %g3 sllx | |
83 | %g3 d# 64 #vabits - %g3 srlx | |
84 | %g3 %g2 %g7 andn \ recover PA | |
85 | %g7 %g6 memory-asi %g3 ldxa \ L1 vpt tte | |
86 | %g3 %g0 %g0 subcc | |
87 | 0< if | |
88 | %g4 pageshift %g1 srlx | |
89 | %g1 tteshift %g1 sllx | |
90 | %g1 %g2 %g6 and \ L2 VPT offset | |
91 | %g3 d# 64 #vabits - %g3 sllx | |
92 | %g3 d# 64 #vabits - %g3 srlx | |
93 | %g3 %g2 %g7 andn \ recover PA | |
94 | retl | |
95 | %g7 %g6 memory-asi %g3 ldxa \ VA tte | |
96 | then | |
97 | then | |
98 | else | |
99 | nop | |
100 | %g4 %g6 %g0 subcc | |
101 | u< if | |
102 | %g1 pageshift tteshift - %g6 srax \ %g6 = vpt-L2 | |
103 | %g4 pageshift tteshift - 2 * tteshift + %g1 srlx | |
104 | %g1 tteshift %g1 sllx | |
105 | %g1 %g2 %g6 and \ root VPT offset | |
106 | %g7 %g6 memory-asi %g3 ldxa \ L2 vpt tte | |
107 | %g3 %g0 %g0 subcc | |
108 | 0< if | |
109 | %g4 pageshift %g1 srlx | |
110 | %g1 tteshift %g1 sllx | |
111 | %g1 %g2 %g6 and \ L2 VPT offset | |
112 | %g3 d# 64 #vabits - %g3 sllx | |
113 | %g3 d# 64 #vabits - %g3 srlx | |
114 | %g3 %g2 %g7 andn \ recover PA | |
115 | retl | |
116 | %g7 %g6 memory-asi %g3 ldxa \ L1 vpt tte | |
117 | then | |
118 | else | |
119 | nop | |
120 | %g0 1 %g6 sub | |
121 | %g6 pageshift 1+ %g6 sllx \ VPT root PA | |
122 | %g4 pageshift %g1 srlx | |
123 | %g1 pageshift %g3 sllx | |
124 | %g3 %g6 %g0 subcc \ in VPT root? | |
125 | 0= if | |
126 | %g1 tteshift %g1 sllx \ miss PFN | |
127 | here tte-lookup - is vpt-patch-pt | |
128 | nop \ TTE patched later!! | |
129 | nop | |
130 | nop | |
131 | nop | |
132 | nop \ THESE WILL BE SWAPPED | |
133 | retl \ WATCHOUT!! | |
134 | nop | |
135 | then | |
136 | %g1 %g2 %g6 and \ offset | |
137 | retl | |
138 | %g7 %g6 memory-asi %g3 ldxa \ L2 vpt tte | |
139 | then | |
140 | then | |
141 | retl | |
142 | %g0 %g3 move \ invalid | |
143 | end-code | |
144 | ||
145 | \ we have to assemble/patch the mmu lookup routines | |
146 | \ this requires that the assembler be available.. | |
147 | \ this is horrible, but the vpt root access is in the fast path, and the tte | |
148 | \ formation is ugly, so we patch the instructions as efficiently as | |
149 | \ we can - including the swap of the retl to use the setx delay slot | |
150 | : setup-root-vpt ( pa -- ) | |
151 | here >r tte-lookup dp ! | |
152 | [ also assembler ] | |
153 | ( n ) dup %g6 %g7 setx | |
154 | tte-lookup vpt-patch-pt + dp ! | |
155 | >tte-cp >tte-cv >tte-writable >tte-soft >tte-priv >tte-valid | |
156 | %g6 %g3 setx | |
157 | here /l - dup l@ swap dp ! retl l, | |
158 | \ The last patched instruction may not be flushed, flush it all the time | |
159 | here i-flush | |
160 | [ previous ] | |
161 | r> dp ! | |
162 | ; | |
163 |