Changeset fbb8b2b in mainline
- Timestamp:
- 2006-06-17T17:26:14Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8e3bf3e2
- Parents:
- 74b22cc5
- Location:
- arch/ppc32
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
arch/ppc32/include/mm/page.h
r74b22cc5 rfbb8b2b 27 27 */ 28 28 29 29 /** @addtogroup ppc32mm 30 30 * @{ 31 31 */ … … 133 133 extern void page_arch_init(void); 134 134 135 #define PHT_BITS 16136 #define PHT_ORDER 4137 138 135 typedef struct { 139 136 unsigned v : 1; /**< Valid */ … … 151 148 152 149 extern void pht_refill(int n, istate_t *istate); 150 extern bool pht_real_refill(int n, istate_t *istate) __attribute__ ((section("K_UNMAPPED_TEXT_START"))); 153 151 extern void pht_init(void); 154 152 … … 159 157 #endif 160 158 161 159 /** @} 162 160 */ 163 -
arch/ppc32/src/exception.S
r74b22cc5 rfbb8b2b 122 122 CONTEXT_STORE 123 123 124 lis r12, exc_dispatch@ha125 addi r12, r12, exc_dispatch@l126 mtsrr0 r12127 128 124 li r3, 0 129 125 b jump_to_kernel … … 134 130 CONTEXT_STORE 135 131 136 lis r12, exc_dispatch@ha137 addi r12, r12, exc_dispatch@l138 mtsrr0 r12139 140 132 li r3, 1 141 133 b jump_to_kernel … … 146 138 CONTEXT_STORE 147 139 148 lis r12, exc_dispatch@ha 149 addi r12, r12, exc_dispatch@l 150 mtsrr0 r12 140 # li r3, 2 141 # mr r4, sp 142 # addi r4, r4, 8 143 # bl pht_real_refill 144 145 # cmpwi r3, 0 146 # bne iret_real 151 147 152 148 li r3, 2 … … 158 154 CONTEXT_STORE 159 155 160 lis r12, exc_dispatch@ha 161 addi r12, r12, exc_dispatch@l 162 mtsrr0 r12 163 156 # li r3, 3 157 # mr r4, sp 158 # addi r4, r4, 8 159 # bl pht_real_refill 160 161 # cmpwi r3, 0 162 # bne iret_real 163 164 164 li r3, 3 165 165 b jump_to_kernel … … 170 170 CONTEXT_STORE 171 171 172 lis r12, exc_dispatch@ha173 addi r12, r12, exc_dispatch@l174 mtsrr0 r12175 176 172 li r3, 4 177 173 b jump_to_kernel … … 182 178 CONTEXT_STORE 183 179 184 lis r12, exc_dispatch@ha185 addi r12, r12, exc_dispatch@l186 mtsrr0 r12187 188 180 li r3, 5 189 181 b jump_to_kernel … … 194 186 CONTEXT_STORE 195 187 196 lis r12, exc_dispatch@ha197 addi r12, r12, exc_dispatch@l198 mtsrr0 r12199 200 188 li r3, 6 201 189 b jump_to_kernel … … 206 194 CONTEXT_STORE 207 195 208 lis r12, exc_dispatch@ha209 addi r12, r12, exc_dispatch@l210 mtsrr0 r12211 212 196 li r3, 7 213 197 b jump_to_kernel … … 217 201 exc_decrementer: 218 202 CONTEXT_STORE 219 220 lis r12, exc_dispatch@ha221 addi r12, r12, exc_dispatch@l222 mtsrr0 r12223 203 224 204 li r3, 8 … … 230 210 CONTEXT_STORE 231 211 232 lis r12, exc_dispatch@ha233 addi r12, r12, exc_dispatch@l234 mtsrr0 r12235 236 212 li r3, 9 237 213 b jump_to_kernel … … 241 217 exc_reserved1: 242 218 CONTEXT_STORE 243 244 lis r12, exc_dispatch@ha245 addi r12, r12, exc_dispatch@l246 mtsrr0 r12247 219 248 220 li r3, 10 … … 260 232 exc_trace: 261 233 CONTEXT_STORE 262 263 lis r12, exc_dispatch@ha264 addi r12, r12, exc_dispatch@l265 mtsrr0 r12266 234 267 235 li r3, 12 … … 273 241 addi r12, r12, iret@l 274 242 mtlr r12 275 243 244 lis r12, exc_dispatch@ha 245 addi r12, r12, exc_dispatch@l 246 mtsrr0 r12 247 276 248 mfmsr r12 277 249 ori r12, r12, (msr_ir | msr_dr)@l … … 292 264 addi r12, r12, iret_syscall@l 293 265 mtlr r12 294 266 295 267 mfmsr r12 296 268 ori r12, r12, (msr_ir | msr_dr)@l … … 299 271 addis sp, sp, 0x8000 300 272 rfi 273 274 iret_real: 275 276 lwz r0, 8(sp) 277 lwz r2, 12(sp) 278 lwz r3, 16(sp) 279 lwz r4, 20(sp) 280 lwz r5, 24(sp) 281 lwz r6, 28(sp) 282 lwz r7, 32(sp) 283 lwz r8, 36(sp) 284 lwz r9, 40(sp) 285 lwz r10, 44(sp) 286 lwz r11, 48(sp) 287 lwz r13, 52(sp) 288 lwz r14, 56(sp) 289 lwz r15, 60(sp) 290 lwz r16, 64(sp) 291 lwz r17, 68(sp) 292 lwz r18, 72(sp) 293 lwz r19, 76(sp) 294 lwz r20, 80(sp) 295 lwz r21, 84(sp) 296 lwz r22, 88(sp) 297 lwz r23, 92(sp) 298 lwz r24, 96(sp) 299 lwz r25, 100(sp) 300 lwz r26, 104(sp) 301 lwz r27, 108(sp) 302 lwz r28, 112(sp) 303 lwz r29, 116(sp) 304 lwz r30, 120(sp) 305 lwz r31, 124(sp) 306 307 lwz r12, 128(sp) 308 mtcr r12 309 310 lwz r12, 132(sp) 311 mtsrr0 r12 312 313 lwz r12, 136(sp) 314 mtsrr1 r12 315 316 lwz r12, 140(sp) 317 mtlr r12 318 319 lwz r12, 144(sp) 320 mtctr r12 321 322 lwz r12, 148(sp) 323 mtxer r12 324 325 lwz r12, 152(sp) 326 lwz sp, 156(sp) 327 328 rfi -
arch/ppc32/src/mm/as.c
r74b22cc5 rfbb8b2b 27 27 */ 28 28 29 29 /** @addtogroup ppc32mm 30 30 * @{ 31 31 */ … … 42 42 } 43 43 44 44 /** @} 45 45 */ 46 -
arch/ppc32/src/mm/frame.c
r74b22cc5 rfbb8b2b 27 27 */ 28 28 29 29 /** @addtogroup ppc32mm 30 30 * @{ 31 31 */ … … 69 69 } 70 70 71 71 /** @} 72 72 */ 73 -
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.