diff options
| author | rsc <rsc> | 2007-08-08 09:02:42 +0000 | 
|---|---|---|
| committer | rsc <rsc> | 2007-08-08 09:02:42 +0000 | 
| commit | b6dc6187f7b0868f0a08e80a20c2a13c32e519ed (patch) | |
| tree | e680e25b97933c24e61c80ec9552860b0f359283 | |
| parent | f83f7ce2f6ef5b840d8af8ed2573e1934865406f (diff) | |
| download | xv6-labs-b6dc6187f7b0868f0a08e80a20c2a13c32e519ed.tar.gz xv6-labs-b6dc6187f7b0868f0a08e80a20c2a13c32e519ed.tar.bz2 xv6-labs-b6dc6187f7b0868f0a08e80a20c2a13c32e519ed.zip | |
add DPL_USER constant
| -rw-r--r-- | main.c | 4 | ||||
| -rw-r--r-- | mmu.h | 2 | ||||
| -rw-r--r-- | proc.c | 4 | ||||
| -rw-r--r-- | trap.c | 4 | 
4 files changed, 8 insertions, 6 deletions
| @@ -138,8 +138,8 @@ process0()    // process to return to.    p0->tf = &tf;    memset(p0->tf, 0, sizeof(struct trapframe)); -  p0->tf->es = p0->tf->ds = p0->tf->ss = (SEG_UDATA << 3) | 3; -  p0->tf->cs = (SEG_UCODE << 3) | 3; +  p0->tf->es = p0->tf->ds = p0->tf->ss = (SEG_UDATA << 3) | DPL_USER; +  p0->tf->cs = (SEG_UCODE << 3) | DPL_USER;    p0->tf->eflags = FL_IF;    p0->tf->esp = p0->sz; @@ -55,6 +55,8 @@ struct segdesc {      type, 1, dpl, 1, (uint) (lim) >> 16, 0, 0, 1, 0,            \      (uint) (base) >> 24 } +#define DPL_USER    0x3     // User DPL +  // Application segment type bits  #define STA_X       0x8     // Executable segment  #define STA_E       0x4     // Expand down (non-executable segments) @@ -43,8 +43,8 @@ setupsegs(struct proc *p)    c->gdt[SEG_TSS] = SEG16(STS_T32A, (uint) &c->ts, sizeof(c->ts), 0);    c->gdt[SEG_TSS].s = 0;    if(p){ -    c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, (uint)p->mem, p->sz, 3); -    c->gdt[SEG_UDATA] = SEG(STA_W, (uint)p->mem, p->sz, 3); +    c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, (uint)p->mem, p->sz, DPL_USER); +    c->gdt[SEG_UDATA] = SEG(STA_W, (uint)p->mem, p->sz, DPL_USER);    } else {      c->gdt[SEG_UCODE] = SEG_NULL;      c->gdt[SEG_UDATA] = SEG_NULL; @@ -18,7 +18,7 @@ tvinit(void)    for(i = 0; i < 256; i++)      SETGATE(idt[i], 0, SEG_KCODE << 3, vectors[i], 0); -  SETGATE(idt[T_SYSCALL], 0, SEG_KCODE << 3, vectors[T_SYSCALL], 3); +  SETGATE(idt[T_SYSCALL], 0, SEG_KCODE << 3, vectors[T_SYSCALL], DPL_USER);  }  void @@ -56,7 +56,7 @@ trap(struct trapframe *tf)        // Force process exit if it has been killed and is in user space.        // (If it is still executing in the kernel, let it keep running        // until it gets to the regular system call return.) -      if((tf->cs&3) == 3 && cp->killed) +      if((tf->cs&3) == DPL_USER && cp->killed)          proc_exit();        // Force process to give up CPU and let others run. | 
