Rev 1426 | Rev 1550 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1426 | Rev 1546 | ||
---|---|---|---|
Line 105... | Line 105... | ||
105 | break; |
105 | break; |
106 | } |
106 | } |
107 | } |
107 | } |
108 | } |
108 | } |
109 | if (frame || found) { |
109 | if (frame || found) { |
- | 110 | frame_reference_add(ADDR2PFN(frame)); |
|
110 | page_mapping_insert(AS, addr, frame, as_area_get_flags(area)); |
111 | page_mapping_insert(AS, addr, frame, as_area_get_flags(area)); |
- | 112 | frame_reference_add(ADDR2PFN(PTE_GET_FRAME(pte))); |
|
111 | if (!used_space_insert(area, ALIGN_DOWN(addr, PAGE_SIZE), 1)) |
113 | if (!used_space_insert(area, ALIGN_DOWN(addr, PAGE_SIZE), 1)) |
112 | panic("Could not insert used space.\n"); |
114 | panic("Could not insert used space.\n"); |
113 | mutex_unlock(&area->sh_info->lock); |
115 | mutex_unlock(&area->sh_info->lock); |
114 | return AS_PF_OK; |
116 | return AS_PF_OK; |
115 | } |
117 | } |
Line 131... | Line 133... | ||
131 | if (entry->p_flags & PF_W) { |
133 | if (entry->p_flags & PF_W) { |
132 | frame = PFN2ADDR(frame_alloc(ONE_FRAME, 0)); |
134 | frame = PFN2ADDR(frame_alloc(ONE_FRAME, 0)); |
133 | memcpy((void *) PA2KA(frame), (void *) (base + i*FRAME_SIZE), FRAME_SIZE); |
135 | memcpy((void *) PA2KA(frame), (void *) (base + i*FRAME_SIZE), FRAME_SIZE); |
134 | 136 | ||
135 | if (area->sh_info) { |
137 | if (area->sh_info) { |
- | 138 | frame_reference_add(ADDR2PFN(frame)); |
|
136 | btree_insert(&area->sh_info->pagemap, ALIGN_DOWN(addr, PAGE_SIZE) - area->base, |
139 | btree_insert(&area->sh_info->pagemap, ALIGN_DOWN(addr, PAGE_SIZE) - area->base, |
137 | (void *) frame, leaf); |
140 | (void *) frame, leaf); |
138 | } |
141 | } |
139 | 142 | ||
140 | } else { |
143 | } else { |
Line 149... | Line 152... | ||
149 | */ |
152 | */ |
150 | frame = PFN2ADDR(frame_alloc(ONE_FRAME, 0)); |
153 | frame = PFN2ADDR(frame_alloc(ONE_FRAME, 0)); |
151 | memsetb(PA2KA(frame), FRAME_SIZE, 0); |
154 | memsetb(PA2KA(frame), FRAME_SIZE, 0); |
152 | 155 | ||
153 | if (area->sh_info) { |
156 | if (area->sh_info) { |
- | 157 | frame_reference_add(ADDR2PFN(frame)); |
|
154 | btree_insert(&area->sh_info->pagemap, ALIGN_DOWN(addr, PAGE_SIZE) - area->base, |
158 | btree_insert(&area->sh_info->pagemap, ALIGN_DOWN(addr, PAGE_SIZE) - area->base, |
155 | (void *) frame, leaf); |
159 | (void *) frame, leaf); |
156 | } |
160 | } |
157 | 161 | ||
158 | } else { |
162 | } else { |
Line 166... | Line 170... | ||
166 | frame = PFN2ADDR(frame_alloc(ONE_FRAME, 0)); |
170 | frame = PFN2ADDR(frame_alloc(ONE_FRAME, 0)); |
167 | memsetb(PA2KA(frame) + size, FRAME_SIZE - size, 0); |
171 | memsetb(PA2KA(frame) + size, FRAME_SIZE - size, 0); |
168 | memcpy((void *) PA2KA(frame), (void *) (base + i*FRAME_SIZE), size); |
172 | memcpy((void *) PA2KA(frame), (void *) (base + i*FRAME_SIZE), size); |
169 | 173 | ||
170 | if (area->sh_info) { |
174 | if (area->sh_info) { |
- | 175 | frame_reference_add(ADDR2PFN(frame)); |
|
171 | btree_insert(&area->sh_info->pagemap, ALIGN_DOWN(addr, PAGE_SIZE) - area->base, |
176 | btree_insert(&area->sh_info->pagemap, ALIGN_DOWN(addr, PAGE_SIZE) - area->base, |
172 | (void *) frame, leaf); |
177 | (void *) frame, leaf); |
173 | } |
178 | } |
174 | 179 | ||
175 | } |
180 | } |
Line 287... | Line 292... | ||
287 | pte = page_mapping_find(area->as, base + j*PAGE_SIZE); |
292 | pte = page_mapping_find(area->as, base + j*PAGE_SIZE); |
288 | ASSERT(pte && PTE_VALID(pte) && PTE_PRESENT(pte)); |
293 | ASSERT(pte && PTE_VALID(pte) && PTE_PRESENT(pte)); |
289 | btree_insert(&area->sh_info->pagemap, (base + j*PAGE_SIZE) - area->base, |
294 | btree_insert(&area->sh_info->pagemap, (base + j*PAGE_SIZE) - area->base, |
290 | (void *) PTE_GET_FRAME(pte), NULL); |
295 | (void *) PTE_GET_FRAME(pte), NULL); |
291 | page_table_unlock(area->as, false); |
296 | page_table_unlock(area->as, false); |
- | 297 | frame_reference_add(ADDR2PFN(PTE_GET_FRAME(pte))); |
|
292 | } |
298 | } |
293 | 299 | ||
294 | } |
300 | } |
295 | } |
301 | } |
296 | mutex_unlock(&area->sh_info->lock); |
302 | mutex_unlock(&area->sh_info->lock); |