Changeset fbb8b2b in mainline for arch/ppc32/src/mm/page.c
- Timestamp:
- 2006-06-17T17:26:14Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8e3bf3e2
- Parents:
- 74b22cc5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
arch/ppc32/src/mm/page.c
r74b22cc5 rfbb8b2b 27 27 */ 28 28 29 29 /** @addtogroup ppc32mm 30 30 * @{ 31 31 */ … … 49 49 #include <symtab.h> 50 50 51 static phte_t *phte;52 53 51 54 52 /** Try to find PTE for faulting address … … 67 65 * 68 66 */ 69 static pte_t *find_mapping_and_check(as_t *as, bool lock, __address badvaddr, int access, 70 istate_t *istate, int *pfrc) 67 static pte_t *find_mapping_and_check(as_t *as, bool lock, __address badvaddr, int access, istate_t *istate, int *pfrc) 71 68 { 72 69 /* … … 133 130 __u32 page = (vaddr >> 12) & 0xffff; 134 131 __u32 api = (vaddr >> 22) & 0x3f; 132 135 133 __u32 vsid; 136 137 134 asm volatile ( 138 135 "mfsrin %0, %1\n" … … 140 137 : "r" (vaddr) 141 138 ); 139 140 __u32 sdr1; 141 asm volatile ( 142 "mfsdr1 %0\n" 143 : "=r" (sdr1) 144 ); 145 phte_t *phte = (phte_t *) PA2KA(sdr1 & 0xffff0000); 142 146 143 147 /* Primary hash (xor) */ … … 186 190 phte[base + i].c = 0; 187 191 phte[base + i].pp = 2; // FIXME 192 } 193 194 195 static void pht_real_insert(const __address vaddr, const pfn_t pfn) 196 { 197 __u32 page = (vaddr >> 12) & 0xffff; 198 __u32 api = (vaddr >> 22) & 0x3f; 199 200 __u32 vsid; 201 asm volatile ( 202 "mfsrin %0, %1\n" 203 : "=r" (vsid) 204 : "r" (vaddr) 205 ); 206 207 __u32 sdr1; 208 asm volatile ( 209 "mfsdr1 %0\n" 210 : "=r" (sdr1) 211 ); 212 phte_t *phte_physical = (phte_t *) (sdr1 & 0xffff0000); 213 214 /* Primary hash (xor) */ 215 __u32 h = 0; 216 __u32 hash = vsid ^ page; 217 __u32 base = (hash & 0x3ff) << 3; 218 __u32 i; 219 bool found = false; 220 221 /* Find unused or colliding 222 PTE in PTEG */ 223 for (i = 0; i < 8; i++) { 224 if ((!phte_physical[base + i].v) || ((phte_physical[base + i].vsid == vsid) && (phte_physical[base + i].api == api))) { 225 found = true; 226 break; 227 } 228 } 229 230 if (!found) { 231 /* Secondary hash (not) */ 232 __u32 base2 = (~hash & 0x3ff) << 3; 233 234 /* Find unused or colliding 235 PTE in PTEG */ 236 for (i = 0; i < 8; i++) { 237 if ((!phte_physical[base2 + i].v) || ((phte_physical[base2 + i].vsid == vsid) && (phte_physical[base2 + i].api == api))) { 238 found = true; 239 base = base2; 240 h = 1; 241 break; 242 } 243 } 244 245 if (!found) { 246 // TODO: A/C precedence groups 247 i = page % 8; 248 } 249 } 250 251 phte_physical[base + i].v = 1; 252 phte_physical[base + i].vsid = vsid; 253 phte_physical[base + i].h = h; 254 phte_physical[base + i].api = api; 255 phte_physical[base + i].rpn = pfn; 256 phte_physical[base + i].r = 0; 257 phte_physical[base + i].c = 0; 258 phte_physical[base + i].pp = 2; // FIXME 188 259 } 189 260 … … 251 322 252 323 324 /** Process Instruction/Data Storage Interrupt in Real Mode 325 * 326 * @param n Interrupt vector number. 327 * @param istate Interrupted register context. 328 * 329 */ 330 bool pht_real_refill(int n, istate_t *istate) 331 { 332 __address badvaddr; 333 334 if (n == VECTOR_DATA_STORAGE) { 335 asm volatile ( 336 "mfdar %0\n" 337 : "=r" (badvaddr) 338 ); 339 } else 340 badvaddr = istate->pc; 341 342 __u32 physmem; 343 asm volatile ( 344 "mfsprg3 %0\n" 345 : "=r" (physmem) 346 ); 347 348 if ((badvaddr >= PA2KA(0)) && (badvaddr <= PA2KA(physmem))) { 349 pht_real_insert(badvaddr, KA2PA(badvaddr) >> 12); 350 return true; 351 } 352 353 return false; 354 } 355 356 253 357 void pht_init(void) 254 358 { 255 memsetb((__address) phte, 1 << PHT_BITS, 0); 359 // FIXME 360 361 __u32 sdr1; 362 asm volatile ( 363 "mfsdr1 %0\n" 364 : "=r" (sdr1) 365 ); 366 phte_t *phte = (phte_t *) PA2KA(sdr1 & 0xffff0000); 367 368 memsetb((__address) phte, 65536, 0); 256 369 } 257 370 … … 259 372 void page_arch_init(void) 260 373 { 261 if (config.cpu_active == 1) {374 if (config.cpu_active == 1) 262 375 page_mapping_operations = &pt_mapping_operations; 263 264 __address cur;265 int flags;266 267 /* Frames below 128 MB are mapped using BAT,268 map rest of the physical memory */269 for (cur = 128 << 20; cur < last_frame; cur += FRAME_SIZE) {270 flags = PAGE_CACHEABLE;271 if ((PA2KA(cur) >= config.base) && (PA2KA(cur) < config.base + config.kernel_size))272 flags |= PAGE_GLOBAL;273 page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, flags);274 }275 276 /* Allocate page hash table */277 phte_t *physical_phte = (phte_t *) PFN2ADDR(frame_alloc(PHT_ORDER, FRAME_KA | FRAME_PANIC));278 phte = (phte_t *) PA2KA((__address) physical_phte);279 280 ASSERT((__address) physical_phte % (1 << PHT_BITS) == 0);281 pht_init();282 283 asm volatile (284 "mtsdr1 %0\n"285 :286 : "r" ((__address) physical_phte)287 );288 }289 376 } 290 377 … … 305 392 } 306 393 307 /** @} 308 */ 309 394 /** @} 395 */
Note:
See TracChangeset
for help on using the changeset viewer.