Rev 1374 | Rev 1383 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1374 | Rev 1378 | ||
---|---|---|---|
Line 112... | Line 112... | ||
112 | if (s) |
112 | if (s) |
113 | sym2 = s; |
113 | sym2 = s; |
114 | panic("%p: PHT Refill Exception at %p (%s<-%s)\n", badvaddr, istate->pc, symbol, sym2); |
114 | panic("%p: PHT Refill Exception at %p (%s<-%s)\n", badvaddr, istate->pc, symbol, sym2); |
115 | } |
115 | } |
116 | 116 | ||
- | 117 | ||
117 | static void pht_insert(const __address vaddr, const pfn_t pfn) |
118 | static void pht_insert(const __address vaddr, const pfn_t pfn) |
118 | { |
119 | { |
119 | __u32 page = (vaddr >> 12) & 0xffff; |
120 | __u32 page = (vaddr >> 12) & 0xffff; |
120 | __u32 api = (vaddr >> 22) & 0x3f; |
121 | __u32 api = (vaddr >> 22) & 0x3f; |
121 | __u32 vsid; |
122 | __u32 vsid; |
Line 128... | Line 129... | ||
128 | 129 | ||
129 | /* Primary hash (xor) */ |
130 | /* Primary hash (xor) */ |
130 | __u32 hash = ((vsid ^ page) & 0x3ff) << 3; |
131 | __u32 hash = ((vsid ^ page) & 0x3ff) << 3; |
131 | 132 | ||
132 | __u32 i; |
133 | __u32 i; |
- | 134 | bool found = false; |
|
133 | /* Find unused PTE in PTEG */ |
135 | /* Find unused PTE in PTEG */ |
134 | for (i = 0; i < 8; i++) { |
136 | for (i = 0; i < 8; i++) { |
135 | if (!phte[hash + i].v) |
137 | if (!phte[hash + i].v) { |
- | 138 | found = true; |
|
136 | break; |
139 | break; |
137 | } |
140 | } |
- | 141 | } |
|
138 | 142 | ||
- | 143 | if (!found) { |
|
139 | // TODO: Check access/change bits, secondary hash |
144 | /* Secondary hash (not) */ |
- | 145 | hash = ~hash; |
|
140 | 146 | ||
- | 147 | /* Find unused PTE in PTEG */ |
|
- | 148 | for (i = 0; i < 8; i++) { |
|
- | 149 | if (!phte[hash + i].v) { |
|
- | 150 | found = true; |
|
- | 151 | break; |
|
- | 152 | } |
|
- | 153 | } |
|
- | 154 | ||
141 | if (i == 8) |
155 | if (!found) { |
- | 156 | // TODO: A/C precedence groups |
|
142 | i = page % 8; |
157 | i = page % 8; |
- | 158 | } |
|
- | 159 | } |
|
143 | 160 | ||
144 | phte[hash + i].v = 1; |
161 | phte[hash + i].v = 1; |
145 | phte[hash + i].vsid = vsid; |
162 | phte[hash + i].vsid = vsid; |
146 | phte[hash + i].h = 0; |
163 | phte[hash + i].h = 0; |
147 | phte[hash + i].api = api; |
164 | phte[hash + i].api = api; |
Line 193... | Line 210... | ||
193 | */ |
210 | */ |
194 | page_table_unlock(AS, true); |
211 | page_table_unlock(AS, true); |
195 | return; |
212 | return; |
196 | default: |
213 | default: |
197 | panic("Unexpected pfrc (%d)\n", pfcr); |
214 | panic("Unexpected pfrc (%d)\n", pfcr); |
198 | break; |
- | |
199 | } |
215 | } |
200 | } |
216 | } |
201 | 217 | ||
202 | pte->a = 1; /* Record access to PTE */ |
218 | pte->a = 1; /* Record access to PTE */ |
203 | pht_insert(badvaddr, pte->pfn); |
219 | pht_insert(badvaddr, pte->pfn); |
Line 212... | Line 228... | ||
212 | 228 | ||
213 | 229 | ||
214 | void pht_init(void) |
230 | void pht_init(void) |
215 | { |
231 | { |
216 | memsetb((__address) phte, 1 << PHT_BITS, 0); |
232 | memsetb((__address) phte, 1 << PHT_BITS, 0); |
217 | - | ||
218 | /* Insert global kernel mapping */ |
- | |
219 | - | ||
220 | __address cur; |
- | |
221 | for (cur = 0; cur < last_frame; cur += FRAME_SIZE) { |
- | |
222 | pte_t *pte = page_mapping_find(AS_KERNEL, PA2KA(cur)); |
- | |
223 | if ((pte) && (pte->p) && (pte->g)) |
- | |
224 | pht_insert(PA2KA(cur), pte->pfn); |
- | |
225 | } |
- | |
226 | } |
233 | } |
227 | 234 | ||
228 | 235 | ||
229 | void page_arch_init(void) |
236 | void page_arch_init(void) |
230 | { |
237 | { |
Line 254... | Line 261... | ||
254 | asm volatile ( |
261 | asm volatile ( |
255 | "mtsdr1 %0\n" |
262 | "mtsdr1 %0\n" |
256 | : |
263 | : |
257 | : "r" ((__address) physical_phte) |
264 | : "r" ((__address) physical_phte) |
258 | ); |
265 | ); |
259 | - | ||
260 | /* Invalidate block address translation registers, |
- | |
261 | thus remove the temporary mapping */ |
- | |
262 | // invalidate_bat(); |
- | |
263 | } |
266 | } |
264 | } |
267 | } |