diff --git a/mmu.h b/mmu.h index 685f51d..310d5de 100644 --- a/mmu.h +++ b/mmu.h @@ -39,6 +39,7 @@ #define CR4_PSE 0x00000010 // Page size extension +// various segment selectors. #define SEG_KCODE 1 // kernel code #define SEG_KDATA 2 // kernel data+stack #define SEG_KCPU 3 // kernel per-cpu data @@ -46,6 +47,9 @@ #define SEG_UDATA 5 // user data+stack #define SEG_TSS 6 // this process's task state +// cpu->gdt[NSEGS] holds the above segments. +#define NSEGS 7 + //PAGEBREAK! #ifndef __ASSEMBLER__ // Segment Descriptor diff --git a/proc.h b/proc.h index 3b9c3ac..33a9558 100644 --- a/proc.h +++ b/proc.h @@ -1,6 +1,3 @@ -// Segments in proc->gdt. -#define NSEGS 7 - // Per-CPU state struct cpu { uchar id; // Local APIC ID; index into cpus[] below diff --git a/vm.c b/vm.c index 85f6ce2..cd36db5 100644 --- a/vm.c +++ b/vm.c @@ -9,7 +9,6 @@ extern char data[]; // defined by kernel.ld pde_t *kpgdir; // for use in scheduler() -struct segdesc gdt[NSEGS]; // Set up CPU's kernel segment descriptors. // Run once on entry on each CPU. @@ -28,7 +27,7 @@ seginit(void) c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, DPL_USER); c->gdt[SEG_UDATA] = SEG(STA_W, 0, 0xffffffff, DPL_USER); - // Map cpu, and curproc + // Map cpu and curproc -- these are private per cpu. c->gdt[SEG_KCPU] = SEG(STA_W, &c->cpu, 8, 0); lgdt(c->gdt, sizeof(c->gdt));