Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | /* |
2 | * ========== Copyright Header Begin ========================================== | |
3 | * | |
4 | * Hypervisor Software File: mmuinit.s | |
5 | * | |
6 | * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. | |
7 | * | |
8 | * - Do no alter or remove copyright notices | |
9 | * | |
10 | * - Redistribution and use of this software in source and binary forms, with | |
11 | * or without modification, are permitted provided that the following | |
12 | * conditions are met: | |
13 | * | |
14 | * - Redistribution of source code must retain the above copyright notice, | |
15 | * this list of conditions and the following disclaimer. | |
16 | * | |
17 | * - Redistribution in binary form must reproduce the above copyright notice, | |
18 | * this list of conditions and the following disclaimer in the | |
19 | * documentation and/or other materials provided with the distribution. | |
20 | * | |
21 | * Neither the name of Sun Microsystems, Inc. or the names of contributors | |
22 | * may be used to endorse or promote products derived from this software | |
23 | * without specific prior written permission. | |
24 | * | |
25 | * This software is provided "AS IS," without a warranty of any kind. | |
26 | * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, | |
27 | * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A | |
28 | * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN | |
29 | * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR | |
30 | * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR | |
31 | * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN | |
32 | * OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR | |
33 | * FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE | |
34 | * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, | |
35 | * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF | |
36 | * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. | |
37 | * | |
38 | * You acknowledge that this software is not designed, licensed or | |
39 | * intended for use in the design, construction, operation or maintenance of | |
40 | * any nuclear facility. | |
41 | * | |
42 | * ========== Copyright Header End ============================================ | |
43 | */ | |
44 | /* | |
45 | * Copyright 2007 Sun Microsystems, Inc. All rights reserved. | |
46 | * Use is subject to license terms. | |
47 | */ | |
48 | ||
49 | .ident "@(#)mmuinit.s 1.8 07/06/07 SMI" | |
50 | ||
51 | .file "mmuinit.s" | |
52 | ||
53 | #include <sys/privregs.h> | |
54 | #include <sys/asm_linkage.h> | |
55 | #include <hypervisor.h> | |
56 | ||
57 | .seg ".bss" | |
58 | .align 0x100 | |
59 | .global mmu_miss_info_area0 | |
60 | mmu_miss_info_area0: | |
61 | .skip 0x100 | |
62 | #if defined(lint) | |
63 | void | |
64 | mmu_init(uint64_t rabase) | |
65 | { | |
66 | } | |
67 | #else | |
68 | ENTRY(mmu_init) | |
69 | save %g0, %g0, %g0 | |
70 | ||
71 | ! %i0 - RAbase | |
72 | setx traptable0, %o1, %i1 ! %i1 - VAbase | |
73 | sub %i1, %i0, %i3 ! %i3 VA-RA delta | |
74 | ||
75 | mov %i1, %o0 ! VA | |
76 | mov %i0, %o1 ! RA | |
77 | mov 3, %o2 ! Size = 4M | |
78 | call setup_itlb_entry | |
79 | mov %g0, %o3 ! Mode bits = 0 | |
80 | ||
81 | mov %i1, %o0 ! VA | |
82 | mov %i0, %o1 ! RA | |
83 | mov 3, %o2 ! Size = 4M | |
84 | call setup_dtlb_entry | |
85 | mov %g0, %o3 ! Mode bits = 0 | |
86 | ||
87 | setx mmu_miss_info_area0, %o2, %o1 ! VA | |
88 | sub %o1, %i3, %o0 ! VA->RA | |
89 | mov MMU_FAULT_AREA_CONF, %o5 | |
90 | ta FAST_TRAP | |
91 | brnz %o0, 2f | |
92 | nop | |
93 | ||
94 | setx 1f, %o2, %o1 ! VA | |
95 | mov 1, %o0 | |
96 | mov MMU_ENABLE, %o5 | |
97 | ta FAST_TRAP | |
98 | 1: | |
99 | brnz %o0, 2f | |
100 | nop | |
101 | add %i7, %i3, %i7 ! RA->VA | |
102 | ret | |
103 | restore | |
104 | 2: | |
105 | mov API_EXIT, %o5 | |
106 | ta CORE_TRAP | |
107 | SET_SIZE(mmu_init) | |
108 | #endif /* lint */ | |
109 | ||
110 | ||
111 | #if defined(lint) | |
112 | void | |
113 | setup_itlb_entry(uint64_t va, uint64_t pa, uint64_t size, uint64_t tte_mode) | |
114 | { | |
115 | } | |
116 | #else | |
117 | #define NPABITS (43) | |
118 | #define TTE_WRITABLE (1 << 6) | |
119 | #define TTE_PRIV (1 << 8) | |
120 | #define TTE_EFFECT (1 << 11) | |
121 | #define TTE_CV (1 << 9) | |
122 | #define TTE_CP (1 << 10) | |
123 | ||
124 | #define TTE_64K (0xa) | |
125 | #define TTE_512K (0xc) | |
126 | #define TTE_4M (0xe) | |
127 | ! %o0 = VA | |
128 | ! %o1 = PA | |
129 | ! %o2 = Size 0 = 8K, 1 = 64K , 3 = 4M , 5 = 256M | |
130 | ! %o3 = TTE Mode bits | |
131 | ENTRY(setup_itlb_entry) | |
132 | sllx %o1, 64-NPABITS, %o5 | |
133 | subcc %o5,%g0,%g0 | |
134 | bpos 0f | |
135 | or %o1, TTE_PRIV+TTE_CV+TTE_CP+TTE_WRITABLE, %o5 ! P,CP,CV,W | |
136 | or %o1, TTE_PRIV+TTE_EFFECT+TTE_WRITABLE, %o5 ! P,E,W | |
137 | 0: | |
138 | ||
139 | or %o5, %o3, %o1 ! Other bits | |
140 | mov %g0, %o3 ! all this | |
141 | or %o3, 1, %o3 ! to set | |
142 | sllx %o3, 63, %o3 ! the V bit | |
143 | ||
144 | or %o2, %o1, %o2 ! %o2 = TTE | |
145 | or %o2, %o3, %o2 ! set V bit | |
146 | mov %g0, %o1 | |
147 | add %g0, 2, %o3 | |
148 | ! %o0 = Virt | |
149 | ! %o1 = context | |
150 | ! %o2 = TTE | |
151 | ! %o3 = ITLB | |
152 | add %g0, MMU_MAP_PERM_ADDR, %o5 | |
153 | ta FAST_TRAP | |
154 | brnz %o0, 1f | |
155 | nop | |
156 | retl | |
157 | nop | |
158 | 1: | |
159 | mov API_EXIT, %o5 | |
160 | ta CORE_TRAP | |
161 | SET_SIZE(setup_itlb_entry) | |
162 | ||
163 | ! %o0 = VA | |
164 | ! %o1 = PA | |
165 | ! %o2 = Size 0 = 8K, 1 = 64K , 3 = 4M , 5 = 256M | |
166 | ! %o3 = TTE Mode bits | |
167 | ENTRY(setup_dtlb_entry) | |
168 | sllx %o1, 64-NPABITS, %o5 | |
169 | subcc %o5,%g0,%g0 | |
170 | bpos 0f | |
171 | or %o1, TTE_PRIV+TTE_CV+TTE_CP+TTE_WRITABLE, %o5 ! P,CP,CV,W | |
172 | or %o1, TTE_PRIV+TTE_EFFECT+TTE_WRITABLE, %o5 ! P,E,W | |
173 | 0: | |
174 | or %o5, %o3, %o1 ! Other bits | |
175 | mov %g0, %o3 ! All this | |
176 | or %o3, 1, %o3 ! to set | |
177 | sllx %o3, 63, %o3 ! the V bit | |
178 | ||
179 | or %o2, %o1, %o2 ! %o2 = TTE | |
180 | or %o2, %o3, %o2 ! set V bit | |
181 | mov %g0, %o1 | |
182 | add %g0, 1, %o3 | |
183 | ! %o0 = Virt | |
184 | ! %o1 = context | |
185 | ! %o2 = TTE | |
186 | ! %o3 = DTLB | |
187 | add %g0, MMU_MAP_PERM_ADDR, %o5 | |
188 | ta FAST_TRAP | |
189 | brnz %o0, 1f | |
190 | nop | |
191 | retl | |
192 | nop | |
193 | 1: | |
194 | mov API_EXIT, %o5 | |
195 | ta CORE_TRAP | |
196 | SET_SIZE(setup_dtlb_entry) | |
197 | #endif /* lint */ |