diff options
| author | Russ Cox <rsc@swtch.com> | 2011-01-11 13:51:40 -0500 | 
|---|---|---|
| committer | Russ Cox <rsc@swtch.com> | 2011-01-11 13:51:40 -0500 | 
| commit | 417c37115e0c7fc3b2a65c3c4d213e566cbc8807 (patch) | |
| tree | cfeb8340b4f382261b12f1be447632ec5fbe5532 | |
| parent | 89bfdd4db183cbe75a3a0c2254ca48a50e37276f (diff) | |
| download | xv6-labs-417c37115e0c7fc3b2a65c3c4d213e566cbc8807.tar.gz xv6-labs-417c37115e0c7fc3b2a65c3c4d213e566cbc8807.tar.bz2 xv6-labs-417c37115e0c7fc3b2a65c3c4d213e566cbc8807.zip | |
more trivial cleanup
| -rw-r--r-- | defs.h | 6 | ||||
| -rw-r--r-- | kalloc.c | 2 | ||||
| -rw-r--r-- | vm.c | 21 | 
3 files changed, 13 insertions, 16 deletions
| @@ -161,11 +161,11 @@ int             allocuvm(pde_t*, uint, uint);  int             deallocuvm(pde_t*, uint, uint);  void            freevm(pde_t*);  void            inituvm(pde_t*, char*, uint); -int             loaduvm(pde_t*, char*, struct inode *, uint, uint); -pde_t*          copyuvm(pde_t*,uint); +int             loaduvm(pde_t*, char*, struct inode*, uint, uint); +pde_t*          copyuvm(pde_t*, uint);  void            switchuvm(struct proc*);  void            switchkvm(void); -int             copyout(pde_t *pgdir, uint va, void *buf, uint len); +int             copyout(pde_t*, uint, void*, uint);  // number of elements in fixed-size array  #define NELEM(x) (sizeof(x)/sizeof((x)[0])) @@ -27,7 +27,7 @@ kinit(void)    initlock(&kmem.lock, "kmem");    p = (char*)PGROUNDUP((uint)end); -  for(; p + PGSIZE - 1 < (char*)PHYSTOP; p += PGSIZE) +  for(; p + PGSIZE <= (char*)PHYSTOP; p += PGSIZE)      kfree(p);  } @@ -250,16 +250,16 @@ loaduvm(pde_t *pgdir, char *addr, struct inode *ip, uint offset, uint sz)  int  allocuvm(pde_t *pgdir, uint oldsz, uint newsz)  { -  char *a, *last, *mem; +  char *mem; +  uint a;    if(newsz > USERTOP)      return 0;    if(newsz < oldsz)      return oldsz; -  a = (char*)PGROUNDUP(oldsz); -  last = PGROUNDDOWN(newsz - 1); -  for(; a <= last; a += PGSIZE){ +  a = PGROUNDUP(oldsz); +  for(; a < newsz; a += PGSIZE){      mem = kalloc();      if(mem == 0){        cprintf("allocuvm out of memory\n"); @@ -267,7 +267,7 @@ allocuvm(pde_t *pgdir, uint oldsz, uint newsz)        return 0;      }      memset(mem, 0, PGSIZE); -    mappages(pgdir, a, PGSIZE, PADDR(mem), PTE_W|PTE_U); +    mappages(pgdir, (char*)a, PGSIZE, PADDR(mem), PTE_W|PTE_U);    }    return newsz;  } @@ -279,17 +279,15 @@ allocuvm(pde_t *pgdir, uint oldsz, uint newsz)  int  deallocuvm(pde_t *pgdir, uint oldsz, uint newsz)  { -  char *a, *last;    pte_t *pte; -  uint pa; +  uint a, pa;    if(newsz >= oldsz)      return oldsz; -  a = (char*)PGROUNDUP(newsz); -  last = PGROUNDDOWN(oldsz - 1); -  for(; a <= last; a += PGSIZE){ -    pte = walkpgdir(pgdir, a, 0); +  a = PGROUNDUP(newsz); +  for(; a  < oldsz; a += PGSIZE){ +    pte = walkpgdir(pgdir, (char*)a, 0);      if(pte && (*pte & PTE_P) != 0){        pa = PTE_ADDR(*pte);        if(pa == 0) @@ -351,7 +349,6 @@ bad:  // copy some data to user address va in page table pgdir.  // most useful when pgdir is not the current page table. -// returns 1 if everthing OK, 0 on error.  // uva2ka ensures this only works for PTE_U pages.  int  copyout(pde_t *pgdir, uint va, void *xbuf, uint len) | 
