Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
93a1e4cb
提交
93a1e4cb
9月 02, 2010
创建
作者:
Austin Clements
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix comment capitalization
上级
f25a3f9a
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
14 行增加
和
14 行删除
+14
-14
vm.c
vm.c
+14
-14
没有找到文件。
vm.c
浏览文件 @
93a1e4cb
...
@@ -27,7 +27,7 @@ ksegment(void)
...
@@ -27,7 +27,7 @@ ksegment(void)
c
->
gdt
[
SEG_UCODE
]
=
SEG
(
STA_X
|
STA_R
,
0
,
0xffffffff
,
DPL_USER
);
c
->
gdt
[
SEG_UCODE
]
=
SEG
(
STA_X
|
STA_R
,
0
,
0xffffffff
,
DPL_USER
);
c
->
gdt
[
SEG_UDATA
]
=
SEG
(
STA_W
,
0
,
0xffffffff
,
DPL_USER
);
c
->
gdt
[
SEG_UDATA
]
=
SEG
(
STA_W
,
0
,
0xffffffff
,
DPL_USER
);
//
m
ap cpu, and curproc
//
M
ap cpu, and curproc
c
->
gdt
[
SEG_KCPU
]
=
SEG
(
STA_W
,
&
c
->
cpu
,
8
,
0
);
c
->
gdt
[
SEG_KCPU
]
=
SEG
(
STA_W
,
&
c
->
cpu
,
8
,
0
);
lgdt
(
c
->
gdt
,
sizeof
(
c
->
gdt
));
lgdt
(
c
->
gdt
,
sizeof
(
c
->
gdt
));
...
@@ -38,8 +38,8 @@ ksegment(void)
...
@@ -38,8 +38,8 @@ ksegment(void)
proc
=
0
;
proc
=
0
;
}
}
//
r
eturn the address of the PTE in page table pgdir
//
R
eturn the address of the PTE in page table pgdir
// that corresponds to linear address va.
i
f create!=0,
// that corresponds to linear address va.
I
f create!=0,
// create any required page table pages.
// create any required page table pages.
static
pte_t
*
static
pte_t
*
walkpgdir
(
pde_t
*
pgdir
,
const
void
*
va
,
int
create
)
walkpgdir
(
pde_t
*
pgdir
,
const
void
*
va
,
int
create
)
...
@@ -65,7 +65,7 @@ walkpgdir(pde_t *pgdir, const void *va, int create)
...
@@ -65,7 +65,7 @@ walkpgdir(pde_t *pgdir, const void *va, int create)
return
&
pgtab
[
PTX
(
va
)];
return
&
pgtab
[
PTX
(
va
)];
}
}
//
c
reate PTEs for linear addresses starting at la that refer to
//
C
reate PTEs for linear addresses starting at la that refer to
// physical addresses starting at pa. la and size might not
// physical addresses starting at pa. la and size might not
// be page-aligned.
// be page-aligned.
static
int
static
int
...
@@ -152,12 +152,12 @@ vmenable(void)
...
@@ -152,12 +152,12 @@ vmenable(void)
lcr0
(
cr0
);
lcr0
(
cr0
);
}
}
// Switch h/w page table register to the kernel-only page table,
for when
// Switch h/w page table register to the kernel-only page table,
// no process is running.
//
for when
no process is running.
void
void
switchkvm
()
switchkvm
()
{
{
lcr3
(
PADDR
(
kpgdir
));
//
S
witch to the kernel page table
lcr3
(
PADDR
(
kpgdir
));
//
s
witch to the kernel page table
}
}
// Switch h/w page table and TSS registers to point to process p.
// Switch h/w page table and TSS registers to point to process p.
...
@@ -180,8 +180,8 @@ switchuvm(struct proc *p)
...
@@ -180,8 +180,8 @@ switchuvm(struct proc *p)
popcli
();
popcli
();
}
}
//
r
eturn the physical address that a given user address
//
R
eturn the physical address that a given user address
// maps to.
t
he result is also a kernel logical address,
// maps to.
T
he result is also a kernel logical address,
// since the kernel maps the physical memory allocated to user
// since the kernel maps the physical memory allocated to user
// processes directly.
// processes directly.
char
*
char
*
...
@@ -224,10 +224,10 @@ loaduvm(pde_t *pgdir, char *addr, struct inode *ip, uint offset, uint sz)
...
@@ -224,10 +224,10 @@ loaduvm(pde_t *pgdir, char *addr, struct inode *ip, uint offset, uint sz)
return
1
;
return
1
;
}
}
//
a
llocate sz bytes more memory for a process starting at the
//
A
llocate sz bytes more memory for a process starting at the
// given user address; allocates physical memory and page
// given user address; allocates physical memory and page
// table entries. addr and sz need not be page-aligned.
// table entries. addr and sz need not be page-aligned.
//
i
t is a no-op for any parts of the requested memory
//
I
t is a no-op for any parts of the requested memory
// that are already allocated.
// that are already allocated.
int
int
allocuvm
(
pde_t
*
pgdir
,
char
*
addr
,
uint
sz
)
allocuvm
(
pde_t
*
pgdir
,
char
*
addr
,
uint
sz
)
...
@@ -252,7 +252,7 @@ allocuvm(pde_t *pgdir, char *addr, uint sz)
...
@@ -252,7 +252,7 @@ allocuvm(pde_t *pgdir, char *addr, uint sz)
return
1
;
return
1
;
}
}
//
deallocate some of the user pages. i
f addr is not page-aligned,
//
Deallocate some of the user pages. I
f addr is not page-aligned,
// then only deallocates starting at the next page boundary.
// then only deallocates starting at the next page boundary.
int
int
deallocuvm
(
pde_t
*
pgdir
,
char
*
addr
,
uint
sz
)
deallocuvm
(
pde_t
*
pgdir
,
char
*
addr
,
uint
sz
)
...
@@ -274,7 +274,7 @@ deallocuvm(pde_t *pgdir, char *addr, uint sz)
...
@@ -274,7 +274,7 @@ deallocuvm(pde_t *pgdir, char *addr, uint sz)
return
1
;
return
1
;
}
}
//
f
ree a page table and all the physical memory pages
//
F
ree a page table and all the physical memory pages
// in the user part.
// in the user part.
void
void
freevm
(
pde_t
*
pgdir
)
freevm
(
pde_t
*
pgdir
)
...
@@ -291,7 +291,7 @@ freevm(pde_t *pgdir)
...
@@ -291,7 +291,7 @@ freevm(pde_t *pgdir)
kfree
((
void
*
)
pgdir
);
kfree
((
void
*
)
pgdir
);
}
}
//
g
iven a parent process's page table, create a copy
//
G
iven a parent process's page table, create a copy
// of it for a child.
// of it for a child.
pde_t
*
pde_t
*
copyuvm
(
pde_t
*
pgdir
,
uint
sz
)
copyuvm
(
pde_t
*
pgdir
,
uint
sz
)
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论