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
72ea69fb
Commit
72ea69fb
authored
18 years ago
by
kaashoek
Browse files
Options
Downloads
Patches
Plain Diff
read the disk using interrupts
parent
7837c71b
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
defs.h
+3
-1
3 additions, 1 deletion
defs.h
ide.c
+12
-7
12 additions, 7 deletions
ide.c
main.c
+5
-3
5 additions, 3 deletions
main.c
syscall.c
+16
-6
16 additions, 6 deletions
syscall.c
with
36 additions
and
17 deletions
defs.h
+
3
−
1
View file @
72ea69fb
...
...
@@ -70,6 +70,8 @@ int fd_read(struct fd *fd, char *addr, int n);
int
fd_write
(
struct
fd
*
fd
,
char
*
addr
,
int
n
);
// ide.c
extern
int
disk_channel
;
void
ide_init
(
void
);
void
ide_intri
(
void
);
void
ide_intr
(
void
);
int
ide_start_read
(
uint32_t
secno
,
void
*
dst
,
unsigned
nsecs
);
int
ide_read
(
uint32_t
secno
,
void
*
dst
,
unsigned
nsecs
);
This diff is collapsed.
Click to expand it.
ide.c
+
12
−
7
View file @
72ea69fb
...
...
@@ -17,6 +17,7 @@
#define IDE_ERR 0x01
static
int
diskno
=
0
;
int
disk_channel
;
static
int
ide_wait_ready
(
int
check_error
)
...
...
@@ -43,6 +44,7 @@ void
ide_intr
(
void
)
{
cprintf
(
"ide_intr
\n
"
);
wakeup
(
&
disk_channel
);
}
...
...
@@ -78,12 +80,10 @@ ide_set_disk(int d)
}
int
ide_read
(
uint32_t
secno
,
void
*
dst
,
unsigned
nsecs
)
ide_
start_
read
(
uint32_t
secno
,
void
*
dst
,
unsigned
nsecs
)
{
int
r
;
if
(
nsecs
>
256
)
panic
(
"ide_
read
"
);
panic
(
"ide_
start_read: nsecs too large
"
);
ide_wait_ready
(
0
);
...
...
@@ -95,14 +95,19 @@ ide_read(uint32_t secno, void *dst, unsigned nsecs)
outb
(
0x1F6
,
0xE0
|
((
diskno
&
1
)
<<
4
)
|
((
secno
>>
24
)
&
0x0F
));
outb
(
0x1F7
,
0x20
);
// CMD 0x20 means read sector
#if 0
return
0
;
}
int
ide_read
(
uint32_t
secno
,
void
*
dst
,
unsigned
nsecs
)
{
int
r
;
for
(;
nsecs
>
0
;
nsecs
--
,
dst
+=
512
)
{
if
((
r
=
ide_wait_ready
(
1
))
<
0
)
return
r
;
insl
(
0x1F0
,
dst
,
512
/
4
);
}
#endif
return
0
;
}
...
...
This diff is collapsed.
Click to expand it.
main.c
+
5
−
3
View file @
72ea69fb
...
...
@@ -60,12 +60,14 @@ main()
p
->
ppid
=
0
;
setupsegs
(
p
);
// become interruptable
write_eflags
(
read_eflags
()
|
FL_IF
);
// turn on timer and enable interrupts on the local APIC
lapic_timerinit
();
lapic_enableintr
();
// init disk device
ide_init
();
// become interruptable
write_eflags
(
read_eflags
()
|
FL_IF
);
p
=
newproc
();
// load_icode(p, _binary_usertests_start, (unsigned) _binary_usertests_size);
...
...
This diff is collapsed.
Click to expand it.
syscall.c
+
16
−
6
View file @
72ea69fb
...
...
@@ -227,14 +227,24 @@ sys_cons_putc()
int
sys_block
(
void
)
{
char
buf
[
1
];
char
buf
[
512
];
int
i
,
j
;
cprintf
(
"%d: call sys_block
\n
"
,
cpu
());
ide_init
();
ide_read
(
0
,
buf
,
1
);
// cprintf("sec0.0 %x\n", buf[0] & 0xff);
cprintf
(
"call sleep
\n
"
);
sleep
(
0
);
for
(
i
=
0
;
i
<
100
;
i
++
)
{
if
(
ide_start_read
(
i
,
buf
,
1
))
{
panic
(
"couldn't start read
\n
"
);
}
cprintf
(
"call sleep
\n
"
);
sleep
(
&
disk_channel
);
if
(
ide_read
(
i
,
buf
,
1
))
{
panic
(
"couldn't do read
\n
"
);
}
cprintf
(
"sector %d: "
,
i
);
for
(
j
=
0
;
j
<
2
;
j
++
)
cprintf
(
"%x "
,
buf
[
j
]
&
0xff
);
cprintf
(
"
\n
"
);
}
return
0
;
}
...
...
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