xv6

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit b6dc6187f7b0868f0a08e80a20c2a13c32e519ed
parent f83f7ce2f6ef5b840d8af8ed2573e1934865406f
Author: rsc <rsc>
Date:   Wed,  8 Aug 2007 09:02:42 +0000

add DPL_USER constant

Diffstat:
Mmain.c | 4++--
Mmmu.h | 2++
Mproc.c | 4++--
Mtrap.c | 4++--
4 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/main.c b/main.c @@ -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; diff --git a/mmu.h b/mmu.h @@ -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) diff --git a/proc.c b/proc.c @@ -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; diff --git a/trap.c b/trap.c @@ -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.