Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
8d774afb
提交
8d774afb
8月 31, 2010
创建
作者:
Robert Morris
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
no more pminit, or ELF header at 0x10000
kinit() knows about end and PHYSTOP map all of kernel read/write (rather than r/o instructions) thanks, austin
上级
880ee18a
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
13 行增加
和
49 行删除
+13
-49
defs.h
defs.h
+1
-2
kalloc.c
kalloc.c
+5
-3
main.c
main.c
+1
-1
mkfs.c
mkfs.c
+2
-2
vm.c
vm.c
+4
-41
没有找到文件。
defs.h
浏览文件 @
8d774afb
...
...
@@ -62,7 +62,7 @@ void ioapicinit(void);
// kalloc.c
char
*
kalloc
(
void
);
void
kfree
(
char
*
);
void
kinit
(
char
*
,
uint
);
void
kinit
();
// kbd.c
void
kbdintr
(
void
);
...
...
@@ -151,7 +151,6 @@ void uartintr(void);
void
uartputc
(
int
);
// vm.c
void
pminit
(
void
);
void
ksegment
(
void
);
void
kvmalloc
(
void
);
void
vmenable
(
void
);
...
...
kalloc.c
浏览文件 @
8d774afb
...
...
@@ -19,11 +19,13 @@ struct {
// Initialize free list of physical pages.
void
kinit
(
char
*
p
,
uint
len
)
kinit
(
void
)
{
extern
char
end
[];
initlock
(
&
kmem
.
lock
,
"kmem"
);
char
*
p1
=
(
char
*
)
PGROUNDUP
((
uint
)
p
);
char
*
p2
=
PGROUNDDOWN
(
p
+
len
);
char
*
p1
=
(
char
*
)
PGROUNDUP
((
uint
)
end
);
char
*
p2
=
PGROUNDDOWN
(
PHYSTOP
);
for
(
;
p1
<
p2
;
p1
+=
4096
)
kfree
(
p1
);
}
...
...
main.c
浏览文件 @
8d774afb
...
...
@@ -21,7 +21,7 @@ main(void)
ioapicinit
();
// another interrupt controller
consoleinit
();
// I/O devices & their interrupts
uartinit
();
// serial port
pminit
();
// discover how much memory there is
kinit
();
// initialize memory allocator
jkstack
();
// call mainc() on a properly-allocated stack
}
...
...
mkfs.c
浏览文件 @
8d774afb
...
...
@@ -82,7 +82,7 @@ main(int argc, char *argv[])
usedblocks
=
ninodes
/
IPB
+
3
+
bitblocks
;
freeblock
=
usedblocks
;
printf
(
"used %d (bit %d ninode %u) free %u total %d
\n
"
,
usedblocks
,
printf
(
"used %d (bit %d ninode %
l
u) free %u total %d
\n
"
,
usedblocks
,
bitblocks
,
ninodes
/
IPB
+
1
,
freeblock
,
nblocks
+
usedblocks
);
assert
(
nblocks
+
usedblocks
==
size
);
...
...
@@ -230,7 +230,7 @@ balloc(int used)
for
(
i
=
0
;
i
<
used
;
i
++
)
{
buf
[
i
/
8
]
=
buf
[
i
/
8
]
|
(
0x1
<<
(
i
%
8
));
}
printf
(
"balloc: write bitmap block at sector %u
\n
"
,
ninodes
/
IPB
+
3
);
printf
(
"balloc: write bitmap block at sector %
l
u
\n
"
,
ninodes
/
IPB
+
3
);
wsect
(
ninodes
/
IPB
+
3
,
buf
);
}
...
...
vm.c
浏览文件 @
8d774afb
...
...
@@ -17,8 +17,8 @@
// setupkvm() and exec() set up every page table like this:
// 0..640K : user memory (text, data, stack, heap)
// 640K..1M : mapped direct (for IO space)
// 1M..
kernend
: mapped direct (for the kernel's text and data)
//
kernend..PHYSTOP
: mapped direct (kernel heap and user pages)
// 1M..
end
: mapped direct (for the kernel's text and data)
//
end..PHYSTOP
: mapped direct (kernel heap and user pages)
// 0xfe000000..0 : mapped direct (devices such as ioapic)
//
// The kernel allocates memory for its heap and for user memory
...
...
@@ -31,12 +31,6 @@
#define USERTOP 0xA0000
static
uint
kerntext
;
// Linker starts kernel at 1MB
static
uint
kerntsz
;
static
uint
kerndata
;
static
uint
kerndsz
;
static
uint
kernend
;
static
uint
freesz
;
static
pde_t
*
kpgdir
;
// for use in scheduler()
// return the address of the PTE in page table pgdir
...
...
@@ -161,14 +155,8 @@ setupkvm(void)
// Map IO space from 640K to 1Mbyte
if
(
!
mappages
(
pgdir
,
(
void
*
)
USERTOP
,
0x60000
,
USERTOP
,
PTE_W
))
return
0
;
// Map kernel text read-only
if
(
!
mappages
(
pgdir
,
(
void
*
)
kerntext
,
kerntsz
,
kerntext
,
0
))
return
0
;
// Map kernel data read/write
if
(
!
mappages
(
pgdir
,
(
void
*
)
kerndata
,
kerndsz
,
kerndata
,
PTE_W
))
return
0
;
// Map dynamically-allocated memory read/write (kernel stacks, user mem)
if
(
!
mappages
(
pgdir
,
(
void
*
)
kernend
,
freesz
,
PADDR
(
kernend
),
PTE_W
))
// Map kernel and free memory pool
if
(
!
mappages
(
pgdir
,
(
void
*
)
0x100000
,
PHYSTOP
-
0x100000
,
0x100000
,
PTE_W
))
return
0
;
// Map devices such as ioapic, lapic, ...
if
(
!
mappages
(
pgdir
,
(
void
*
)
0xFE000000
,
0x2000000
,
0xFE000000
,
PTE_W
))
...
...
@@ -333,31 +321,6 @@ copyuvm(pde_t *pgdir, uint sz)
return
d
;
}
// Gather information about physical memory layout.
// Called once during boot.
// Really should find out how much physical memory
// there is rather than assuming PHYSTOP.
void
pminit
(
void
)
{
extern
char
end
[];
struct
proghdr
*
ph
;
struct
elfhdr
*
elf
=
(
struct
elfhdr
*
)
0x10000
;
// scratch space
if
(
elf
->
magic
!=
ELF_MAGIC
||
elf
->
phnum
!=
2
)
panic
(
"pminit: need a text and data segment
\n
"
);
ph
=
(
struct
proghdr
*
)((
uchar
*
)
elf
+
elf
->
phoff
);
kernend
=
((
uint
)
end
+
PGSIZE
)
&
~
(
PGSIZE
-
1
);
kerntext
=
ph
[
0
].
va
;
kerndata
=
ph
[
1
].
va
;
kerntsz
=
ph
[
0
].
memsz
;
kerndsz
=
ph
[
1
].
memsz
;
freesz
=
PHYSTOP
-
kernend
;
kinit
((
char
*
)
kernend
,
freesz
);
}
// Allocate one page table for the machine for the kernel address
// space for scheduler processes.
void
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论