mirror of
https://github.com/reactos/reactos.git
synced 2025-02-25 01:39:30 +00:00
Issue SPECIFY command upon initialization.
svn path=/trunk/; revision=6529
This commit is contained in:
parent
f1259f48fe
commit
3911ce2391
3 changed files with 61 additions and 42 deletions
|
@ -185,6 +185,16 @@ FloppyCreateController(PDRIVER_OBJECT DriverObject,
|
||||||
// point we should get the bios disk parameters passed in to the kernel at boot
|
// point we should get the bios disk parameters passed in to the kernel at boot
|
||||||
// and stored in the HARDWARE registry key for us to pick up here.
|
// and stored in the HARDWARE registry key for us to pick up here.
|
||||||
|
|
||||||
|
// Issue SPECIFY command
|
||||||
|
FloppyWriteDATA (ControllerExtension->PortBase, FLOPPY_CMD_SPEC_CHARS);
|
||||||
|
KeStallExecutionProcessor (100);
|
||||||
|
FloppyWriteDATA (ControllerExtension->PortBase, 0xD1);
|
||||||
|
KeStallExecutionProcessor (100);
|
||||||
|
FloppyWriteDATA (ControllerExtension->PortBase, 0x02);
|
||||||
|
KeStallExecutionProcessor (10000);
|
||||||
|
FloppyWriteMSTAT (ControllerExtension->PortBase, 0x00);
|
||||||
|
|
||||||
|
|
||||||
// turn on motor, wait for spinup time, and recalibrate the drive
|
// turn on motor, wait for spinup time, and recalibrate the drive
|
||||||
FloppyWriteDOR( ControllerExtension->PortBase, FLOPPY_DRIVE0_ON );
|
FloppyWriteDOR( ControllerExtension->PortBase, FLOPPY_DRIVE0_ON );
|
||||||
Timeout.QuadPart = FLOPPY_MOTOR_SPINUP_TIME;
|
Timeout.QuadPart = FLOPPY_MOTOR_SPINUP_TIME;
|
||||||
|
@ -292,15 +302,16 @@ FloppyExecuteReadWrite(PDEVICE_OBJECT DeviceObject,
|
||||||
PFLOPPY_CONTROLLER_EXTENSION ControllerExtension = (PFLOPPY_CONTROLLER_EXTENSION)DeviceExtension->Controller->ControllerExtension;
|
PFLOPPY_CONTROLLER_EXTENSION ControllerExtension = (PFLOPPY_CONTROLLER_EXTENSION)DeviceExtension->Controller->ControllerExtension;
|
||||||
LARGE_INTEGER Timeout;
|
LARGE_INTEGER Timeout;
|
||||||
BOOLEAN WriteToDevice;
|
BOOLEAN WriteToDevice;
|
||||||
DWORD Cyl, Sector, Head;
|
ULONG Cyl, Sector, Head;
|
||||||
PIO_STACK_LOCATION Stk;
|
PIO_STACK_LOCATION Stk;
|
||||||
DWORD Length;
|
ULONG Length;
|
||||||
|
|
||||||
|
DPRINT( "FloppyExecuteReadWrite()\n" );
|
||||||
|
|
||||||
ControllerExtension->Irp = Irp = (PIRP)Context;
|
ControllerExtension->Irp = Irp = (PIRP)Context;
|
||||||
Stk = IoGetCurrentIrpStackLocation( Irp );
|
Stk = IoGetCurrentIrpStackLocation( Irp );
|
||||||
ControllerExtension->Device = DeviceObject;
|
ControllerExtension->Device = DeviceObject;
|
||||||
Timeout.QuadPart = FLOPPY_MOTOR_SPINUP_TIME;
|
Timeout.QuadPart = FLOPPY_MOTOR_SPINUP_TIME;
|
||||||
DPRINT( "FloppyExecuteReadWrite()\n" );
|
|
||||||
CHECKPOINT;
|
CHECKPOINT;
|
||||||
WriteToDevice = Stk->MajorFunction == IRP_MJ_WRITE ? TRUE : FALSE;
|
WriteToDevice = Stk->MajorFunction == IRP_MJ_WRITE ? TRUE : FALSE;
|
||||||
// verify drive is spun up and selected
|
// verify drive is spun up and selected
|
||||||
|
@ -319,14 +330,15 @@ FloppyExecuteReadWrite(PDEVICE_OBJECT DeviceObject,
|
||||||
&ControllerExtension->MotorSpinupDpc );
|
&ControllerExtension->MotorSpinupDpc );
|
||||||
return KeepObject;
|
return KeepObject;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
Timeout.QuadPart = FLOPPY_MOTOR_SPINDOWN_TIME;
|
{
|
||||||
// motor is already spinning, so reset the spindown timer
|
Timeout.QuadPart = FLOPPY_MOTOR_SPINDOWN_TIME;
|
||||||
KeCancelTimer( &ControllerExtension->SpinupTimer );
|
// motor is already spinning, so reset the spindown timer
|
||||||
KeSetTimer( &ControllerExtension->SpinupTimer,
|
KeCancelTimer( &ControllerExtension->SpinupTimer );
|
||||||
Timeout,
|
KeSetTimer( &ControllerExtension->SpinupTimer,
|
||||||
&ControllerExtension->MotorSpindownDpc );
|
Timeout,
|
||||||
}
|
&ControllerExtension->MotorSpindownDpc );
|
||||||
|
}
|
||||||
#if 0
|
#if 0
|
||||||
/* Handle disk change, doesn't work correctly */
|
/* Handle disk change, doesn't work correctly */
|
||||||
if( FloppyReadDIR( ControllerExtension->PortBase ) & FLOPPY_DI_DSKCHNG )
|
if( FloppyReadDIR( ControllerExtension->PortBase ) & FLOPPY_DI_DSKCHNG )
|
||||||
|
|
|
@ -85,6 +85,7 @@
|
||||||
//
|
//
|
||||||
#define FloppyWriteDOR(A, V) (WRITE_PORT_UCHAR((PVOID)(A) + FLOPPY_REG_DOR, (V)))
|
#define FloppyWriteDOR(A, V) (WRITE_PORT_UCHAR((PVOID)(A) + FLOPPY_REG_DOR, (V)))
|
||||||
#define FloppyReadMSTAT(A) (READ_PORT_UCHAR((PVOID)(A) + FLOPPY_REG_MSTAT))
|
#define FloppyReadMSTAT(A) (READ_PORT_UCHAR((PVOID)(A) + FLOPPY_REG_MSTAT))
|
||||||
|
#define FloppyWriteMSTAT(A, V) (WRITE_PORT_UCHAR((PVOID)(A) + FLOPPY_REG_MSTAT, (V)))
|
||||||
#define FloppyReadDATA(A) (READ_PORT_UCHAR((PVOID)(A) + FLOPPY_REG_DATA))
|
#define FloppyReadDATA(A) (READ_PORT_UCHAR((PVOID)(A) + FLOPPY_REG_DATA))
|
||||||
#define FloppyWriteDATA(A, V) (WRITE_PORT_UCHAR((PVOID)(A) + FLOPPY_REG_DATA, (V)))
|
#define FloppyWriteDATA(A, V) (WRITE_PORT_UCHAR((PVOID)(A) + FLOPPY_REG_DATA, (V)))
|
||||||
#define FloppyReadDIR(A) (READ_PORT_UCHAR((PVOID)(A) + FLOPPY_REG_DIR))
|
#define FloppyReadDIR(A) (READ_PORT_UCHAR((PVOID)(A) + FLOPPY_REG_DIR))
|
||||||
|
|
|
@ -49,6 +49,9 @@ BOOLEAN FloppyIsrDetectMedia( PCONTROLLER_OBJECT Controller )
|
||||||
{
|
{
|
||||||
PFLOPPY_CONTROLLER_EXTENSION ControllerExtension = (PFLOPPY_CONTROLLER_EXTENSION)Controller->ControllerExtension;
|
PFLOPPY_CONTROLLER_EXTENSION ControllerExtension = (PFLOPPY_CONTROLLER_EXTENSION)Controller->ControllerExtension;
|
||||||
BYTE SectorSize;
|
BYTE SectorSize;
|
||||||
|
|
||||||
|
DPRINT("FloppyIsrDetectMedia() called\n");
|
||||||
|
|
||||||
// media detect in progress, read ID command already issued
|
// media detect in progress, read ID command already issued
|
||||||
// first, read result registers
|
// first, read result registers
|
||||||
KeStallExecutionProcessor( 1000 );
|
KeStallExecutionProcessor( 1000 );
|
||||||
|
@ -74,47 +77,50 @@ BOOLEAN FloppyIsrDetectMedia( PCONTROLLER_OBJECT Controller )
|
||||||
ControllerExtension->Irp,
|
ControllerExtension->Irp,
|
||||||
Controller );
|
Controller );
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOLEAN FloppyIsrRecal( PCONTROLLER_OBJECT Controller )
|
BOOLEAN FloppyIsrRecal( PCONTROLLER_OBJECT Controller )
|
||||||
{
|
{
|
||||||
PFLOPPY_CONTROLLER_EXTENSION ControllerExtension = (PFLOPPY_CONTROLLER_EXTENSION)Controller->ControllerExtension;
|
PFLOPPY_CONTROLLER_EXTENSION ControllerExtension = (PFLOPPY_CONTROLLER_EXTENSION)Controller->ControllerExtension;
|
||||||
// issue sense interrupt status, and read St0 and cyl
|
// issue sense interrupt status, and read St0 and cyl
|
||||||
|
|
||||||
FloppyWriteDATA( ControllerExtension->PortBase, FLOPPY_CMD_SNS_INTR );
|
DPRINT("FloppyIsrRecal() called\n");
|
||||||
KeStallExecutionProcessor( 1000 );
|
|
||||||
ControllerExtension->St0 = FloppyReadDATA( ControllerExtension->PortBase );
|
|
||||||
KeStallExecutionProcessor( 1000 );
|
|
||||||
FloppyReadDATA( ControllerExtension->PortBase ); // ignore cyl number
|
|
||||||
if (FLOPPY_MS_DATARDYR ==
|
|
||||||
(FloppyReadMSTAT( ControllerExtension->PortBase ) & FLOPPY_MS_RDYMASK))
|
|
||||||
{
|
|
||||||
/* There's something still to be read (what is it???? only happens on some
|
|
||||||
controllers). Ignore it. */
|
|
||||||
(void) FloppyReadDATA( ControllerExtension->PortBase );
|
|
||||||
}
|
|
||||||
DPRINT( "Recal St0: %2x\n", ControllerExtension->St0 );
|
|
||||||
|
|
||||||
// If recalibrate worked, issue read ID for each media type untill one works
|
FloppyWriteDATA( ControllerExtension->PortBase, FLOPPY_CMD_SNS_INTR );
|
||||||
if( ControllerExtension->St0 != FLOPPY_ST0_SEEKGD )
|
KeStallExecutionProcessor( 1000 );
|
||||||
{
|
ControllerExtension->St0 = FloppyReadDATA( ControllerExtension->PortBase );
|
||||||
|
KeStallExecutionProcessor( 1000 );
|
||||||
|
FloppyReadDATA( ControllerExtension->PortBase ); // ignore cyl number
|
||||||
|
if (FLOPPY_MS_DATARDYR ==
|
||||||
|
(FloppyReadMSTAT( ControllerExtension->PortBase ) & FLOPPY_MS_RDYMASK))
|
||||||
|
{
|
||||||
|
/* There's something still to be read (what is it???? only happens on some
|
||||||
|
controllers). Ignore it. */
|
||||||
|
(void) FloppyReadDATA( ControllerExtension->PortBase );
|
||||||
|
}
|
||||||
|
DPRINT( "Recal St0: %2x\n", ControllerExtension->St0 );
|
||||||
|
|
||||||
|
// If recalibrate worked, issue read ID for each media type untill one works
|
||||||
|
if ( ControllerExtension->St0 != FLOPPY_ST0_SEEKGD )
|
||||||
|
{
|
||||||
DPRINT( "Recalibrate failed, ST0 = %2x\n", ControllerExtension->St0 );
|
DPRINT( "Recalibrate failed, ST0 = %2x\n", ControllerExtension->St0 );
|
||||||
// queue DPC to fail IRP
|
// queue DPC to fail IRP
|
||||||
ControllerExtension->DpcState = FloppyDpcFailIrp;
|
ControllerExtension->DpcState = FloppyDpcFailIrp;
|
||||||
IoRequestDpc( ControllerExtension->Device,
|
IoRequestDpc( ControllerExtension->Device,
|
||||||
ControllerExtension->Irp,
|
ControllerExtension->Irp,
|
||||||
Controller );
|
Controller );
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
// issue first read id, FloppyIsrDetectMedia will handle
|
{
|
||||||
DPRINT( "Recalibrate worked, issuing read ID mark command\n" );
|
// issue first read id, FloppyIsrDetectMedia will handle
|
||||||
ControllerExtension->IsrState = FloppyIsrDetectMedia;
|
DPRINT( "Recalibrate worked, issuing read ID mark command\n" );
|
||||||
KeStallExecutionProcessor( 1000 );
|
ControllerExtension->IsrState = FloppyIsrDetectMedia;
|
||||||
FloppyWriteDATA( ControllerExtension->PortBase, FLOPPY_CMD_RD_ID | FLOPPY_C0M_MFM );
|
KeStallExecutionProcessor( 1000 );
|
||||||
KeStallExecutionProcessor( 1000 );
|
FloppyWriteDATA( ControllerExtension->PortBase, FLOPPY_CMD_RD_ID | FLOPPY_C0M_MFM );
|
||||||
FloppyWriteDATA( ControllerExtension->PortBase, ((PFLOPPY_DEVICE_EXTENSION)ControllerExtension->Device->DeviceExtension)->DriveSelect );
|
KeStallExecutionProcessor( 1000 );
|
||||||
}
|
FloppyWriteDATA( ControllerExtension->PortBase, ((PFLOPPY_DEVICE_EXTENSION)ControllerExtension->Device->DeviceExtension)->DriveSelect );
|
||||||
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue