projects
/
pintos-anon
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Update patch.
[pintos-anon]
/
src
/
devices
/
disk.c
diff --git
a/src/devices/disk.c
b/src/devices/disk.c
index baf120864399f11a8c33ae27f37a41992b413cab..0a131740b00711bc94af611330518d9e919b18f5 100644
(file)
--- a/
src/devices/disk.c
+++ b/
src/devices/disk.c
@@
-8,6
+8,9
@@
#include "threads/interrupt.h"
#include "threads/synch.h"
#include "threads/interrupt.h"
#include "threads/synch.h"
+/* The code in this file is an interface to an ATA (IDE)
+ controller. It attempts to comply to [ATA-3]. */
+
/* ATA command block port addresses. */
#define reg_data(CHANNEL) ((CHANNEL)->reg_base + 0) /* Data. */
#define reg_error(CHANNEL) ((CHANNEL)->reg_base + 1) /* Error. */
/* ATA command block port addresses. */
#define reg_data(CHANNEL) ((CHANNEL)->reg_base + 0) /* Data. */
#define reg_error(CHANNEL) ((CHANNEL)->reg_base + 1) /* Error. */
@@
-106,7
+109,7
@@
disk_init (void)
int dev_no;
/* Initialize channel. */
int dev_no;
/* Initialize channel. */
- snprintf (c->name, sizeof c->name, "hd%z
d
", chan_no);
+ snprintf (c->name, sizeof c->name, "hd%z
u
", chan_no);
switch (chan_no)
{
case 0:
switch (chan_no)
{
case 0:
@@
-120,9
+123,9
@@
disk_init (void)
default:
NOT_REACHED ();
}
default:
NOT_REACHED ();
}
- lock_init (&c->lock
, c->name
);
+ lock_init (&c->lock);
c->expecting_interrupt = false;
c->expecting_interrupt = false;
- sema_init (&c->completion_wait, 0
, c->name
);
+ sema_init (&c->completion_wait, 0);
/* Initialize devices. */
for (dev_no = 0; dev_no < 2; dev_no++)
/* Initialize devices. */
for (dev_no = 0; dev_no < 2; dev_no++)
@@
-139,7
+142,7
@@
disk_init (void)
}
/* Register interrupt handler. */
}
/* Register interrupt handler. */
- intr_register
(c->irq, 0, INTR_OFF
, interrupt_handler, c->name);
+ intr_register
_ext (c->irq
, interrupt_handler, c->name);
/* Reset hardware. */
reset_channel (c);
/* Reset hardware. */
reset_channel (c);
@@
-176,7
+179,14
@@
disk_print_stats (void)
}
/* Returns the disk numbered DEV_NO--either 0 or 1 for master or
}
/* Returns the disk numbered DEV_NO--either 0 or 1 for master or
- slave, respectively--within the channel numbered CHAN_NO. */
+ slave, respectively--within the channel numbered CHAN_NO.
+
+ Pintos uses disks this way:
+ 0:0 - operating system kernel
+ 0:1 - file system
+ 1:0 - scratch
+ 1:1 - swap
+*/
struct disk *
disk_get (int chan_no, int dev_no)
{
struct disk *
disk_get (int chan_no, int dev_no)
{
@@
-282,12
+292,12
@@
reset_channel (struct channel *c)
/* Issue soft reset sequence, which selects device 0 as a side effect.
Also enable interrupts. */
outb (reg_ctl (c), 0);
/* Issue soft reset sequence, which selects device 0 as a side effect.
Also enable interrupts. */
outb (reg_ctl (c), 0);
- timer_
sleep (timer_us2ticks (10)
);
+ timer_
usleep (10
);
outb (reg_ctl (c), CTL_SRST);
outb (reg_ctl (c), CTL_SRST);
- timer_
sleep (timer_us2ticks (10)
);
+ timer_
usleep (10
);
outb (reg_ctl (c), 0);
outb (reg_ctl (c), 0);
- timer_
sleep (timer_ms2ticks (150)
);
+ timer_
msleep (150
);
/* Wait for device 0 to clear BSY. */
if (present[0])
/* Wait for device 0 to clear BSY. */
if (present[0])
@@
-306,7
+316,7
@@
reset_channel (struct channel *c)
{
if (inb (reg_nsect (c)) == 1 && inb (reg_lbal (c)) == 1)
break;
{
if (inb (reg_nsect (c)) == 1 && inb (reg_lbal (c)) == 1)
break;
- timer_
sleep (timer_ms2ticks (10)
);
+ timer_
msleep (10
);
}
wait_while_busy (&c->devices[1]);
}
}
wait_while_busy (&c->devices[1]);
}
@@
-472,7
+482,7
@@
wait_until_idle (const struct disk *d)
{
if ((inb (reg_status (d->channel)) & (STA_BSY | STA_DRQ)) == 0)
return;
{
if ((inb (reg_status (d->channel)) & (STA_BSY | STA_DRQ)) == 0)
return;
- timer_
sleep (timer_us2ticks (10)
);
+ timer_
usleep (10
);
}
printf ("%s: idle timeout\n", d->name);
}
printf ("%s: idle timeout\n", d->name);
@@
-498,7
+508,7
@@
wait_while_busy (const struct disk *d)
printf ("ok\n");
return (inb (reg_alt_status (c)) & STA_DRQ) != 0;
}
printf ("ok\n");
return (inb (reg_alt_status (c)) & STA_DRQ) != 0;
}
- timer_
sleep (timer_ms2ticks (10)
);
+ timer_
msleep (10
);
}
printf ("failed\n");
}
printf ("failed\n");
@@
-515,7
+525,7
@@
select_device (const struct disk *d)
dev |= DEV_DEV;
outb (reg_device (c), dev);
inb (reg_alt_status (c));
dev |= DEV_DEV;
outb (reg_device (c), dev);
inb (reg_alt_status (c));
- timer_
sleep (timer_ns2ticks (400)
);
+ timer_
nsleep (400
);
}
/* Select disk D in its channel, as select_device(), but wait for
}
/* Select disk D in its channel, as select_device(), but wait for