Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CSEP551
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Krishna Vinnakota
CSEP551
Commits
c47bc4fd
Commit
c47bc4fd
authored
15 years ago
by
rsc
Browse files
Options
Downloads
Patches
Plain Diff
ide.c: make names more regular
parent
7b644318
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ide.c
+26
-23
26 additions, 23 deletions
ide.c
with
26 additions
and
23 deletions
ide.c
+
26
−
23
View file @
c47bc4fd
...
...
@@ -18,14 +18,14 @@
#define IDE_CMD_READ 0x20
#define IDE_CMD_WRITE 0x30
// ide
_
queue points to the buf now being read/written to the disk.
// ide
_
queue->qnext points to the next buf to be processed.
// You must hold ide
_
lock while manipulating queue.
// idequeue points to the buf now being read/written to the disk.
// idequeue->qnext points to the next buf to be processed.
// You must hold idelock while manipulating queue.
static
struct
spinlock
ide
_
lock
;
static
struct
buf
*
ide
_
queue
;
static
struct
spinlock
idelock
;
static
struct
buf
*
idequeue
;
static
int
disk_1_present
;
static
int
havedisk1
;
static
void
idestart
(
struct
buf
*
);
// Wait for IDE disk to become ready.
...
...
@@ -34,7 +34,7 @@ idewait(int check_error)
{
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
)
return
-
1
;
...
...
@@ -46,7 +46,7 @@ ideinit(void)
{
int
i
;
initlock
(
&
ide
_
lock
,
"ide"
);
initlock
(
&
idelock
,
"ide"
);
picenable
(
IRQ_IDE
);
ioapicenable
(
IRQ_IDE
,
ncpu
-
1
);
idewait
(
0
);
...
...
@@ -55,7 +55,7 @@ ideinit(void)
outb
(
0x1f6
,
0xe0
|
(
1
<<
4
));
for
(
i
=
0
;
i
<
1000
;
i
++
){
if
(
inb
(
0x1f7
)
!=
0
){
disk_1_present
=
1
;
havedisk1
=
1
;
break
;
}
}
...
...
@@ -64,7 +64,7 @@ ideinit(void)
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
idestart
(
struct
buf
*
b
)
{
...
...
@@ -92,11 +92,14 @@ ideintr(void)
{
struct
buf
*
b
;
acquire
(
&
ide_lock
);
if
((
b
=
ide_queue
)
==
0
){
release
(
&
ide_lock
);
// Take first buffer off queue.
acquire
(
&
idelock
);
if
((
b
=
idequeue
)
==
0
){
release
(
&
idelock
);
cprintf
(
"Spurious IDE interrupt.
\n
"
);
return
;
}
idequeue
=
b
->
qnext
;
// Read data if needed.
if
(
!
(
b
->
flags
&
B_DIRTY
)
&&
idewait
(
1
)
>=
0
)
...
...
@@ -108,10 +111,10 @@ ideintr(void)
wakeup
(
b
);
// Start disk on next buf in queue.
if
(
(
ide
_
queue
=
b
->
qnext
)
!=
0
)
idestart
(
ide
_
queue
);
if
(
idequeue
!=
0
)
idestart
(
idequeue
);
release
(
&
ide
_
lock
);
release
(
&
idelock
);
}
//PAGEBREAK!
...
...
@@ -127,25 +130,25 @@ iderw(struct buf *b)
panic
(
"iderw: buf not busy"
);
if
((
b
->
flags
&
(
B_VALID
|
B_DIRTY
))
==
B_VALID
)
panic
(
"iderw: nothing to do"
);
if
(
b
->
dev
!=
0
&&
!
disk_1_present
)
if
(
b
->
dev
!=
0
&&
!
havedisk1
)
panic
(
"idrw: ide disk 1 not present"
);
acquire
(
&
ide
_
lock
);
acquire
(
&
idelock
);
// Append b to ide
_
queue.
// Append b to idequeue.
b
->
qnext
=
0
;
for
(
pp
=&
ide
_
queue
;
*
pp
;
pp
=&
(
*
pp
)
->
qnext
)
for
(
pp
=&
idequeue
;
*
pp
;
pp
=&
(
*
pp
)
->
qnext
)
;
*
pp
=
b
;
// Start disk if necessary.
if
(
ide
_
queue
==
b
)
if
(
idequeue
==
b
)
idestart
(
b
);
// Wait for request to finish.
// Assuming will not sleep too long: ignore cp->killed.
while
((
b
->
flags
&
(
B_VALID
|
B_DIRTY
))
!=
B_VALID
)
sleep
(
b
,
&
ide
_
lock
);
sleep
(
b
,
&
idelock
);
release
(
&
ide
_
lock
);
release
(
&
idelock
);
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment