[UNIATA]
authorAleksey Bragin <aleksey@reactos.org>
Fri, 5 Mar 2010 13:23:43 +0000 (13:23 +0000)
committerAleksey Bragin <aleksey@reactos.org>
Fri, 5 Mar 2010 13:23:43 +0000 (13:23 +0000)
- Really perform a controller hard-reset if it can't recover from a soft reset. Fixes VirtualBox one IDE controller configuration (master - IDE, slave - ATAPI).
See issue #5145 for more details.

svn path=/trunk/; revision=45869

reactos/drivers/storage/ide/uniata/id_probe.cpp

index 752c88c..725f5ff 100644 (file)
@@ -2723,6 +2723,7 @@ CheckDevice(
                          signatureHigh;
     UCHAR                statusByte;
     ULONG                RetVal=0;
+    ULONG                waitCount = 10000;
 
     KdPrint2((PRINT_PREFIX "CheckDevice: Device %#x\n",
                deviceNumber));
@@ -2745,7 +2746,22 @@ CheckDevice(
             // Perform hard-reset.
             KdPrint2((PRINT_PREFIX
                         "CheckDevice: BUSY\n"));
+
+            AtapiWritePort1(chan, IDX_IO2_o_Control, IDE_DC_RESET_CONTROLLER );
+            AtapiStallExecution(500 * 1000);
+            AtapiWritePort1(chan, IDX_IO2_o_Control, IDE_DC_REENABLE_CONTROLLER);
+            SelectDrive(chan, deviceNumber & 0x01);
+
+            do {
+                // Wait for Busy to drop.
+                AtapiStallExecution(100);
+                GetStatus(chan, statusByte);
+
+            } while ((statusByte & IDE_STATUS_BUSY) && waitCount--);
+
             GetBaseStatus(chan, statusByte);
+            KdPrint2((PRINT_PREFIX
+                        "CheckDevice: status after hard reset %x\n", statusByte));
         }
 
         if((statusByte | IDE_STATUS_BUSY) == 0xff) {