Get rid of -rndpg option for now, because none of the tests use it.
[pintos-anon] / src / devices / disk.c
index 1810fc4b1c474961d618a4002cb75ac4299d93a4..2bae0577ff044ec07657711cae1d7586338b9c49 100644 (file)
@@ -30,6 +30,7 @@
 
 /* Alternate Status Register bits. */
 #define STA_BSY 0x80            /* Busy. */
+#define STA_DRDY 0x40           /* Device Ready. */
 #define STA_DRQ 0x08            /* Data Request. */
 
 /* Control Register bits. */
@@ -123,9 +124,9 @@ disk_init (void)
         default:
           NOT_REACHED ();
         }
-      lock_init (&c->lock, c->name);
+      lock_init (&c->lock);
       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++)
@@ -142,7 +143,7 @@ disk_init (void)
         }
 
       /* 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);
@@ -331,15 +332,18 @@ static bool
 check_device_type (struct disk *d) 
 {
   struct channel *c = d->channel;
-  uint8_t error, lbam, lbah;
+  uint8_t error, lbam, lbah, status;
 
   select_device (d);
 
   error = inb (reg_error (c));
   lbam = inb (reg_lbam (c));
   lbah = inb (reg_lbah (c));
+  status = inb (reg_status (c));
 
-  if (error != 1 && (error != 0x81 || d->dev_no == 1)) 
+  if ((error != 1 && (error != 0x81 || d->dev_no == 1))
+      || (status & STA_DRDY) == 0
+      || (status & STA_BSY) != 0)
     {
       d->is_ata = false;
       return error != 0x81;