add DPL_USER constant
This commit is contained in:
parent
f83f7ce2f6
commit
b6dc6187f7
4 changed files with 8 additions and 6 deletions
4
main.c
4
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;
|
||||
|
||||
|
|
2
mmu.h
2
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)
|
||||
|
|
4
proc.c
4
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;
|
||||
|
|
4
trap.c
4
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.
|
||||
|
|
Loading…
Reference in a new issue