Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
23c3e52c
提交
23c3e52c
8月 31, 2010
创建
作者:
Robert Morris
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
git+ssh://amsterdam.csail.mit.edu/home/am0/6.828/xv6
上级
3597d5dc
5048762c
隐藏空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
82 行增加
和
81 行删除
+82
-81
Makefile
Makefile
+1
-1
README
README
+3
-0
kalloc.c
kalloc.c
+1
-0
mmu.h
mmu.h
+14
-19
proc.c
proc.c
+2
-1
runoff
runoff
+9
-7
runoff.list
runoff.list
+3
-4
runoff.spec
runoff.spec
+3
-3
trap.c
trap.c
+2
-1
x86.h
x86.h
+44
-45
没有找到文件。
Makefile
浏览文件 @
23c3e52c
...
@@ -159,7 +159,7 @@ clean:
...
@@ -159,7 +159,7 @@ clean:
# make a printout
# make a printout
FILES
=
$(
shell
grep
-v
'^\#'
runoff.list
)
FILES
=
$(
shell
grep
-v
'^\#'
runoff.list
)
PRINT
=
runoff.list
$(FILES)
PRINT
=
runoff.list
runoff.spec
$(FILES)
xv6.pdf
:
$(PRINT)
xv6.pdf
:
$(PRINT)
./runoff
./runoff
...
...
README
浏览文件 @
23c3e52c
...
@@ -20,6 +20,9 @@ The following people made contributions:
...
@@ -20,6 +20,9 @@ The following people made contributions:
Cliff Frey (MP)
Cliff Frey (MP)
Xiao Yu (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
The code in the files that constitute xv6 is
Copyright 2006-2007 Frans Kaashoek, Robert Morris, and Russ Cox.
Copyright 2006-2007 Frans Kaashoek, Robert Morris, and Russ Cox.
...
...
kalloc.c
浏览文件 @
23c3e52c
...
@@ -29,6 +29,7 @@ kinit(void)
...
@@ -29,6 +29,7 @@ kinit(void)
kfree
(
p
);
kfree
(
p
);
}
}
//PAGEBREAK: 21
// Free the page of physical memory pointed at by v,
// Free the page of physical memory pointed at by v,
// which normally should have been returned by a
// which normally should have been returned by a
// call to kalloc(). (The exception is when
// call to kalloc(). (The exception is when
...
...
mmu.h
浏览文件 @
23c3e52c
...
@@ -24,6 +24,20 @@
...
@@ -24,6 +24,20 @@
#define FL_VIP 0x00100000 // Virtual Interrupt Pending
#define FL_VIP 0x00100000 // Virtual Interrupt Pending
#define FL_ID 0x00200000 // ID flag
#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
// Segment Descriptor
struct
segdesc
{
struct
segdesc
{
uint
lim_15_0
:
16
;
// Low bits of segment limit
uint
lim_15_0
:
16
;
// Low bits of segment limit
...
@@ -46,7 +60,6 @@ struct segdesc {
...
@@ -46,7 +60,6 @@ struct segdesc {
{ ((lim) >> 12) & 0xffff, (uint)(base) & 0xffff, \
{ ((lim) >> 12) & 0xffff, (uint)(base) & 0xffff, \
((uint)(base) >> 16) & 0xff, type, 1, dpl, 1, \
((uint)(base) >> 16) & 0xff, type, 1, dpl, 1, \
(uint)(lim) >> 28, 0, 0, 1, 1, (uint)(base) >> 24 }
(uint)(lim) >> 28, 0, 0, 1, 1, (uint)(base) >> 24 }
#define SEG16(type, base, lim, dpl) (struct segdesc) \
#define SEG16(type, base, lim, dpl) (struct segdesc) \
{ (lim) & 0xffff, (uint)(base) & 0xffff, \
{ (lim) & 0xffff, (uint)(base) & 0xffff, \
((uint)(base) >> 16) & 0xff, type, 1, dpl, 1, \
((uint)(base) >> 16) & 0xff, type, 1, dpl, 1, \
...
@@ -62,8 +75,6 @@ struct segdesc {
...
@@ -62,8 +75,6 @@ struct segdesc {
#define STA_R 0x2 // Readable (executable segments)
#define STA_R 0x2 // Readable (executable segments)
#define STA_A 0x1 // Accessed
#define STA_A 0x1 // Accessed
//
// System segment type bits
// System segment type bits
#define STS_T16A 0x1 // Available 16-bit TSS
#define STS_T16A 0x1 // Available 16-bit TSS
#define STS_LDT 0x2 // Local Descriptor Table
#define STS_LDT 0x2 // Local Descriptor Table
...
@@ -78,7 +89,6 @@ struct segdesc {
...
@@ -78,7 +89,6 @@ struct segdesc {
#define STS_IG32 0xE // 32-bit Interrupt Gate
#define STS_IG32 0xE // 32-bit Interrupt Gate
#define STS_TG32 0xF // 32-bit Trap Gate
#define STS_TG32 0xF // 32-bit Trap Gate
// A linear address 'la' has a three-part structure as follows:
// A linear address 'la' has a three-part structure as follows:
//
//
// +--------10------+-------10-------+---------12----------+
// +--------10------+-------10-------+---------12----------+
...
@@ -130,21 +140,6 @@ struct segdesc {
...
@@ -130,21 +140,6 @@ struct segdesc {
typedef
uint
pte_t
;
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
// Task state segment format
struct
taskstate
{
struct
taskstate
{
uint
link
;
// Old ts selector
uint
link
;
// Old ts selector
...
...
proc.c
浏览文件 @
23c3e52c
...
@@ -120,7 +120,8 @@ userinit(void)
...
@@ -120,7 +120,8 @@ userinit(void)
panic
(
"userinit: out of memory?"
);
panic
(
"userinit: out of memory?"
);
if
(
!
allocuvm
(
p
->
pgdir
,
0x0
,
(
int
)
_binary_initcode_size
))
if
(
!
allocuvm
(
p
->
pgdir
,
0x0
,
(
int
)
_binary_initcode_size
))
panic
(
"userinit: out of memory?"
);
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
);
p
->
sz
=
PGROUNDUP
((
int
)
_binary_initcode_size
);
memset
(
p
->
tf
,
0
,
sizeof
(
*
p
->
tf
));
memset
(
p
->
tf
,
0
,
sizeof
(
*
p
->
tf
));
p
->
tf
->
cs
=
(
SEG_UCODE
<<
3
)
|
DPL_USER
;
p
->
tf
->
cs
=
(
SEG_UCODE
<<
3
)
|
DPL_USER
;
...
...
runoff
浏览文件 @
23c3e52c
...
@@ -82,23 +82,25 @@ perl -e '
...
@@ -82,23 +82,25 @@ perl -e '
next;
next;
}
}
if(/(left|right): (.*)/){
if(/(left|right)
(\+?)
: (.*)/){
$what = $1;
$what = $1;
$file = $2;
$tens = ($2 eq "+" ? "5" : "0");
$file = $3;
if(!defined($toc{$file})){
if(!defined($toc{$file})){
print STDERR "Have no toc for $file\n";
print STDERR "Have no toc for $file\n";
next;
next;
}
}
# this assumes that sheet 1 of code is a left page
# this assumes that sheet 1 of code is a right page
# double-check the PDF
# double-check the PDF. swap the two regexps below
# otherwise.
if(!$leftwarn++) {
if(!$leftwarn++) {
print STDERR "assuming that sheet 1 is a
lef
t page. double-check!\n";
print STDERR "assuming that sheet 1 is a
righ
t 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";
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?
# 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){
if($what eq "right" && !$x){
print STDERR "$file does not start on a fresh right page [$toc{$file}] [$x]\n";
print STDERR "$file does not start on a fresh right page [$toc{$file}] [$x]\n";
}
}
...
...
runoff.list
浏览文件 @
23c3e52c
...
@@ -9,8 +9,8 @@ elf.h
...
@@ -9,8 +9,8 @@ elf.h
# startup
# startup
bootasm.S
bootasm.S
bootother.S
bootmain.c
bootmain.c
bootother.S
main.c
main.c
# locks
# locks
...
@@ -23,7 +23,6 @@ proc.c
...
@@ -23,7 +23,6 @@ proc.c
swtch.S
swtch.S
kalloc.c
kalloc.c
vm.c
vm.c
# system calls
# system calls
traps.h
traps.h
vectors.pl
vectors.pl
...
@@ -46,8 +45,6 @@ file.c
...
@@ -46,8 +45,6 @@ file.c
sysfile.c
sysfile.c
exec.c
exec.c
# pipes
# pipes
pipe.c
pipe.c
...
@@ -73,3 +70,5 @@ init.c
...
@@ -73,3 +70,5 @@ init.c
sh.c
sh.c
runoff.spec
浏览文件 @
23c3e52c
...
@@ -16,15 +16,15 @@ even: main.c
...
@@ -16,15 +16,15 @@ even: main.c
# odd: init.c
# odd: init.c
# spinlock.h either
# spinlock.h either
# spinlock.c either
right: spinlock.c # mild preference
even: proc.h # mild preference
even: proc.h # mild preference
# goal is to have two action-packed 2-page spreads,
# goal is to have two action-packed 2-page spreads,
# one with
# one with
#
ksegment usegment
allocproc userinit growproc fork
# allocproc userinit growproc fork
# and another with
# and another with
# scheduler sched yield forkret sleep wakeup1 wakeup
# scheduler sched yield forkret sleep wakeup1 wakeup
right: proc.c # VERY important
right
+
: proc.c # VERY important
# setjmp.S either
# setjmp.S either
# vm.c either
# vm.c either
...
...
trap.c
浏览文件 @
23c3e52c
...
@@ -83,7 +83,8 @@ trap(struct trapframe *tf)
...
@@ -83,7 +83,8 @@ trap(struct trapframe *tf)
panic
(
"trap"
);
panic
(
"trap"
);
}
}
// In user space, assume process misbehaved.
// 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
,
proc
->
pid
,
proc
->
name
,
tf
->
trapno
,
tf
->
err
,
cpu
->
id
,
tf
->
eip
,
rcr2
());
rcr2
());
proc
->
killed
=
1
;
proc
->
killed
=
1
;
...
...
x86.h
浏览文件 @
23c3e52c
...
@@ -90,23 +90,26 @@ readeflags(void)
...
@@ -90,23 +90,26 @@ readeflags(void)
return
eflags
;
return
eflags
;
}
}
static
inline
void
loadgs
(
ushort
v
)
{
asm
volatile
(
"movw %0, %%gs"
:
:
"r"
(
v
));
}
static
inline
uint
static
inline
uint
xchg
(
volatile
uint
*
addr
,
uint
newval
)
rebp
(
void
)
{
{
uint
result
;
uint
val
;
asm
volatile
(
"movl %%ebp,%0"
:
"=r"
(
val
));
// The + in "+m" denotes a read-modify-write operand.
return
val
;
asm
volatile
(
"lock; xchgl %0, %1"
:
"+m"
(
*
addr
),
"=a"
(
result
)
:
"1"
(
newval
)
:
"cc"
);
return
result
;
}
}
static
inline
void
static
inline
uint
loadgs
(
ushort
v
)
resp
(
void
)
{
{
asm
volatile
(
"movw %0, %%gs"
:
:
"r"
(
v
));
uint
val
;
asm
volatile
(
"movl %%esp,%0"
:
"=r"
(
val
));
return
val
;
}
}
static
inline
void
static
inline
void
...
@@ -121,66 +124,62 @@ sti(void)
...
@@ -121,66 +124,62 @@ sti(void)
asm
volatile
(
"sti"
);
asm
volatile
(
"sti"
);
}
}
static
inline
void
lcr0
(
uint
val
)
static
inline
uint
{
xchg
(
volatile
uint
*
addr
,
uint
newval
)
asm
volatile
(
"movl %0,%%cr0"
:
:
"r"
(
val
));
}
static
inline
uint
rcr0
(
void
)
{
{
uint
val
;
uint
result
;
asm
volatile
(
"movl %%cr0,%0"
:
"=r"
(
val
));
return
val
;
// 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
(
"pause"
:
:
);
asm
volatile
(
"movl %%cr2,%0"
:
"=r"
(
val
));
return
val
;
}
}
static
inline
void
lcr3
(
uint
val
)
//PAGEBREAK!
static
inline
void
lcr0
(
uint
val
)
{
{
asm
volatile
(
"movl %0,%%cr
3
"
:
:
"r"
(
val
));
asm
volatile
(
"movl %0,%%cr
0
"
:
:
"r"
(
val
));
}
}
static
inline
uint
rcr3
(
void
)
static
inline
uint
rcr0
(
void
)
{
{
uint
val
;
uint
val
;
asm
volatile
(
"movl %%cr
3
,%0"
:
"=r"
(
val
));
asm
volatile
(
"movl %%cr
0
,%0"
:
"=r"
(
val
));
return
val
;
return
val
;
}
}
static
inline
void
lebp
(
uint
val
)
static
inline
uint
{
rcr2
(
void
)
asm
volatile
(
"movl %0,%%ebp"
:
:
"r"
(
val
));
}
static
inline
uint
rebp
(
void
)
{
{
uint
val
;
uint
val
;
asm
volatile
(
"movl %%
ebp
,%0"
:
"=r"
(
val
));
asm
volatile
(
"movl %%
cr2
,%0"
:
"=r"
(
val
));
return
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
;
uint
val
;
asm
volatile
(
"movl %%
esp
,%0"
:
"=r"
(
val
));
asm
volatile
(
"movl %%
cr3
,%0"
:
"=r"
(
val
));
return
val
;
return
val
;
}
}
static
inline
void
nop_pause
(
void
)
{
asm
volatile
(
"pause"
:
:
);
}
//PAGEBREAK: 36
//PAGEBREAK: 36
// Layout of the trap frame built on the stack by the
// Layout of the trap frame built on the stack by the
// hardware and by trapasm.S, and passed to trap().
// hardware and by trapasm.S, and passed to trap().
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论