diff options
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | README | 3 | ||||
| -rw-r--r-- | kalloc.c | 1 | ||||
| -rw-r--r-- | mmu.h | 33 | ||||
| -rw-r--r-- | proc.c | 3 | ||||
| -rwxr-xr-x | runoff | 16 | ||||
| -rw-r--r-- | runoff.list | 7 | ||||
| -rw-r--r-- | runoff.spec | 6 | ||||
| -rw-r--r-- | trap.c | 3 | ||||
| -rw-r--r-- | x86.h | 89 | 
10 files changed, 82 insertions, 81 deletions
| @@ -159,7 +159,7 @@ clean:  # make a printout  FILES = $(shell grep -v '^\#' runoff.list) -PRINT = runoff.list $(FILES) +PRINT = runoff.list runoff.spec $(FILES)  xv6.pdf: $(PRINT)  	./runoff @@ -20,6 +20,9 @@ The following people made contributions:      Cliff Frey (MP)      Xiao Yu (MP) +In addition, we are grateful for the patches submitted by Greg Price, +Yandong Mao, and Hitoshi Mitake. +  The code in the files that constitute xv6 is  Copyright 2006-2007 Frans Kaashoek, Robert Morris, and Russ Cox. @@ -29,6 +29,7 @@ kinit(void)      kfree(p);  } +//PAGEBREAK: 21  // Free the page of physical memory pointed at by v,  // which normally should have been returned by a  // call to kalloc().  (The exception is when @@ -24,6 +24,20 @@  #define FL_VIP          0x00100000      // Virtual Interrupt Pending  #define FL_ID           0x00200000      // ID flag +// Control Register flags +#define CR0_PE		0x00000001	// Protection Enable +#define CR0_MP		0x00000002	// Monitor coProcessor +#define CR0_EM		0x00000004	// Emulation +#define CR0_TS		0x00000008	// Task Switched +#define CR0_ET		0x00000010	// Extension Type +#define CR0_NE		0x00000020	// Numeric Errror +#define CR0_WP		0x00010000	// Write Protect +#define CR0_AM		0x00040000	// Alignment Mask +#define CR0_NW		0x20000000	// Not Writethrough +#define CR0_CD		0x40000000	// Cache Disable +#define CR0_PG		0x80000000	// Paging + +//PAGEBREAK!  // Segment Descriptor  struct segdesc {    uint lim_15_0 : 16;  // Low bits of segment limit @@ -46,7 +60,6 @@ struct segdesc {  { ((lim) >> 12) & 0xffff, (uint)(base) & 0xffff,      \    ((uint)(base) >> 16) & 0xff, type, 1, dpl, 1,       \    (uint)(lim) >> 28, 0, 0, 1, 1, (uint)(base) >> 24 } -  #define SEG16(type, base, lim, dpl) (struct segdesc)  \  { (lim) & 0xffff, (uint)(base) & 0xffff,              \    ((uint)(base) >> 16) & 0xff, type, 1, dpl, 1,       \ @@ -62,8 +75,6 @@ struct segdesc {  #define STA_R       0x2     // Readable (executable segments)  #define STA_A       0x1     // Accessed -//  -  // System segment type bits  #define STS_T16A    0x1     // Available 16-bit TSS  #define STS_LDT     0x2     // Local Descriptor Table @@ -78,7 +89,6 @@ struct segdesc {  #define STS_IG32    0xE     // 32-bit Interrupt Gate  #define STS_TG32    0xF     // 32-bit Trap Gate -  // A linear address 'la' has a three-part structure as follows:  //  // +--------10------+-------10-------+---------12----------+ @@ -130,21 +140,6 @@ struct segdesc {  typedef uint pte_t; -// Control Register flags -#define CR0_PE		0x00000001	// Protection Enable -#define CR0_MP		0x00000002	// Monitor coProcessor -#define CR0_EM		0x00000004	// Emulation -#define CR0_TS		0x00000008	// Task Switched -#define CR0_ET		0x00000010	// Extension Type -#define CR0_NE		0x00000020	// Numeric Errror -#define CR0_WP		0x00010000	// Write Protect -#define CR0_AM		0x00040000	// Alignment Mask -#define CR0_NW		0x20000000	// Not Writethrough -#define CR0_CD		0x40000000	// Cache Disable -#define CR0_PG		0x80000000	// Paging - - -// PAGEBREAK: 40  // Task state segment format  struct taskstate {    uint link;         // Old ts selector @@ -120,7 +120,8 @@ userinit(void)      panic("userinit: out of memory?");    if (!allocuvm(p->pgdir, 0x0, (int)_binary_initcode_size))      panic("userinit: out of memory?"); -  inituvm(p->pgdir, 0x0, _binary_initcode_start, (int)_binary_initcode_size); +  inituvm(p->pgdir, 0x0, _binary_initcode_start, +          (int)_binary_initcode_size);    p->sz = PGROUNDUP((int)_binary_initcode_size);    memset(p->tf, 0, sizeof(*p->tf));    p->tf->cs = (SEG_UCODE << 3) | DPL_USER; @@ -82,23 +82,25 @@ perl -e '  			next;  		} -		if(/(left|right): (.*)/){ +		if(/(left|right)(\+?): (.*)/){  			$what = $1; -			$file = $2; +			$tens = ($2 eq "+" ? "5" : "0"); +			$file = $3;  			if(!defined($toc{$file})){  				print STDERR "Have no toc for $file\n";  				next;  			} -			# this assumes that sheet 1 of code is a left page -			# double-check the PDF +			# this assumes that sheet 1 of code is a right page +			# double-check the PDF.  swap the two regexps below +			# otherwise.  			if(!$leftwarn++) { -				print STDERR "assuming that sheet 1 is a left page.  double-check!\n"; +				print STDERR "assuming that sheet 1 is a right page.  double-check!\n";  			} -			if($what eq "left" && !($toc{$file} =~ /^\d[13579]0/)){ +			if($what eq "left" && !($toc{$file} =~ /^\d[02468]$tens/)){  				print STDERR "$file does not start on a fresh left page [$toc{$file}]\n";  			}  			# why does this not work if I inline $x in the if? -			$x = ($toc{$file} =~ /^\d[02468]0/); +			$x = ($toc{$file} =~ /^\d[13579]$tens/);  			if($what eq "right" && !$x){  				print STDERR "$file does not start on a fresh right page [$toc{$file}] [$x]\n";  			} diff --git a/runoff.list b/runoff.list index 3258398..025bbe2 100644 --- a/runoff.list +++ b/runoff.list @@ -9,8 +9,8 @@ elf.h  # startup  bootasm.S -bootother.S  bootmain.c +bootother.S  main.c  # locks @@ -23,7 +23,6 @@ proc.c  swtch.S  kalloc.c  vm.c -  # system calls  traps.h  vectors.pl @@ -46,8 +45,6 @@ file.c  sysfile.c  exec.c - -  # pipes  pipe.c @@ -73,3 +70,5 @@ init.c  sh.c + + diff --git a/runoff.spec b/runoff.spec index e4cfd42..e6f5a95 100644 --- a/runoff.spec +++ b/runoff.spec @@ -16,15 +16,15 @@ even: main.c  # odd: init.c  # spinlock.h either -# spinlock.c either +right: spinlock.c  # mild preference  even: proc.h  # mild preference  # goal is to have two action-packed 2-page spreads,  # one with -#     ksegment usegment allocproc userinit growproc fork +#     allocproc userinit growproc fork  # and another with  #     scheduler sched yield forkret sleep wakeup1 wakeup -right: proc.c   # VERY important +right+: proc.c   # VERY important  # setjmp.S either  # vm.c either @@ -83,7 +83,8 @@ trap(struct trapframe *tf)        panic("trap");      }      // In user space, assume process misbehaved. -    cprintf("pid %d %s: trap %d err %d on cpu %d eip 0x%x addr 0x%x--kill proc\n", +    cprintf("pid %d %s: trap %d err %d on cpu %d " +            "eip 0x%x addr 0x%x--kill proc\n",              proc->pid, proc->name, tf->trapno, tf->err, cpu->id, tf->eip,   	    rcr2());      proc->killed = 1; @@ -90,23 +90,26 @@ readeflags(void)    return eflags;  } +static inline void +loadgs(ushort v) +{ +  asm volatile("movw %0, %%gs" : : "r" (v)); +} +  static inline uint -xchg(volatile uint *addr, uint newval) +rebp(void)  { -  uint result; -   -  // The + in "+m" denotes a read-modify-write operand. -  asm volatile("lock; xchgl %0, %1" : -               "+m" (*addr), "=a" (result) : -               "1" (newval) : -               "cc"); -  return result; +  uint val; +  asm volatile("movl %%ebp,%0" : "=r" (val)); +  return val;  } -static inline void -loadgs(ushort v) +static inline uint +resp(void)  { -  asm volatile("movw %0, %%gs" : : "r" (v)); +  uint val; +  asm volatile("movl %%esp,%0" : "=r" (val)); +  return val;  }  static inline void @@ -121,66 +124,62 @@ sti(void)    asm volatile("sti");  } -static inline void lcr0(uint val) -{ -  asm volatile("movl %0,%%cr0" : : "r" (val)); -} - -static inline uint rcr0(void) +static inline uint +xchg(volatile uint *addr, uint newval)  { -  uint val; -  asm volatile("movl %%cr0,%0" : "=r" (val)); -  return val; +  uint result; +   +  // The + in "+m" denotes a read-modify-write operand. +  asm volatile("lock; xchgl %0, %1" : +               "+m" (*addr), "=a" (result) : +               "1" (newval) : +               "cc"); +  return result;  } -static inline uint rcr2(void) +static inline void +nop_pause(void)  { -  uint val; -  asm volatile("movl %%cr2,%0" : "=r" (val)); -  return val; +  asm volatile("pause" : :);  } -static inline void lcr3(uint val)  +//PAGEBREAK! +static inline void +lcr0(uint val)  { -  asm volatile("movl %0,%%cr3" : : "r" (val)); +  asm volatile("movl %0,%%cr0" : : "r" (val));  } -static inline uint rcr3(void) +static inline uint +rcr0(void)  {    uint val; -  asm volatile("movl %%cr3,%0" : "=r" (val)); +  asm volatile("movl %%cr0,%0" : "=r" (val));    return val;  } -static inline void lebp(uint val) -{ -  asm volatile("movl %0,%%ebp" : : "r" (val)); -} - -static inline uint rebp(void) +static inline uint +rcr2(void)  {    uint val; -  asm volatile("movl %%ebp,%0" : "=r" (val)); +  asm volatile("movl %%cr2,%0" : "=r" (val));    return val;  } -static inline void lesp(uint val) +static inline void +lcr3(uint val)   { -  asm volatile("movl %0,%%esp" : : "r" (val)); +  asm volatile("movl %0,%%cr3" : : "r" (val));  } -static inline uint resp(void) +static inline uint +rcr3(void)  {    uint val; -  asm volatile("movl %%esp,%0" : "=r" (val)); +  asm volatile("movl %%cr3,%0" : "=r" (val));    return val;  } -static inline void nop_pause(void) -{ -  asm volatile("pause" : :); -} -  //PAGEBREAK: 36  // Layout of the trap frame built on the stack by the  // hardware and by trapasm.S, and passed to trap(). | 
