[ros-kernel] Atapi device detection bug

Eric Kohl eric.kohl at t-online.de
Fri Sep 17 14:27:13 CEST 2004


Hi!

I found a bug in the latest device detection routine of the atapi driver.
The original atapi.c 1.54 won't boot on one of my machines. The attached
patch fixes this bug. Please test the patch if you cannot boot ReactOS!

Index: atapi.c
===================================================================
RCS file: /CVS/ReactOS/reactos/drivers/storage/atapi/atapi.c,v
retrieving revision 1.54
diff -u -r1.54 atapi.c
--- atapi.c 14 Sep 2004 22:09:06 -0000 1.54
+++ atapi.c 17 Sep 2004 11:00:49 -0000
@@ -1113,10 +1113,15 @@
   for (UnitNumber = 0; UnitNumber < 2; UnitNumber++)
     {
       /* Select drive */
-      IDEWriteDriveControl(ControlPortBase, 0);
-      IDEWriteDriveHead(CommandPortBase, IDE_DH_FIXED |
-                        (UnitNumber ? IDE_DH_DRV1 : IDE_DH_DRV0));
+      IDEWriteDriveHead(CommandPortBase,
+   IDE_DH_FIXED | (UnitNumber ? IDE_DH_DRV1 : IDE_DH_DRV0));
       ScsiPortStallExecution(500);
+
+      /* Disable interrupts */
+      IDEWriteDriveControl(ControlPortBase,
+      IDE_DC_nIEN);
+      ScsiPortStallExecution(500);
+
       /* Check if a device is attached to the interface */
       IDEWriteCylinderHigh(CommandPortBase, 0xaa);
       IDEWriteCylinderLow(CommandPortBase, 0x55);
@@ -1248,13 +1253,14 @@
        DPRINT("  No IDE drive found!\n");
      }
  }
-    }

-  /* Reset pending interrupts */
-  IDEReadStatus(CommandPortBase);
-  /* Reenable interrupts */
-  IDEWriteDriveControl(ControlPortBase, 0);
-  ScsiPortStallExecution(500);
+      /* Reset pending interrupts */
+      IDEReadStatus(CommandPortBase);
+
+      /* Reenable interrupts */
+      IDEWriteDriveControl(ControlPortBase, 0);
+      ScsiPortStallExecution(500);
+    }

   DPRINT("AtapiFindDrives() done (DeviceFound %s)\n", (DeviceFound) ?
"TRUE" : "FALSE");


I am also concerned about the use of a hardware reset of the ATA hardware.
According to the ATA specification it can take up to 30.5 seconds until an
ATA master plus slave device complete the hardware reset. The hardware
should also be issued by the BIOS so the devices are in a known state when
the atapi driver gains control of the devices. So I don't see any need for
hardware reset.


Regards,
Eric



More information about the Ros-kernel mailing list