summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Morris <[email protected]>2010-08-31 19:21:52 -0400
committerRobert Morris <[email protected]>2010-08-31 19:21:52 -0400
commit23c3e52c2fb5f1709bf5053a8e93161931b56bf9 (patch)
treecb51f605a35de8980efce5dcab3e5df9757c022a
parent3597d5dc704c192a85b9902f7264fe9025aad277 (diff)
parent5048762c7e27789a014cc1e74e1002e749c924ce (diff)
downloadxv6-labs-23c3e52c2fb5f1709bf5053a8e93161931b56bf9.tar.gz
xv6-labs-23c3e52c2fb5f1709bf5053a8e93161931b56bf9.tar.bz2
xv6-labs-23c3e52c2fb5f1709bf5053a8e93161931b56bf9.zip
Merge branch 'master' of git+ssh://amsterdam.csail.mit.edu/home/am0/6.828/xv6
-rw-r--r--Makefile2
-rw-r--r--README3
-rw-r--r--kalloc.c1
-rw-r--r--mmu.h33
-rw-r--r--proc.c3
-rwxr-xr-xrunoff16
-rw-r--r--runoff.list7
-rw-r--r--runoff.spec6
-rw-r--r--trap.c3
-rw-r--r--x86.h89
10 files changed, 82 insertions, 81 deletions
diff --git a/Makefile b/Makefile
index 8f820e1..37924e2 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/README b/README
index 286d336..c46ec2a 100644
--- a/README
+++ b/README
@@ -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.
diff --git a/kalloc.c b/kalloc.c
index 43e80e8..5f690f5 100644
--- a/kalloc.c
+++ b/kalloc.c
@@ -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
diff --git a/mmu.h b/mmu.h
index db40f25..475eae8 100644
--- a/mmu.h
+++ b/mmu.h
@@ -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
diff --git a/proc.c b/proc.c
index 5ac2780..0dc77b8 100644
--- a/proc.c
+++ b/proc.c
@@ -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;
diff --git a/runoff b/runoff
index 21ee8ed..14db252 100755
--- a/runoff
+++ b/runoff
@@ -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
diff --git a/trap.c b/trap.c
index daee22f..ae26739 100644
--- a/trap.c
+++ b/trap.c
@@ -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;
diff --git a/x86.h b/x86.h
index b9fa8b8..33e240d 100644
--- a/x86.h
+++ b/x86.h
@@ -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().