Formatting only, no code changes.

svn path=/trunk/; revision=51410
This commit is contained in:
Rafal Harabien 2011-04-20 18:13:27 +00:00
parent 057f42a554
commit 1e27c057e4
10 changed files with 1936 additions and 1884 deletions

View file

@ -56,9 +56,9 @@ KSEMAPHORE QueueSemaphore;
* CSQ Callbacks * CSQ Callbacks
*/ */
VOID NTAPI CsqRemoveIrp(PIO_CSQ UnusedCsq, VOID NTAPI
PIRP Irp) CsqRemoveIrp(PIO_CSQ UnusedCsq, PIRP Irp)
/* /*
* FUNCTION: Remove an IRP from the queue * FUNCTION: Remove an IRP from the queue
* ARGUMENTS: * ARGUMENTS:
@ -68,15 +68,14 @@ VOID NTAPI CsqRemoveIrp(PIO_CSQ UnusedCsq,
* - Called under the protection of the queue lock * - Called under the protection of the queue lock
*/ */
{ {
UNREFERENCED_PARAMETER(UnusedCsq); UNREFERENCED_PARAMETER(UnusedCsq);
TRACE_(FLOPPY, "CSQ: Removing IRP 0x%p\n", Irp); TRACE_(FLOPPY, "CSQ: Removing IRP 0x%p\n", Irp);
RemoveEntryList(&Irp->Tail.Overlay.ListEntry); RemoveEntryList(&Irp->Tail.Overlay.ListEntry);
} }
PIRP NTAPI CsqPeekNextIrp(PIO_CSQ UnusedCsq, PIRP NTAPI
PIRP Irp, CsqPeekNextIrp(PIO_CSQ UnusedCsq, PIRP Irp, PVOID PeekContext)
PVOID PeekContext)
/* /*
* FUNCTION: Find the next matching IRP in the queue * FUNCTION: Find the next matching IRP in the queue
* ARGUMENTS: * ARGUMENTS:
@ -90,22 +89,22 @@ PIRP NTAPI CsqPeekNextIrp(PIO_CSQ UnusedCsq,
* - Called under the protection of the queue lock * - Called under the protection of the queue lock
*/ */
{ {
UNREFERENCED_PARAMETER(UnusedCsq); UNREFERENCED_PARAMETER(UnusedCsq);
UNREFERENCED_PARAMETER(PeekContext); UNREFERENCED_PARAMETER(PeekContext);
TRACE_(FLOPPY, "CSQ: Peeking for next IRP\n"); TRACE_(FLOPPY, "CSQ: Peeking for next IRP\n");
if(Irp) if(Irp)
return CONTAINING_RECORD(&Irp->Tail.Overlay.ListEntry.Flink, IRP, Tail.Overlay.ListEntry); return CONTAINING_RECORD(&Irp->Tail.Overlay.ListEntry.Flink, IRP, Tail.Overlay.ListEntry);
if(IsListEmpty(&IrpQueue)) if(IsListEmpty(&IrpQueue))
return NULL; return NULL;
return CONTAINING_RECORD(IrpQueue.Flink, IRP, Tail.Overlay.ListEntry); return CONTAINING_RECORD(IrpQueue.Flink, IRP, Tail.Overlay.ListEntry);
} }
VOID NTAPI CsqAcquireLock(PIO_CSQ UnusedCsq, VOID NTAPI
PKIRQL Irql) CsqAcquireLock(PIO_CSQ UnusedCsq, PKIRQL Irql)
/* /*
* FUNCTION: Acquire the queue lock * FUNCTION: Acquire the queue lock
* ARGUMENTS: * ARGUMENTS:
@ -113,14 +112,14 @@ VOID NTAPI CsqAcquireLock(PIO_CSQ UnusedCsq,
* Irql: Pointer to a variable to store the old irql into * Irql: Pointer to a variable to store the old irql into
*/ */
{ {
UNREFERENCED_PARAMETER(UnusedCsq); UNREFERENCED_PARAMETER(UnusedCsq);
INFO_(FLOPPY, "CSQ: Acquiring spin lock\n"); INFO_(FLOPPY, "CSQ: Acquiring spin lock\n");
KeAcquireSpinLock(&IrpQueueLock, Irql); KeAcquireSpinLock(&IrpQueueLock, Irql);
} }
VOID NTAPI CsqReleaseLock(PIO_CSQ UnusedCsq, VOID NTAPI
KIRQL Irql) CsqReleaseLock(PIO_CSQ UnusedCsq, KIRQL Irql)
/* /*
* FUNCTION: Release the queue lock * FUNCTION: Release the queue lock
* ARGUMENTS: * ARGUMENTS:
@ -128,14 +127,14 @@ VOID NTAPI CsqReleaseLock(PIO_CSQ UnusedCsq,
* Irql: IRQL to lower to on release * Irql: IRQL to lower to on release
*/ */
{ {
UNREFERENCED_PARAMETER(UnusedCsq); UNREFERENCED_PARAMETER(UnusedCsq);
INFO_(FLOPPY, "CSQ: Releasing spin lock\n"); INFO_(FLOPPY, "CSQ: Releasing spin lock\n");
KeReleaseSpinLock(&IrpQueueLock, Irql); KeReleaseSpinLock(&IrpQueueLock, Irql);
} }
VOID NTAPI CsqCompleteCanceledIrp(PIO_CSQ UnusedCsq, VOID NTAPI
PIRP Irp) CsqCompleteCanceledIrp(PIO_CSQ UnusedCsq, PIRP Irp)
/* /*
* FUNCTION: Complete a canceled IRP * FUNCTION: Complete a canceled IRP
* ARGUMENTS: * ARGUMENTS:
@ -146,16 +145,16 @@ VOID NTAPI CsqCompleteCanceledIrp(PIO_CSQ UnusedCsq,
* - MS misspelled CANCELLED... sigh... * - MS misspelled CANCELLED... sigh...
*/ */
{ {
UNREFERENCED_PARAMETER(UnusedCsq); UNREFERENCED_PARAMETER(UnusedCsq);
TRACE_(FLOPPY, "CSQ: Canceling irp 0x%p\n", Irp); TRACE_(FLOPPY, "CSQ: Canceling irp 0x%p\n", Irp);
Irp->IoStatus.Status = STATUS_CANCELLED; Irp->IoStatus.Status = STATUS_CANCELLED;
Irp->IoStatus.Information = 0; Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT); IoCompleteRequest(Irp, IO_NO_INCREMENT);
} }
VOID NTAPI CsqInsertIrp(PIO_CSQ UnusedCsq, VOID NTAPI
PIRP Irp) CsqInsertIrp(PIO_CSQ UnusedCsq, PIRP Irp)
/* /*
* FUNCTION: Queue an IRP * FUNCTION: Queue an IRP
* ARGUMENTS: * ARGUMENTS:
@ -171,9 +170,9 @@ VOID NTAPI CsqInsertIrp(PIO_CSQ UnusedCsq,
* that at least one IRP is canceled at some point * that at least one IRP is canceled at some point
*/ */
{ {
UNREFERENCED_PARAMETER(UnusedCsq); UNREFERENCED_PARAMETER(UnusedCsq);
TRACE_(FLOPPY, "CSQ: Inserting IRP 0x%p\n", Irp); TRACE_(FLOPPY, "CSQ: Inserting IRP 0x%p\n", Irp);
InsertTailList(&IrpQueue, &Irp->Tail.Overlay.ListEntry); InsertTailList(&IrpQueue, &Irp->Tail.Overlay.ListEntry);
KeReleaseSemaphore(&QueueSemaphore, 0, 1, FALSE); KeReleaseSemaphore(&QueueSemaphore, 0, 1, FALSE);
} }

View file

@ -38,22 +38,21 @@ extern LIST_ENTRY IrpQueue;
extern KSPIN_LOCK IrpQueueLock; extern KSPIN_LOCK IrpQueueLock;
extern KSEMAPHORE QueueSemaphore; extern KSEMAPHORE QueueSemaphore;
VOID NTAPI CsqInsertIrp(PIO_CSQ Csq, VOID NTAPI
PIRP Irp); CsqInsertIrp(PIO_CSQ Csq, PIRP Irp);
VOID NTAPI CsqRemoveIrp(PIO_CSQ Csq, VOID NTAPI
PIRP Irp); CsqRemoveIrp(PIO_CSQ Csq, PIRP Irp);
PIRP NTAPI CsqPeekNextIrp(PIO_CSQ Csq, PIRP NTAPI
PIRP Irp, CsqPeekNextIrp(PIO_CSQ Csq, PIRP Irp, PVOID PeekContext);
PVOID PeekContext);
VOID NTAPI CsqAcquireLock(PIO_CSQ Csq, VOID NTAPI
PKIRQL Irql); CsqAcquireLock(PIO_CSQ Csq, PKIRQL Irql);
VOID NTAPI CsqReleaseLock(PIO_CSQ Csq, VOID NTAPI
KIRQL Irql); CsqReleaseLock(PIO_CSQ Csq, KIRQL Irql);
VOID NTAPI CsqCompleteCanceledIrp(PIO_CSQ Csq, VOID NTAPI
PIRP Irp); CsqCompleteCanceledIrp(PIO_CSQ Csq, PIRP Irp);

File diff suppressed because it is too large Load diff

View file

@ -39,64 +39,68 @@ struct _CONTROLLER_INFO;
typedef struct _DRIVE_INFO typedef struct _DRIVE_INFO
{ {
struct _CONTROLLER_INFO *ControllerInfo; struct _CONTROLLER_INFO *ControllerInfo;
UCHAR UnitNumber; /* 0,1,2,3 */ UCHAR UnitNumber; /* 0,1,2,3 */
LARGE_INTEGER MotorStartTime; LARGE_INTEGER MotorStartTime;
PDEVICE_OBJECT DeviceObject; PDEVICE_OBJECT DeviceObject;
CM_FLOPPY_DEVICE_DATA FloppyDeviceData; CM_FLOPPY_DEVICE_DATA FloppyDeviceData;
DISK_GEOMETRY DiskGeometry; DISK_GEOMETRY DiskGeometry;
UCHAR BytesPerSectorCode; UCHAR BytesPerSectorCode;
WCHAR SymLinkBuffer[MAX_DEVICE_NAME]; WCHAR SymLinkBuffer[MAX_DEVICE_NAME];
WCHAR ArcPathBuffer[MAX_ARC_PATH_LEN]; WCHAR ArcPathBuffer[MAX_ARC_PATH_LEN];
ULONG DiskChangeCount; ULONG DiskChangeCount;
BOOLEAN Initialized; BOOLEAN Initialized;
} DRIVE_INFO, *PDRIVE_INFO; } DRIVE_INFO, *PDRIVE_INFO;
typedef struct _CONTROLLER_INFO typedef struct _CONTROLLER_INFO
{ {
BOOLEAN Populated; BOOLEAN Populated;
BOOLEAN Initialized; BOOLEAN Initialized;
ULONG ControllerNumber; ULONG ControllerNumber;
INTERFACE_TYPE InterfaceType; INTERFACE_TYPE InterfaceType;
ULONG BusNumber; ULONG BusNumber;
ULONG Level; ULONG Level;
KIRQL MappedLevel; KIRQL MappedLevel;
ULONG Vector; ULONG Vector;
ULONG MappedVector; ULONG MappedVector;
KINTERRUPT_MODE InterruptMode; KINTERRUPT_MODE InterruptMode;
PUCHAR BaseAddress; PUCHAR BaseAddress;
ULONG Dma; ULONG Dma;
ULONG MapRegisters; ULONG MapRegisters;
PVOID MapRegisterBase; PVOID MapRegisterBase;
BOOLEAN Master; BOOLEAN Master;
KEVENT SynchEvent; KEVENT SynchEvent;
KDPC Dpc; KDPC Dpc;
PKINTERRUPT InterruptObject; PKINTERRUPT InterruptObject;
PADAPTER_OBJECT AdapterObject; PADAPTER_OBJECT AdapterObject;
UCHAR NumberOfDrives; UCHAR NumberOfDrives;
BOOLEAN ImpliedSeeks; BOOLEAN ImpliedSeeks;
DRIVE_INFO DriveInfo[MAX_DRIVES_PER_CONTROLLER]; DRIVE_INFO DriveInfo[MAX_DRIVES_PER_CONTROLLER];
PDRIVE_INFO CurrentDrive; PDRIVE_INFO CurrentDrive;
BOOLEAN Model30; BOOLEAN Model30;
KEVENT MotorStoppedEvent; KEVENT MotorStoppedEvent;
KTIMER MotorTimer; KTIMER MotorTimer;
KDPC MotorStopDpc; KDPC MotorStopDpc;
BOOLEAN StopDpcQueued; BOOLEAN StopDpcQueued;
} CONTROLLER_INFO, *PCONTROLLER_INFO; } CONTROLLER_INFO, *PCONTROLLER_INFO;
NTSTATUS NTAPI DriverEntry(PDRIVER_OBJECT DriverObject, NTSTATUS NTAPI
PUNICODE_STRING RegistryPath); DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath);
VOID NTAPI SignalMediaChanged(PDEVICE_OBJECT DeviceObject, VOID NTAPI
PIRP Irp); SignalMediaChanged(PDEVICE_OBJECT DeviceObject, PIRP Irp);
VOID NTAPI WaitForControllerInterrupt(PCONTROLLER_INFO ControllerInfo); VOID NTAPI
WaitForControllerInterrupt(PCONTROLLER_INFO ControllerInfo);
NTSTATUS NTAPI ResetChangeFlag(PDRIVE_INFO DriveInfo); NTSTATUS NTAPI
ResetChangeFlag(PDRIVE_INFO DriveInfo);
VOID NTAPI StartMotor(PDRIVE_INFO DriveInfo); VOID NTAPI
StartMotor(PDRIVE_INFO DriveInfo);
VOID NTAPI StopMotor(PCONTROLLER_INFO ControllerInfo); VOID NTAPI
StopMotor(PCONTROLLER_INFO ControllerInfo);
/* /*
* MEDIA TYPES * MEDIA TYPES

File diff suppressed because it is too large Load diff

View file

@ -260,76 +260,94 @@
/* /*
* FUNCTIONS * FUNCTIONS
*/ */
NTSTATUS NTAPI HwTurnOnMotor(PDRIVE_INFO DriveInfo); NTSTATUS NTAPI
HwTurnOnMotor(PDRIVE_INFO DriveInfo);
NTSTATUS NTAPI HwSenseDriveStatus(PDRIVE_INFO DriveInfo); NTSTATUS NTAPI
HwSenseDriveStatus(PDRIVE_INFO DriveInfo);
NTSTATUS NTAPI HwReadWriteData(PCONTROLLER_INFO ControllerInfo, NTSTATUS NTAPI
BOOLEAN Read, HwReadWriteData(PCONTROLLER_INFO ControllerInfo,
UCHAR Unit, BOOLEAN Read,
UCHAR Cylinder, UCHAR Unit,
UCHAR Head, UCHAR Cylinder,
UCHAR Sector, UCHAR Head,
UCHAR BytesPerSector, UCHAR Sector,
UCHAR EndOfTrack, UCHAR BytesPerSector,
UCHAR Gap3Length, UCHAR EndOfTrack,
UCHAR DataLength); UCHAR Gap3Length,
UCHAR DataLength);
NTSTATUS NTAPI HwRecalibrate(PDRIVE_INFO DriveInfo); NTSTATUS NTAPI
HwRecalibrate(PDRIVE_INFO DriveInfo);
NTSTATUS NTAPI HwSenseInterruptStatus(PCONTROLLER_INFO ControllerInfo); NTSTATUS NTAPI
HwSenseInterruptStatus(PCONTROLLER_INFO ControllerInfo);
NTSTATUS NTAPI HwReadId(PDRIVE_INFO DriveInfo, NTSTATUS NTAPI
UCHAR Head); HwReadId(PDRIVE_INFO DriveInfo, UCHAR Head);
NTSTATUS NTAPI HwFormatTrack(PCONTROLLER_INFO ControllerInfo, NTSTATUS NTAPI
UCHAR Unit, HwFormatTrack(PCONTROLLER_INFO ControllerInfo,
UCHAR Head, UCHAR Unit,
UCHAR BytesPerSector, UCHAR Head,
UCHAR SectorsPerTrack, UCHAR BytesPerSector,
UCHAR Gap3Length, UCHAR SectorsPerTrack,
UCHAR FillerPattern); UCHAR Gap3Length,
UCHAR FillerPattern);
NTSTATUS NTAPI HwSeek(PDRIVE_INFO DriveInfo, NTSTATUS NTAPI
UCHAR Cylinder); HwSeek(PDRIVE_INFO DriveInfo, UCHAR Cylinder);
NTSTATUS NTAPI HwReadWriteResult(PCONTROLLER_INFO ControllerInfo); NTSTATUS NTAPI
HwReadWriteResult(PCONTROLLER_INFO ControllerInfo);
NTSTATUS NTAPI HwGetVersion(PCONTROLLER_INFO ControllerInfo); NTSTATUS NTAPI
HwGetVersion(PCONTROLLER_INFO ControllerInfo);
NTSTATUS NTAPI HwConfigure(PCONTROLLER_INFO ControllerInfo, NTSTATUS NTAPI
BOOLEAN EIS, HwConfigure(PCONTROLLER_INFO ControllerInfo,
BOOLEAN EFIFO, BOOLEAN EIS,
BOOLEAN POLL, BOOLEAN EFIFO,
UCHAR FIFOTHR, BOOLEAN POLL,
UCHAR PRETRK) ; UCHAR FIFOTHR,
UCHAR PRETRK) ;
NTSTATUS NTAPI HwRecalibrateResult(PCONTROLLER_INFO ControllerInfo); NTSTATUS NTAPI
HwRecalibrateResult(PCONTROLLER_INFO ControllerInfo);
NTSTATUS NTAPI HwDiskChanged(PDRIVE_INFO DriveInfo, NTSTATUS NTAPI
PBOOLEAN DiskChanged); HwDiskChanged(PDRIVE_INFO DriveInfo,
PBOOLEAN DiskChanged);
NTSTATUS NTAPI HwSenseDriveStatusResult(PCONTROLLER_INFO ControllerInfo, NTSTATUS NTAPI
PUCHAR Status); HwSenseDriveStatusResult(PCONTROLLER_INFO ControllerInfo,
PUCHAR Status);
NTSTATUS NTAPI HwSpecify(PCONTROLLER_INFO ControllerInfo, NTSTATUS NTAPI
UCHAR HeadLoadTime, HwSpecify(PCONTROLLER_INFO ControllerInfo,
UCHAR HeadUnloadTime, UCHAR HeadLoadTime,
UCHAR StepRateTime, UCHAR HeadUnloadTime,
BOOLEAN NonDma); UCHAR StepRateTime,
BOOLEAN NonDma);
NTSTATUS NTAPI HwReadIdResult(PCONTROLLER_INFO ControllerInfo, NTSTATUS NTAPI
PUCHAR CurCylinder, HwReadIdResult(PCONTROLLER_INFO ControllerInfo,
PUCHAR CurHead); PUCHAR CurCylinder,
PUCHAR CurHead);
NTSTATUS NTAPI HwSetDataRate(PCONTROLLER_INFO ControllerInfo, NTSTATUS NTAPI
UCHAR DataRate); HwSetDataRate(PCONTROLLER_INFO ControllerInfo, UCHAR DataRate);
NTSTATUS NTAPI HwReset(PCONTROLLER_INFO Controller); NTSTATUS NTAPI
HwReset(PCONTROLLER_INFO Controller);
NTSTATUS NTAPI HwPowerOff(PCONTROLLER_INFO ControllerInfo); NTSTATUS NTAPI
HwPowerOff(PCONTROLLER_INFO ControllerInfo);
VOID NTAPI HwDumpRegisters(PCONTROLLER_INFO ControllerInfo); VOID NTAPI
HwDumpRegisters(PCONTROLLER_INFO ControllerInfo);
NTSTATUS NTAPI HwTurnOffMotor(PCONTROLLER_INFO ControllerInfo); NTSTATUS NTAPI
HwTurnOffMotor(PCONTROLLER_INFO ControllerInfo);

View file

@ -39,9 +39,9 @@
#include "csqrtns.h" #include "csqrtns.h"
#include "ioctl.h" #include "ioctl.h"
NTSTATUS NTAPI DeviceIoctl(PDEVICE_OBJECT DeviceObject, NTSTATUS NTAPI
PIRP Irp) DeviceIoctl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
/* /*
* FUNCTION: Queue IOCTL IRPs * FUNCTION: Queue IOCTL IRPs
* ARGUMENTS: * ARGUMENTS:
@ -55,18 +55,18 @@ NTSTATUS NTAPI DeviceIoctl(PDEVICE_OBJECT DeviceObject,
* read/write or ioctl irps. * read/write or ioctl irps.
*/ */
{ {
ASSERT(DeviceObject); ASSERT(DeviceObject);
ASSERT(Irp); ASSERT(Irp);
Irp->Tail.Overlay.DriverContext[0] = DeviceObject; Irp->Tail.Overlay.DriverContext[0] = DeviceObject;
IoCsqInsertIrp(&Csq, Irp, NULL); IoCsqInsertIrp(&Csq, Irp, NULL);
return STATUS_PENDING; return STATUS_PENDING;
} }
VOID NTAPI DeviceIoctlPassive(PDRIVE_INFO DriveInfo, VOID NTAPI
PIRP Irp) DeviceIoctlPassive(PDRIVE_INFO DriveInfo, PIRP Irp)
/* /*
* FUNCTION: Handlees IOCTL requests at PASSIVE_LEVEL * FUNCTION: Handlees IOCTL requests at PASSIVE_LEVEL
* ARGUMENTS: * ARGUMENTS:
@ -74,108 +74,108 @@ VOID NTAPI DeviceIoctlPassive(PDRIVE_INFO DriveInfo,
* Irp: IRP with the request in it * Irp: IRP with the request in it
*/ */
{ {
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp); PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
ULONG OutputLength = Stack->Parameters.DeviceIoControl.OutputBufferLength; ULONG OutputLength = Stack->Parameters.DeviceIoControl.OutputBufferLength;
PVOID OutputBuffer = Irp->AssociatedIrp.SystemBuffer; PVOID OutputBuffer = Irp->AssociatedIrp.SystemBuffer;
ULONG Code = Stack->Parameters.DeviceIoControl.IoControlCode; ULONG Code = Stack->Parameters.DeviceIoControl.IoControlCode;
BOOLEAN DiskChanged; BOOLEAN DiskChanged;
TRACE_(FLOPPY, "DeviceIoctl called\n"); TRACE_(FLOPPY, "DeviceIoctl called\n");
Irp->IoStatus.Status = STATUS_SUCCESS; Irp->IoStatus.Status = STATUS_SUCCESS;
Irp->IoStatus.Information = 0; Irp->IoStatus.Information = 0;
/* /*
* First the non-change-sensitive ioctls * First the non-change-sensitive ioctls
*/ */
if(Code == IOCTL_DISK_GET_MEDIA_TYPES) if(Code == IOCTL_DISK_GET_MEDIA_TYPES)
{ {
PDISK_GEOMETRY Geometry = OutputBuffer; PDISK_GEOMETRY Geometry = OutputBuffer;
INFO_(FLOPPY, "IOCTL_DISK_GET_MEDIA_TYPES Called\n"); INFO_(FLOPPY, "IOCTL_DISK_GET_MEDIA_TYPES Called\n");
if(OutputLength < sizeof(DISK_GEOMETRY)) if(OutputLength < sizeof(DISK_GEOMETRY))
{ {
INFO_(FLOPPY, "IOCTL_DISK_GET_MEDIA_TYPES: insufficient buffer; returning STATUS_INVALID_PARAMETER\n"); INFO_(FLOPPY, "IOCTL_DISK_GET_MEDIA_TYPES: insufficient buffer; returning STATUS_INVALID_PARAMETER\n");
Irp->IoStatus.Status = STATUS_INVALID_PARAMETER; Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
IoCompleteRequest(Irp, IO_NO_INCREMENT); IoCompleteRequest(Irp, IO_NO_INCREMENT);
return; return;
} }
/* /*
* for now, this driver only supports 3.5" HD media * for now, this driver only supports 3.5" HD media
*/ */
Geometry->MediaType = F3_1Pt44_512; Geometry->MediaType = F3_1Pt44_512;
Geometry->Cylinders.QuadPart = 80; Geometry->Cylinders.QuadPart = 80;
Geometry->TracksPerCylinder = 2 * 18; Geometry->TracksPerCylinder = 2 * 18;
Geometry->SectorsPerTrack = 18; Geometry->SectorsPerTrack = 18;
Geometry->BytesPerSector = 512; Geometry->BytesPerSector = 512;
Irp->IoStatus.Status = STATUS_SUCCESS; Irp->IoStatus.Status = STATUS_SUCCESS;
Irp->IoStatus.Information = sizeof(DISK_GEOMETRY); Irp->IoStatus.Information = sizeof(DISK_GEOMETRY);
INFO_(FLOPPY, "Ioctl: completing with STATUS_SUCCESS\n"); INFO_(FLOPPY, "Ioctl: completing with STATUS_SUCCESS\n");
IoCompleteRequest(Irp, IO_NO_INCREMENT); IoCompleteRequest(Irp, IO_NO_INCREMENT);
return; return;
} }
/* /*
* Now, check to see if the volume needs to be verified. If so, * Now, check to see if the volume needs to be verified. If so,
* return STATUS_VERIFY_REQUIRED. * return STATUS_VERIFY_REQUIRED.
* *
* NOTE: This code, which is outside of the switch and if/else blocks, * NOTE: This code, which is outside of the switch and if/else blocks,
* will implicity catch and correctly service IOCTL_DISK_CHECK_VERIFY. * will implicity catch and correctly service IOCTL_DISK_CHECK_VERIFY.
* Therefore if we see one below in the switch, we can return STATUS_SUCCESS * Therefore if we see one below in the switch, we can return STATUS_SUCCESS
* immediately. * immediately.
*/ */
if(DriveInfo->DeviceObject->Flags & DO_VERIFY_VOLUME && !(DriveInfo->DeviceObject->Flags & SL_OVERRIDE_VERIFY_VOLUME)) if(DriveInfo->DeviceObject->Flags & DO_VERIFY_VOLUME && !(DriveInfo->DeviceObject->Flags & SL_OVERRIDE_VERIFY_VOLUME))
{ {
INFO_(FLOPPY, "DeviceIoctl(): completing with STATUS_VERIFY_REQUIRED\n"); INFO_(FLOPPY, "DeviceIoctl(): completing with STATUS_VERIFY_REQUIRED\n");
Irp->IoStatus.Status = STATUS_VERIFY_REQUIRED; Irp->IoStatus.Status = STATUS_VERIFY_REQUIRED;
Irp->IoStatus.Information = 0; Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT); IoCompleteRequest(Irp, IO_NO_INCREMENT);
return; return;
} }
/* /*
* Start the drive to see if the disk has changed * Start the drive to see if the disk has changed
*/ */
StartMotor(DriveInfo); StartMotor(DriveInfo);
/* /*
* Check the change line, and if it's set, return * Check the change line, and if it's set, return
*/ */
if(HwDiskChanged(DriveInfo, &DiskChanged) != STATUS_SUCCESS) if(HwDiskChanged(DriveInfo, &DiskChanged) != STATUS_SUCCESS)
{ {
WARN_(FLOPPY, "DeviceIoctl(): unable to sense disk change; completing with STATUS_UNSUCCESSFUL\n"); WARN_(FLOPPY, "DeviceIoctl(): unable to sense disk change; completing with STATUS_UNSUCCESSFUL\n");
Irp->IoStatus.Status = STATUS_UNSUCCESSFUL; Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
Irp->IoStatus.Information = 0; Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT); IoCompleteRequest(Irp, IO_NO_INCREMENT);
StopMotor(DriveInfo->ControllerInfo); StopMotor(DriveInfo->ControllerInfo);
return; return;
} }
if(DiskChanged) if(DiskChanged)
{ {
INFO_(FLOPPY, "DeviceIoctl(): detected disk changed; signalling media change and completing\n"); INFO_(FLOPPY, "DeviceIoctl(): detected disk changed; signalling media change and completing\n");
SignalMediaChanged(DriveInfo->DeviceObject, Irp); SignalMediaChanged(DriveInfo->DeviceObject, Irp);
/* /*
* Just guessing here - I have a choice of returning NO_MEDIA or VERIFY_REQUIRED. If there's * Just guessing here - I have a choice of returning NO_MEDIA or VERIFY_REQUIRED. If there's
* really no disk in the drive, I'm thinking I can save time by just reporting that fact, rather * really no disk in the drive, I'm thinking I can save time by just reporting that fact, rather
* than forcing windows to ask me twice. If this doesn't work, we'll need to split this up and * than forcing windows to ask me twice. If this doesn't work, we'll need to split this up and
* handle the CHECK_VERIFY IOCTL separately. * handle the CHECK_VERIFY IOCTL separately.
*/ */
if(ResetChangeFlag(DriveInfo) == STATUS_NO_MEDIA_IN_DEVICE) if(ResetChangeFlag(DriveInfo) == STATUS_NO_MEDIA_IN_DEVICE)
Irp->IoStatus.Status = STATUS_NO_MEDIA_IN_DEVICE; Irp->IoStatus.Status = STATUS_NO_MEDIA_IN_DEVICE;
IoCompleteRequest(Irp, IO_NO_INCREMENT); IoCompleteRequest(Irp, IO_NO_INCREMENT);
StopMotor(DriveInfo->ControllerInfo); StopMotor(DriveInfo->ControllerInfo);
return; return;
} }
switch(Code) switch(Code)
{ {
case IOCTL_DISK_IS_WRITABLE: case IOCTL_DISK_IS_WRITABLE:
{ {
UCHAR Status; UCHAR Status;
INFO_(FLOPPY, "IOCTL_DISK_IS_WRITABLE Called\n"); INFO_(FLOPPY, "IOCTL_DISK_IS_WRITABLE Called\n");
@ -184,93 +184,93 @@ VOID NTAPI DeviceIoctlPassive(PDRIVE_INFO DriveInfo,
Irp->IoStatus.Information = 0; Irp->IoStatus.Information = 0;
if(HwSenseDriveStatus(DriveInfo) != STATUS_SUCCESS) if(HwSenseDriveStatus(DriveInfo) != STATUS_SUCCESS)
{ {
WARN_(FLOPPY, "IoctlDiskIsWritable(): unable to sense drive status\n"); WARN_(FLOPPY, "IoctlDiskIsWritable(): unable to sense drive status\n");
Irp->IoStatus.Status = STATUS_IO_DEVICE_ERROR; Irp->IoStatus.Status = STATUS_IO_DEVICE_ERROR;
break; break;
} }
/* Now, read the drive's status back */ /* Now, read the drive's status back */
if(HwSenseDriveStatusResult(DriveInfo->ControllerInfo, &Status) != STATUS_SUCCESS) if(HwSenseDriveStatusResult(DriveInfo->ControllerInfo, &Status) != STATUS_SUCCESS)
{ {
WARN_(FLOPPY, "IoctlDiskIsWritable(): unable to read drive status result\n"); WARN_(FLOPPY, "IoctlDiskIsWritable(): unable to read drive status result\n");
Irp->IoStatus.Status = STATUS_IO_DEVICE_ERROR; Irp->IoStatus.Status = STATUS_IO_DEVICE_ERROR;
break; break;
} }
/* Check to see if the write flag is set. */ /* Check to see if the write flag is set. */
if(Status & SR3_WRITE_PROTECT_STATUS_SIGNAL) if(Status & SR3_WRITE_PROTECT_STATUS_SIGNAL)
{ {
INFO_(FLOPPY, "IOCTL_DISK_IS_WRITABLE: disk is write protected\n"); INFO_(FLOPPY, "IOCTL_DISK_IS_WRITABLE: disk is write protected\n");
Irp->IoStatus.Status = STATUS_MEDIA_WRITE_PROTECTED; Irp->IoStatus.Status = STATUS_MEDIA_WRITE_PROTECTED;
} }
else else
Irp->IoStatus.Status = STATUS_SUCCESS; Irp->IoStatus.Status = STATUS_SUCCESS;
} }
break; break;
case IOCTL_DISK_CHECK_VERIFY: case IOCTL_DISK_CHECK_VERIFY:
INFO_(FLOPPY, "IOCTL_DISK_CHECK_VERIFY called\n"); INFO_(FLOPPY, "IOCTL_DISK_CHECK_VERIFY called\n");
if (OutputLength != 0) if (OutputLength != 0)
{ {
if (OutputLength < sizeof(ULONG)) if (OutputLength < sizeof(ULONG))
{ {
Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL; Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL;
Irp->IoStatus.Information = 0; Irp->IoStatus.Information = 0;
} }
else else
{ {
*((PULONG)OutputBuffer) = DriveInfo->DiskChangeCount; *((PULONG)OutputBuffer) = DriveInfo->DiskChangeCount;
Irp->IoStatus.Status = STATUS_SUCCESS; Irp->IoStatus.Status = STATUS_SUCCESS;
Irp->IoStatus.Information = sizeof(ULONG); Irp->IoStatus.Information = sizeof(ULONG);
} }
} }
else else
{ {
Irp->IoStatus.Status = STATUS_SUCCESS; Irp->IoStatus.Status = STATUS_SUCCESS;
Irp->IoStatus.Information = 0; Irp->IoStatus.Information = 0;
} }
break; break;
case IOCTL_DISK_GET_DRIVE_GEOMETRY: case IOCTL_DISK_GET_DRIVE_GEOMETRY:
{ {
INFO_(FLOPPY, "IOCTL_DISK_GET_DRIVE_GEOMETRY Called\n"); INFO_(FLOPPY, "IOCTL_DISK_GET_DRIVE_GEOMETRY Called\n");
if(OutputLength < sizeof(DISK_GEOMETRY)) if(OutputLength < sizeof(DISK_GEOMETRY))
{ {
Irp->IoStatus.Status = STATUS_INVALID_PARAMETER; Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
break; break;
} }
/* This still works right even if DriveInfo->DiskGeometry->MediaType = Unknown */ /* This still works right even if DriveInfo->DiskGeometry->MediaType = Unknown */
memcpy(OutputBuffer, &DriveInfo->DiskGeometry, sizeof(DISK_GEOMETRY)); memcpy(OutputBuffer, &DriveInfo->DiskGeometry, sizeof(DISK_GEOMETRY));
Irp->IoStatus.Information = sizeof(DISK_GEOMETRY); Irp->IoStatus.Information = sizeof(DISK_GEOMETRY);
break; break;
} }
case IOCTL_DISK_FORMAT_TRACKS: case IOCTL_DISK_FORMAT_TRACKS:
case IOCTL_DISK_FORMAT_TRACKS_EX: case IOCTL_DISK_FORMAT_TRACKS_EX:
ERR_(FLOPPY, "Format called; not supported yet\n"); ERR_(FLOPPY, "Format called; not supported yet\n");
Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED; Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
Irp->IoStatus.Information = 0; Irp->IoStatus.Information = 0;
break; break;
case IOCTL_DISK_GET_PARTITION_INFO: case IOCTL_DISK_GET_PARTITION_INFO:
INFO_(FLOPPY, "IOCTL_DISK_GET_PARTITION_INFO Called; not supported by a floppy driver\n"); INFO_(FLOPPY, "IOCTL_DISK_GET_PARTITION_INFO Called; not supported by a floppy driver\n");
Irp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST; Irp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST;
Irp->IoStatus.Information = 0; Irp->IoStatus.Information = 0;
break; break;
default: default:
ERR_(FLOPPY, "UNKNOWN IOCTL CODE: 0x%x\n", Code); ERR_(FLOPPY, "UNKNOWN IOCTL CODE: 0x%x\n", Code);
Irp->IoStatus.Status = STATUS_NOT_SUPPORTED; Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
Irp->IoStatus.Information = 0; Irp->IoStatus.Information = 0;
break; break;
} }
INFO_(FLOPPY, "ioctl: completing with status 0x%x\n", Irp->IoStatus.Status); INFO_(FLOPPY, "ioctl: completing with status 0x%x\n", Irp->IoStatus.Status);
IoCompleteRequest(Irp, IO_NO_INCREMENT); IoCompleteRequest(Irp, IO_NO_INCREMENT);
StopMotor(DriveInfo->ControllerInfo); StopMotor(DriveInfo->ControllerInfo);
return; return;
} }

View file

@ -25,9 +25,10 @@
*/ */
DRIVER_DISPATCH DeviceIoctl; DRIVER_DISPATCH DeviceIoctl;
NTSTATUS NTAPI DeviceIoctl(PDEVICE_OBJECT DeviceObject,
PIRP Irp);
VOID NTAPI DeviceIoctlPassive(PDRIVE_INFO DriveInfo, NTSTATUS NTAPI
PIRP Irp); DeviceIoctl(PDEVICE_OBJECT DeviceObject, PIRP Irp);
VOID NTAPI
DeviceIoctlPassive(PDRIVE_INFO DriveInfo, PIRP Irp);

File diff suppressed because it is too large Load diff

View file

@ -25,8 +25,10 @@
*/ */
DRIVER_DISPATCH ReadWrite; DRIVER_DISPATCH ReadWrite;
NTSTATUS NTAPI ReadWrite(PDEVICE_OBJECT DeviceObject,
PIRP Irp);
VOID NTAPI ReadWritePassive(PDRIVE_INFO DriveInfo, PIRP Irp); NTSTATUS NTAPI
ReadWrite(PDEVICE_OBJECT DeviceObject, PIRP Irp);
VOID NTAPI
ReadWritePassive(PDRIVE_INFO DriveInfo, PIRP Irp);