From 296c5258a46e821424242f0ee4ea052d123d264d Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Wed, 4 Sep 2002 21:33:26 +0000 Subject: [PATCH] Check for a busy device in AtapiInterrupt(). svn path=/trunk/; revision=3458 --- reactos/drivers/storage/atapi/atapi.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/reactos/drivers/storage/atapi/atapi.c b/reactos/drivers/storage/atapi/atapi.c index 9ff0a989605..41eca614c4a 100644 --- a/reactos/drivers/storage/atapi/atapi.c +++ b/reactos/drivers/storage/atapi/atapi.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: atapi.c,v 1.27 2002/08/28 18:36:18 ekohl Exp $ +/* $Id: atapi.c,v 1.28 2002/09/04 21:33:26 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS ATAPI miniport driver @@ -704,7 +704,6 @@ AtapiInterrupt(IN PVOID DeviceExtension) ULONG SectorSize; ULONG TransferSize; - DPRINT("AtapiInterrupt() called!\n"); DevExt = (PATAPI_MINIPORT_EXTENSION)DeviceExtension; @@ -727,6 +726,26 @@ AtapiInterrupt(IN PVOID DeviceExtension) IsLastBlock = FALSE; DeviceStatus = IDEReadStatus(CommandPortBase); + DPRINT("DeviceStatus: %x\n", DeviceStatus); + + if (DeviceStatus & IDE_SR_BUSY) + { + /* Wait for BUSY to drop */ + for (Retries = 0; Retries < IDE_MAX_BUSY_RETRIES; Retries++) + { + DeviceStatus = IDEReadStatus(CommandPortBase); + if (!(DeviceStatus & IDE_SR_BUSY)) + { + break; + } + ScsiPortStallExecution(10); + } + if (Retries >= IDE_MAX_BUSY_RETRIES) + { + DPRINT1("Drive is BUSY for too long\n"); + /* FIXME: handle timeout */ + } + } if ((DeviceStatus & IDE_SR_ERR) && (Srb->Cdb[0] != SCSIOP_REQUEST_SENSE))