Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
d9818bdd
提交
d9818bdd
8月 15, 2011
创建
作者:
Frans Kaashoek
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make Austin happier
2011
上级
a4b213cf
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
13 行增加
和
13 行删除
+13
-13
README
README
+1
-1
vm.c
vm.c
+12
-12
没有找到文件。
README
浏览文件 @
d9818bdd
...
...
@@ -26,7 +26,7 @@ In addition, we are grateful for the patches contributed by Greg
Price, Yandong Mao, and Hitoshi Mitake.
The code in the files that constitute xv6 is
Copyright 2006-20
07
Frans Kaashoek, Robert Morris, and Russ Cox.
Copyright 2006-20
11
Frans Kaashoek, Robert Morris, and Russ Cox.
ERROR REPORTS
...
...
vm.c
浏览文件 @
d9818bdd
...
...
@@ -18,7 +18,7 @@ seginit(void)
{
struct
cpu
*
c
;
// Map
virtual addresses to linear
addresses using identity map.
// Map
"logical" addresses to virtual
addresses using identity map.
// Cannot share a CODE descriptor for both kernel and user
// because it would have to have DPL_USR, but the CPU forbids
// an interrupt from CPL=0 to DPL=3.
...
...
@@ -40,7 +40,7 @@ seginit(void)
}
// Return the address of the PTE in page table pgdir
// that corresponds to
linear
address va. If alloc!=0,
// that corresponds to
virtual
address va. If alloc!=0,
// create any required page table pages.
static
pte_t
*
walkpgdir
(
pde_t
*
pgdir
,
const
void
*
va
,
char
*
(
*
alloc
)(
void
))
...
...
@@ -64,17 +64,17 @@ walkpgdir(pde_t *pgdir, const void *va, char* (*alloc)(void))
return
&
pgtab
[
PTX
(
va
)];
}
// Create PTEs for
linear
addresses starting at la that refer to
// Create PTEs for
virtual
addresses starting at la that refer to
// physical addresses starting at pa. la and size might not
// be page-aligned.
static
int
mappages
(
pde_t
*
pgdir
,
void
*
l
a
,
uint
size
,
uint
pa
,
int
perm
,
char
*
(
*
alloc
)(
void
))
mappages
(
pde_t
*
pgdir
,
void
*
v
a
,
uint
size
,
uint
pa
,
int
perm
,
char
*
(
*
alloc
)(
void
))
{
char
*
a
,
*
last
;
pte_t
*
pte
;
a
=
PGROUNDDOWN
(
l
a
);
last
=
PGROUNDDOWN
(
l
a
+
size
-
1
);
a
=
PGROUNDDOWN
(
v
a
);
last
=
PGROUNDDOWN
(
v
a
+
size
-
1
);
for
(;;){
pte
=
walkpgdir
(
pgdir
,
a
,
alloc
);
if
(
pte
==
0
)
...
...
@@ -90,7 +90,7 @@ mappages(pde_t *pgdir, void *la, uint size, uint pa, int perm, char* (*alloc)(vo
return
0
;
}
// The mappings from logical to
linear
are one to one (i.e.,
// The mappings from logical to
virtual
are one to one (i.e.,
// segmentation doesn't do anything).
// There is one page table per process, plus one that's used
// when a CPU is not running any process (kpgdir).
...
...
@@ -98,7 +98,6 @@ mappages(pde_t *pgdir, void *la, uint size, uint pa, int perm, char* (*alloc)(vo
// page protection bits prevent it from using anything other
// than its memory.
//
//
// setupkvm() and exec() set up every page table like this:
// 0..USERTOP : user memory (text, data, stack, heap), mapped to some unused phys mem
// KERNBASE..KERNBASE+1M: mapped to 0..1M
...
...
@@ -112,9 +111,9 @@ mappages(pde_t *pgdir, void *la, uint size, uint pa, int perm, char* (*alloc)(vo
// (which is inaccessible in user mode). The user program sits in
// the bottom of the address space, and the kernel at the top at KERNBASE.
static
struct
kmap
{
void
*
l
;
uint
p
;
uint
e
;
void
*
virt
;
uint
p
hys_start
;
uint
phys_end
;
int
perm
;
}
kmap
[]
=
{
{
P2V
(
0
),
0
,
1024
*
1024
,
PTE_W
},
// First 1Mbyte contains BIOS and some IO devices
...
...
@@ -135,7 +134,8 @@ setupkvm(char* (*alloc)(void))
memset
(
pgdir
,
0
,
PGSIZE
);
k
=
kmap
;
for
(
k
=
kmap
;
k
<
&
kmap
[
NELEM
(
kmap
)];
k
++
)
if
(
mappages
(
pgdir
,
k
->
l
,
k
->
e
-
k
->
p
,
(
uint
)
k
->
p
,
k
->
perm
,
alloc
)
<
0
)
if
(
mappages
(
pgdir
,
k
->
virt
,
k
->
phys_end
-
k
->
phys_start
,
(
uint
)
k
->
phys_start
,
k
->
perm
,
alloc
)
<
0
)
return
0
;
return
pgdir
;
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论