Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CSEP551
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
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
10420772
Commit
10420772
authored
18 years ago
by
kaashoek
Browse files
Options
Downloads
Patches
Plain Diff
bwrite
parent
8ec6530f
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
bio.c
+13
-0
13 additions, 0 deletions
bio.c
defs.h
+2
-0
2 additions, 0 deletions
defs.h
ide.c
+10
-8
10 additions, 8 deletions
ide.c
syscall.c
+8
-0
8 additions, 0 deletions
syscall.c
with
33 additions
and
8 deletions
bio.c
+
13
−
0
View file @
10420772
...
...
@@ -50,6 +50,19 @@ bread(uint dev, uint sector)
return
b
;
}
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
)
{
...
...
This diff is collapsed.
Click to expand it.
defs.h
+
2
−
0
View file @
10420772
...
...
@@ -96,7 +96,9 @@ int ide_finish(void *);
// bio.c
struct
buf
;
struct
buf
*
getblk
(
void
);
struct
buf
*
bread
(
uint
,
uint
);
void
bwrite
(
uint
,
struct
buf
*
,
uint
);
void
brelse
(
struct
buf
*
);
// fs.c
...
...
This diff is collapsed.
Click to expand it.
ide.c
+
10
−
8
View file @
10420772
...
...
@@ -101,7 +101,10 @@ ide_start_request (void)
outb
(
0x1F5
,
(
r
->
secno
>>
16
)
&
0xFF
);
outb
(
0x1F6
,
0xE0
|
((
r
->
diskno
&
1
)
<<
4
)
|
((
r
->
secno
>>
24
)
&
0x0F
));
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)
if
(
!
holding
(
&
ide_lock
))
panic
(
"ide_start_read: not holding ide_lock"
);
if
(
nsecs
>
256
)
if
(
nsecs
>
1
)
panic
(
"ide_start_read: nsecs too large"
);
while
((
head
+
1
)
%
NREQUEST
==
tail
)
...
...
@@ -136,7 +139,7 @@ ide_start_rw(int diskno, uint secno, void *addr, uint nsecs, int read)
int
ide_finish
(
void
*
c
)
{
int
r
=
0
;
int
r
;
struct
ide_request
*
req
=
(
struct
ide_request
*
)
c
;
if
(
c
!=
&
request
[
tail
])
...
...
@@ -144,11 +147,10 @@ ide_finish(void *c)
if
(
!
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
)
break
;
if
(
req
->
read
)
insl
(
0x1F0
,
req
->
addr
,
512
/
4
);
else
outsl
(
0x1F0
,
req
->
addr
,
512
/
4
);
if
(
req
->
read
)
{
if
((
r
=
ide_wait_ready
(
1
))
>=
0
)
insl
(
0x1F0
,
req
->
addr
,
512
/
4
);
}
if
((
head
+
1
)
%
NREQUEST
==
tail
)
{
...
...
This diff is collapsed.
Click to expand it.
syscall.c
+
8
−
0
View file @
10420772
...
...
@@ -426,6 +426,14 @@ sys_block(void)
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
);
cprintf
(
"iget 1: %d %d %d %d %d %d %d %d
\n
"
,
ip
->
dev
,
ip
->
inum
,
ip
->
count
,
ip
->
busy
,
...
...
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