Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
fd9c281b
提交
fd9c281b
10月 28, 2011
创建
作者:
Silas Boyd-Wickizer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
vm.h
上级
e096f2f8
显示空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
59 行增加
和
56 行删除
+59
-56
exec.c
exec.c
+1
-0
hwvm.c
hwvm.c
+17
-0
proc.c
proc.c
+1
-0
proc.h
proc.h
+0
-39
sysproc.c
sysproc.c
+1
-0
vm.c
vm.c
+1
-17
vm.h
vm.h
+38
-0
没有找到文件。
exec.c
浏览文件 @
fd9c281b
...
@@ -12,6 +12,7 @@
...
@@ -12,6 +12,7 @@
#include "file.h"
#include "file.h"
#include "elf.h"
#include "elf.h"
#include "cpu.h"
#include "cpu.h"
#include "vm.h"
#define USTACKPAGES 2
#define USTACKPAGES 2
...
...
hwvm.c
浏览文件 @
fd9c281b
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
#include "queue.h"
#include "queue.h"
#include "condvar.h"
#include "condvar.h"
#include "proc.h"
#include "proc.h"
#include "vm.h"
#include <stddef.h>
#include <stddef.h>
extern
pml4e_t
kpml4
[];
extern
pml4e_t
kpml4
[];
...
@@ -189,3 +190,19 @@ freevm(pml4e_t *pml4)
...
@@ -189,3 +190,19 @@ freevm(pml4e_t *pml4)
kfree
(
pml4
);
kfree
(
pml4
);
}
}
// Set up CPU's kernel segment descriptors.
// Run once at boot time on each CPU.
void
inittls
(
void
)
{
struct
cpu
*
c
;
// Initialize cpu-local storage.
c
=
&
cpus
[
cpunum
()];
writegs
(
KDSEG
);
writemsr
(
MSR_GS_BASE
,
(
u64
)
&
c
->
cpu
);
c
->
cpu
=
c
;
c
->
proc
=
NULL
;
c
->
kmem
=
&
kmems
[
cpunum
()];
}
proc.c
浏览文件 @
fd9c281b
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
#include "cpu.h"
#include "cpu.h"
#include "bits.h"
#include "bits.h"
#include "xv6-mtrace.h"
#include "xv6-mtrace.h"
#include "vm.h"
extern
void
trapret
(
void
);
extern
void
trapret
(
void
);
...
...
proc.h
浏览文件 @
fd9c281b
#include "spinlock.h"
#include "spinlock.h"
// A mapping of a chunk of an address space to
// a specific memory object.
enum
vmatype
{
PRIVATE
,
COW
};
struct
vma
{
uptr
va_start
;
// start of mapping
uptr
va_end
;
// one past the last byte
enum
vmatype
va_type
;
struct
vmnode
*
n
;
struct
spinlock
lock
;
// serialize fault/unmap
char
lockname
[
16
];
};
// A memory object (physical pages or inode).
enum
vmntype
{
EAGER
,
ONDEMAND
};
struct
vmnode
{
u64
npages
;
char
*
page
[
128
];
u64
ref
;
enum
vmntype
type
;
struct
inode
*
ip
;
u64
offset
;
u64
sz
;
};
// An address space: a set of vmas plus h/w page table.
// The elements of e[] are not ordered by address.
struct
vmap
{
#ifdef TREE
struct
node
*
root
;
#else
struct
vma
*
e
[
16
];
#endif
struct
spinlock
lock
;
// serialize map/lookup/unmap
u64
ref
;
u64
alloc
;
pml4e_t
*
pml4
;
// Page table
char
lockname
[
16
];
};
// Saved registers for kernel context switches.
// Saved registers for kernel context switches.
// (also implicitly defined in swtch.S)
// (also implicitly defined in swtch.S)
struct
context
{
struct
context
{
...
...
sysproc.c
浏览文件 @
fd9c281b
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
#include "queue.h"
#include "queue.h"
#include "proc.h"
#include "proc.h"
#include "cpu.h"
#include "cpu.h"
#include "vm.h"
int
int
sys_fork
(
void
)
sys_fork
(
void
)
...
...
vm.c
浏览文件 @
fd9c281b
...
@@ -10,23 +10,7 @@
...
@@ -10,23 +10,7 @@
#include "queue.h"
#include "queue.h"
#include "condvar.h"
#include "condvar.h"
#include "proc.h"
#include "proc.h"
#include <stddef.h>
#include "vm.h"
// Set up CPU's kernel segment descriptors.
// Run once at boot time on each CPU.
void
inittls
(
void
)
{
struct
cpu
*
c
;
// Initialize cpu-local storage.
c
=
&
cpus
[
cpunum
()];
writegs
(
KDSEG
);
writemsr
(
MSR_GS_BASE
,
(
u64
)
&
c
->
cpu
);
c
->
cpu
=
c
;
c
->
proc
=
NULL
;
c
->
kmem
=
&
kmems
[
cpunum
()];
}
static
struct
vma
*
static
struct
vma
*
vma_alloc
(
void
)
vma_alloc
(
void
)
...
...
vm.h
0 → 100644
浏览文件 @
fd9c281b
// A mapping of a chunk of an address space to
// a specific memory object.
enum
vmatype
{
PRIVATE
,
COW
};
struct
vma
{
uptr
va_start
;
// start of mapping
uptr
va_end
;
// one past the last byte
enum
vmatype
va_type
;
struct
vmnode
*
n
;
struct
spinlock
lock
;
// serialize fault/unmap
char
lockname
[
16
];
};
// A memory object (physical pages or inode).
enum
vmntype
{
EAGER
,
ONDEMAND
};
struct
vmnode
{
u64
npages
;
char
*
page
[
128
];
u64
ref
;
enum
vmntype
type
;
struct
inode
*
ip
;
u64
offset
;
u64
sz
;
};
// An address space: a set of vmas plus h/w page table.
// The elements of e[] are not ordered by address.
struct
vmap
{
#ifdef TREE
struct
node
*
root
;
#else
struct
vma
*
e
[
16
];
#endif
struct
spinlock
lock
;
// serialize map/lookup/unmap
u64
ref
;
u64
alloc
;
pml4e_t
*
pml4
;
// Page table
char
lockname
[
16
];
};
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论