Tab police

This commit is contained in:
Austin Clements 2010-09-01 00:32:27 -04:00
parent 5c4dc7395b
commit 5efca9054f
4 changed files with 15 additions and 15 deletions

View file

@ -18,8 +18,8 @@ static void consputc(int);
static int panicked = 0; static int panicked = 0;
static struct { static struct {
struct spinlock lock; struct spinlock lock;
int locking; int locking;
} cons; } cons;
static void static void

10
exec.c
View file

@ -30,7 +30,7 @@ exec(char *path, char **argv)
if(elf.magic != ELF_MAGIC) if(elf.magic != ELF_MAGIC)
goto bad; goto bad;
if (!(pgdir = setupkvm())) if(!(pgdir = setupkvm()))
goto bad; goto bad;
// Load program into memory. // Load program into memory.
@ -41,11 +41,11 @@ exec(char *path, char **argv)
continue; continue;
if(ph.memsz < ph.filesz) if(ph.memsz < ph.filesz)
goto bad; goto bad;
if (!allocuvm(pgdir, (char *)ph.va, ph.memsz)) if(!allocuvm(pgdir, (char *)ph.va, ph.memsz))
goto bad; goto bad;
if(ph.va + ph.memsz > sz) if(ph.va + ph.memsz > sz)
sz = ph.va + ph.memsz; sz = ph.va + ph.memsz;
if (!loaduvm(pgdir, (char *)ph.va, ip, ph.offset, ph.filesz)) if(!loaduvm(pgdir, (char *)ph.va, ip, ph.offset, ph.filesz))
goto bad; goto bad;
} }
iunlockput(ip); iunlockput(ip);
@ -53,7 +53,7 @@ exec(char *path, char **argv)
// Allocate and initialize stack at sz // Allocate and initialize stack at sz
sz = PGROUNDUP(sz); sz = PGROUNDUP(sz);
sz += PGSIZE; // leave an invalid page sz += PGSIZE; // leave an invalid page
if (!allocuvm(pgdir, (char *)sz, PGSIZE)) if(!allocuvm(pgdir, (char *)sz, PGSIZE))
goto bad; goto bad;
mem = uva2ka(pgdir, (char *)sz); mem = uva2ka(pgdir, (char *)sz);
spoffset = sz; spoffset = sz;
@ -105,7 +105,7 @@ exec(char *path, char **argv)
return 0; return 0;
bad: bad:
if (pgdir) freevm(pgdir); if(pgdir) freevm(pgdir);
iunlockput(ip); iunlockput(ip);
return -1; return -1;
} }

2
trap.c
View file

@ -86,7 +86,7 @@ trap(struct trapframe *tf)
cprintf("pid %d %s: trap %d err %d on cpu %d " cprintf("pid %d %s: trap %d err %d on cpu %d "
"eip 0x%x addr 0x%x--kill proc\n", "eip 0x%x addr 0x%x--kill proc\n",
proc->pid, proc->name, tf->trapno, tf->err, cpu->id, tf->eip, proc->pid, proc->name, tf->trapno, tf->err, cpu->id, tf->eip,
rcr2()); rcr2());
proc->killed = 1; proc->killed = 1;
} }

14
vm.c
View file

@ -244,13 +244,13 @@ freevm(pde_t *pgdir)
if (da != 0) { if (da != 0) {
pte_t *pgtab = (pte_t*) da; pte_t *pgtab = (pte_t*) da;
for (j = 0; j < NPTENTRIES; j++) { for (j = 0; j < NPTENTRIES; j++) {
if (pgtab[j] != 0) { if (pgtab[j] != 0) {
uint pa = PTE_ADDR(pgtab[j]); uint pa = PTE_ADDR(pgtab[j]);
uint va = PGADDR(i, j, 0); uint va = PGADDR(i, j, 0);
if (va < USERTOP) // user memory if (va < USERTOP) // user memory
kfree((void *) pa); kfree((void *) pa);
pgtab[j] = 0; pgtab[j] = 0;
} }
} }
kfree((void *) da); kfree((void *) da);
pgdir[i] = 0; pgdir[i] = 0;
@ -287,7 +287,7 @@ inituvm(pde_t *pgdir, char *addr, char *init, uint sz)
for (i = 0; i < sz; i += PGSIZE) { for (i = 0; i < sz; i += PGSIZE) {
if (!(pte = walkpgdir(pgdir, (void *)(i+addr), 0))) if (!(pte = walkpgdir(pgdir, (void *)(i+addr), 0)))
panic("inituvm: pte should exist\n"); panic("inituvm: pte should exist\n");
off = (i+(uint)addr) % PGSIZE; off = (i+(uint)addr) % PGSIZE;
pa = PTE_ADDR(*pte); pa = PTE_ADDR(*pte);
if (sz - i < PGSIZE) n = sz - i; if (sz - i < PGSIZE) n = sz - i;