Changeset 125e944 in mainline for arch/ppc32/src/mm/page.c
- Timestamp:
- 2006-05-20T22:18:06Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a33c990
- Parents:
- c1982e45
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
arch/ppc32/src/mm/page.c
rc1982e45 r125e944 37 37 #include <arch/types.h> 38 38 #include <arch/exception.h> 39 #include <align.h> 39 40 #include <config.h> 40 41 #include <print.h> … … 47 48 * 48 49 * Try to find PTE for faulting address. 49 * The AS->lock must be held on entry to this function. 50 * 50 * The as->lock must be held on entry to this function 51 * if lock is true. 52 * 53 * @param as Address space. 54 * @param lock Lock/unlock the address space. 51 55 * @param badvaddr Faulting virtual address. 52 56 * @param istate Pointer to interrupted state. … … 55 59 * 56 60 */ 57 static pte_t *find_mapping_and_check( __address badvaddr, istate_t *istate, int *pfcr)61 static pte_t *find_mapping_and_check(as_t *as, bool lock, __address badvaddr, istate_t *istate, int *pfcr) 58 62 { 59 63 /* 60 64 * Check if the mapping exists in page tables. 61 65 */ 62 pte_t *pte = page_mapping_find( AS, badvaddr);66 pte_t *pte = page_mapping_find(as, badvaddr); 63 67 if ((pte) && (pte->p)) { 64 68 /* … … 74 78 * Resort to higher-level page fault handler. 75 79 */ 76 page_table_unlock( AS, true);80 page_table_unlock(as, lock); 77 81 switch (rc = as_page_fault(badvaddr, istate)) { 78 82 case AS_PF_OK: … … 81 85 * The mapping ought to be in place. 82 86 */ 83 page_table_lock( AS, true);84 pte = page_mapping_find( AS, badvaddr);87 page_table_lock(as, lock); 88 pte = page_mapping_find(as, badvaddr); 85 89 ASSERT((pte) && (pte->p)); 86 90 return pte; 87 91 case AS_PF_DEFER: 88 page_table_lock( AS, true);92 page_table_lock(as, lock); 89 93 *pfcr = rc; 90 94 return NULL; 91 95 case AS_PF_FAULT: 92 page_table_lock( AS, true);96 page_table_lock(as, lock); 93 97 printf("Page fault.\n"); 94 98 *pfcr = rc; … … 181 185 __address badvaddr; 182 186 pte_t *pte; 183 184 187 int pfcr; 188 as_t *as; 189 bool lock; 190 191 if (AS == NULL) { 192 as = AS_KERNEL; 193 lock = false; 194 } else { 195 as = AS; 196 lock = true; 197 } 185 198 186 199 if (data) { … … 192 205 badvaddr = istate->pc; 193 206 194 spinlock_lock(& AS->lock);195 asid = AS->asid;196 spinlock_unlock(& AS->lock);197 198 page_table_lock( AS, true);199 200 pte = find_mapping_and_check( badvaddr, istate, &pfcr);207 spinlock_lock(&as->lock); 208 asid = as->asid; 209 spinlock_unlock(&as->lock); 210 211 page_table_lock(as, lock); 212 213 pte = find_mapping_and_check(as, lock, badvaddr, istate, &pfcr); 201 214 if (!pte) { 202 215 switch (pfcr) { … … 209 222 * or copy_to_uspace(). 210 223 */ 211 page_table_unlock( AS, true);224 page_table_unlock(as, lock); 212 225 return; 213 226 default: … … 219 232 pht_insert(badvaddr, pte->pfn); 220 233 221 page_table_unlock( AS, true);234 page_table_unlock(as, lock); 222 235 return; 223 236 224 237 fail: 225 page_table_unlock( AS, true);238 page_table_unlock(as, lock); 226 239 pht_refill_fail(badvaddr, istate); 227 240 } … … 238 251 if (config.cpu_active == 1) { 239 252 page_mapping_operations = &pt_mapping_operations; 240 241 /*242 * PA2KA(identity) mapping for all frames until last_frame.243 */244 __address cur;245 int flags;246 247 for (cur = 0; cur < last_frame; cur += FRAME_SIZE) {248 flags = PAGE_CACHEABLE;249 if ((PA2KA(cur) >= config.base) && (PA2KA(cur) < config.base + config.kernel_size))250 flags |= PAGE_GLOBAL;251 page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, flags);252 }253 253 254 254 /* Allocate page hash table */ … … 266 266 } 267 267 } 268 269 270 __address hw_map(__address physaddr, size_t size) 271 { 272 if (last_frame + ALIGN_UP(size, PAGE_SIZE) > KA2PA(KERNEL_ADDRESS_SPACE_END_ARCH)) 273 panic("Unable to map physical memory %p (%d bytes)", physaddr, size) 274 275 __address virtaddr = PA2KA(last_frame); 276 pfn_t i; 277 for (i = 0; i < ADDR2PFN(ALIGN_UP(size, PAGE_SIZE)); i++) 278 page_mapping_insert(AS_KERNEL, virtaddr + PFN2ADDR(i), physaddr + PFN2ADDR(i), PAGE_NOT_CACHEABLE); 279 280 last_frame = ALIGN_UP(last_frame + size, FRAME_SIZE); 281 282 return virtaddr; 283 }
Note:
See TracChangeset
for help on using the changeset viewer.