Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
9e4272c1
提交
9e4272c1
9月 02, 2011
创建
作者:
Austin Clements
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Cleanup comments and fit setupkvm on same page as kmap, which aligns lots of other things
上级
14835ec9
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
6 行增加
和
10 行删除
+6
-10
vm.c
vm.c
+6
-10
没有找到文件。
vm.c
浏览文件 @
9e4272c1
...
@@ -92,10 +92,9 @@ mappages(pde_t *pgdir, void *va, uint size, uint pa,
...
@@ -92,10 +92,9 @@ mappages(pde_t *pgdir, void *va, uint size, uint pa,
// The mappings from logical to virtual 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
// 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, plus one that's used when a CPU is not running any process
// process (kpgdir). A user process uses the same page table as
// (kpgdir). A user process uses the same page table as the kernel; the
// the kernel; the page protection bits prevent it from using
// page protection bits prevent it from accessing kernel memory.
// anything other than its memory.
//
//
// setupkvm() and exec() set up every page table like this:
// setupkvm() and exec() set up every page table like this:
// 0..KERNBASE: user memory (text+data+stack+heap), mapped to some free
// 0..KERNBASE: user memory (text+data+stack+heap), mapped to some free
...
@@ -108,10 +107,9 @@ mappages(pde_t *pgdir, void *va, uint size, uint pa,
...
@@ -108,10 +107,9 @@ mappages(pde_t *pgdir, void *va, uint size, uint pa,
// 0xfe000000..0: mapped direct (devices such as ioapic)
// 0xfe000000..0: mapped direct (devices such as ioapic)
//
//
// The kernel allocates memory for its heap and for user memory
// The kernel allocates memory for its heap and for user memory
// between kernend and the end of physical memory (PHYSTOP).
// between KERNBASE+end and the end of physical memory (PHYSTOP).
// The virtual address space of each user program includes the kernel
// The user program sits in the bottom of the address space, and the
// (which is inaccessible in user mode). The user program sits in
// kernel at the top at KERNBASE.
// the bottom of the address space, and the kernel at the top at KERNBASE.
static
struct
kmap
{
static
struct
kmap
{
void
*
virt
;
void
*
virt
;
uint
phys_start
;
uint
phys_start
;
...
@@ -134,14 +132,12 @@ setupkvm(char* (*alloc)(void))
...
@@ -134,14 +132,12 @@ setupkvm(char* (*alloc)(void))
if
((
pgdir
=
(
pde_t
*
)
alloc
())
==
0
)
if
((
pgdir
=
(
pde_t
*
)
alloc
())
==
0
)
return
0
;
return
0
;
memset
(
pgdir
,
0
,
PGSIZE
);
memset
(
pgdir
,
0
,
PGSIZE
);
k
=
kmap
;
if
(
p2v
(
PHYSTOP
)
>
(
void
*
)
DEVSPACE
)
if
(
p2v
(
PHYSTOP
)
>
(
void
*
)
DEVSPACE
)
panic
(
"PHYSTOP too high"
);
panic
(
"PHYSTOP too high"
);
for
(
k
=
kmap
;
k
<
&
kmap
[
NELEM
(
kmap
)];
k
++
)
for
(
k
=
kmap
;
k
<
&
kmap
[
NELEM
(
kmap
)];
k
++
)
if
(
mappages
(
pgdir
,
k
->
virt
,
k
->
phys_end
-
k
->
phys_start
,
if
(
mappages
(
pgdir
,
k
->
virt
,
k
->
phys_end
-
k
->
phys_start
,
(
uint
)
k
->
phys_start
,
k
->
perm
,
alloc
)
<
0
)
(
uint
)
k
->
phys_start
,
k
->
perm
,
alloc
)
<
0
)
return
0
;
return
0
;
return
pgdir
;
return
pgdir
;
}
}
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论