Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
7e7cb106
提交
7e7cb106
9月 13, 2011
创建
作者:
Robert Morris
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more regular kmap[] and description
上级
90a81b32
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
27 行增加
和
24 行删除
+27
-24
entry.S
entry.S
+1
-1
memlayout.h
memlayout.h
+4
-4
vm.c
vm.c
+22
-19
没有找到文件。
entry.S
浏览文件 @
7e7cb106
...
@@ -36,7 +36,7 @@ multiboot_header:
...
@@ -36,7 +36,7 @@ multiboot_header:
.globl _start
.globl _start
_start = V2P_WO(entry)
_start = V2P_WO(entry)
# Entering xv6 on boot processor
. Machine is mostly set up
.
# Entering xv6 on boot processor
, with paging off
.
.globl entry
.globl entry
entry:
entry:
# Turn on page size extension for 4Mbyte pages
# Turn on page size extension for 4Mbyte pages
...
...
memlayout.h
浏览文件 @
7e7cb106
...
@@ -10,13 +10,13 @@
...
@@ -10,13 +10,13 @@
#ifndef __ASSEMBLER__
#ifndef __ASSEMBLER__
static
inline
uint
v2p
(
void
*
a
)
{
return
(
uint
)
a
-
KERNBASE
;
}
static
inline
uint
v2p
(
void
*
a
)
{
return
(
(
uint
)
(
a
))
-
KERNBASE
;
}
static
inline
void
*
p2v
(
uint
a
)
{
return
(
void
*
)
a
+
KERNBASE
;
}
static
inline
void
*
p2v
(
uint
a
)
{
return
(
void
*
)
((
a
)
+
KERNBASE
)
;
}
#endif
#endif
#define V2P(a) ((
uint) a
- KERNBASE)
#define V2P(a) ((
(uint) (a))
- KERNBASE)
#define P2V(a) ((
void *) a
+ KERNBASE)
#define P2V(a) ((
(void *) (a))
+ KERNBASE)
#define V2P_WO(x) ((x) - KERNBASE) // same as V2P, but without casts
#define V2P_WO(x) ((x) - KERNBASE) // same as V2P, but without casts
#define P2V_WO(x) ((x) + KERNBASE) // same as V2P, but without casts
#define P2V_WO(x) ((x) + KERNBASE) // same as V2P, but without casts
vm.c
浏览文件 @
7e7cb106
...
@@ -90,36 +90,39 @@ mappages(pde_t *pgdir, void *va, uint size, uint pa,
...
@@ -90,36 +90,39 @@ mappages(pde_t *pgdir, void *va, uint size, uint pa,
return
0
;
return
0
;
}
}
// The
mappings from logical to virtual are one to one (i.e.,
// The
re is one page table per process, plus one that's used when
//
segmentation doesn't do anything). There is one page table per
//
a CPU is not running any process (kpgdir). The kernel uses the
//
process, plus one that's used when a CPU is not running any process
//
current process's page table during system calls and interrupts;
//
(kpgdir). A user process uses the same page table as the kernel; the
//
page protection bits prevent user code from using the kernel's
//
page protection bits prevent it from accessing kernel memory
.
//
mappings
.
//
//
// 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
//
// phys memory
// 0..KERNBASE: user memory (text+data+stack+heap), mapped to
// phys memory allocated by the kernel
// KERNBASE..KERNBASE+EXTMEM: mapped to 0..EXTMEM (for I/O space)
// KERNBASE..KERNBASE+EXTMEM: mapped to 0..EXTMEM (for I/O space)
// KERNBASE+EXTMEM..
KERNBASE+end: mapped to EXTMEM..end kernel,
// KERNBASE+EXTMEM..
data: mapped to EXTMEM..V2P(data)
//
w. no write permission
//
for the kernel's instructions and r/o data
//
KERNBASE+end..KERBASE+PHYSTOP: mapped to end
..PHYSTOP,
//
data..KERNBASE+PHYSTOP: mapped to V2P(data)
..PHYSTOP,
// rw data + free memory
// rw data + free
physical
memory
// 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 physical memory for its heap and for user memory
// between KERNBASE+end and the end of physical memory (PHYSTOP).
// between V2P(end) and the end of physical memory (PHYSTOP)
// The user program sits in the bottom of the address space, and the
// (directly addressable from end..P2V(PHYSTOP)).
// kernel at the top at KERNBASE.
// This table defines the kernel's mappings, which are present in
// every process's page table.
static
struct
kmap
{
static
struct
kmap
{
void
*
virt
;
void
*
virt
;
uint
phys_start
;
uint
phys_start
;
uint
phys_end
;
uint
phys_end
;
int
perm
;
int
perm
;
}
kmap
[]
=
{
}
kmap
[]
=
{
{
P2V
(
0
),
0
,
1024
*
1024
,
PTE_W
},
// I/O space
{
(
void
*
)
KERNBASE
,
0
,
EXTMEM
,
PTE_W
},
// I/O space
{
(
void
*
)
KERNLINK
,
V2P
(
KERNLINK
),
V2P
(
data
),
0
},
// kernel text+rodata
{
(
void
*
)
KERNLINK
,
V2P
(
KERNLINK
),
V2P
(
data
),
0
},
// kernel text+rodata
{
data
,
V2P
(
data
),
PHYSTOP
,
PTE_W
},
// kernel data, memory
{
(
void
*
)
data
,
V2P
(
data
),
PHYSTOP
,
PTE_W
},
// kernel data, memory
{
(
void
*
)
DEVSPACE
,
DEVSPACE
,
0
,
PTE_W
},
// more devices
{
(
void
*
)
DEVSPACE
,
DEVSPACE
,
0
,
PTE_W
},
// more devices
};
};
// Set up kernel part of a page table.
// Set up kernel part of a page table.
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论