Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
ceb0e427
提交
ceb0e427
8月 16, 2006
创建
作者:
rtm
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
proc[0] can sleep(), at least after it gets to main00()
proc[0] calls iget(rootdev, 1) before forking init
上级
350e63f7
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
48 行增加
和
22 行删除
+48
-22
Makefile
Makefile
+2
-2
main.c
main.c
+43
-18
proc.h
proc.h
+1
-2
trap.c
trap.c
+2
-0
没有找到文件。
Makefile
浏览文件 @
ceb0e427
...
...
@@ -46,12 +46,12 @@ bootblock : bootasm.S bootmain.c
$(OBJCOPY)
-S
-O
binary bootblock.o bootblock
./sign.pl bootblock
kernel
:
$(OBJS) bootother.S
userfs
init
kernel
:
$(OBJS) bootother.S init
$(CC)
-nostdinc
-I
.
-c
bootother.S
$(LD)
-N
-e
start
-Ttext
0x7000
-o
bootother.out bootother.o
$(OBJCOPY)
-S
-O
binary bootother.out bootother
$(OBJDUMP)
-S
bootother.o
>
bootother.asm
$(LD)
-Ttext
0x100000
-e
main0
-o
kernel
$(OBJS)
-b
binary bootother
userfs
init
$(LD)
-Ttext
0x100000
-e
main0
-o
kernel
$(OBJS)
-b
binary bootother init
$(OBJDUMP)
-S
kernel
>
kernel.asm
vectors.S
:
vectors.pl
...
...
main.c
浏览文件 @
ceb0e427
...
...
@@ -11,9 +11,10 @@
#include "spinlock.h"
extern
char
edata
[],
end
[];
extern
uchar
_binary_userfs_start
[],
_binary_userfs_size
[];
extern
uchar
_binary_init_start
[],
_binary_init_size
[];
void
main00
();
// CPU 0 starts running C code here.
// This is called main0 not main so that it can have
// a void return type. Gcc can't handle functions named
...
...
@@ -59,18 +60,18 @@ main0(void)
fd_init
();
iinit
();
//
fix process 0 so that copyproc() will work
//
initialize process 0
p
=
&
proc
[
0
];
p
->
state
=
IDLEPROC
;
p
->
state
=
RUNNABLE
;
p
->
sz
=
4
*
PAGE
;
p
->
mem
=
kalloc
(
p
->
sz
);
memset
(
p
->
mem
,
0
,
p
->
sz
);
p
->
kstack
=
kalloc
(
KSTACKSIZE
);
p
->
tf
=
(
struct
trapframe
*
)
(
p
->
kstack
+
KSTACKSIZE
)
-
1
;
memset
(
p
->
tf
,
0
,
sizeof
(
struct
trapframe
));
p
->
tf
->
es
=
p
->
tf
->
ds
=
p
->
tf
->
ss
=
(
SEG_UDATA
<<
3
)
|
3
;
p
->
tf
->
cs
=
(
SEG_UCODE
<<
3
)
|
3
;
p
->
tf
->
eflags
=
FL_IF
;
// cause proc[0] to start in kernel at main00
memset
(
&
p
->
jmpbuf
,
0
,
sizeof
p
->
jmpbuf
)
;
p
->
jmpbuf
.
eip
=
(
uint
)
main00
;
p
->
jmpbuf
.
esp
=
(
uint
)
(
p
->
kstack
+
KSTACKSIZE
-
4
)
;
// make sure there's a TSS
setupsegs
(
0
);
...
...
@@ -89,15 +90,6 @@ main0(void)
cpus
[
cpu
()].
nlock
--
;
sti
();
// p->cwd = iget(rootdev, 1);
// iunlock(p->cwd);
p
=
copyproc
(
&
proc
[
0
]);
//load_icode(p, _binary_usertests_start, (uint) _binary_usertests_size);
//load_icode(p, _binary_userfs_start, (uint) _binary_userfs_size);
load_icode
(
p
,
_binary_init_start
,
(
uint
)
_binary_init_size
);
p
->
state
=
RUNNABLE
;
scheduler
();
}
...
...
@@ -128,6 +120,40 @@ mpmain(void)
scheduler
();
}
// proc[0] starts here, called by scheduler() in the ordinary way.
void
main00
()
{
struct
proc
*
p0
=
&
proc
[
0
];
struct
proc
*
p1
;
extern
struct
spinlock
proc_table_lock
;
struct
trapframe
tf
;
release
(
&
proc_table_lock
);
p0
->
cwd
=
iget
(
rootdev
,
1
);
iunlock
(
p0
->
cwd
);
// fake a trap frame as if a user process had made a system
// call, so that copyproc will have a place for the new
// process to return to.
p0
=
&
proc
[
0
];
p0
->
tf
=
&
tf
;
memset
(
p0
->
tf
,
0
,
sizeof
(
struct
trapframe
));
p0
->
tf
->
es
=
p0
->
tf
->
ds
=
p0
->
tf
->
ss
=
(
SEG_UDATA
<<
3
)
|
3
;
p0
->
tf
->
cs
=
(
SEG_UCODE
<<
3
)
|
3
;
p0
->
tf
->
eflags
=
FL_IF
;
p0
->
tf
->
esp
=
p0
->
sz
;
p1
=
copyproc
(
&
proc
[
0
]);
load_icode
(
p1
,
_binary_init_start
,
(
uint
)
_binary_init_size
);
p1
->
state
=
RUNNABLE
;
proc_wait
();
panic
(
"init exited"
);
}
void
load_icode
(
struct
proc
*
p
,
uchar
*
binary
,
uint
size
)
{
...
...
@@ -141,7 +167,6 @@ load_icode(struct proc *p, uchar *binary, uint size)
panic
(
"load_icode: not an ELF binary"
);
p
->
tf
->
eip
=
elf
->
entry
;
p
->
tf
->
esp
=
p
->
sz
;
// Map and load segments as directed.
ph
=
(
struct
proghdr
*
)
(
binary
+
elf
->
phoff
);
...
...
proc.h
浏览文件 @
ceb0e427
...
...
@@ -33,8 +33,7 @@ struct jmpbuf {
int
eip
;
};
enum
proc_state
{
UNUSED
,
EMBRYO
,
SLEEPING
,
RUNNABLE
,
RUNNING
,
ZOMBIE
,
IDLEPROC
};
enum
proc_state
{
UNUSED
,
EMBRYO
,
SLEEPING
,
RUNNABLE
,
RUNNING
,
ZOMBIE
};
struct
proc
{
char
*
mem
;
// start of process's physical memory
...
...
trap.c
浏览文件 @
ceb0e427
...
...
@@ -126,6 +126,8 @@ trap(struct trapframe *tf)
}
cprintf
(
"trap %d from cpu %d eip %x
\n
"
,
v
,
cpu
(),
tf
->
eip
);
if
(
curproc
[
cpu
()])
cprintf
(
"pid %d
\n
"
,
curproc
[
cpu
()]
->
pid
);
panic
(
"trap"
);
return
;
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论