Changeset c142860 in mainline
- Timestamp:
- 2012-01-13T22:29:44Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c7f8fc5
- Parents:
- f7f47a7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/mm/backend_anon.c
rf7f47a7 rc142860 44 44 #include <mm/frame.h> 45 45 #include <mm/slab.h> 46 #include <mm/km.h> 46 47 #include <synch/mutex.h> 47 48 #include <adt/list.h> … … 155 156 int anon_page_fault(as_area_t *area, uintptr_t addr, pf_access_t access) 156 157 { 158 uintptr_t upage = ALIGN_DOWN(addr, PAGE_SIZE); 159 uintptr_t kpage; 157 160 uintptr_t frame; 158 161 … … 175 178 mutex_lock(&area->sh_info->lock); 176 179 frame = (uintptr_t) btree_search(&area->sh_info->pagemap, 177 ALIGN_DOWN(addr, PAGE_SIZE)- area->base, &leaf);180 upage - area->base, &leaf); 178 181 if (!frame) { 179 182 bool allocate = true; … … 185 188 */ 186 189 for (i = 0; i < leaf->keys; i++) { 187 if (leaf->key[i] == 188 ALIGN_DOWN(addr, PAGE_SIZE) - area->base) { 190 if (leaf->key[i] == upage - area->base) { 189 191 allocate = false; 190 192 break; … … 192 194 } 193 195 if (allocate) { 194 frame = (uintptr_t) frame_alloc_noreserve( 195 ONE_FRAME, 0); 196 memsetb((void *) PA2KA(frame), FRAME_SIZE, 0); 196 kpage = km_temporary_page_get(&frame, 197 FRAME_NO_RESERVE); 198 memsetb((void *) kpage, PAGE_SIZE, 0); 199 km_temporary_page_put(kpage); 197 200 198 201 /* … … 201 204 */ 202 205 btree_insert(&area->sh_info->pagemap, 203 ALIGN_DOWN(addr, PAGE_SIZE) - area->base, 204 (void *) frame, leaf); 206 upage - area->base, (void *) frame, leaf); 205 207 } 206 208 } … … 223 225 * the different causes 224 226 */ 225 frame = (uintptr_t) frame_alloc_noreserve(ONE_FRAME, 0); 226 memsetb((void *) PA2KA(frame), FRAME_SIZE, 0); 227 kpage = km_temporary_page_get(&frame, FRAME_NO_RESERVE); 228 memsetb((void *) kpage, PAGE_SIZE, 0); 229 km_temporary_page_put(kpage); 227 230 } 228 231 229 232 /* 230 * Map ' page' to 'frame'.233 * Map 'upage' to 'frame'. 231 234 * Note that TLB shootdown is not attempted as only new information is 232 235 * being inserted into page tables. 233 236 */ 234 page_mapping_insert(AS, addr, frame, as_area_get_flags(area));235 if (!used_space_insert(area, ALIGN_DOWN(addr, PAGE_SIZE), 1))237 page_mapping_insert(AS, upage, frame, as_area_get_flags(area)); 238 if (!used_space_insert(area, upage, 1)) 236 239 panic("Cannot insert used space."); 237 240
Note:
See TracChangeset
for help on using the changeset viewer.