Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
8ec6530f
提交
8ec6530f
8月 06, 2006
创建
作者:
kaashoek
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
generalize async read to support write too
上级
36618921
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
17 行增加
和
12 行删除
+17
-12
bio.c
bio.c
+2
-2
defs.h
defs.h
+2
-2
ide.c
ide.c
+13
-8
没有找到文件。
bio.c
浏览文件 @
8ec6530f
...
@@ -42,9 +42,9 @@ bread(uint dev, uint sector)
...
@@ -42,9 +42,9 @@ bread(uint dev, uint sector)
b
=
getblk
();
b
=
getblk
();
acquire
(
&
ide_lock
);
acquire
(
&
ide_lock
);
c
=
ide_start_r
ead
(
dev
&
0xff
,
sector
,
b
->
data
,
1
);
c
=
ide_start_r
w
(
dev
&
0xff
,
sector
,
b
->
data
,
1
,
1
);
sleep
(
c
,
&
ide_lock
);
sleep
(
c
,
&
ide_lock
);
ide_finish
_read
(
c
);
ide_finish
(
c
);
release
(
&
ide_lock
);
release
(
&
ide_lock
);
return
b
;
return
b
;
...
...
defs.h
浏览文件 @
8ec6530f
...
@@ -91,8 +91,8 @@ void fd_incref(struct fd *fd);
...
@@ -91,8 +91,8 @@ void fd_incref(struct fd *fd);
// ide.c
// ide.c
void
ide_init
(
void
);
void
ide_init
(
void
);
void
ide_intr
(
void
);
void
ide_intr
(
void
);
void
*
ide_start_r
ead
(
int
diskno
,
uint
secno
,
void
*
dst
,
uint
nsecs
);
void
*
ide_start_r
w
(
int
diskno
,
uint
secno
,
void
*
dst
,
uint
nsecs
,
int
read
);
int
ide_finish
_read
(
void
*
);
int
ide_finish
(
void
*
);
// bio.c
// bio.c
struct
buf
;
struct
buf
;
...
...
ide.c
浏览文件 @
8ec6530f
...
@@ -20,8 +20,9 @@
...
@@ -20,8 +20,9 @@
struct
ide_request
{
struct
ide_request
{
int
diskno
;
int
diskno
;
uint
secno
;
uint
secno
;
void
*
dst
;
void
*
addr
;
uint
nsecs
;
uint
nsecs
;
uint
read
;
};
};
struct
ide_request
request
[
NREQUEST
];
struct
ide_request
request
[
NREQUEST
];
int
head
,
tail
;
int
head
,
tail
;
...
@@ -93,20 +94,22 @@ ide_start_request (void)
...
@@ -93,20 +94,22 @@ ide_start_request (void)
if
(
head
!=
tail
)
{
if
(
head
!=
tail
)
{
r
=
&
request
[
tail
];
r
=
&
request
[
tail
];
ide_wait_ready
(
0
);
ide_wait_ready
(
0
);
outb
(
0x3f6
,
0
);
outb
(
0x3f6
,
0
);
// generate interrupt
outb
(
0x1F2
,
r
->
nsecs
);
outb
(
0x1F2
,
r
->
nsecs
);
outb
(
0x1F3
,
r
->
secno
&
0xFF
);
outb
(
0x1F3
,
r
->
secno
&
0xFF
);
outb
(
0x1F4
,
(
r
->
secno
>>
8
)
&
0xFF
);
outb
(
0x1F4
,
(
r
->
secno
>>
8
)
&
0xFF
);
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
));
outb
(
0x1F7
,
0x20
);
// CMD 0x20 means read sector
if
(
r
->
read
)
outb
(
0x1F7
,
0x20
);
// read
else
outb
(
0x1F7
,
0x30
);
// write
}
}
}
}
void
*
void
*
ide_start_r
ead
(
int
diskno
,
uint
secno
,
void
*
dst
,
uint
nsecs
)
ide_start_r
w
(
int
diskno
,
uint
secno
,
void
*
addr
,
uint
nsecs
,
int
read
)
{
{
struct
ide_request
*
r
;
struct
ide_request
*
r
;
if
(
!
holding
(
&
ide_lock
))
if
(
!
holding
(
&
ide_lock
))
panic
(
"ide_start_read: not holding ide_lock"
);
panic
(
"ide_start_read: not holding ide_lock"
);
...
@@ -118,9 +121,10 @@ ide_start_read(int diskno, uint secno, void *dst, uint nsecs)
...
@@ -118,9 +121,10 @@ ide_start_read(int diskno, uint secno, void *dst, uint nsecs)
r
=
&
request
[
head
];
r
=
&
request
[
head
];
r
->
secno
=
secno
;
r
->
secno
=
secno
;
r
->
dst
=
dst
;
r
->
addr
=
addr
;
r
->
nsecs
=
nsecs
;
r
->
nsecs
=
nsecs
;
r
->
diskno
=
diskno
;
r
->
diskno
=
diskno
;
r
->
read
=
read
;
head
=
(
head
+
1
)
%
NREQUEST
;
head
=
(
head
+
1
)
%
NREQUEST
;
...
@@ -130,7 +134,7 @@ ide_start_read(int diskno, uint secno, void *dst, uint nsecs)
...
@@ -130,7 +134,7 @@ ide_start_read(int diskno, uint secno, void *dst, uint nsecs)
}
}
int
int
ide_finish
_read
(
void
*
c
)
ide_finish
(
void
*
c
)
{
{
int
r
=
0
;
int
r
=
0
;
struct
ide_request
*
req
=
(
struct
ide_request
*
)
c
;
struct
ide_request
*
req
=
(
struct
ide_request
*
)
c
;
...
@@ -140,10 +144,11 @@ ide_finish_read(void *c)
...
@@ -140,10 +144,11 @@ ide_finish_read(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
->
dst
+=
512
)
{
for
(;
req
->
nsecs
>
0
;
req
->
nsecs
--
,
req
->
addr
+=
512
)
{
if
((
r
=
ide_wait_ready
(
1
))
<
0
)
if
((
r
=
ide_wait_ready
(
1
))
<
0
)
break
;
break
;
insl
(
0x1F0
,
req
->
dst
,
512
/
4
);
if
(
req
->
read
)
insl
(
0x1F0
,
req
->
addr
,
512
/
4
);
else
outsl
(
0x1F0
,
req
->
addr
,
512
/
4
);
}
}
if
((
head
+
1
)
%
NREQUEST
==
tail
)
{
if
((
head
+
1
)
%
NREQUEST
==
tail
)
{
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论