Mercurial > hg > CbC > CbC_xv6
comparison src/impl/vm_impl_private.cbc @ 208:f940ff602312
copyuvm_loop
author | tobaru |
---|---|
date | Fri, 24 Jan 2020 16:17:25 +0900 |
parents | 0f1700bd5cff |
children | 1c923ae14607 |
comparison
equal
deleted
inserted
replaced
207:0f1700bd5cff | 208:f940ff602312 |
---|---|
211 // in ARM, we change the AP field (ap & 0x3) << 4) | 211 // in ARM, we change the AP field (ap & 0x3) << 4) |
212 *pte = (*pte & ~(0x03 << 4)) | AP_KO << 4; | 212 *pte = (*pte & ~(0x03 << 4)) | AP_KO << 4; |
213 | 213 |
214 goto next(ret, ...); | 214 goto next(ret, ...); |
215 } | 215 } |
216 | |
217 __code copyuvm_check_nullvm_impl(struct vm_impl* vm_impl, pde_t* pgdir, uint sz, __code next(int ret, ...)) { | |
218 pde_t *d; | |
219 pte_t *pte; | |
220 uint pa, i, ap; | |
221 char *mem; | |
222 | |
223 // allocate a new first level page directory | |
224 d = kpt_alloc(); | |
225 if (d == NULL ) { | |
226 ret = NULL; | |
227 goto next(ret, ...); | |
228 } | |
229 i = 0; | |
230 | |
231 goto copyuvm_loopvm_impl(vm_impl, pgdir, sz, *d, *pte, pa, i, ap, *mem, next(ret, ...)); | |
232 } | |
233 | |
234 __code copyuvm_loopvm_impl(struct vm_impl* vm_impl, pde_t* pgdir, uint sz, pde_t* d, pte_t* pte, uint pa, uint i, uint ap, char* mem, __code next(int ret, ...)) { | |
235 | |
236 if (i < sz) { | |
237 if ((pte = walkpgdir(pgdir, (void *) i, 0)) == 0) { | |
238 panic("copyuvm: pte should exist"); | |
239 } | |
240 | |
241 if (!(*pte & PE_TYPES)) { | |
242 panic("copyuvm: page not present"); | |
243 } | |
244 | |
245 pa = PTE_ADDR (*pte); | |
246 ap = PTE_AP (*pte); | |
247 | |
248 if ((mem = alloc_page()) == 0) { | |
249 goto copyuvm_loop_bad(vm_impl, d, next(...)); | |
250 } | |
251 | |
252 memmove(mem, (char*) p2v(pa), PTE_SZ); | |
253 | |
254 if (mappages(d, (void*) i, PTE_SZ, v2p(mem), ap) < 0) { | |
255 goto copyuvm_loop_bad(vm_impl, d, next(...)); | |
256 } | |
257 goto copyuvm_loopvm_impl(vm_impl, pgdir, sz, d, pte, pa, i + PTE_SZ, ap, mem, next(ret, ...)); | |
258 } | |
259 ret = d; | |
260 goto next(ret, ...); | |
261 } | |
262 | |
263 __code copyuvm_loop_check_walkpgdir() { | |
264 | |
265 } | |
266 | |
267 __code copyuvm_loop_bad(struct vm_impl* vm_impl, pde_t* d, __code next(int ret, ...)) { | |
268 freevm(d); | |
269 ret = 0; | |
270 goto next(ret, ...); | |
271 } |