diff options
author | Frans Kaashoek <[email protected]> | 2018-10-09 14:28:54 -0400 |
---|---|---|
committer | Frans Kaashoek <[email protected]> | 2018-10-09 14:28:54 -0400 |
commit | 54e6f829e4019e10734588b9ba63c2c186c94f8e (patch) | |
tree | c4fae7ef568183e9566d69fb6f563c218c12819b /proc.c | |
parent | f241e67d911d790376de26698f8bf8ba02550212 (diff) | |
download | xv6-labs-54e6f829e4019e10734588b9ba63c2c186c94f8e.tar.gz xv6-labs-54e6f829e4019e10734588b9ba63c2c186c94f8e.tar.bz2 xv6-labs-54e6f829e4019e10734588b9ba63c2c186c94f8e.zip |
Separate system call path from trap path. Passes usertests on 1 and 2 cpus.
Diffstat (limited to 'proc.c')
-rw-r--r-- | proc.c | 26 |
1 files changed, 11 insertions, 15 deletions
@@ -17,10 +17,8 @@ static struct proc *initproc; int nextpid = 1; extern void forkret(void); -// we can return two ways out of the kernel and -// for new processes we can choose either way +// for returning out of the kernel extern void sysexit(void); -extern void trapret(void); static void wakeup1(void *chan); @@ -102,16 +100,16 @@ found: } sp = p->kstack + KSTACKSIZE; - // Leave room for trap frame. - sp -= sizeof *p->tf; + // Leave room for syscall frame. + sp -= sizeof *p->sf; if ((uint64) sp % 16) panic("misaligned sp"); - p->tf = (struct trapframe*)sp; + p->sf = (struct sysframe*)sp; // Set up new context to start executing at forkret, - // which returns to trapret. + // which returns to sysexit. sp -= sizeof(uint64); *(uint64*)sp = (uint64)sysexit; @@ -138,12 +136,10 @@ userinit(void) panic("userinit: out of memory?"); inituvm(p->pgdir, _binary_initcode_start, (uint64)_binary_initcode_size); p->sz = PGSIZE; - memset(p->tf, 0, sizeof(*p->tf)); - p->tf->cs = SEG_UCODE | DPL_USER; - p->tf->ss = SEG_UDATA | DPL_USER; - p->tf->r11 = FL_IF; - p->tf->rsp = PGSIZE; - p->tf->rcx = 0; // beginning of initcode.S + memset(p->sf, 0, sizeof(*p->sf)); + p->sf->r11 = FL_IF; + p->sf->rsp = PGSIZE; + p->sf->rcx = 0; // beginning of initcode.S safestrcpy(p->name, "initcode", sizeof(p->name)); p->cwd = namei("/"); @@ -204,10 +200,10 @@ fork(void) } np->sz = curproc->sz; np->parent = curproc; - *np->tf = *curproc->tf; + *np->sf = *curproc->sf; // Clear %eax so that fork returns 0 in the child. - np->tf->rax = 0; + np->sf->rax = 0; for(i = 0; i < NOFILE; i++) if(curproc->ofile[i]) |