From eb6bae0c08f2a8fce1a8ee670ef5ffced3047b43 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Fri, 5 Mar 2010 13:23:43 +0000 Subject: [PATCH] [UNIATA] - 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 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/reactos/drivers/storage/ide/uniata/id_probe.cpp b/reactos/drivers/storage/ide/uniata/id_probe.cpp index 752c88c826e..725f5ffe790 100644 --- a/reactos/drivers/storage/ide/uniata/id_probe.cpp +++ b/reactos/drivers/storage/ide/uniata/id_probe.cpp @@ -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) {