Skip to content

Commit

Permalink
tiny clarifications to some gdt code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Morris committed Aug 10, 2016
1 parent 0a4a423 commit 858475e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 4 additions & 0 deletions mmu.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,17 @@

#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
#define SEG_UCODE 4 // user code
#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
Expand Down
3 changes: 0 additions & 3 deletions proc.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 1 addition & 2 deletions vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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));
Expand Down

0 comments on commit 858475e

Please sign in to comment.