mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
Rollback identify code (Filip reluctantly agrees)
svn path=/trunk/; revision=11694
This commit is contained in:
parent
f404e670d5
commit
583f2092ad
1 changed files with 38 additions and 87 deletions
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: atapi.c,v 1.55 2004/09/26 09:14:20 hbirr Exp $
|
/* $Id: atapi.c,v 1.56 2004/11/18 08:32:32 gvg Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS ATAPI miniport driver
|
* PROJECT: ReactOS ATAPI miniport driver
|
||||||
|
@ -169,7 +169,6 @@ AtapiInitDma(PATAPI_MINIPORT_EXTENSION DevExt,
|
||||||
BYTE cmd);
|
BYTE cmd);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_PCI
|
|
||||||
static ULONG STDCALL
|
static ULONG STDCALL
|
||||||
AtapiFindCompatiblePciController(PVOID DeviceExtension,
|
AtapiFindCompatiblePciController(PVOID DeviceExtension,
|
||||||
PVOID HwContext,
|
PVOID HwContext,
|
||||||
|
@ -177,9 +176,7 @@ AtapiFindCompatiblePciController(PVOID DeviceExtension,
|
||||||
PCHAR ArgumentString,
|
PCHAR ArgumentString,
|
||||||
PPORT_CONFIGURATION_INFORMATION ConfigInfo,
|
PPORT_CONFIGURATION_INFORMATION ConfigInfo,
|
||||||
PBOOLEAN Again);
|
PBOOLEAN Again);
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ENABLE_ISA
|
|
||||||
static ULONG STDCALL
|
static ULONG STDCALL
|
||||||
AtapiFindIsaBusController(PVOID DeviceExtension,
|
AtapiFindIsaBusController(PVOID DeviceExtension,
|
||||||
PVOID HwContext,
|
PVOID HwContext,
|
||||||
|
@ -187,9 +184,7 @@ AtapiFindIsaBusController(PVOID DeviceExtension,
|
||||||
PCHAR ArgumentString,
|
PCHAR ArgumentString,
|
||||||
PPORT_CONFIGURATION_INFORMATION ConfigInfo,
|
PPORT_CONFIGURATION_INFORMATION ConfigInfo,
|
||||||
PBOOLEAN Again);
|
PBOOLEAN Again);
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ENABLE_NATIVE_PCI
|
|
||||||
static ULONG STDCALL
|
static ULONG STDCALL
|
||||||
AtapiFindNativePciController(PVOID DeviceExtension,
|
AtapiFindNativePciController(PVOID DeviceExtension,
|
||||||
PVOID HwContext,
|
PVOID HwContext,
|
||||||
|
@ -197,7 +192,6 @@ AtapiFindNativePciController(PVOID DeviceExtension,
|
||||||
PCHAR ArgumentString,
|
PCHAR ArgumentString,
|
||||||
PPORT_CONFIGURATION_INFORMATION ConfigInfo,
|
PPORT_CONFIGURATION_INFORMATION ConfigInfo,
|
||||||
PBOOLEAN Again);
|
PBOOLEAN Again);
|
||||||
#endif
|
|
||||||
|
|
||||||
static BOOLEAN STDCALL
|
static BOOLEAN STDCALL
|
||||||
AtapiInitialize(IN PVOID DeviceExtension);
|
AtapiInitialize(IN PVOID DeviceExtension);
|
||||||
|
@ -294,10 +288,7 @@ AtapiErrorToScsi(PVOID DeviceExtension,
|
||||||
PSCSI_REQUEST_BLOCK Srb);
|
PSCSI_REQUEST_BLOCK Srb);
|
||||||
|
|
||||||
static VOID
|
static VOID
|
||||||
AtapiScsiSrbToAtapi(PSCSI_REQUEST_BLOCK Srb);
|
AtapiScsiSrbToAtapi (PSCSI_REQUEST_BLOCK Srb);
|
||||||
|
|
||||||
static BOOLEAN
|
|
||||||
AtapiWaitForStatus(ULONG CommandPort, ULONG Mask, ULONG Value, ULONG Timeout);
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------- Inlines
|
// ---------------------------------------------------------------- Inlines
|
||||||
|
|
||||||
|
@ -1097,10 +1088,9 @@ AtapiFindDevices(PATAPI_MINIPORT_EXTENSION DeviceExtension,
|
||||||
ULONG CommandPortBase;
|
ULONG CommandPortBase;
|
||||||
ULONG ControlPortBase;
|
ULONG ControlPortBase;
|
||||||
ULONG UnitNumber;
|
ULONG UnitNumber;
|
||||||
ULONG Status;
|
ULONG Retries;
|
||||||
UCHAR High;
|
UCHAR High;
|
||||||
UCHAR Low;
|
UCHAR Low;
|
||||||
BOOL UnitPresent[2];
|
|
||||||
|
|
||||||
DPRINT("AtapiFindDevices() called\n");
|
DPRINT("AtapiFindDevices() called\n");
|
||||||
|
|
||||||
|
@ -1113,68 +1103,47 @@ AtapiFindDevices(PATAPI_MINIPORT_EXTENSION DeviceExtension,
|
||||||
for (UnitNumber = 0; UnitNumber < 2; UnitNumber++)
|
for (UnitNumber = 0; UnitNumber < 2; UnitNumber++)
|
||||||
{
|
{
|
||||||
/* Select drive */
|
/* Select drive */
|
||||||
IDEWriteDriveControl(ControlPortBase, 0);
|
IDEWriteDriveHead(CommandPortBase,
|
||||||
IDEWriteDriveHead(CommandPortBase, IDE_DH_FIXED |
|
IDE_DH_FIXED | (UnitNumber ? IDE_DH_DRV1 : 0));
|
||||||
(UnitNumber ? IDE_DH_DRV1 : IDE_DH_DRV0));
|
|
||||||
ScsiPortStallExecution(500);
|
ScsiPortStallExecution(500);
|
||||||
|
|
||||||
|
/* Disable interrupts */
|
||||||
|
IDEWriteDriveControl(ControlPortBase,
|
||||||
|
IDE_DC_nIEN);
|
||||||
|
ScsiPortStallExecution(500);
|
||||||
|
|
||||||
/* Check if a device is attached to the interface */
|
/* Check if a device is attached to the interface */
|
||||||
IDEWriteCylinderHigh(CommandPortBase, 0xaa);
|
IDEWriteCylinderHigh(CommandPortBase, 0xaa);
|
||||||
IDEWriteCylinderLow(CommandPortBase, 0x55);
|
IDEWriteCylinderLow(CommandPortBase, 0x55);
|
||||||
|
|
||||||
High = IDEReadCylinderHigh(CommandPortBase);
|
High = IDEReadCylinderHigh(CommandPortBase);
|
||||||
Low = IDEReadCylinderLow(CommandPortBase);
|
Low = IDEReadCylinderLow(CommandPortBase);
|
||||||
UnitPresent[UnitNumber] = (Low == 0x55 || High == 0xaa);
|
|
||||||
#ifndef NDEBUG
|
IDEWriteCylinderHigh(CommandPortBase, 0);
|
||||||
|
IDEWriteCylinderLow(CommandPortBase, 0);
|
||||||
|
|
||||||
if (Low != 0x55 || High != 0xaa)
|
if (Low != 0x55 || High != 0xaa)
|
||||||
{
|
{
|
||||||
DPRINT("No Drive found. UnitNumber %d CommandPortBase %x\n", UnitNumber, CommandPortBase);
|
DPRINT("No Drive found. UnitNumber %d CommandPortBase %x\n", UnitNumber, CommandPortBase);
|
||||||
}
|
continue;
|
||||||
#endif
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* Check if any unit was found. */
|
AtapiExecuteCommand(DeviceExtension, IDE_CMD_RESET, NULL);
|
||||||
if (UnitPresent[0] == FALSE && UnitPresent[1] == FALSE)
|
|
||||||
{
|
|
||||||
DPRINT("No device found\n");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (UnitNumber = 0; UnitNumber < 2; UnitNumber++)
|
for (Retries = 0; Retries < 20000; Retries++)
|
||||||
{
|
{
|
||||||
/* Skip initilization of non-existent units */
|
if (!(IDEReadStatus(CommandPortBase) & IDE_SR_BUSY))
|
||||||
if (!UnitPresent[UnitNumber])
|
{
|
||||||
{
|
break;
|
||||||
continue;
|
}
|
||||||
}
|
ScsiPortStallExecution(150);
|
||||||
|
}
|
||||||
/* Select drive */
|
if (Retries >= 20000)
|
||||||
IDEWriteDriveHead(CommandPortBase, IDE_DH_FIXED |
|
{
|
||||||
(UnitNumber ? IDE_DH_DRV1 : IDE_DH_DRV0));
|
DPRINT("Timeout on drive %lu\n", UnitNumber);
|
||||||
/* Soft reset */
|
DeviceExtension->DeviceFlags[UnitNumber] &= ~DEVICE_PRESENT;
|
||||||
IDEWriteDriveControl(ControlPortBase, IDE_DC_SRST);
|
continue;
|
||||||
ScsiPortStallExecution(500);
|
}
|
||||||
IDEWriteDriveControl(ControlPortBase, IDE_DC_nIEN);
|
|
||||||
ScsiPortStallExecution(200);
|
|
||||||
|
|
||||||
/* Wait for busy to clear */
|
|
||||||
if (!AtapiWaitForStatus(CommandPortBase, IDE_SR_BUSY, 0, 20000))
|
|
||||||
{
|
|
||||||
DPRINT("Timeout on drive %lu\n", UnitNumber);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Status = IDEReadStatus(DeviceExtension->CommandPortBase);
|
|
||||||
if (Status & IDE_SR_ERR)
|
|
||||||
{
|
|
||||||
DPRINT("Error while doing software reset\n");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Select drive */
|
|
||||||
IDEWriteDriveHead(CommandPortBase, IDE_DH_FIXED |
|
|
||||||
(UnitNumber ? IDE_DH_DRV1 : IDE_DH_DRV0));
|
|
||||||
ScsiPortStallExecution(500);
|
|
||||||
|
|
||||||
High = IDEReadCylinderHigh(CommandPortBase);
|
High = IDEReadCylinderHigh(CommandPortBase);
|
||||||
Low = IDEReadCylinderLow(CommandPortBase);
|
Low = IDEReadCylinderLow(CommandPortBase);
|
||||||
|
@ -1203,8 +1172,6 @@ AtapiFindDevices(PATAPI_MINIPORT_EXTENSION DeviceExtension,
|
||||||
DeviceExtension->DeviceFlags[UnitNumber] |= DEVICE_DMA_CMD;
|
DeviceExtension->DeviceFlags[UnitNumber] |= DEVICE_DMA_CMD;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
AtapiExecuteCommand(DeviceExtension, IDE_CMD_RESET, NULL);
|
|
||||||
ScsiPortStallExecution(500);
|
|
||||||
DeviceFound = TRUE;
|
DeviceFound = TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1260,6 +1227,9 @@ AtapiFindDevices(PATAPI_MINIPORT_EXTENSION DeviceExtension,
|
||||||
/* Reenable interrupts */
|
/* Reenable interrupts */
|
||||||
IDEWriteDriveControl(ControlPortBase, 0);
|
IDEWriteDriveControl(ControlPortBase, 0);
|
||||||
ScsiPortStallExecution(500);
|
ScsiPortStallExecution(500);
|
||||||
|
/* Return with drive 0 selected */
|
||||||
|
IDEWriteDriveHead(CommandPortBase, IDE_DH_FIXED);
|
||||||
|
ScsiPortStallExecution(500);
|
||||||
|
|
||||||
DPRINT("AtapiFindDrives() done (DeviceFound %s)\n", (DeviceFound) ? "TRUE" : "FALSE");
|
DPRINT("AtapiFindDrives() done (DeviceFound %s)\n", (DeviceFound) ? "TRUE" : "FALSE");
|
||||||
|
|
||||||
|
@ -3064,23 +3034,4 @@ AtapiInitDma(PATAPI_MINIPORT_EXTENSION DevExt,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static BOOLEAN
|
|
||||||
AtapiWaitForStatus( ULONG CommandPort, ULONG Mask, ULONG Value, ULONG Timeout )
|
|
||||||
{
|
|
||||||
ULONG RetryCount, Status;
|
|
||||||
|
|
||||||
for (RetryCount = 0; RetryCount < Timeout; RetryCount++)
|
|
||||||
{
|
|
||||||
Status = IDEReadStatus(CommandPort);
|
|
||||||
if ((Status & Mask) == Value)
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
ScsiPortStallExecution(10);
|
|
||||||
}
|
|
||||||
DPRINT("status=%02x\n", Status);
|
|
||||||
DPRINT("waited %ld usecs\n", RetryCount * 10);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
Loading…
Reference in a new issue