Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
10420772
提交
10420772
8月 07, 2006
创建
作者:
kaashoek
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
bwrite
上级
8ec6530f
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
33 行增加
和
8 行删除
+33
-8
bio.c
bio.c
+13
-0
defs.h
defs.h
+2
-0
ide.c
ide.c
+10
-8
syscall.c
syscall.c
+8
-0
没有找到文件。
bio.c
浏览文件 @
10420772
...
@@ -51,6 +51,19 @@ bread(uint dev, uint sector)
...
@@ -51,6 +51,19 @@ bread(uint dev, uint sector)
}
}
void
void
bwrite
(
uint
dev
,
struct
buf
*
b
,
uint
sector
)
{
void
*
c
;
extern
struct
spinlock
ide_lock
;
acquire
(
&
ide_lock
);
c
=
ide_start_rw
(
dev
&
0xff
,
sector
,
b
->
data
,
1
,
0
);
sleep
(
c
,
&
ide_lock
);
ide_finish
(
c
);
release
(
&
ide_lock
);
}
void
brelse
(
struct
buf
*
b
)
brelse
(
struct
buf
*
b
)
{
{
if
((
b
->
flags
&
B_BUSY
)
==
0
)
if
((
b
->
flags
&
B_BUSY
)
==
0
)
...
...
defs.h
浏览文件 @
10420772
...
@@ -96,7 +96,9 @@ int ide_finish(void *);
...
@@ -96,7 +96,9 @@ int ide_finish(void *);
// bio.c
// bio.c
struct
buf
;
struct
buf
;
struct
buf
*
getblk
(
void
);
struct
buf
*
bread
(
uint
,
uint
);
struct
buf
*
bread
(
uint
,
uint
);
void
bwrite
(
uint
,
struct
buf
*
,
uint
);
void
brelse
(
struct
buf
*
);
void
brelse
(
struct
buf
*
);
// fs.c
// fs.c
...
...
ide.c
浏览文件 @
10420772
...
@@ -101,7 +101,10 @@ ide_start_request (void)
...
@@ -101,7 +101,10 @@ ide_start_request (void)
outb
(
0x1F5
,
(
r
->
secno
>>
16
)
&
0xFF
);
outb
(
0x1F5
,
(
r
->
secno
>>
16
)
&
0xFF
);
outb
(
0x1F6
,
0xE0
|
((
r
->
diskno
&
1
)
<<
4
)
|
((
r
->
secno
>>
24
)
&
0x0F
));
outb
(
0x1F6
,
0xE0
|
((
r
->
diskno
&
1
)
<<
4
)
|
((
r
->
secno
>>
24
)
&
0x0F
));
if
(
r
->
read
)
outb
(
0x1F7
,
0x20
);
// read
if
(
r
->
read
)
outb
(
0x1F7
,
0x20
);
// read
else
outb
(
0x1F7
,
0x30
);
// write
else
{
outb
(
0x1F7
,
0x30
);
// write
outsl
(
0x1F0
,
r
->
addr
,
512
/
4
);
}
}
}
}
}
...
@@ -113,7 +116,7 @@ ide_start_rw(int diskno, uint secno, void *addr, uint nsecs, int read)
...
@@ -113,7 +116,7 @@ ide_start_rw(int diskno, uint secno, void *addr, uint nsecs, int read)
if
(
!
holding
(
&
ide_lock
))
if
(
!
holding
(
&
ide_lock
))
panic
(
"ide_start_read: not holding ide_lock"
);
panic
(
"ide_start_read: not holding ide_lock"
);
if
(
nsecs
>
256
)
if
(
nsecs
>
1
)
panic
(
"ide_start_read: nsecs too large"
);
panic
(
"ide_start_read: nsecs too large"
);
while
((
head
+
1
)
%
NREQUEST
==
tail
)
while
((
head
+
1
)
%
NREQUEST
==
tail
)
...
@@ -136,7 +139,7 @@ ide_start_rw(int diskno, uint secno, void *addr, uint nsecs, int read)
...
@@ -136,7 +139,7 @@ ide_start_rw(int diskno, uint secno, void *addr, uint nsecs, int read)
int
int
ide_finish
(
void
*
c
)
ide_finish
(
void
*
c
)
{
{
int
r
=
0
;
int
r
;
struct
ide_request
*
req
=
(
struct
ide_request
*
)
c
;
struct
ide_request
*
req
=
(
struct
ide_request
*
)
c
;
if
(
c
!=
&
request
[
tail
])
if
(
c
!=
&
request
[
tail
])
...
@@ -144,11 +147,10 @@ ide_finish(void *c)
...
@@ -144,11 +147,10 @@ ide_finish(void *c)
if
(
!
holding
(
&
ide_lock
))
if
(
!
holding
(
&
ide_lock
))
panic
(
"ide_start_read: not holding ide_lock"
);
panic
(
"ide_start_read: not holding ide_lock"
);
for
(;
req
->
nsecs
>
0
;
req
->
nsecs
--
,
req
->
addr
+=
512
)
{
if
((
r
=
ide_wait_ready
(
1
))
<
0
)
if
(
req
->
read
)
{
break
;
if
((
r
=
ide_wait_ready
(
1
))
>=
0
)
if
(
req
->
read
)
insl
(
0x1F0
,
req
->
addr
,
512
/
4
);
insl
(
0x1F0
,
req
->
addr
,
512
/
4
);
else
outsl
(
0x1F0
,
req
->
addr
,
512
/
4
);
}
}
if
((
head
+
1
)
%
NREQUEST
==
tail
)
{
if
((
head
+
1
)
%
NREQUEST
==
tail
)
{
...
...
syscall.c
浏览文件 @
10420772
...
@@ -426,6 +426,14 @@ sys_block(void)
...
@@ -426,6 +426,14 @@ sys_block(void)
brelse
(
b
);
brelse
(
b
);
}
}
#if 0
cprintf("overwrite fs.img!\n");
b = getblk();
memset (b->data, 'f', 10);
bwrite(1, b, 0);
cprintf("write is done\n");
#endif
ip
=
iget
(
1
,
1
);
ip
=
iget
(
1
,
1
);
cprintf
(
"iget 1: %d %d %d %d %d %d %d %d
\n
"
,
cprintf
(
"iget 1: %d %d %d %d %d %d %d %d
\n
"
,
ip
->
dev
,
ip
->
inum
,
ip
->
count
,
ip
->
busy
,
ip
->
dev
,
ip
->
inum
,
ip
->
count
,
ip
->
busy
,
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论