mirror of
https://github.com/reactos/reactos.git
synced 2024-12-30 11:02:49 +00:00
Remove obsolete ide and (old) floppy drivers
svn path=/trunk/; revision=9698
This commit is contained in:
parent
c792e5b04c
commit
2d902a8146
13 changed files with 0 additions and 4053 deletions
|
@ -1,8 +0,0 @@
|
|||
*.tmp
|
||||
*.exp
|
||||
*.coff
|
||||
*.d
|
||||
*.o
|
||||
*.sym
|
||||
*.sys
|
||||
*.map
|
|
@ -1,20 +0,0 @@
|
|||
# $Id: Makefile,v 1.12 2003/11/13 14:22:03 ekohl Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_BOOTSTRAP = yes
|
||||
|
||||
TARGET_TYPE = driver
|
||||
|
||||
TARGET_NAME = floppy
|
||||
|
||||
TARGET_OBJECTS = \
|
||||
dpc.o \
|
||||
floppy.o \
|
||||
isr.o
|
||||
|
||||
TARGET_CFLAGS = -Wall -Werror
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
|
@ -1,279 +0,0 @@
|
|||
/****************************************************************************
|
||||
* Defered procedure calls for floppy disk driver, reactos project, created *
|
||||
* by Phillip Susi on 2/25/2001. This software is published under the GNU *
|
||||
* general public license, see the README file for more details *
|
||||
***************************************************************************/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
#include "floppy.h"
|
||||
|
||||
|
||||
VOID STDCALL
|
||||
FloppyDpc (PKDPC Dpc,
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp,
|
||||
PVOID Context)
|
||||
{
|
||||
PCONTROLLER_OBJECT Controller;
|
||||
PFLOPPY_CONTROLLER_EXTENSION ControllerExtension;
|
||||
|
||||
Controller = (PCONTROLLER_OBJECT)Context;
|
||||
ControllerExtension = (PFLOPPY_CONTROLLER_EXTENSION)Controller->ControllerExtension;
|
||||
|
||||
ControllerExtension->DpcState (Dpc,
|
||||
DeviceObject,
|
||||
Irp,
|
||||
Context);
|
||||
}
|
||||
|
||||
|
||||
VOID STDCALL
|
||||
FloppyDpcDetect (PKDPC Dpc,
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp,
|
||||
PVOID Context)
|
||||
{
|
||||
PCONTROLLER_OBJECT Controller;
|
||||
PFLOPPY_CONTROLLER_EXTENSION ControllerExtension;
|
||||
|
||||
Controller = (PCONTROLLER_OBJECT)Context;
|
||||
ControllerExtension = (PFLOPPY_CONTROLLER_EXTENSION)Controller->ControllerExtension;
|
||||
|
||||
KeSetEvent (&ControllerExtension->Event,
|
||||
0,
|
||||
FALSE);
|
||||
}
|
||||
|
||||
|
||||
VOID STDCALL
|
||||
FloppyDpcFailIrp (PKDPC Dpc,
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp,
|
||||
PVOID Context)
|
||||
{
|
||||
Irp->IoStatus.Status = STATUS_DEVICE_NOT_READY;
|
||||
Irp->IoStatus.Information = 0;
|
||||
CHECKPOINT;
|
||||
IoCompleteRequest (Irp,
|
||||
IO_NO_INCREMENT);
|
||||
}
|
||||
|
||||
|
||||
VOID STDCALL
|
||||
FloppyMotorSpindownDpc (PKDPC Dpc,
|
||||
PVOID Context,
|
||||
PVOID Arg1,
|
||||
PVOID Arg2)
|
||||
{
|
||||
PCONTROLLER_OBJECT Controller;
|
||||
PFLOPPY_CONTROLLER_EXTENSION ControllerExtension;
|
||||
|
||||
Controller = (PCONTROLLER_OBJECT)Context;
|
||||
ControllerExtension = (PFLOPPY_CONTROLLER_EXTENSION)Controller->ControllerExtension;
|
||||
|
||||
/* queue call to turn off motor */
|
||||
IoAllocateController (Controller,
|
||||
ControllerExtension->Device,
|
||||
FloppyExecuteSpindown,
|
||||
ControllerExtension);
|
||||
}
|
||||
|
||||
|
||||
VOID STDCALL
|
||||
FloppyMotorSpinupDpc (PKDPC Dpc,
|
||||
PVOID Context,
|
||||
PVOID Arg1,
|
||||
PVOID Arg2)
|
||||
{
|
||||
PCONTROLLER_OBJECT Controller;
|
||||
PFLOPPY_CONTROLLER_EXTENSION ControllerExtension;
|
||||
PFLOPPY_DEVICE_EXTENSION DeviceExtension;
|
||||
LARGE_INTEGER Timeout;
|
||||
|
||||
Controller = (PCONTROLLER_OBJECT)Context;
|
||||
ControllerExtension = (PFLOPPY_CONTROLLER_EXTENSION)Controller->ControllerExtension;
|
||||
DeviceExtension = (PFLOPPY_DEVICE_EXTENSION)ControllerExtension->Device->DeviceExtension;
|
||||
Timeout.QuadPart = FLOPPY_MOTOR_SPINDOWN_TIME;
|
||||
|
||||
// Motor has had time to spin up, mark motor as spun up and restart IRP
|
||||
// don't forget to set the spindown timer
|
||||
KeSetTimer (&ControllerExtension->SpinupTimer,
|
||||
Timeout,
|
||||
&ControllerExtension->MotorSpindownDpc);
|
||||
DPRINT ("Motor spun up, retrying operation\n");
|
||||
|
||||
ControllerExtension->MotorOn = DeviceExtension->DriveSelect;
|
||||
|
||||
IoFreeController (Controller);
|
||||
IoAllocateController (Controller,
|
||||
ControllerExtension->Device,
|
||||
FloppyExecuteReadWrite,
|
||||
ControllerExtension->Irp);
|
||||
}
|
||||
|
||||
|
||||
VOID STDCALL
|
||||
FloppySeekDpc (PKDPC Dpc,
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp,
|
||||
PVOID Context)
|
||||
{
|
||||
PFLOPPY_DEVICE_EXTENSION DeviceExtension;
|
||||
PFLOPPY_CONTROLLER_EXTENSION ControllerExtension;
|
||||
|
||||
DeviceExtension = (PFLOPPY_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||
ControllerExtension = (PFLOPPY_CONTROLLER_EXTENSION)DeviceExtension->Controller->ControllerExtension;
|
||||
|
||||
/* If the seek failed, fail the IRP */
|
||||
if (ControllerExtension->St0 & FLOPPY_ST0_GDMASK)
|
||||
{
|
||||
ControllerExtension->Irp->IoStatus.Status = STATUS_DISK_CORRUPT_ERROR;
|
||||
ControllerExtension->Irp->IoStatus.Information = 0;
|
||||
DPRINT ("Failing IRP: St0 = %2x, St1 = %2x, St2 = %2x\n",
|
||||
ControllerExtension->St0,
|
||||
ControllerExtension->St1,
|
||||
ControllerExtension->St2);
|
||||
for (;;);
|
||||
IoCompleteRequest (ControllerExtension->Irp,
|
||||
IO_NO_INCREMENT);
|
||||
IoFreeController (DeviceExtension->Controller);
|
||||
return;
|
||||
}
|
||||
|
||||
KeStallExecutionProcessor (10000);
|
||||
|
||||
DPRINT ("Seek completed, now on cyl %2x\n", DeviceExtension->Cyl);
|
||||
|
||||
/* Now that we are on the right cyl, restart the read */
|
||||
if (FloppyExecuteReadWrite (DeviceObject,
|
||||
ControllerExtension->Irp,
|
||||
ControllerExtension->MapRegisterBase,
|
||||
ControllerExtension->Irp) == DeallocateObject)
|
||||
{
|
||||
IoFreeController (DeviceExtension->Controller);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
VOID STDCALL
|
||||
FloppyDpcReadWrite (PKDPC Dpc,
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp,
|
||||
PVOID Context)
|
||||
{
|
||||
PCONTROLLER_OBJECT Controller;
|
||||
PFLOPPY_CONTROLLER_EXTENSION ControllerExtension;
|
||||
PFLOPPY_DEVICE_EXTENSION DeviceExtension;
|
||||
ULONG SectorSize;
|
||||
PIO_STACK_LOCATION Stack;
|
||||
BOOLEAN WriteToDevice;
|
||||
|
||||
|
||||
Controller = (PCONTROLLER_OBJECT)Context;
|
||||
ControllerExtension = (PFLOPPY_CONTROLLER_EXTENSION)Controller->ControllerExtension;
|
||||
DeviceExtension = (PFLOPPY_DEVICE_EXTENSION)ControllerExtension->Device->DeviceExtension;
|
||||
|
||||
Irp = ControllerExtension->Irp;
|
||||
|
||||
Stack = IoGetCurrentIrpStackLocation (Irp);
|
||||
|
||||
SectorSize = 128 << ControllerExtension->SectorSizeCode;
|
||||
|
||||
WriteToDevice = Stack->MajorFunction == IRP_MJ_WRITE ? TRUE : FALSE;
|
||||
|
||||
/* If the IO failed, fail the IRP */
|
||||
if (ControllerExtension->St0 & FLOPPY_ST0_GDMASK)
|
||||
{
|
||||
Irp->IoStatus.Status = STATUS_DISK_CORRUPT_ERROR;
|
||||
Irp->IoStatus.Information = 0;
|
||||
DPRINT( "Failing IRP: St0 = %2x, St1 = %2x, St2 = %2x\n",
|
||||
ControllerExtension->St0,
|
||||
ControllerExtension->St1,
|
||||
ControllerExtension->St2 );
|
||||
for(;;);
|
||||
IoCompleteRequest (Irp,
|
||||
IO_NO_INCREMENT);
|
||||
IoFreeController (Controller);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Don't forget to flush the buffers */
|
||||
IoFlushAdapterBuffers( ControllerExtension->AdapterObject,
|
||||
ControllerExtension->Irp->MdlAddress,
|
||||
ControllerExtension->MapRegisterBase,
|
||||
ControllerExtension->Irp->Tail.Overlay.DriverContext[0],
|
||||
ControllerExtension->TransferLength,
|
||||
WriteToDevice);
|
||||
DPRINT ("St0 = %2x St1 = %2x St2 = %2x\n",
|
||||
ControllerExtension->St0,
|
||||
ControllerExtension->St1,
|
||||
ControllerExtension->St2);
|
||||
|
||||
/* Update buffer info */
|
||||
Stack->Parameters.Read.ByteOffset.u.LowPart += ControllerExtension->TransferLength;
|
||||
Stack->Parameters.Read.Length -= ControllerExtension->TransferLength;
|
||||
|
||||
/* drivercontext used for current va */
|
||||
ControllerExtension->Irp->Tail.Overlay.DriverContext[0] = (PVOID) ((ULONG) ControllerExtension->Irp->Tail.Overlay.DriverContext[0]
|
||||
+ ControllerExtension->TransferLength);
|
||||
DPRINT ("First ulong: %x\n", *((PULONG)ControllerExtension->MapRegisterBase))
|
||||
|
||||
/* If there is more IO to be done, restart execute routine to issue next read */
|
||||
if (Stack->Parameters.Read.Length != 0)
|
||||
{
|
||||
if (FloppyExecuteReadWrite (DeviceObject,
|
||||
Irp,
|
||||
ControllerExtension->MapRegisterBase,
|
||||
Irp ) == DeallocateObject)
|
||||
{
|
||||
IoFreeController (Controller);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Otherwise, complete the IRP */
|
||||
IoCompleteRequest (Irp,
|
||||
IO_NO_INCREMENT);
|
||||
IoFreeController (Controller);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
VOID STDCALL
|
||||
FloppyDpcDetectMedia (PKDPC Dpc,
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp,
|
||||
PVOID Context)
|
||||
{
|
||||
PCONTROLLER_OBJECT Controller;
|
||||
PFLOPPY_CONTROLLER_EXTENSION ControllerExtension;
|
||||
|
||||
Controller = (PCONTROLLER_OBJECT)Context;
|
||||
ControllerExtension = (PFLOPPY_CONTROLLER_EXTENSION)Controller->ControllerExtension;
|
||||
|
||||
/* If the read ID failed, fail the IRP */
|
||||
if (ControllerExtension->St1 != 0)
|
||||
{
|
||||
DPRINT1 ("Read ID failed: ST1 = %2x\n", ControllerExtension->St1);
|
||||
IoFreeController (Controller);
|
||||
Irp->IoStatus.Information = 0;
|
||||
Irp->IoStatus.Status = STATUS_DEVICE_NOT_READY;
|
||||
IoCompleteRequest (Irp,
|
||||
IO_NO_INCREMENT);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Set media type, and restart the IRP from the beginning */
|
||||
((PFLOPPY_DEVICE_EXTENSION)ControllerExtension->Device->DeviceExtension)->MediaType = 0;
|
||||
DPRINT ("Media detected, restarting IRP\n");
|
||||
|
||||
/* Don't forget to free the controller so that the now queued routine may execute */
|
||||
IoFreeController (Controller);
|
||||
|
||||
IoAllocateController (Controller,
|
||||
DeviceObject,
|
||||
FloppyExecuteReadWrite,
|
||||
Irp);
|
||||
}
|
|
@ -1,609 +0,0 @@
|
|||
/*
|
||||
* FLOPPY.C - NEC-765/8272A floppy device driver
|
||||
* written by Rex Jolliff
|
||||
* with help from various other sources, including but not limited to:
|
||||
* Art Baker's NT Device Driver Book, Linux Source, and the internet.
|
||||
*
|
||||
* Modification History:
|
||||
* 08/19/98 RJJ Created.
|
||||
* 01/31/01 PJS Heavy rewrite, most of code thrown out
|
||||
*
|
||||
* To do:
|
||||
* FIXME: get it working
|
||||
* FIXME: add support for DMA hardware
|
||||
* FIXME: should add support for floppy tape/zip devices
|
||||
*/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include "floppy.h"
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
#include <rosrtl/string.h>
|
||||
|
||||
FLOPPY_CONTROLLER_PARAMETERS ControllerParameters[FLOPPY_MAX_CONTROLLERS] =
|
||||
{
|
||||
{0x03f0, 6, 2, Latched}
|
||||
// {0x0370, 6, 6, Latched}
|
||||
};
|
||||
|
||||
const FLOPPY_MEDIA_TYPE MediaTypes[] = {
|
||||
{ 0x02, 80, 2, 18, 512 },
|
||||
{ 0, 0, 0, 0, 0 } };
|
||||
|
||||
static BOOLEAN
|
||||
FloppyCreateController(PDRIVER_OBJECT DriverObject,
|
||||
PFLOPPY_CONTROLLER_PARAMETERS ControllerParameters,
|
||||
int Index)
|
||||
{
|
||||
PCONTROLLER_OBJECT ControllerObject;
|
||||
PFLOPPY_CONTROLLER_EXTENSION ControllerExtension;
|
||||
PFLOPPY_DEVICE_EXTENSION DeviceExtension;
|
||||
UNICODE_STRING DeviceName;
|
||||
NTSTATUS Status;
|
||||
PDEVICE_OBJECT DeviceObject;
|
||||
// PCONFIGURATION_INFORMATION ConfigInfo;
|
||||
LARGE_INTEGER Timeout;
|
||||
// BYTE Byte;
|
||||
// int c;
|
||||
PCONFIGURATION_INFORMATION Config;
|
||||
DEVICE_DESCRIPTION DeviceDescription;
|
||||
ULONG MaxMapRegs;
|
||||
ULONG MappedIrq;
|
||||
KIRQL Dirql;
|
||||
KAFFINITY Affinity;
|
||||
KIRQL oldIrql;
|
||||
|
||||
/* FIXME: Register port ranges with HAL */
|
||||
MappedIrq = HalGetInterruptVector(Isa,
|
||||
0,
|
||||
ControllerParameters->Vector,
|
||||
ControllerParameters->Vector,
|
||||
&Dirql,
|
||||
&Affinity);
|
||||
|
||||
/* Create controller object for FDC */
|
||||
ControllerObject = IoCreateController(sizeof(FLOPPY_CONTROLLER_EXTENSION));
|
||||
if (ControllerObject == NULL)
|
||||
{
|
||||
DPRINT("Could not create controller object for controller %d\n",
|
||||
Index);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* FIXME: fill out controller data */
|
||||
ControllerExtension = (PFLOPPY_CONTROLLER_EXTENSION)
|
||||
ControllerObject->ControllerExtension;
|
||||
ControllerExtension->Number = Index;
|
||||
ControllerExtension->PortBase = ControllerParameters->PortBase;
|
||||
ControllerExtension->Vector = MappedIrq;
|
||||
KeInitializeEvent( &ControllerExtension->Event, SynchronizationEvent, FALSE );
|
||||
ControllerExtension->Device = 0; // no active device
|
||||
ControllerExtension->Irp = 0; // no active IRP
|
||||
/* Initialize the spin lock in the controller extension */
|
||||
KeInitializeSpinLock(&ControllerExtension->SpinLock);
|
||||
ControllerExtension->IsrState = FloppyIsrDetect;
|
||||
ControllerExtension->DpcState = FloppyDpcDetect;
|
||||
|
||||
/* Register an interrupt handler for this controller */
|
||||
Status = IoConnectInterrupt(&ControllerExtension->Interrupt,
|
||||
FloppyIsr,
|
||||
ControllerObject,
|
||||
&ControllerExtension->SpinLock,
|
||||
MappedIrq,
|
||||
Dirql,
|
||||
Dirql,
|
||||
ControllerParameters->InterruptMode,
|
||||
FALSE,
|
||||
Affinity,
|
||||
FALSE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("Could not Connect Interrupt %d\n",
|
||||
ControllerExtension->Vector);
|
||||
goto controllercleanup;
|
||||
}
|
||||
|
||||
|
||||
/* setup DMA stuff for controller */
|
||||
DeviceDescription.Version = DEVICE_DESCRIPTION_VERSION;
|
||||
DeviceDescription.Master = FALSE;
|
||||
DeviceDescription.ScatterGather = FALSE;
|
||||
DeviceDescription.AutoInitialize = FALSE;
|
||||
DeviceDescription.Dma32BitAddresses = FALSE;
|
||||
DeviceDescription.DmaChannel = ControllerParameters->DmaChannel;
|
||||
DeviceDescription.InterfaceType = Isa;
|
||||
// DeviceDescription.DmaWidth = Width8Bits;
|
||||
ControllerExtension->AdapterObject = HalGetAdapter( &DeviceDescription, &MaxMapRegs );
|
||||
if( ControllerExtension->AdapterObject == NULL )
|
||||
{
|
||||
DPRINT1( "Could not get adapter object\n" );
|
||||
goto interruptcleanup;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* Check for each possible drive and create devices for them */
|
||||
for (DriveIdx = 0; DriveIdx < FLOPPY_MAX_DRIVES; DriveIdx++)
|
||||
{
|
||||
/* FIXME: try to identify the drive */
|
||||
/* FIXME: create a device if it's there */
|
||||
}
|
||||
#endif
|
||||
|
||||
/* FIXME: Let's assume one drive and one controller for the moment */
|
||||
RtlRosInitUnicodeStringFromLiteral(&DeviceName, L"\\Device\\Floppy0");
|
||||
Status = IoCreateDevice(DriverObject,
|
||||
sizeof(FLOPPY_DEVICE_EXTENSION),
|
||||
&DeviceName,
|
||||
FILE_DEVICE_DISK,
|
||||
FILE_REMOVABLE_MEDIA | FILE_FLOPPY_DISKETTE,
|
||||
FALSE,
|
||||
&DeviceObject);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
goto interruptcleanup;
|
||||
}
|
||||
DeviceExtension = (PFLOPPY_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||
DeviceExtension->DriveSelect = 0;
|
||||
DeviceExtension->Controller = ControllerObject;
|
||||
DeviceExtension->MediaType = ~0;
|
||||
ControllerExtension->MotorOn = ~0;
|
||||
// set up DPC
|
||||
ControllerExtension->Device = DeviceObject;
|
||||
KeInitializeDpc( &ControllerExtension->MotorSpinupDpc,
|
||||
FloppyMotorSpinupDpc,
|
||||
ControllerObject );
|
||||
KeInitializeDpc( &ControllerExtension->MotorSpindownDpc,
|
||||
FloppyMotorSpindownDpc,
|
||||
ControllerObject );
|
||||
KeInitializeTimer( &ControllerExtension->SpinupTimer );
|
||||
IoInitializeDpcRequest( DeviceObject, FloppyDpc );
|
||||
// reset controller and wait for interrupt
|
||||
DPRINT( "Controller Off\n" );
|
||||
FloppyWriteDOR( ControllerExtension->PortBase, 0 );
|
||||
// let controller reset for at least FLOPPY_RESET_TIME
|
||||
KeStallExecutionProcessor( FLOPPY_RESET_TIME );
|
||||
DPRINT( "Controller On\n" );
|
||||
FloppyWriteDOR( ControllerExtension->PortBase, FLOPPY_DOR_ENABLE | FLOPPY_DOR_DMA );
|
||||
// wait for interrupt now
|
||||
Timeout.QuadPart = -10000000;
|
||||
Status = KeWaitForSingleObject( &ControllerExtension->Event,
|
||||
Executive,
|
||||
KernelMode,
|
||||
FALSE,
|
||||
&Timeout );
|
||||
if( Status != STATUS_WAIT_0 )
|
||||
{
|
||||
DPRINT1( "Error: KeWaitForSingleObject returned: %x\n", Status );
|
||||
goto devicecleanup;
|
||||
}
|
||||
// set for high speed mode
|
||||
// FloppyWriteCCNTL( ControllerExtension->PortBase, FLOPPY_CCNTL_1MBIT );
|
||||
// ok, so we have an FDC, now check for drives
|
||||
// aparently the sense drive status command does not work on any FDC I can find
|
||||
// so instead we will just have to assume a 1.44 meg 3.5 inch floppy. At some
|
||||
// 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.
|
||||
|
||||
// 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
|
||||
FloppyWriteDOR( ControllerExtension->PortBase, FLOPPY_DRIVE0_ON );
|
||||
Timeout.QuadPart = FLOPPY_MOTOR_SPINUP_TIME;
|
||||
KeDelayExecutionThread( KernelMode, FALSE, &Timeout );
|
||||
DPRINT( "MSTAT: %2x\n", FloppyReadMSTAT( ControllerExtension->PortBase ) );
|
||||
FloppyWriteDATA( ControllerExtension->PortBase, FLOPPY_CMD_RECAL );
|
||||
DPRINT( "MSTAT: %2x\n", FloppyReadMSTAT( ControllerExtension->PortBase ) );
|
||||
KeStallExecutionProcessor( 10000 );
|
||||
FloppyWriteDATA( ControllerExtension->PortBase, 0 ); // drive select
|
||||
Timeout.QuadPart = FLOPPY_RECAL_TIMEOUT;
|
||||
Status = KeWaitForSingleObject( &ControllerExtension->Event,
|
||||
Executive,
|
||||
KernelMode,
|
||||
FALSE,
|
||||
&Timeout );
|
||||
if( Status != STATUS_WAIT_0 )
|
||||
{
|
||||
DPRINT1( "Error: KeWaitForSingleObject returned: %x\n", Status );
|
||||
goto devicecleanup;
|
||||
}
|
||||
if( ControllerExtension->St0 != FLOPPY_ST0_SEEKGD )
|
||||
{
|
||||
DbgPrint( "Floppy: error recalibrating drive, ST0: %2x\n", (DWORD)ControllerExtension->St0 );
|
||||
goto devicecleanup;
|
||||
}
|
||||
DeviceExtension->Cyl = 0;
|
||||
// drive is good, and it is now on track 0, turn off the motor
|
||||
FloppyWriteDOR( ControllerExtension->PortBase, FLOPPY_DOR_ENABLE | FLOPPY_DOR_DMA );
|
||||
/* Initialize the device */
|
||||
DeviceObject->Flags = DeviceObject->Flags | DO_DIRECT_IO;
|
||||
DeviceObject->AlignmentRequirement = FILE_512_BYTE_ALIGNMENT;
|
||||
// change state machine, no interrupt expected
|
||||
ControllerExtension->IsrState = FloppyIsrUnexpected;
|
||||
Config = IoGetConfigurationInformation();
|
||||
Config->FloppyCount++;
|
||||
// call IoAllocateAdapterChannel, and wait for execution routine to be given the channel
|
||||
CHECKPOINT;
|
||||
|
||||
/* DDK: IoAllocateAdapterChannel _must_ be called at DISPATCH_LEVEL */
|
||||
KeRaiseIrql(DISPATCH_LEVEL, &oldIrql);
|
||||
Status = IoAllocateAdapterChannel( ControllerExtension->AdapterObject,
|
||||
DeviceObject,
|
||||
0x3000/PAGE_SIZE, // max track size is 12k
|
||||
FloppyAdapterControl,
|
||||
ControllerExtension );
|
||||
KeLowerIrql(oldIrql);
|
||||
|
||||
if( !NT_SUCCESS( Status ) )
|
||||
{
|
||||
DPRINT1( "Error: IoAllocateAdapterChannel returned %x\n", Status );
|
||||
goto devicecleanup;
|
||||
}
|
||||
CHECKPOINT;
|
||||
Status = KeWaitForSingleObject( &ControllerExtension->Event,
|
||||
Executive,
|
||||
KernelMode,
|
||||
FALSE,
|
||||
&Timeout );
|
||||
CHECKPOINT;
|
||||
if( Status != STATUS_WAIT_0 )
|
||||
{
|
||||
DPRINT1( "Error: KeWaitForSingleObject returned: %x\n", Status );
|
||||
goto devicecleanup;
|
||||
}
|
||||
// Ok, we own the adapter object, from now on we can just IoMapTransfer, and not
|
||||
// bother releasing the adapter ever.
|
||||
|
||||
DPRINT( "Floppy drive initialized\n" );
|
||||
return TRUE;
|
||||
|
||||
devicecleanup:
|
||||
IoDeleteDevice( DeviceObject );
|
||||
interruptcleanup:
|
||||
IoDisconnectInterrupt(ControllerExtension->Interrupt);
|
||||
controllercleanup:
|
||||
// turn off controller
|
||||
FloppyWriteDOR( ControllerExtension->PortBase, 0 );
|
||||
IoDeleteController(ControllerObject);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
IO_ALLOCATION_ACTION STDCALL
|
||||
FloppyExecuteSpindown(PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp,
|
||||
PVOID MapRegisterbase,
|
||||
PVOID Context)
|
||||
{
|
||||
PFLOPPY_CONTROLLER_EXTENSION ControllerExtension= (PFLOPPY_CONTROLLER_EXTENSION)Context;
|
||||
|
||||
// turn off motor, and return
|
||||
DPRINT( "Spinning down motor\n" );
|
||||
ControllerExtension->MotorOn = ~0;
|
||||
FloppyWriteDOR( ControllerExtension->PortBase,
|
||||
FLOPPY_DOR_ENABLE | FLOPPY_DOR_DMA );
|
||||
return DeallocateObject;
|
||||
}
|
||||
|
||||
IO_ALLOCATION_ACTION STDCALL
|
||||
FloppyExecuteReadWrite(PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp,
|
||||
PVOID MapRegisterbase,
|
||||
PVOID Context)
|
||||
{
|
||||
PFLOPPY_DEVICE_EXTENSION DeviceExtension = (PFLOPPY_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||
PFLOPPY_CONTROLLER_EXTENSION ControllerExtension = (PFLOPPY_CONTROLLER_EXTENSION)DeviceExtension->Controller->ControllerExtension;
|
||||
LARGE_INTEGER Timeout;
|
||||
BOOLEAN WriteToDevice;
|
||||
ULONG Cyl, Sector, Head;
|
||||
PIO_STACK_LOCATION Stk;
|
||||
ULONG Length;
|
||||
|
||||
DPRINT( "FloppyExecuteReadWrite()\n" );
|
||||
|
||||
ControllerExtension->Irp = Irp = (PIRP)Context;
|
||||
Stk = IoGetCurrentIrpStackLocation( Irp );
|
||||
ControllerExtension->Device = DeviceObject;
|
||||
Timeout.QuadPart = FLOPPY_MOTOR_SPINUP_TIME;
|
||||
CHECKPOINT;
|
||||
WriteToDevice = Stk->MajorFunction == IRP_MJ_WRITE ? TRUE : FALSE;
|
||||
// verify drive is spun up and selected
|
||||
if( ControllerExtension->MotorOn != DeviceExtension->DriveSelect )
|
||||
{
|
||||
// turn on and select drive, and allow it to spin up
|
||||
// FloppyMotorSpinupDpc will restart this operation once motor is spun up
|
||||
DPRINT( "Motor not on, turning it on now\n" );
|
||||
FloppyWriteDOR( ControllerExtension->PortBase,
|
||||
DeviceExtension->DriveSelect ? FLOPPY_DRIVE1_ON : FLOPPY_DRIVE0_ON );
|
||||
// cancel possible spindown timer first
|
||||
KeCancelTimer( &ControllerExtension->SpinupTimer );
|
||||
KeSetTimerEx( &ControllerExtension->SpinupTimer,
|
||||
Timeout,
|
||||
0,
|
||||
&ControllerExtension->MotorSpinupDpc );
|
||||
return KeepObject;
|
||||
}
|
||||
else
|
||||
{
|
||||
Timeout.QuadPart = FLOPPY_MOTOR_SPINDOWN_TIME;
|
||||
// motor is already spinning, so reset the spindown timer
|
||||
KeCancelTimer( &ControllerExtension->SpinupTimer );
|
||||
KeSetTimer( &ControllerExtension->SpinupTimer,
|
||||
Timeout,
|
||||
&ControllerExtension->MotorSpindownDpc );
|
||||
}
|
||||
#if 0
|
||||
/* Handle disk change, doesn't work correctly */
|
||||
if( FloppyReadDIR( ControllerExtension->PortBase ) & FLOPPY_DI_DSKCHNG )
|
||||
{
|
||||
// No disk is in the drive
|
||||
DPRINT( "No disk is in the drive\n" );
|
||||
Irp->IoStatus.Status = STATUS_MEDIA_CHANGED;
|
||||
Irp->IoStatus.Information = 0;
|
||||
IoCompleteRequest( Irp, 0 );
|
||||
return DeallocateObject;
|
||||
}
|
||||
#endif
|
||||
if( DeviceExtension->MediaType == ~0 )
|
||||
{
|
||||
// media is in disk, but we have not yet detected what kind it is,
|
||||
// so detect it now
|
||||
// First, we need to recalibrate the drive though
|
||||
ControllerExtension->IsrState = FloppyIsrRecal;
|
||||
DPRINT( "Recalibrating drive\n" );
|
||||
KeStallExecutionProcessor( 1000 );
|
||||
FloppyWriteDATA( ControllerExtension->PortBase, FLOPPY_CMD_RECAL );
|
||||
KeStallExecutionProcessor( 1000 );
|
||||
FloppyWriteDATA( ControllerExtension->PortBase, DeviceExtension->DriveSelect );
|
||||
return KeepObject;
|
||||
}
|
||||
// looks like we have media in the drive.... do the read
|
||||
// first, calculate geometry for read
|
||||
Sector = Stk->Parameters.Read.ByteOffset.u.LowPart / MediaTypes[DeviceExtension->MediaType].BytesPerSector;
|
||||
// absolute sector right now
|
||||
Cyl = Sector / MediaTypes[DeviceExtension->MediaType].SectorsPerTrack;
|
||||
DPRINT( "Sector = %x, Offset = %x, Cyl = %x, Heads = %x MediaType = %x\n", Sector, Stk->Parameters.Read.ByteOffset.u.LowPart, (DWORD)Cyl, (DWORD)MediaTypes[DeviceExtension->MediaType].Heads, (DWORD)DeviceExtension->MediaType );
|
||||
Head = Cyl % MediaTypes[DeviceExtension->MediaType].Heads;
|
||||
DPRINT( "Head = %2x\n", Head );
|
||||
// convert absolute cyl to relative
|
||||
Cyl /= MediaTypes[DeviceExtension->MediaType].Heads;
|
||||
// convert absolute sector to relative
|
||||
Sector %= MediaTypes[DeviceExtension->MediaType].SectorsPerTrack;
|
||||
Sector++; // track relative sector numbers are 1 based, not 0 based
|
||||
DPRINT( "Cyl = %2x, Head = %2x, Sector = %2x\n", Cyl, Head, Sector );
|
||||
|
||||
// seek if we need to seek
|
||||
if( DeviceExtension->Cyl != Cyl )
|
||||
{
|
||||
DPRINT( "Seeking...\n" );
|
||||
ControllerExtension->IsrState = FloppyIsrDetect;
|
||||
ControllerExtension->DpcState = FloppySeekDpc;
|
||||
FloppyWriteDATA( ControllerExtension->PortBase, FLOPPY_CMD_SEEK );
|
||||
KeStallExecutionProcessor( 100 );
|
||||
FloppyWriteDATA( ControllerExtension->PortBase, DeviceExtension->DriveSelect );
|
||||
KeStallExecutionProcessor( 100 );
|
||||
FloppyWriteDATA( ControllerExtension->PortBase, Cyl );
|
||||
return KeepObject;
|
||||
}
|
||||
//set up DMA and issue read command
|
||||
Length = MediaTypes[DeviceExtension->MediaType].SectorsPerTrack - Sector + 1;
|
||||
// number of sectors untill end of track
|
||||
Length *= 512; // convert to bytes
|
||||
if( Length > Stk->Parameters.Read.Length )
|
||||
Length = Stk->Parameters.Read.Length;
|
||||
DPRINT( "Sector: %d, Length: %d\n", Sector, Length );
|
||||
ControllerExtension->TransferLength = Length;
|
||||
IoMapTransfer( ControllerExtension->AdapterObject,
|
||||
Irp->MdlAddress,
|
||||
ControllerExtension->MapRegisterBase,
|
||||
Irp->Tail.Overlay.DriverContext[0], // current va
|
||||
&Length,
|
||||
WriteToDevice );
|
||||
ControllerExtension->IsrState = FloppyIsrReadWrite;
|
||||
ControllerExtension->DpcState = FloppyDpcReadWrite;
|
||||
CHECKPOINT;
|
||||
FloppyWriteDATA( ControllerExtension->PortBase, WriteToDevice ? FLOPPY_CMD_WRITE : FLOPPY_CMD_READ );
|
||||
KeStallExecutionProcessor( 100 );
|
||||
FloppyWriteDATA( ControllerExtension->PortBase, ( Head << 2 ) | DeviceExtension->DriveSelect );
|
||||
KeStallExecutionProcessor( 100 );
|
||||
FloppyWriteDATA( ControllerExtension->PortBase, Cyl );
|
||||
KeStallExecutionProcessor( 100 );
|
||||
FloppyWriteDATA( ControllerExtension->PortBase, Head );
|
||||
KeStallExecutionProcessor( 100 );
|
||||
FloppyWriteDATA( ControllerExtension->PortBase, Sector );
|
||||
KeStallExecutionProcessor( 100 );
|
||||
FloppyWriteDATA( ControllerExtension->PortBase, MediaTypes[DeviceExtension->MediaType].SectorSizeCode );
|
||||
KeStallExecutionProcessor( 100 );
|
||||
FloppyWriteDATA( ControllerExtension->PortBase, MediaTypes[DeviceExtension->MediaType].SectorsPerTrack );
|
||||
KeStallExecutionProcessor( 100 );
|
||||
FloppyWriteDATA( ControllerExtension->PortBase, 0 );
|
||||
KeStallExecutionProcessor( 100 );
|
||||
FloppyWriteDATA( ControllerExtension->PortBase, 0xFF );
|
||||
CHECKPOINT;
|
||||
// eventually, the FDC will interrupt and we will read results then
|
||||
return KeepObject;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS STDCALL
|
||||
FloppyDispatchOpenClose (PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp)
|
||||
{
|
||||
DPRINT ("FloppyDispatchOpenClose\n");
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS STDCALL
|
||||
FloppyDispatchReadWrite (PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp)
|
||||
{
|
||||
PFLOPPY_DEVICE_EXTENSION DeviceExtension;
|
||||
PIO_STACK_LOCATION Stack;
|
||||
KIRQL oldlvl;
|
||||
|
||||
DeviceExtension = (PFLOPPY_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||
|
||||
Stack = IoGetCurrentIrpStackLocation (Irp);
|
||||
|
||||
if (Stack->Parameters.Read.ByteOffset.u.HighPart)
|
||||
{
|
||||
Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
|
||||
Irp->IoStatus.Information = 0;
|
||||
IoCompleteRequest (Irp, 1);
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
/* Store currentva in drivercontext */
|
||||
Irp->Tail.Overlay.DriverContext[0] = MmGetMdlVirtualAddress (Irp->MdlAddress);
|
||||
DPRINT ("FloppyDispatchReadWrite: offset = %x, length = %x, va = %x\n",
|
||||
Stack->Parameters.Read.ByteOffset.u.LowPart,
|
||||
Stack->Parameters.Read.Length,
|
||||
Irp->Tail.Overlay.DriverContext[0]);
|
||||
|
||||
/* Queue IRP */
|
||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||
Irp->IoStatus.Information = Stack->Parameters.Read.Length;
|
||||
IoMarkIrpPending (Irp);
|
||||
|
||||
KeRaiseIrql (DISPATCH_LEVEL,
|
||||
&oldlvl);
|
||||
IoAllocateController (DeviceExtension->Controller,
|
||||
DeviceObject,
|
||||
FloppyExecuteReadWrite,
|
||||
Irp);
|
||||
KeLowerIrql (oldlvl);
|
||||
|
||||
DPRINT( "oldlvl = %x\n", oldlvl );
|
||||
|
||||
return STATUS_PENDING;
|
||||
}
|
||||
|
||||
|
||||
IO_ALLOCATION_ACTION STDCALL
|
||||
FloppyAdapterControl (PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp,
|
||||
PVOID MapRegisterBase,
|
||||
PVOID Context)
|
||||
{
|
||||
PFLOPPY_CONTROLLER_EXTENSION ControllerExtension;
|
||||
|
||||
ControllerExtension = (PFLOPPY_CONTROLLER_EXTENSION)Context;
|
||||
CHECKPOINT;
|
||||
|
||||
/* Just set the event, and return KeepObject */
|
||||
ControllerExtension->MapRegisterBase = MapRegisterBase;
|
||||
KeSetEvent (&ControllerExtension->Event,
|
||||
0,
|
||||
FALSE);
|
||||
|
||||
return KeepObject;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS STDCALL
|
||||
FloppyDispatchDeviceControl (PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp)
|
||||
{
|
||||
PIO_STACK_LOCATION Stack;
|
||||
ULONG ControlCode;
|
||||
ULONG InputLength;
|
||||
ULONG OutputLength;
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT ("FloppyDispatchDeviceControl\n");
|
||||
|
||||
Stack = IoGetCurrentIrpStackLocation(Irp);
|
||||
ControlCode = Stack->Parameters.DeviceIoControl.IoControlCode;
|
||||
InputLength = Stack->Parameters.DeviceIoControl.InputBufferLength;
|
||||
OutputLength = Stack->Parameters.DeviceIoControl.OutputBufferLength;
|
||||
|
||||
switch (ControlCode)
|
||||
{
|
||||
case IOCTL_DISK_GET_DRIVE_GEOMETRY:
|
||||
if (OutputLength < sizeof(DISK_GEOMETRY))
|
||||
{
|
||||
Status = STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
else
|
||||
{
|
||||
PDISK_GEOMETRY Geometry = Irp->AssociatedIrp.SystemBuffer;
|
||||
|
||||
// FIXME: read the first sector of the diskette
|
||||
Geometry->MediaType = F3_1Pt44_512;
|
||||
Geometry->Cylinders.QuadPart = 80;
|
||||
Geometry->TracksPerCylinder = 2 * 18;
|
||||
Geometry->SectorsPerTrack = 18;
|
||||
Geometry->BytesPerSector = 512;
|
||||
Status = STATUS_SUCCESS;
|
||||
Irp->IoStatus.Information = sizeof(DISK_GEOMETRY);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
Status = STATUS_INVALID_DEVICE_REQUEST;
|
||||
Irp->IoStatus.Information = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
IoCompleteRequest (Irp,
|
||||
NT_SUCCESS(Status) ? IO_DISK_INCREMENT : IO_NO_INCREMENT);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* DriverEntry
|
||||
*
|
||||
* DESCRIPTION:
|
||||
* This function initializes the driver, locates and claims
|
||||
* hardware resources, and creates various NT objects needed
|
||||
* to process I/O requests.
|
||||
*
|
||||
* RUN LEVEL:
|
||||
* PASSIVE_LEVEL
|
||||
*
|
||||
* ARGUMENTS:
|
||||
* IN PDRIVER_OBJECT DriverObject System allocated Driver Object
|
||||
* for this driver
|
||||
* IN PUNICODE_STRING RegistryPath Name of registry driver service
|
||||
* key
|
||||
*
|
||||
* RETURNS:
|
||||
* NTSTATUS
|
||||
*/
|
||||
NTSTATUS STDCALL
|
||||
DriverEntry (IN PDRIVER_OBJECT DriverObject,
|
||||
IN PUNICODE_STRING RegistryPath)
|
||||
{
|
||||
DPRINT ("Floppy driver\n");
|
||||
|
||||
/* Export other driver entry points... */
|
||||
DriverObject->MajorFunction[IRP_MJ_CREATE] = FloppyDispatchOpenClose;
|
||||
DriverObject->MajorFunction[IRP_MJ_CLOSE] = FloppyDispatchOpenClose;
|
||||
DriverObject->MajorFunction[IRP_MJ_READ] = FloppyDispatchReadWrite;
|
||||
DriverObject->MajorFunction[IRP_MJ_WRITE] = FloppyDispatchReadWrite;
|
||||
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = FloppyDispatchDeviceControl;
|
||||
|
||||
/* Try to detect controller and abort if it fails */
|
||||
if (!FloppyCreateController (DriverObject,
|
||||
&ControllerParameters[0],
|
||||
0))
|
||||
{
|
||||
DPRINT ("Could not find floppy controller\n");
|
||||
return STATUS_NO_SUCH_DEVICE;
|
||||
}
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/* EOF */
|
|
@ -1,258 +0,0 @@
|
|||
//
|
||||
// Floppy register definitions
|
||||
//
|
||||
|
||||
#define FLOPPY_REG_DOR 0x0002
|
||||
#define FLOPPY_DOR_ENABLE 0x04
|
||||
#define FLOPPY_DOR_DMA 0x08
|
||||
#define FLOPPY_DOR_MOTOR0 0x10
|
||||
#define FLOPPY_DOR_MOTOR1 0x20
|
||||
#define FLOPPY_DRIVE0_ON ( FLOPPY_DOR_ENABLE | FLOPPY_DOR_DMA | FLOPPY_DOR_MOTOR0 )
|
||||
#define FLOPPY_DRIVE1_ON ( FLOPPY_DOR_ENABLE | FLOPPY_DOR_DMA | FLOPPY_DOR_MOTOR1 | 1 )
|
||||
#define FLOPPY_REG_MSTAT 0x0004
|
||||
#define FLOPPY_MS_DRV0BUSY 0x01
|
||||
#define FLOPPY_MS_DRV1BUSY 0x02
|
||||
#define FLOPPY_MS_DRV2BUSY 0x04
|
||||
#define FLOPPY_MS_DRV3BUSY 0x08
|
||||
#define FLOPPY_MS_FDCBUSY 0x10
|
||||
#define FLOPPY_MS_DMAMODE 0x20
|
||||
#define FLOPPY_MS_DATADIR 0x40
|
||||
#define FLOPPY_MS_RDYMASK 0xC0
|
||||
#define FLOPPY_MS_DATARDYW 0x80
|
||||
#define FLOPPY_MS_DATARDYR 0xC0
|
||||
#define FLOPPY_REG_DATA 0x0005
|
||||
#define FLOPPY_REG_DIR 0x0007 /* READ ONLY */
|
||||
#define FLOPPY_DI_DSKCHNG 0x80
|
||||
#define FLOPPY_REG_CCNTL 0x0007 /* WRITE ONLY */
|
||||
#define FLOPPY_CCNTL_1MBIT 0x03
|
||||
|
||||
#define FLOPPY_CMD_RD_TRK 0x02
|
||||
#define FLOPPY_CMD_SPEC_CHARS 0x03
|
||||
#define FLOPPY_CSC_SRT_SHIFT 4
|
||||
#define FLOPPY_CSC_HUT_MASK 0x0f
|
||||
#define FLOPPY_CSC_HLT_SHIFT 1
|
||||
#define FLOPPY_CSC_NON_DMA 0x01
|
||||
#define FLOPPY_CMD_SNS_DRV 0x04
|
||||
#define FLOPPY_CMD_WRT_DATA 0x05
|
||||
#define FLOPPY_CMD_RD_DATA 0x06
|
||||
#define FLOPPY_CMD_RECAL 0x07
|
||||
#define FLOPPY_CMD_SNS_INTR 0x08
|
||||
#define FLOPPY_ST0_SEEKGD 0x20
|
||||
#define FLOPPY_ST0_GDMASK 0xd8
|
||||
#define FLOPPY_CMD_WRT_DEL 0x09
|
||||
#define FLOPPY_CMD_RD_ID 0x0a
|
||||
#define FLOPPY_CMD_RD_DEL 0x0c
|
||||
#define FLOPPY_CMD_FMT_TRK 0x0d
|
||||
#define FLOPPY_CMD_DUMP_FDC 0x0e
|
||||
#define FLOPPY_CMD_SEEK 0x0f
|
||||
#define FLOPPY_CMD_VERSION 0x10
|
||||
#define FLOPPY_CMD_SCN_EQ 0x11
|
||||
#define FLOPPY_CMD_PPND_RW 0x12
|
||||
#define FLOPPY_CMD_CFG_FIFO 0x13
|
||||
#define FLOPPY_CMD_LCK_FIFO 0x14
|
||||
#define FLOPPY_CMD_PARTID 0x18
|
||||
#define FLOPPY_CMD_SCN_LE 0x19
|
||||
#define FLOPPY_CMD_SCN_GE 0x1d
|
||||
#define FLOPPY_CMD_CFG_PWR 0x27
|
||||
#define FLOPPY_CMD_SAVE_FDC 0x2e
|
||||
#define FLOPPY_CMD_FMT_ISO 0x33
|
||||
#define FLOPPY_CMD_DMA_READ 0x46
|
||||
#define FLOPPY_CMD_DMA_WRT 0x4a
|
||||
#define FLOPPY_CMD_REST_FDC 0x4e
|
||||
#define FLOPPY_CMD_DRV_SPEC 0x8e
|
||||
#define FLOPPY_CMD_RSEEK_OUT 0x8f
|
||||
#define FLOPPY_CMD_ULK_FIFO 0x94
|
||||
#define FLOPPY_CMD_RSEEK_IN 0xcf
|
||||
#define FLOPPY_CMD_FMT_WRT 0xef
|
||||
|
||||
// Command Code modifiers
|
||||
#define FLOPPY_C0M_SK 0x20
|
||||
#define FLOPPY_C0M_MFM 0x40
|
||||
#define FLOPPY_C0M_MT 0x80
|
||||
#define FLOPPY_C1M_DRVMASK 0x03
|
||||
#define FLOPPY_C1M_HEAD1 0x04
|
||||
|
||||
// Status code values and masks
|
||||
#define FLOPPY_ST0_INVALID 0x80
|
||||
|
||||
// useful command defines
|
||||
#define FLOPPY_CMD_READ (FLOPPY_CMD_RD_DATA | FLOPPY_C0M_SK | FLOPPY_C0M_MFM | FLOPPY_C0M_MT)
|
||||
#define FLOPPY_CMD_WRITE (FLOPPY_CMD_WRT_DATA | FLOPPY_C0M_MFM | FLOPPY_C0M_MT)
|
||||
#define FLOPPY_CMD_FORMAT (FLOPPY_CMD_FMT_TRK | FLOPPY_C0M_MFM)
|
||||
|
||||
//
|
||||
// HAL floppy register access commands
|
||||
//
|
||||
#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 FloppyWriteMSTAT(A, V) (WRITE_PORT_UCHAR((PVOID)(A) + FLOPPY_REG_MSTAT, (V)))
|
||||
#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 FloppyReadDIR(A) (READ_PORT_UCHAR((PVOID)(A) + FLOPPY_REG_DIR))
|
||||
#define FloppyWriteCCNTL(A, V) (WRITE_PORT_UCHAR((PVOID)(A) + FLOPPY_REG_CCNTL, (V)))
|
||||
|
||||
typedef struct _FLOPPY_ERROR_THRESHOLDS
|
||||
{
|
||||
/* number of errors to be reached before aborting */
|
||||
unsigned int Abort;
|
||||
/* maximal number of errors permitted to read an entire track at once */
|
||||
unsigned int ReadTrack;
|
||||
/* maximal number of errors before a reset is tried */
|
||||
unsigned int Reset;
|
||||
/* maximal number of errors before a recalibrate is tried */
|
||||
unsigned int Recal;
|
||||
/*
|
||||
* Threshold for reporting FDC errors to the console.
|
||||
* Setting this to zero may flood your screen when using
|
||||
* ultra cheap floppies ;-)
|
||||
*/
|
||||
unsigned int Reporting;
|
||||
} FLOPPY_ERROR_THRESHOLDS;
|
||||
|
||||
typedef struct _FLOPPY_MEDIA_TYPE
|
||||
{
|
||||
BYTE SectorSizeCode;
|
||||
BYTE MaximumTrack;
|
||||
BYTE Heads;
|
||||
DWORD SectorsPerTrack;
|
||||
ULONG BytesPerSector;
|
||||
} FLOPPY_MEDIA_TYPE;
|
||||
|
||||
extern const FLOPPY_MEDIA_TYPE MediaTypes[];
|
||||
|
||||
#define FDP_DEBUG 0x02
|
||||
#define FDP_SILENT_DCL_CLEAR 0x04
|
||||
#define FDP_MSG 0x10
|
||||
#define FDP_BROKEN_DCL 0x20
|
||||
#define FDP_INVERTED_DCL 0x80
|
||||
|
||||
// time to hold reset line low
|
||||
#define FLOPPY_RESET_TIME 50000
|
||||
#define FLOPPY_MOTOR_SPINUP_TIME -15000000
|
||||
#define FLOPPY_MOTOR_SPINDOWN_TIME -50000000
|
||||
#define FLOPPY_RECAL_TIMEOUT -30000000
|
||||
|
||||
typedef BOOLEAN (*FloppyIsrStateRoutine)( PCONTROLLER_OBJECT Controller );
|
||||
typedef PIO_DPC_ROUTINE FloppyDpcStateRoutine;
|
||||
|
||||
typedef struct _FLOPPY_DEVICE_EXTENSION
|
||||
{
|
||||
PCONTROLLER_OBJECT Controller;
|
||||
CHAR DriveSelect;
|
||||
CHAR Cyl; // current cylinder
|
||||
ULONG MediaType; // Media type index
|
||||
} FLOPPY_DEVICE_EXTENSION, *PFLOPPY_DEVICE_EXTENSION;
|
||||
|
||||
typedef struct _FLOPPY_CONTROLLER_EXTENSION
|
||||
{
|
||||
PKINTERRUPT Interrupt;
|
||||
KSPIN_LOCK SpinLock;
|
||||
ULONG Number;
|
||||
ULONG PortBase;
|
||||
ULONG Vector;
|
||||
KEVENT Event; // Event set by ISR/DPC to wake DeviceEntry
|
||||
PDEVICE_OBJECT Device; // Pointer to the primary device on this controller
|
||||
PIRP Irp; // Current IRP
|
||||
CHAR St0; // Status registers
|
||||
CHAR St1;
|
||||
CHAR St2;
|
||||
CHAR SectorSizeCode;
|
||||
FloppyIsrStateRoutine IsrState; // pointer to state routine handler for ISR
|
||||
FloppyDpcStateRoutine DpcState; // pointer to state routine handler for DPC
|
||||
CHAR MotorOn; // drive select for drive with motor on
|
||||
KDPC MotorSpinupDpc; // DPC for motor spin up time
|
||||
KTIMER SpinupTimer; // Timer for motor spin up time
|
||||
KDPC MotorSpindownDpc; // DPC for motor spin down
|
||||
PADAPTER_OBJECT AdapterObject; // Adapter object for dma
|
||||
PVOID MapRegisterBase;
|
||||
DWORD TransferLength; // Length of the transfer
|
||||
} FLOPPY_CONTROLLER_EXTENSION, *PFLOPPY_CONTROLLER_EXTENSION;
|
||||
|
||||
typedef struct _FLOPPY_CONTROLLER_PARAMETERS
|
||||
{
|
||||
ULONG PortBase;
|
||||
ULONG Vector;
|
||||
ULONG DmaChannel;
|
||||
KINTERRUPT_MODE InterruptMode;
|
||||
} FLOPPY_CONTROLLER_PARAMETERS, *PFLOPPY_CONTROLLER_PARAMETERS;
|
||||
|
||||
#define FLOPPY_MAX_CONTROLLERS 1
|
||||
|
||||
VOID STDCALL
|
||||
FloppyDpcDetectMedia(PKDPC Dpc,
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp,
|
||||
PVOID Context);
|
||||
VOID STDCALL
|
||||
FloppyDpcFailIrp(PKDPC Dpc,
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp,
|
||||
PVOID Context);
|
||||
|
||||
IO_ALLOCATION_ACTION STDCALL
|
||||
FloppyExecuteReadWrite(PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp,
|
||||
PVOID MapRegisterbase,
|
||||
PVOID Context);
|
||||
|
||||
IO_ALLOCATION_ACTION STDCALL
|
||||
FloppyExecuteSpindown(PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp,
|
||||
PVOID MapRegisterbase,
|
||||
PVOID Context);
|
||||
|
||||
VOID STDCALL
|
||||
FloppyMotorSpinupDpc(PKDPC Dpc,
|
||||
PVOID Context,
|
||||
PVOID Arg1,
|
||||
PVOID Arg2);
|
||||
|
||||
VOID STDCALL
|
||||
FloppySeekDpc(PKDPC Dpc,
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp,
|
||||
PVOID Context);
|
||||
|
||||
VOID STDCALL
|
||||
FloppyMotorSpindownDpc(PKDPC Dpc,
|
||||
PVOID Context,
|
||||
PVOID Arg1,
|
||||
PVOID Arg2);
|
||||
|
||||
VOID STDCALL
|
||||
FloppyDpcDetect(PKDPC Dpc,
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp,
|
||||
PVOID Context );
|
||||
|
||||
VOID STDCALL
|
||||
FloppyDpcReadWrite(PKDPC Dpc,
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp,
|
||||
PVOID Context);
|
||||
|
||||
VOID STDCALL
|
||||
FloppyDpc(PKDPC Dpc,
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp,
|
||||
PVOID Context);
|
||||
|
||||
BOOLEAN FloppyIsrDetect( PCONTROLLER_OBJECT Controller );
|
||||
|
||||
BOOLEAN FloppyIsrReadWrite( PCONTROLLER_OBJECT Controller );
|
||||
|
||||
BOOLEAN FloppyIsrUnexpected( PCONTROLLER_OBJECT Controller );
|
||||
|
||||
BOOLEAN FloppyIsrDetectMedia( PCONTROLLER_OBJECT Controller );
|
||||
|
||||
BOOLEAN FloppyIsrRecal( PCONTROLLER_OBJECT Controller );
|
||||
|
||||
BOOLEAN STDCALL
|
||||
FloppyIsr(PKINTERRUPT Interrupt,
|
||||
PVOID ServiceContext);
|
||||
|
||||
IO_ALLOCATION_ACTION STDCALL
|
||||
FloppyAdapterControl(PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp,
|
||||
PVOID MapRegisterBase,
|
||||
PVOID Context);
|
|
@ -1,38 +0,0 @@
|
|||
#include <defines.h>
|
||||
#include <reactos/resource.h>
|
||||
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION RES_UINT_FV_MAJOR,RES_UINT_FV_MINOR,RES_UINT_FV_REVISION,RES_UINT_FV_BUILD
|
||||
PRODUCTVERSION RES_UINT_PV_MAJOR,RES_UINT_PV_MINOR,RES_UINT_PV_REVISION,RES_UINT_PV_BUILD
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x40004L
|
||||
FILETYPE 0x2L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "CompanyName", RES_STR_COMPANY_NAME
|
||||
VALUE "FileDescription", "Floppy Device Driver\0"
|
||||
VALUE "FileVersion", "0.1.4\0"
|
||||
VALUE "InternalName", "floppy\0"
|
||||
VALUE "LegalCopyright", RES_STR_LEGAL_COPYRIGHT
|
||||
VALUE "OriginalFilename", "floppy.sys\0"
|
||||
VALUE "ProductName", RES_STR_PRODUCT_NAME
|
||||
VALUE "ProductVersion", RES_STR_PRODUCT_VERSION
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
|
|
@ -1,210 +0,0 @@
|
|||
/************************************************************************
|
||||
* Interrupt handlers for floppy disk driver, reactos project, created *
|
||||
* by Phillip Susi on 2/25/2001. This software is publised under the *
|
||||
* GNU General public license. See the README file for more details *
|
||||
***********************************************************************/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
#include "floppy.h"
|
||||
|
||||
|
||||
// ISR state machine function called when expecting an interrupt due to reset
|
||||
// During reset, there is nothing ready to read, just issue sense interrupt status
|
||||
|
||||
BOOLEAN FloppyIsrDetect( PCONTROLLER_OBJECT Controller )
|
||||
{
|
||||
PFLOPPY_CONTROLLER_EXTENSION ControllerExtension = (PFLOPPY_CONTROLLER_EXTENSION)Controller->ControllerExtension;
|
||||
PFLOPPY_DEVICE_EXTENSION DeviceExtension = (PFLOPPY_DEVICE_EXTENSION)ControllerExtension->Device->DeviceExtension;
|
||||
// Issue read interrupt status, and store the results
|
||||
FloppyWriteDATA( ControllerExtension->PortBase, FLOPPY_CMD_SNS_INTR );
|
||||
KeStallExecutionProcessor( 100 );
|
||||
ControllerExtension->St0 = FloppyReadDATA( ControllerExtension->PortBase );
|
||||
KeStallExecutionProcessor( 100 );
|
||||
DeviceExtension->Cyl = FloppyReadDATA( ControllerExtension->PortBase );
|
||||
KeStallExecutionProcessor( 100 );
|
||||
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 );
|
||||
}
|
||||
// now queue DPC to set the event
|
||||
IoRequestDpc( ControllerExtension->Device,
|
||||
0,
|
||||
Controller );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// ISR state machine handler for unexpected interrupt
|
||||
BOOLEAN FloppyIsrUnexpected( PCONTROLLER_OBJECT Controller )
|
||||
{
|
||||
DPRINT( "Unexpected interrupt!\n" );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOLEAN FloppyIsrDetectMedia( PCONTROLLER_OBJECT Controller )
|
||||
{
|
||||
PFLOPPY_CONTROLLER_EXTENSION ControllerExtension = (PFLOPPY_CONTROLLER_EXTENSION)Controller->ControllerExtension;
|
||||
UCHAR SectorSize;
|
||||
|
||||
DPRINT("FloppyIsrDetectMedia() called\n");
|
||||
|
||||
// media detect in progress, read ID command already issued
|
||||
// first, read result registers
|
||||
KeStallExecutionProcessor( 1000 );
|
||||
ControllerExtension->St0 = FloppyReadDATA( ControllerExtension->PortBase );
|
||||
KeStallExecutionProcessor( 1000 );
|
||||
ControllerExtension->St1 = FloppyReadDATA( ControllerExtension->PortBase );
|
||||
KeStallExecutionProcessor( 1000 );
|
||||
ControllerExtension->St2 = FloppyReadDATA( ControllerExtension->PortBase );
|
||||
KeStallExecutionProcessor( 1000 );
|
||||
FloppyReadDATA( ControllerExtension->PortBase ); // ignore cyl
|
||||
KeStallExecutionProcessor( 1000 );
|
||||
FloppyReadDATA( ControllerExtension->PortBase ); // ignore head
|
||||
KeStallExecutionProcessor( 1000 );
|
||||
FloppyReadDATA( ControllerExtension->PortBase ); // ignore sector
|
||||
KeStallExecutionProcessor( 1000 );
|
||||
SectorSize = FloppyReadDATA( ControllerExtension->PortBase );
|
||||
DPRINT( "Sector Size Code: %2x\n", SectorSize );
|
||||
DPRINT( "St0 = %2x, St1 = %2x, St2 = %2x\n", ControllerExtension->St0, ControllerExtension->St1, ControllerExtension->St2 );
|
||||
DPRINT( "ControllerExtension->Device = %x, ControllerExtension->Irp = %x\n", ControllerExtension->Device, ControllerExtension->Irp );
|
||||
// queue DPC
|
||||
ControllerExtension->DpcState = FloppyDpcDetectMedia;
|
||||
IoRequestDpc( ControllerExtension->Device,
|
||||
ControllerExtension->Irp,
|
||||
Controller );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOLEAN FloppyIsrRecal( PCONTROLLER_OBJECT Controller )
|
||||
{
|
||||
PFLOPPY_CONTROLLER_EXTENSION ControllerExtension = (PFLOPPY_CONTROLLER_EXTENSION)Controller->ControllerExtension;
|
||||
// issue sense interrupt status, and read St0 and cyl
|
||||
|
||||
DPRINT("FloppyIsrRecal() called\n");
|
||||
|
||||
FloppyWriteDATA( ControllerExtension->PortBase, FLOPPY_CMD_SNS_INTR );
|
||||
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 );
|
||||
// queue DPC to fail IRP
|
||||
ControllerExtension->DpcState = FloppyDpcFailIrp;
|
||||
IoRequestDpc( ControllerExtension->Device,
|
||||
ControllerExtension->Irp,
|
||||
Controller );
|
||||
}
|
||||
else
|
||||
{
|
||||
// issue first read id, FloppyIsrDetectMedia will handle
|
||||
DPRINT( "Recalibrate worked, issuing read ID mark command\n" );
|
||||
ControllerExtension->IsrState = FloppyIsrDetectMedia;
|
||||
KeStallExecutionProcessor( 1000 );
|
||||
FloppyWriteDATA( ControllerExtension->PortBase, FLOPPY_CMD_RD_ID | FLOPPY_C0M_MFM );
|
||||
KeStallExecutionProcessor( 1000 );
|
||||
FloppyWriteDATA( ControllerExtension->PortBase, ((PFLOPPY_DEVICE_EXTENSION)ControllerExtension->Device->DeviceExtension)->DriveSelect );
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOLEAN FloppyIsrReadWrite( PCONTROLLER_OBJECT Controller )
|
||||
{
|
||||
// read result registers from read or write command, and queue dpc to start next operation
|
||||
PFLOPPY_CONTROLLER_EXTENSION ControllerExtension = (PFLOPPY_CONTROLLER_EXTENSION)Controller->ControllerExtension;
|
||||
UCHAR Cyl;
|
||||
UCHAR Head;
|
||||
UCHAR Sector;
|
||||
// PFLOPPY_DEVICE_EXTENSION DeviceExtension = (PFLOPPY_DEVICE_EXTENSION)ControllerExtension->Device->DeviceExtension;
|
||||
// PIO_STACK_LOCATION Stk = IoGetCurrentIrpStackLocation( ControllerExtension->Irp );
|
||||
// BOOLEAN WriteToDevice = Stk->MajorFunction == IRP_MJ_WRITE ? TRUE : FALSE;
|
||||
|
||||
|
||||
ControllerExtension->St0 = FloppyReadDATA( ControllerExtension->PortBase );
|
||||
KeStallExecutionProcessor( 100 );
|
||||
ControllerExtension->St1 = FloppyReadDATA( ControllerExtension->PortBase );
|
||||
KeStallExecutionProcessor( 100 );
|
||||
ControllerExtension->St2 = FloppyReadDATA( ControllerExtension->PortBase );
|
||||
KeStallExecutionProcessor( 100 );
|
||||
Cyl = FloppyReadDATA( ControllerExtension->PortBase ); // cyl
|
||||
KeStallExecutionProcessor( 100 );
|
||||
Head = FloppyReadDATA( ControllerExtension->PortBase ); // head
|
||||
KeStallExecutionProcessor( 100 );
|
||||
Sector = FloppyReadDATA( ControllerExtension->PortBase ); // sector
|
||||
KeStallExecutionProcessor( 100 );
|
||||
ControllerExtension->SectorSizeCode = FloppyReadDATA( ControllerExtension->PortBase );
|
||||
|
||||
// reprogam for next sector if we are not done reading track
|
||||
/* if( ( ControllerExtension->TransferLength -= ( 128 << ControllerExtension->SectorSizeCode ) ) )
|
||||
{
|
||||
DPRINT1( "ISR reprogramming for next sector: %d\n", Sector );
|
||||
Sector++;
|
||||
FloppyWriteDATA( ControllerExtension->PortBase, WriteToDevice ? FLOPPY_CMD_WRITE : FLOPPY_CMD_READ );
|
||||
KeStallExecutionProcessor( 100 );
|
||||
FloppyWriteDATA( ControllerExtension->PortBase, ( Head << 2 ) | DeviceExtension->DriveSelect );
|
||||
KeStallExecutionProcessor( 100 );
|
||||
FloppyWriteDATA( ControllerExtension->PortBase, Cyl );
|
||||
KeStallExecutionProcessor( 100 );
|
||||
FloppyWriteDATA( ControllerExtension->PortBase, Head );
|
||||
KeStallExecutionProcessor( 100 );
|
||||
FloppyWriteDATA( ControllerExtension->PortBase, Sector );
|
||||
KeStallExecutionProcessor( 100 );
|
||||
FloppyWriteDATA( ControllerExtension->PortBase, ControllerExtension->SectorSizeCode );
|
||||
KeStallExecutionProcessor( 100 );
|
||||
FloppyWriteDATA( ControllerExtension->PortBase, MediaTypes[DeviceExtension->MediaType].SectorsPerTrack );
|
||||
KeStallExecutionProcessor( 100 );
|
||||
FloppyWriteDATA( ControllerExtension->PortBase, 0 );
|
||||
KeStallExecutionProcessor( 100 );
|
||||
FloppyWriteDATA( ControllerExtension->PortBase, 0xFF );
|
||||
}
|
||||
else */IoRequestDpc( ControllerExtension->Device,
|
||||
ControllerExtension->Irp,
|
||||
Controller );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
// actual ISR, passes controll to handler for current state in state machine
|
||||
|
||||
BOOLEAN STDCALL
|
||||
FloppyIsr (PKINTERRUPT Interrupt,
|
||||
PVOID ServiceContext)
|
||||
{
|
||||
PCONTROLLER_OBJECT Controller;
|
||||
PFLOPPY_CONTROLLER_EXTENSION ControllerExtension;
|
||||
UCHAR Byte;
|
||||
|
||||
Controller = (PCONTROLLER_OBJECT)ServiceContext;
|
||||
ControllerExtension = (PFLOPPY_CONTROLLER_EXTENSION)Controller->ControllerExtension;
|
||||
|
||||
// need to make sure interrupt is for us, and add some delay for the damn FDC
|
||||
// without the delay, even though the thing has interrupted, it's still not ready
|
||||
// for us to read the data register.
|
||||
KeStallExecutionProcessor( 100 );
|
||||
Byte = FloppyReadMSTAT( ControllerExtension->PortBase );
|
||||
KeStallExecutionProcessor( 100 );
|
||||
if( Byte == 0 )
|
||||
{
|
||||
DPRINT( "Ignoring interrupt, MSTAT = 0\n" );
|
||||
return TRUE;
|
||||
}
|
||||
return ControllerExtension->IsrState( Controller );
|
||||
}
|
||||
|
||||
/* EOF */
|
|
@ -1,8 +0,0 @@
|
|||
*.tmp
|
||||
*.exp
|
||||
*.coff
|
||||
*.d
|
||||
*.o
|
||||
*.sym
|
||||
*.sys
|
||||
*.map
|
File diff suppressed because it is too large
Load diff
|
@ -1,256 +0,0 @@
|
|||
//
|
||||
// IDE.H - defines and typedefs for the IDE Driver module.
|
||||
//
|
||||
|
||||
#ifndef __IDE_H
|
||||
#define __IDE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define IDE_MAXIMUM_DEVICES 8
|
||||
|
||||
#define IDE_MAX_NAME_LENGTH 50
|
||||
|
||||
#define IDE_SECTOR_BUF_SZ 512
|
||||
#define IDE_MAX_SECTORS_PER_XFER 256
|
||||
#define IDE_MAX_RESET_RETRIES 10000
|
||||
#define IDE_MAX_POLL_RETRIES 100000
|
||||
#define IDE_MAX_WRITE_RETRIES 1000
|
||||
#define IDE_MAX_BUSY_RETRIES 50000
|
||||
#define IDE_MAX_DRQ_RETRIES 10000
|
||||
//#define IDE_MAX_CMD_RETRIES 1
|
||||
#define IDE_MAX_CMD_RETRIES 0
|
||||
#define IDE_CMD_TIMEOUT 5
|
||||
#define IDE_RESET_PULSE_LENGTH 500 /* maybe a little too long */
|
||||
#define IDE_RESET_BUSY_TIMEOUT 120
|
||||
#define IDE_RESET_DRDY_TIMEOUT 120
|
||||
|
||||
// Control Block offsets and masks
|
||||
#define IDE_REG_ALT_STATUS 0x0000
|
||||
#define IDE_REG_DEV_CNTRL 0x0000 /* device control register */
|
||||
#define IDE_DC_SRST 0x04 /* drive reset (both drives) */
|
||||
#define IDE_DC_nIEN 0x02 /* IRQ enable (active low) */
|
||||
#define IDE_REG_DRV_ADDR 0x0001
|
||||
|
||||
// Command Block offsets and masks
|
||||
#define IDE_REG_DATA_PORT 0x0000
|
||||
#define IDE_REG_ERROR 0x0001 /* error register */
|
||||
#define IDE_ER_AMNF 0x01 /* addr mark not found */
|
||||
#define IDE_ER_TK0NF 0x02 /* track 0 not found */
|
||||
#define IDE_ER_ABRT 0x04 /* command aborted */
|
||||
#define IDE_ER_MCR 0x08 /* media change requested */
|
||||
#define IDE_ER_IDNF 0x10 /* ID not found */
|
||||
#define IDE_ER_MC 0x20 /* Media changed */
|
||||
#define IDE_ER_UNC 0x40 /* Uncorrectable data error */
|
||||
#define IDE_REG_PRECOMP 0x0001
|
||||
#define IDE_REG_SECTOR_CNT 0x0002
|
||||
#define IDE_REG_SECTOR_NUM 0x0003
|
||||
#define IDE_REG_CYL_LOW 0x0004
|
||||
#define IDE_REG_CYL_HIGH 0x0005
|
||||
#define IDE_REG_DRV_HEAD 0x0006
|
||||
#define IDE_DH_FIXED 0xA0
|
||||
#define IDE_DH_LBA 0x40
|
||||
#define IDE_DH_HDMASK 0x0F
|
||||
#define IDE_DH_DRV0 0x00
|
||||
#define IDE_DH_DRV1 0x10
|
||||
#define IDE_REG_STATUS 0x0007
|
||||
#define IDE_SR_BUSY 0x80
|
||||
#define IDE_SR_DRDY 0x40
|
||||
#define IDE_SR_DRQ 0x08
|
||||
#define IDE_SR_ERR 0x01
|
||||
#define IDE_REG_COMMAND 0x0007
|
||||
#define IDE_CMD_READ 0x20
|
||||
#define IDE_CMD_READ_RETRY 0x21
|
||||
#define IDE_CMD_WRITE 0x30
|
||||
#define IDE_CMD_WRITE_RETRY 0x31
|
||||
#define IDE_CMD_IDENT_DRV 0xEC
|
||||
|
||||
//
|
||||
// Access macros for command registers
|
||||
// Each macro takes an address of the command port block, and data
|
||||
//
|
||||
#define IDEReadError(Address) \
|
||||
(READ_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_ERROR)))
|
||||
#define IDEWritePrecomp(Address, Data) \
|
||||
(WRITE_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_PRECOMP), (Data)))
|
||||
#define IDEReadSectorCount(Address) \
|
||||
(READ_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_SECTOR_CNT)))
|
||||
#define IDEWriteSectorCount(Address, Data) \
|
||||
(WRITE_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_SECTOR_CNT), (Data)))
|
||||
#define IDEReadSectorNum(Address) \
|
||||
(READ_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_SECTOR_NUM)))
|
||||
#define IDEWriteSectorNum(Address, Data) \
|
||||
(WRITE_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_SECTOR_NUM), (Data)))
|
||||
#define IDEReadCylinderLow(Address) \
|
||||
(READ_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_CYL_LOW)))
|
||||
#define IDEWriteCylinderLow(Address, Data) \
|
||||
(WRITE_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_CYL_LOW), (Data)))
|
||||
#define IDEReadCylinderHigh(Address) \
|
||||
(READ_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_CYL_HIGH)))
|
||||
#define IDEWriteCylinderHigh(Address, Data) \
|
||||
(WRITE_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_CYL_HIGH), (Data)))
|
||||
#define IDEReadDriveHead(Address) \
|
||||
(READ_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_DRV_HEAD)))
|
||||
#define IDEWriteDriveHead(Address, Data) \
|
||||
(WRITE_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_DRV_HEAD), (Data)))
|
||||
#define IDEReadStatus(Address) \
|
||||
(READ_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_STATUS)))
|
||||
#define IDEWriteCommand(Address, Data) \
|
||||
(WRITE_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_COMMAND), (Data)))
|
||||
|
||||
|
||||
//
|
||||
// Data block read and write commands
|
||||
//
|
||||
#define IDEReadBlock(Address, Buffer, Count) \
|
||||
(READ_PORT_BUFFER_USHORT((PUSHORT)((Address) + IDE_REG_DATA_PORT), (PUSHORT)(Buffer), (Count) / 2))
|
||||
#define IDEWriteBlock(Address, Buffer, Count) \
|
||||
(WRITE_PORT_BUFFER_USHORT((PUSHORT)((Address) + IDE_REG_DATA_PORT), (PUSHORT)(Buffer), (Count) / 2))
|
||||
|
||||
//
|
||||
// Access macros for control registers
|
||||
// Each macro takes an address of the control port blank and data
|
||||
//
|
||||
#define IDEWriteDriveControl(Address, Data) \
|
||||
(WRITE_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_DEV_CNTRL), (Data)))
|
||||
|
||||
// IDE_DEVICE_EXTENSION
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Extension to be placed in each device object
|
||||
//
|
||||
// ACCESS:
|
||||
// Allocated from NON-PAGED POOL
|
||||
// Available at any IRQL
|
||||
//
|
||||
|
||||
typedef struct _IDE_DEVICE_EXTENSION
|
||||
{
|
||||
PDEVICE_OBJECT DeviceObject;
|
||||
PCONTROLLER_OBJECT ControllerObject;
|
||||
PVOID DiskDeviceExtension;
|
||||
int UnitNumber;
|
||||
BOOLEAN LBASupported;
|
||||
BOOLEAN DMASupported;
|
||||
int BytesPerSector;
|
||||
int LogicalHeads;
|
||||
int LogicalCylinders;
|
||||
int SectorsPerLogCyl;
|
||||
int SectorsPerLogTrk;
|
||||
|
||||
LARGE_INTEGER StartingOffset;
|
||||
LARGE_INTEGER PartitionLength;
|
||||
ULONG HiddenSectors;
|
||||
ULONG PartitionNumber;
|
||||
UCHAR PartitionType;
|
||||
BOOLEAN BootIndicator;
|
||||
|
||||
int Operation;
|
||||
ULONG BytesRequested;
|
||||
ULONG BytesToTransfer;
|
||||
ULONG BytesRemaining;
|
||||
ULONG StartingSector;
|
||||
int SectorsTransferred;
|
||||
BYTE *TargetAddress;
|
||||
|
||||
} IDE_DEVICE_EXTENSION, *PIDE_DEVICE_EXTENSION;
|
||||
|
||||
// IDE_TIMER_STATES
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// An enumeration containing the states in the timer DFA
|
||||
//
|
||||
|
||||
typedef enum _IDE_TIMER_STATES {
|
||||
IDETimerIdle,
|
||||
IDETimerCmdWait,
|
||||
IDETimerResetWaitForBusyNegate,
|
||||
IDETimerResetWaitForDrdyAssert
|
||||
} IDE_TIMER_STATES;
|
||||
|
||||
// IDE_CONTROLLER_EXTENSION
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Driver-defined structure used to hold miscellaneous controller information.
|
||||
//
|
||||
// ACCESS:
|
||||
// Allocated from NON-PAGED POOL
|
||||
// Available at any IRQL
|
||||
//
|
||||
|
||||
typedef struct _IDE_CONTROLLER_EXTENSION {
|
||||
KSPIN_LOCK SpinLock;
|
||||
int Number;
|
||||
int Vector;
|
||||
int CommandPortBase;
|
||||
int ControlPortBase;
|
||||
BOOLEAN DMASupported;
|
||||
BOOLEAN ControllerInterruptBug;
|
||||
PKINTERRUPT Interrupt;
|
||||
|
||||
BOOLEAN OperationInProgress;
|
||||
BYTE DeviceStatus;
|
||||
PIDE_DEVICE_EXTENSION DeviceForOperation;
|
||||
PIRP CurrentIrp;
|
||||
int Retries;
|
||||
|
||||
IDE_TIMER_STATES TimerState;
|
||||
LONG TimerCount;
|
||||
PDEVICE_OBJECT TimerDevice;
|
||||
|
||||
} IDE_CONTROLLER_EXTENSION, *PIDE_CONTROLLER_EXTENSION;
|
||||
|
||||
// IDE_DRIVE_IDENTIFY
|
||||
|
||||
typedef struct _IDE_DRIVE_IDENTIFY {
|
||||
WORD ConfigBits; /*00*/
|
||||
WORD LogicalCyls; /*01*/
|
||||
WORD Reserved02; /*02*/
|
||||
WORD LogicalHeads; /*03*/
|
||||
WORD BytesPerTrack; /*04*/
|
||||
WORD BytesPerSector; /*05*/
|
||||
WORD SectorsPerTrack; /*06*/
|
||||
BYTE InterSectorGap; /*07*/
|
||||
BYTE InterSectorGapSize;
|
||||
BYTE Reserved08H; /*08*/
|
||||
BYTE BytesInPLO;
|
||||
WORD VendorUniqueCnt; /*09*/
|
||||
char SerialNumber[20]; /*10*/
|
||||
WORD ControllerType; /*20*/
|
||||
WORD BufferSize; /*21*/
|
||||
WORD ECCByteCnt; /*22*/
|
||||
char FirmwareRev[8]; /*23*/
|
||||
char ModelNumber[40]; /*27*/
|
||||
WORD RWMultImplemented; /*47*/
|
||||
WORD Reserved48; /*48*/
|
||||
WORD Capabilities; /*49*/
|
||||
#define IDE_DRID_STBY_SUPPORTED 0x2000
|
||||
#define IDE_DRID_IORDY_SUPPORTED 0x0800
|
||||
#define IDE_DRID_IORDY_DISABLE 0x0400
|
||||
#define IDE_DRID_LBA_SUPPORTED 0x0200
|
||||
#define IDE_DRID_DMA_SUPPORTED 0x0100
|
||||
WORD Reserved50; /*50*/
|
||||
WORD MinPIOTransTime; /*51*/
|
||||
WORD MinDMATransTime; /*52*/
|
||||
WORD TMFieldsValid; /*53*/
|
||||
WORD TMCylinders; /*54*/
|
||||
WORD TMHeads; /*55*/
|
||||
WORD TMSectorsPerTrk; /*56*/
|
||||
WORD TMCapacityLo; /*57*/
|
||||
WORD TMCapacityHi; /*58*/
|
||||
WORD Reserved59; /*59*/
|
||||
WORD TMSectorCountLo; /*60*/
|
||||
WORD TMSectorCountHi; /*61*/
|
||||
WORD Reserved62[194]; /*62*/
|
||||
} IDE_DRIVE_IDENTIFY, *PIDE_DRIVE_IDENTIFY;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __IDE_H */
|
||||
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
|
||||
#include <defines.h>
|
||||
#include <reactos/resource.h>
|
||||
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION RES_UINT_FV_MAJOR,RES_UINT_FV_MINOR,RES_UINT_FV_REVISION,RES_UINT_FV_BUILD
|
||||
PRODUCTVERSION RES_UINT_PV_MAJOR,RES_UINT_PV_MINOR,RES_UINT_PV_REVISION,RES_UINT_PV_BUILD
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x40004L
|
||||
FILETYPE 0x2L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "CompanyName", RES_STR_COMPANY_NAME
|
||||
VALUE "FileDescription", "IDE Disk Device Driver\0"
|
||||
VALUE "FileVersion", "0.1.4\0"
|
||||
VALUE "InternalName", "ide\0"
|
||||
VALUE "LegalCopyright", RES_STR_LEGAL_COPYRIGHT
|
||||
VALUE "OriginalFilename", "ide.sys\0"
|
||||
VALUE "ProductName", RES_STR_PRODUCT_NAME
|
||||
VALUE "ProductVersion", RES_STR_PRODUCT_VERSION
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
# $Id: makefile,v 1.27 2003/11/14 17:13:25 weiden Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_TYPE = driver
|
||||
|
||||
TARGET_NAME = ide
|
||||
|
||||
TARGET_CFLAGS = -Wall -Werror
|
||||
|
||||
TARGET_OBJECTS = ide.o
|
||||
|
||||
TARGET_HEADERS = *.h
|
||||
|
||||
TARGET_GCCLIBS = gcc
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
|
@ -1,41 +0,0 @@
|
|||
/**
|
||||
*** Partition.h - defines and structs for harddrive partition info
|
||||
***
|
||||
*** 05/30/98 RJJ Created
|
||||
**/
|
||||
|
||||
#ifndef __PARTITION_H
|
||||
#define __PARTITION_H
|
||||
|
||||
#define PARTITION_MAGIC 0xaa55
|
||||
#define PART_MAGIC_OFFSET 0x01fe
|
||||
#define PARTITION_OFFSET 0x01be
|
||||
#define PARTITION_TBL_SIZE 4
|
||||
#define PTCHSToLBA(c, h, s, scnt, hcnt) ((s) & 0x3f) + \
|
||||
(scnt) * ( (h) + (hcnt) * ((c) | (((s) & 0xc0) << 2)))
|
||||
#define PTLBAToCHS(lba, c, h, s, scnt, hcnt) ( \
|
||||
(s) = (lba) % (scnt) + 1, \
|
||||
(lba) /= (scnt), \
|
||||
(h) = (lba) % (hcnt), \
|
||||
(lba) /= (heads), \
|
||||
(c) = (lba) & 0xff, \
|
||||
(s) |= ((lba) >> 2) & 0xc0)
|
||||
|
||||
|
||||
typedef struct Partition {
|
||||
unsigned char BootFlags;
|
||||
unsigned char StartingHead;
|
||||
unsigned char StartingSector;
|
||||
unsigned char StartingCylinder;
|
||||
unsigned char PartitionType;
|
||||
unsigned char EndingHead;
|
||||
unsigned char EndingSector;
|
||||
unsigned char EndingCylinder;
|
||||
unsigned int StartingBlock;
|
||||
unsigned int SectorCount;
|
||||
|
||||
} PARTITION;
|
||||
|
||||
#endif // PARTITION_H
|
||||
|
||||
|
Loading…
Reference in a new issue