Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
c47bc4fd
提交
c47bc4fd
5月 31, 2009
创建
作者:
rsc
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ide.c: make names more regular
上级
7b644318
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
26 行增加
和
23 行删除
+26
-23
ide.c
ide.c
+26
-23
没有找到文件。
ide.c
浏览文件 @
c47bc4fd
...
@@ -18,14 +18,14 @@
...
@@ -18,14 +18,14 @@
#define IDE_CMD_READ 0x20
#define IDE_CMD_READ 0x20
#define IDE_CMD_WRITE 0x30
#define IDE_CMD_WRITE 0x30
// ide
_
queue points to the buf now being read/written to the disk.
// idequeue points to the buf now being read/written to the disk.
// ide
_
queue->qnext points to the next buf to be processed.
// idequeue->qnext points to the next buf to be processed.
// You must hold ide
_
lock while manipulating queue.
// You must hold idelock while manipulating queue.
static
struct
spinlock
ide
_
lock
;
static
struct
spinlock
idelock
;
static
struct
buf
*
ide
_
queue
;
static
struct
buf
*
idequeue
;
static
int
disk_1_present
;
static
int
havedisk1
;
static
void
idestart
(
struct
buf
*
);
static
void
idestart
(
struct
buf
*
);
// Wait for IDE disk to become ready.
// Wait for IDE disk to become ready.
...
@@ -34,7 +34,7 @@ idewait(int check_error)
...
@@ -34,7 +34,7 @@ idewait(int check_error)
{
{
int
r
;
int
r
;
while
(((
r
=
inb
(
0x1f7
))
&
IDE_BSY
)
||
!
(
r
&
IDE_DRDY
))
while
(((
r
=
inb
(
0x1f7
))
&
(
IDE_BSY
|
IDE_DRDY
))
!=
IDE_DRDY
)
;
;
if
(
check_error
&&
(
r
&
(
IDE_DF
|
IDE_ERR
))
!=
0
)
if
(
check_error
&&
(
r
&
(
IDE_DF
|
IDE_ERR
))
!=
0
)
return
-
1
;
return
-
1
;
...
@@ -46,7 +46,7 @@ ideinit(void)
...
@@ -46,7 +46,7 @@ ideinit(void)
{
{
int
i
;
int
i
;
initlock
(
&
ide
_
lock
,
"ide"
);
initlock
(
&
idelock
,
"ide"
);
picenable
(
IRQ_IDE
);
picenable
(
IRQ_IDE
);
ioapicenable
(
IRQ_IDE
,
ncpu
-
1
);
ioapicenable
(
IRQ_IDE
,
ncpu
-
1
);
idewait
(
0
);
idewait
(
0
);
...
@@ -55,7 +55,7 @@ ideinit(void)
...
@@ -55,7 +55,7 @@ ideinit(void)
outb
(
0x1f6
,
0xe0
|
(
1
<<
4
));
outb
(
0x1f6
,
0xe0
|
(
1
<<
4
));
for
(
i
=
0
;
i
<
1000
;
i
++
){
for
(
i
=
0
;
i
<
1000
;
i
++
){
if
(
inb
(
0x1f7
)
!=
0
){
if
(
inb
(
0x1f7
)
!=
0
){
disk_1_present
=
1
;
havedisk1
=
1
;
break
;
break
;
}
}
}
}
...
@@ -64,7 +64,7 @@ ideinit(void)
...
@@ -64,7 +64,7 @@ ideinit(void)
outb
(
0x1f6
,
0xe0
|
(
0
<<
4
));
outb
(
0x1f6
,
0xe0
|
(
0
<<
4
));
}
}
// Start the request for b. Caller must hold ide
_
lock.
// Start the request for b. Caller must hold idelock.
static
void
static
void
idestart
(
struct
buf
*
b
)
idestart
(
struct
buf
*
b
)
{
{
...
@@ -92,11 +92,14 @@ ideintr(void)
...
@@ -92,11 +92,14 @@ ideintr(void)
{
{
struct
buf
*
b
;
struct
buf
*
b
;
acquire
(
&
ide_lock
);
// Take first buffer off queue.
if
((
b
=
ide_queue
)
==
0
){
acquire
(
&
idelock
);
release
(
&
ide_lock
);
if
((
b
=
idequeue
)
==
0
){
release
(
&
idelock
);
cprintf
(
"Spurious IDE interrupt.
\n
"
);
return
;
return
;
}
}
idequeue
=
b
->
qnext
;
// Read data if needed.
// Read data if needed.
if
(
!
(
b
->
flags
&
B_DIRTY
)
&&
idewait
(
1
)
>=
0
)
if
(
!
(
b
->
flags
&
B_DIRTY
)
&&
idewait
(
1
)
>=
0
)
...
@@ -108,10 +111,10 @@ ideintr(void)
...
@@ -108,10 +111,10 @@ ideintr(void)
wakeup
(
b
);
wakeup
(
b
);
// Start disk on next buf in queue.
// Start disk on next buf in queue.
if
(
(
ide_queue
=
b
->
qnext
)
!=
0
)
if
(
idequeue
!=
0
)
idestart
(
ide
_
queue
);
idestart
(
idequeue
);
release
(
&
ide
_
lock
);
release
(
&
idelock
);
}
}
//PAGEBREAK!
//PAGEBREAK!
...
@@ -127,25 +130,25 @@ iderw(struct buf *b)
...
@@ -127,25 +130,25 @@ iderw(struct buf *b)
panic
(
"iderw: buf not busy"
);
panic
(
"iderw: buf not busy"
);
if
((
b
->
flags
&
(
B_VALID
|
B_DIRTY
))
==
B_VALID
)
if
((
b
->
flags
&
(
B_VALID
|
B_DIRTY
))
==
B_VALID
)
panic
(
"iderw: nothing to do"
);
panic
(
"iderw: nothing to do"
);
if
(
b
->
dev
!=
0
&&
!
disk_1_present
)
if
(
b
->
dev
!=
0
&&
!
havedisk1
)
panic
(
"idrw: ide disk 1 not present"
);
panic
(
"idrw: ide disk 1 not present"
);
acquire
(
&
ide
_
lock
);
acquire
(
&
idelock
);
// Append b to ide
_
queue.
// Append b to idequeue.
b
->
qnext
=
0
;
b
->
qnext
=
0
;
for
(
pp
=&
ide
_
queue
;
*
pp
;
pp
=&
(
*
pp
)
->
qnext
)
for
(
pp
=&
idequeue
;
*
pp
;
pp
=&
(
*
pp
)
->
qnext
)
;
;
*
pp
=
b
;
*
pp
=
b
;
// Start disk if necessary.
// Start disk if necessary.
if
(
ide
_
queue
==
b
)
if
(
idequeue
==
b
)
idestart
(
b
);
idestart
(
b
);
// Wait for request to finish.
// Wait for request to finish.
// Assuming will not sleep too long: ignore cp->killed.
// Assuming will not sleep too long: ignore cp->killed.
while
((
b
->
flags
&
(
B_VALID
|
B_DIRTY
))
!=
B_VALID
)
while
((
b
->
flags
&
(
B_VALID
|
B_DIRTY
))
!=
B_VALID
)
sleep
(
b
,
&
ide
_
lock
);
sleep
(
b
,
&
idelock
);
release
(
&
ide
_
lock
);
release
(
&
idelock
);
}
}
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论