Silent debug messages

svn path=/trunk/; revision=16210
This commit is contained in:
Hervé Poussineau 2005-06-21 21:35:07 +00:00
parent c9d742f6cf
commit a6d58d5291
6 changed files with 192 additions and 203 deletions

View file

@ -38,6 +38,8 @@
* that my lock choice is a spin lock. * that my lock choice is a spin lock.
*/ */
#define NDEBUG
#include <debug.h>
#include <ntddk.h> #include <ntddk.h>
#include "floppy.h" #include "floppy.h"
@ -68,7 +70,7 @@ VOID NTAPI CsqRemoveIrp(PIO_CSQ UnusedCsq,
*/ */
{ {
UNREFERENCED_PARAMETER(UnusedCsq); UNREFERENCED_PARAMETER(UnusedCsq);
KdPrint(("CSQ: Removing IRP 0x%x\n", Irp)); DPRINT(("CSQ: Removing IRP 0x%x\n", Irp));
RemoveEntryList(&Irp->Tail.Overlay.ListEntry); RemoveEntryList(&Irp->Tail.Overlay.ListEntry);
} }
@ -91,7 +93,7 @@ PIRP NTAPI CsqPeekNextIrp(PIO_CSQ UnusedCsq,
{ {
UNREFERENCED_PARAMETER(UnusedCsq); UNREFERENCED_PARAMETER(UnusedCsq);
UNREFERENCED_PARAMETER(PeekContext); UNREFERENCED_PARAMETER(PeekContext);
KdPrint(("CSQ: Peeking for next IRP\n")); DPRINT(("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);
@ -113,7 +115,7 @@ VOID NTAPI CsqAcquireLock(PIO_CSQ UnusedCsq,
*/ */
{ {
UNREFERENCED_PARAMETER(UnusedCsq); UNREFERENCED_PARAMETER(UnusedCsq);
KdPrint(("CSQ: Acquiring spin lock\n")); DPRINT(("CSQ: Acquiring spin lock\n"));
KeAcquireSpinLock(&IrpQueueLock, Irql); KeAcquireSpinLock(&IrpQueueLock, Irql);
} }
@ -128,7 +130,7 @@ VOID NTAPI CsqReleaseLock(PIO_CSQ UnusedCsq,
*/ */
{ {
UNREFERENCED_PARAMETER(UnusedCsq); UNREFERENCED_PARAMETER(UnusedCsq);
KdPrint(("CSQ: Releasing spin lock\n")); DPRINT(("CSQ: Releasing spin lock\n"));
KeReleaseSpinLock(&IrpQueueLock, Irql); KeReleaseSpinLock(&IrpQueueLock, Irql);
} }
@ -146,7 +148,7 @@ VOID NTAPI CsqCompleteCanceledIrp(PIO_CSQ UnusedCsq,
*/ */
{ {
UNREFERENCED_PARAMETER(UnusedCsq); UNREFERENCED_PARAMETER(UnusedCsq);
KdPrint(("CSQ: Canceling irp 0x%x\n", Irp)); DPRINT(("CSQ: Canceling irp 0x%x\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);
@ -171,7 +173,7 @@ VOID NTAPI CsqInsertIrp(PIO_CSQ UnusedCsq,
*/ */
{ {
UNREFERENCED_PARAMETER(UnusedCsq); UNREFERENCED_PARAMETER(UnusedCsq);
KdPrint(("CSQ: Inserting IRP 0x%x\n", Irp)); DPRINT(("CSQ: Inserting IRP 0x%x\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

@ -40,6 +40,8 @@
* TODO: Media detection based on sector 1 * TODO: Media detection based on sector 1
*/ */
#define NDEBUG
#include <debug.h>
#include <ntddk.h> #include <ntddk.h>
#include "floppy.h" #include "floppy.h"
@ -86,7 +88,7 @@ static VOID NTAPI MotorStopDpcFunc(PKDPC UnusedDpc,
ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL); ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL);
ASSERT(ControllerInfo); ASSERT(ControllerInfo);
KdPrint(("floppy: MotorStopDpcFunc called\n")); DPRINT(("floppy: MotorStopDpcFunc called\n"));
HwTurnOffMotor(ControllerInfo); HwTurnOffMotor(ControllerInfo);
ControllerInfo->StopDpcQueued = FALSE; ControllerInfo->StopDpcQueued = FALSE;
@ -113,20 +115,22 @@ VOID NTAPI StartMotor(PDRIVE_INFO DriveInfo)
PAGED_CODE(); PAGED_CODE();
ASSERT(DriveInfo); ASSERT(DriveInfo);
KdPrint(("floppy: StartMotor called\n")); DPRINT(("floppy: StartMotor called\n"));
if(DriveInfo->ControllerInfo->StopDpcQueued && !KeCancelTimer(&DriveInfo->ControllerInfo->MotorTimer)) if(DriveInfo->ControllerInfo->StopDpcQueued && !KeCancelTimer(&DriveInfo->ControllerInfo->MotorTimer))
{ {
/* Motor turner-offer is already running; wait for it to finish */ /* Motor turner-offer is already running; wait for it to finish */
KdPrint(("floppy: StartMotor: motor turner-offer is already running; waiting for it\n")); DPRINT(("floppy: StartMotor: motor turner-offer is already running; waiting for it\n"));
KeWaitForSingleObject(&DriveInfo->ControllerInfo->MotorStoppedEvent, Executive, KernelMode, FALSE, NULL); KeWaitForSingleObject(&DriveInfo->ControllerInfo->MotorStoppedEvent, Executive, KernelMode, FALSE, NULL);
KdPrint(("floppy: StartMotor: wait satisfied\n")); DPRINT(("floppy: StartMotor: wait satisfied\n"));
} }
DriveInfo->ControllerInfo->StopDpcQueued = FALSE; DriveInfo->ControllerInfo->StopDpcQueued = FALSE;
if(HwTurnOnMotor(DriveInfo) != STATUS_SUCCESS) if(HwTurnOnMotor(DriveInfo) != STATUS_SUCCESS)
KdPrint(("floppy: StartMotor(): warning: HwTurnOnMotor failed\n")); {
DPRINT(("floppy: StartMotor(): warning: HwTurnOnMotor failed\n"));
}
} }
@ -145,7 +149,7 @@ VOID NTAPI StopMotor(PCONTROLLER_INFO ControllerInfo)
ASSERT(ControllerInfo); ASSERT(ControllerInfo);
KdPrint(("floppy: StopMotor called\n")); DPRINT(("floppy: StopMotor called\n"));
/* one relative second, in 100-ns units */ /* one relative second, in 100-ns units */
StopTime.QuadPart = 10000000; StopTime.QuadPart = 10000000;
@ -198,7 +202,7 @@ static NTSTATUS NTAPI CreateClose(PDEVICE_OBJECT DeviceObject,
{ {
UNREFERENCED_PARAMETER(DeviceObject); UNREFERENCED_PARAMETER(DeviceObject);
KdPrint(("floppy: CreateClose called\n")); DPRINT(("floppy: CreateClose called\n"));
Irp->IoStatus.Status = STATUS_SUCCESS; Irp->IoStatus.Status = STATUS_SUCCESS;
Irp->IoStatus.Information = FILE_OPENED; Irp->IoStatus.Information = FILE_OPENED;
@ -233,10 +237,10 @@ static NTSTATUS NTAPI Recalibrate(PDRIVE_INFO DriveInfo)
StartMotor(DriveInfo); StartMotor(DriveInfo);
/* set the data rate */ /* set the data rate */
KdPrint(("floppy: FIXME: UN-HARDCODE DATA RATE\n")); DPRINT(("floppy: FIXME: UN-HARDCODE DATA RATE\n"));
if(HwSetDataRate(DriveInfo->ControllerInfo, 0) != STATUS_SUCCESS) if(HwSetDataRate(DriveInfo->ControllerInfo, 0) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: Recalibrate: HwSetDataRate failed\n")); DPRINT(("floppy: Recalibrate: HwSetDataRate failed\n"));
StopMotor(DriveInfo->ControllerInfo); StopMotor(DriveInfo->ControllerInfo);
return STATUS_IO_DEVICE_ERROR; return STATUS_IO_DEVICE_ERROR;
} }
@ -254,7 +258,7 @@ static NTSTATUS NTAPI Recalibrate(PDRIVE_INFO DriveInfo)
Status = HwRecalibrate(DriveInfo); Status = HwRecalibrate(DriveInfo);
if(Status != STATUS_SUCCESS) if(Status != STATUS_SUCCESS)
{ {
KdPrint(("floppy: Recalibrate: HwRecalibrate returned error\n")); DPRINT(("floppy: Recalibrate: HwRecalibrate returned error\n"));
continue; continue;
} }
@ -264,7 +268,7 @@ static NTSTATUS NTAPI Recalibrate(PDRIVE_INFO DriveInfo)
Status = HwRecalibrateResult(DriveInfo->ControllerInfo); Status = HwRecalibrateResult(DriveInfo->ControllerInfo);
if(Status != STATUS_SUCCESS) if(Status != STATUS_SUCCESS)
{ {
KdPrint(("floppy: Recalibrate: HwRecalibrateResult returned error\n")); DPRINT(("floppy: Recalibrate: HwRecalibrateResult returned error\n"));
break; break;
} }
} }
@ -299,7 +303,7 @@ NTSTATUS NTAPI ResetChangeFlag(PDRIVE_INFO DriveInfo)
PAGED_CODE(); PAGED_CODE();
ASSERT(DriveInfo); ASSERT(DriveInfo);
KdPrint(("floppy: ResetChangeFlag called\n")); DPRINT(("floppy: ResetChangeFlag called\n"));
/* Try to recalibrate. We don't care if it works. */ /* Try to recalibrate. We don't care if it works. */
Recalibrate(DriveInfo); Recalibrate(DriveInfo);
@ -313,7 +317,7 @@ NTSTATUS NTAPI ResetChangeFlag(PDRIVE_INFO DriveInfo)
/* Seek to 1 */ /* Seek to 1 */
if(HwSeek(DriveInfo, 1) != STATUS_SUCCESS) if(HwSeek(DriveInfo, 1) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: ResetChangeFlag(): HwSeek failed; returning STATUS_IO_DEVICE_ERROR\n")); DPRINT(("floppy: ResetChangeFlag(): HwSeek failed; returning STATUS_IO_DEVICE_ERROR\n"));
StopMotor(DriveInfo->ControllerInfo); StopMotor(DriveInfo->ControllerInfo);
return STATUS_IO_DEVICE_ERROR; return STATUS_IO_DEVICE_ERROR;
} }
@ -322,7 +326,7 @@ NTSTATUS NTAPI ResetChangeFlag(PDRIVE_INFO DriveInfo)
if(HwSenseInterruptStatus(DriveInfo->ControllerInfo) != STATUS_SUCCESS) if(HwSenseInterruptStatus(DriveInfo->ControllerInfo) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: ResetChangeFlag(): HwSenseInterruptStatus failed; bailing out\n")); DPRINT(("floppy: ResetChangeFlag(): HwSenseInterruptStatus failed; bailing out\n"));
StopMotor(DriveInfo->ControllerInfo); StopMotor(DriveInfo->ControllerInfo);
return STATUS_IO_DEVICE_ERROR; return STATUS_IO_DEVICE_ERROR;
} }
@ -330,7 +334,7 @@ NTSTATUS NTAPI ResetChangeFlag(PDRIVE_INFO DriveInfo)
/* Seek back to 0 */ /* Seek back to 0 */
if(HwSeek(DriveInfo, 0) != STATUS_SUCCESS) if(HwSeek(DriveInfo, 0) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: ResetChangeFlag(): HwSeek failed; returning STATUS_IO_DEVICE_ERROR\n")); DPRINT(("floppy: ResetChangeFlag(): HwSeek failed; returning STATUS_IO_DEVICE_ERROR\n"));
StopMotor(DriveInfo->ControllerInfo); StopMotor(DriveInfo->ControllerInfo);
return STATUS_IO_DEVICE_ERROR; return STATUS_IO_DEVICE_ERROR;
} }
@ -339,7 +343,7 @@ NTSTATUS NTAPI ResetChangeFlag(PDRIVE_INFO DriveInfo)
if(HwSenseInterruptStatus(DriveInfo->ControllerInfo) != STATUS_SUCCESS) if(HwSenseInterruptStatus(DriveInfo->ControllerInfo) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: ResetChangeFlag(): HwSenseInterruptStatus #2 failed; bailing\n")); DPRINT(("floppy: ResetChangeFlag(): HwSenseInterruptStatus #2 failed; bailing\n"));
StopMotor(DriveInfo->ControllerInfo); StopMotor(DriveInfo->ControllerInfo);
return STATUS_IO_DEVICE_ERROR; return STATUS_IO_DEVICE_ERROR;
} }
@ -347,7 +351,7 @@ NTSTATUS NTAPI ResetChangeFlag(PDRIVE_INFO DriveInfo)
/* Check the change bit */ /* Check the change bit */
if(HwDiskChanged(DriveInfo, &DiskChanged) != STATUS_SUCCESS) if(HwDiskChanged(DriveInfo, &DiskChanged) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: ResetChangeFlag(): HwDiskChagned failed; returning STATUS_IO_DEVICE_ERROR\n")); DPRINT(("floppy: ResetChangeFlag(): HwDiskChagned failed; returning STATUS_IO_DEVICE_ERROR\n"));
StopMotor(DriveInfo->ControllerInfo); StopMotor(DriveInfo->ControllerInfo);
return STATUS_IO_DEVICE_ERROR; return STATUS_IO_DEVICE_ERROR;
} }
@ -375,7 +379,7 @@ static VOID NTAPI Unload(PDRIVER_OBJECT DriverObject)
PAGED_CODE(); PAGED_CODE();
UNREFERENCED_PARAMETER(DriverObject); UNREFERENCED_PARAMETER(DriverObject);
KdPrint(("floppy: unloading\n")); DPRINT(("floppy: unloading\n"));
KeSetEvent(&QueueThreadTerminate, 0, FALSE); KeSetEvent(&QueueThreadTerminate, 0, FALSE);
KeWaitForSingleObject(QueueThreadObject, Executive, KernelMode, FALSE, 0); KeWaitForSingleObject(QueueThreadObject, Executive, KernelMode, FALSE, 0);
@ -409,7 +413,9 @@ static VOID NTAPI Unload(PDRIVER_OBJECT DriverObject)
/* Power down the controller */ /* Power down the controller */
if(HwPowerOff(&gControllerInfo[i]) != STATUS_SUCCESS) if(HwPowerOff(&gControllerInfo[i]) != STATUS_SUCCESS)
KdPrint(("floppy: unload: warning: HwPowerOff failed\n")); {
DPRINT(("floppy: unload: warning: HwPowerOff failed\n"));
}
} }
} }
@ -477,7 +483,7 @@ static NTSTATUS NTAPI ConfigCallback(PVOID Context,
UNREFERENCED_PARAMETER(PathName); UNREFERENCED_PARAMETER(PathName);
KdPrint(("floppy: ConfigCallback called with ControllerNumber %d\n", ControllerNumber)); DPRINT(("floppy: ConfigCallback called with ControllerNumber %d\n", ControllerNumber));
gControllerInfo[gNumberOfControllers].ControllerNumber = ControllerNumber; gControllerInfo[gNumberOfControllers].ControllerNumber = ControllerNumber;
gControllerInfo[gNumberOfControllers].InterfaceType = BusType; gControllerInfo[gNumberOfControllers].InterfaceType = BusType;
@ -508,7 +514,7 @@ static NTSTATUS NTAPI ConfigCallback(PVOID Context,
if(!HalTranslateBusAddress(BusType, BusNumber, PartialDescriptor->u.Port.Start, &AddressSpace, &TranslatedAddress)) if(!HalTranslateBusAddress(BusType, BusNumber, PartialDescriptor->u.Port.Start, &AddressSpace, &TranslatedAddress))
{ {
KdPrint(("floppy: HalTranslateBusAddress failed; returning\n")); DPRINT(("floppy: HalTranslateBusAddress failed; returning\n"));
return STATUS_IO_DEVICE_ERROR; return STATUS_IO_DEVICE_ERROR;
} }
@ -600,7 +606,7 @@ static BOOLEAN NTAPI Isr(PKINTERRUPT Interrupt,
ASSERT(ControllerInfo); ASSERT(ControllerInfo);
KdPrint(("floppy: ISR called\n")); DPRINT(("floppy: ISR called\n"));
/* /*
* Due to the stupidity of the drive/controller relationship on the floppy drive, only one device object * Due to the stupidity of the drive/controller relationship on the floppy drive, only one device object
@ -644,7 +650,7 @@ VOID NTAPI DpcForIsr(PKDPC UnusedDpc,
ASSERT(ControllerInfo); ASSERT(ControllerInfo);
KdPrint(("floppy: DpcForIsr called\n")); DPRINT(("floppy: DpcForIsr called\n"));
KeSetEvent(&ControllerInfo->SynchEvent, EVENT_INCREMENT, FALSE); KeSetEvent(&ControllerInfo->SynchEvent, EVENT_INCREMENT, FALSE);
} }
@ -668,29 +674,29 @@ static NTSTATUS NTAPI InitController(PCONTROLLER_INFO ControllerInfo)
PAGED_CODE(); PAGED_CODE();
ASSERT(ControllerInfo); ASSERT(ControllerInfo);
KdPrint(("floppy: InitController called with Controller 0x%x\n", ControllerInfo)); DPRINT(("floppy: InitController called with Controller 0x%x\n", ControllerInfo));
KeClearEvent(&ControllerInfo->SynchEvent); KeClearEvent(&ControllerInfo->SynchEvent);
KdPrint(("floppy: InitController: resetting the controller\n")); DPRINT(("floppy: InitController: resetting the controller\n"));
/* Reset the controller */ /* Reset the controller */
if(HwReset(ControllerInfo) != STATUS_SUCCESS) if(HwReset(ControllerInfo) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: InitController: unable to reset controller\n")); DPRINT(("floppy: InitController: unable to reset controller\n"));
return STATUS_IO_DEVICE_ERROR; return STATUS_IO_DEVICE_ERROR;
} }
KdPrint(("floppy: InitController: setting data rate\n")); DPRINT(("floppy: InitController: setting data rate\n"));
/* Set data rate */ /* Set data rate */
if(HwSetDataRate(ControllerInfo, DRSR_DSEL_500KBPS) != STATUS_SUCCESS) if(HwSetDataRate(ControllerInfo, DRSR_DSEL_500KBPS) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: InitController: unable to set data rate\n")); DPRINT(("floppy: InitController: unable to set data rate\n"));
return STATUS_IO_DEVICE_ERROR; return STATUS_IO_DEVICE_ERROR;
} }
KdPrint(("floppy: InitController: waiting for initial interrupt\n")); DPRINT(("floppy: InitController: waiting for initial interrupt\n"));
/* Wait for an interrupt */ /* Wait for an interrupt */
WaitForControllerInterrupt(ControllerInfo); WaitForControllerInterrupt(ControllerInfo);
@ -698,16 +704,16 @@ static NTSTATUS NTAPI InitController(PCONTROLLER_INFO ControllerInfo)
/* Reset means you have to clear each of the four interrupts (one per drive) */ /* Reset means you have to clear each of the four interrupts (one per drive) */
for(i = 0; i < MAX_DRIVES_PER_CONTROLLER; i++) for(i = 0; i < MAX_DRIVES_PER_CONTROLLER; i++)
{ {
KdPrint(("floppy: InitController: Sensing interrupt %d\n", i)); DPRINT(("floppy: InitController: Sensing interrupt %d\n", i));
if(HwSenseInterruptStatus(ControllerInfo) != STATUS_SUCCESS) if(HwSenseInterruptStatus(ControllerInfo) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: InitController: Unable to clear interrupt 0x%x\n", i)); DPRINT(("floppy: InitController: Unable to clear interrupt 0x%x\n", i));
return STATUS_IO_DEVICE_ERROR; return STATUS_IO_DEVICE_ERROR;
} }
} }
KdPrint(("floppy: InitController: done sensing interrupts\n")); DPRINT(("floppy: InitController: done sensing interrupts\n"));
/* Next, see if we have the right version to do implied seek */ /* Next, see if we have the right version to do implied seek */
if(HwGetVersion(ControllerInfo) == VERSION_ENHANCED) if(HwGetVersion(ControllerInfo) == VERSION_ENHANCED)
@ -715,12 +721,12 @@ static NTSTATUS NTAPI InitController(PCONTROLLER_INFO ControllerInfo)
/* If so, set that up -- all defaults below except first TRUE for EIS */ /* If so, set that up -- all defaults below except first TRUE for EIS */
if(HwConfigure(ControllerInfo, TRUE, TRUE, FALSE, 0, 0) != STATUS_SUCCESS) if(HwConfigure(ControllerInfo, TRUE, TRUE, FALSE, 0, 0) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: InitController: unable to set up implied seek\n")); DPRINT(("floppy: InitController: unable to set up implied seek\n"));
ControllerInfo->ImpliedSeeks = FALSE; ControllerInfo->ImpliedSeeks = FALSE;
} }
else else
{ {
KdPrint(("floppy: InitController: implied seeks set!\n")); DPRINT(("floppy: InitController: implied seeks set!\n"));
ControllerInfo->ImpliedSeeks = TRUE; ControllerInfo->ImpliedSeeks = TRUE;
} }
@ -747,23 +753,23 @@ static NTSTATUS NTAPI InitController(PCONTROLLER_INFO ControllerInfo)
} }
else else
{ {
KdPrint(("floppy: InitController: enhanced version not supported; disabling implied seeks\n")); DPRINT(("floppy: InitController: enhanced version not supported; disabling implied seeks\n"));
ControllerInfo->ImpliedSeeks = FALSE; ControllerInfo->ImpliedSeeks = FALSE;
ControllerInfo->Model30 = FALSE; ControllerInfo->Model30 = FALSE;
} }
/* Specify */ /* Specify */
KdPrint(("FLOPPY: FIXME: Figure out speed\n")); DPRINT(("FLOPPY: FIXME: Figure out speed\n"));
HeadLoadTime = SPECIFY_HLT_500K; HeadLoadTime = SPECIFY_HLT_500K;
HeadUnloadTime = SPECIFY_HUT_500K; HeadUnloadTime = SPECIFY_HUT_500K;
StepRateTime = SPECIFY_SRT_500K; StepRateTime = SPECIFY_SRT_500K;
KdPrint(("floppy: InitController: issuing specify command to controller\n")); DPRINT(("floppy: InitController: issuing specify command to controller\n"));
/* Don't disable DMA --> enable dma (dumb & confusing) */ /* Don't disable DMA --> enable dma (dumb & confusing) */
if(HwSpecify(ControllerInfo, HeadLoadTime, HeadUnloadTime, StepRateTime, FALSE) != STATUS_SUCCESS) if(HwSpecify(ControllerInfo, HeadLoadTime, HeadUnloadTime, StepRateTime, FALSE) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: InitController: unable to specify options\n")); DPRINT(("floppy: InitController: unable to specify options\n"));
return STATUS_IO_DEVICE_ERROR; return STATUS_IO_DEVICE_ERROR;
} }
@ -779,11 +785,11 @@ static NTSTATUS NTAPI InitController(PCONTROLLER_INFO ControllerInfo)
*/ */
for(i = 0; i < ControllerInfo->NumberOfDrives; i++) for(i = 0; i < ControllerInfo->NumberOfDrives; i++)
{ {
KdPrint(("floppy: InitController: recalibrating drive 0x%x on controller 0x%x\n", i, ControllerInfo)); DPRINT(("floppy: InitController: recalibrating drive 0x%x on controller 0x%x\n", i, ControllerInfo));
Recalibrate(&ControllerInfo->DriveInfo[i]); Recalibrate(&ControllerInfo->DriveInfo[i]);
} }
KdPrint(("floppy: InitController: done initializing; returning STATUS_SUCCESS\n")); DPRINT(("floppy: InitController: done initializing; returning STATUS_SUCCESS\n"));
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
@ -825,7 +831,7 @@ static BOOLEAN NTAPI AddControllers(PDRIVER_OBJECT DriverObject)
*/ */
if(!gControllerInfo[0].Populated) if(!gControllerInfo[0].Populated)
{ {
KdPrint(("floppy: AddControllers: failed to get controller info from registry\n")); DPRINT(("floppy: AddControllers: failed to get controller info from registry\n"));
return FALSE; return FALSE;
} }
@ -843,7 +849,7 @@ static BOOLEAN NTAPI AddControllers(PDRIVER_OBJECT DriverObject)
/* Must set up the DPC before we connect the interrupt */ /* Must set up the DPC before we connect the interrupt */
KeInitializeDpc(&gControllerInfo[i].Dpc, DpcForIsr, &gControllerInfo[i]); KeInitializeDpc(&gControllerInfo[i].Dpc, DpcForIsr, &gControllerInfo[i]);
KdPrint(("floppy: Connecting interrupt %d to controller%d (object 0x%x)\n", gControllerInfo[i].MappedVector, DPRINT(("floppy: Connecting interrupt %d to controller%d (object 0x%x)\n", gControllerInfo[i].MappedVector,
i, &gControllerInfo[i])); i, &gControllerInfo[i]));
/* NOTE: We cannot share our interrupt, even on level-triggered buses. See Isr() for details. */ /* NOTE: We cannot share our interrupt, even on level-triggered buses. See Isr() for details. */
@ -851,7 +857,7 @@ static BOOLEAN NTAPI AddControllers(PDRIVER_OBJECT DriverObject)
gControllerInfo[i].MappedLevel, gControllerInfo[i].MappedLevel, gControllerInfo[i].InterruptMode, gControllerInfo[i].MappedLevel, gControllerInfo[i].MappedLevel, gControllerInfo[i].InterruptMode,
FALSE, Affinity, 0) != STATUS_SUCCESS) FALSE, Affinity, 0) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: AddControllers: unable to connect interrupt\n")); DPRINT(("floppy: AddControllers: unable to connect interrupt\n"));
continue; continue;
} }
@ -870,7 +876,7 @@ static BOOLEAN NTAPI AddControllers(PDRIVER_OBJECT DriverObject)
if(!gControllerInfo[i].AdapterObject) if(!gControllerInfo[i].AdapterObject)
{ {
KdPrint(("floppy: AddControllers: unable to allocate an adapter object\n")); DPRINT(("floppy: AddControllers: unable to allocate an adapter object\n"));
IoDisconnectInterrupt(gControllerInfo[i].InterruptObject); IoDisconnectInterrupt(gControllerInfo[i].InterruptObject);
continue; continue;
} }
@ -878,7 +884,7 @@ static BOOLEAN NTAPI AddControllers(PDRIVER_OBJECT DriverObject)
/* 2b: Initialize the new controller */ /* 2b: Initialize the new controller */
if(InitController(&gControllerInfo[i]) != STATUS_SUCCESS) if(InitController(&gControllerInfo[i]) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: AddControllers():Unable to set up controller %d - initialization failed\n", i)); DPRINT(("floppy: AddControllers():Unable to set up controller %d - initialization failed\n", i));
IoDisconnectInterrupt(gControllerInfo[i].InterruptObject); IoDisconnectInterrupt(gControllerInfo[i].InterruptObject);
continue; continue;
} }
@ -895,7 +901,7 @@ static BOOLEAN NTAPI AddControllers(PDRIVER_OBJECT DriverObject)
UNICODE_STRING ArcPath; UNICODE_STRING ArcPath;
UCHAR DriveNumber; UCHAR DriveNumber;
KdPrint(("floppy: AddControllers(): Configuring drive %d on controller %d\n", i, j)); DPRINT(("floppy: AddControllers(): Configuring drive %d on controller %d\n", i, j));
/* /*
* 3a: create a device object for the drive * 3a: create a device object for the drive
@ -919,12 +925,12 @@ static BOOLEAN NTAPI AddControllers(PDRIVER_OBJECT DriverObject)
FILE_DEVICE_DISK, FILE_REMOVABLE_MEDIA | FILE_FLOPPY_DISKETTE, FALSE, FILE_DEVICE_DISK, FILE_REMOVABLE_MEDIA | FILE_FLOPPY_DISKETTE, FALSE,
&gControllerInfo[i].DriveInfo[j].DeviceObject) != STATUS_SUCCESS) &gControllerInfo[i].DriveInfo[j].DeviceObject) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: AddControllers: unable to register a Device object\n")); DPRINT(("floppy: AddControllers: unable to register a Device object\n"));
IoDisconnectInterrupt(gControllerInfo[i].InterruptObject); IoDisconnectInterrupt(gControllerInfo[i].InterruptObject);
continue; /* continue on to next drive */ continue; /* continue on to next drive */
} }
KdPrint(("floppy: AddControllers: New device: %S (0x%x)\n", DeviceNameBuf, gControllerInfo[i].DriveInfo[j].DeviceObject)); DPRINT(("floppy: AddControllers: New device: %S (0x%x)\n", DeviceNameBuf, gControllerInfo[i].DriveInfo[j].DeviceObject));
/* 3b.5: Create an ARC path in case we're booting from this drive */ /* 3b.5: Create an ARC path in case we're booting from this drive */
swprintf(gControllerInfo[i].DriveInfo[j].ArcPathBuffer, swprintf(gControllerInfo[i].DriveInfo[j].ArcPathBuffer,
@ -941,7 +947,7 @@ static BOOLEAN NTAPI AddControllers(PDRIVER_OBJECT DriverObject)
RtlInitUnicodeString(&LinkName, gControllerInfo[i].DriveInfo[j].SymLinkBuffer); RtlInitUnicodeString(&LinkName, gControllerInfo[i].DriveInfo[j].SymLinkBuffer);
if(IoCreateSymbolicLink(&LinkName, &DeviceName) != STATUS_SUCCESS) if(IoCreateSymbolicLink(&LinkName, &DeviceName) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: AddControllers: Unable to create a symlink for drive %d\n", DriveNumber)); DPRINT(("floppy: AddControllers: Unable to create a symlink for drive %d\n", DriveNumber));
IoDisconnectInterrupt(gControllerInfo[i].InterruptObject); IoDisconnectInterrupt(gControllerInfo[i].InterruptObject);
IoDeassignArcName(&ArcPath); IoDeassignArcName(&ArcPath);
continue; /* continue to next drive */ continue; /* continue to next drive */
@ -964,7 +970,7 @@ static BOOLEAN NTAPI AddControllers(PDRIVER_OBJECT DriverObject)
} }
} }
KdPrint(("floppy: AddControllers: --------------------------------------------> finished adding controllers\n")); DPRINT(("floppy: AddControllers: --------------------------------------------> finished adding controllers\n"));
return TRUE; return TRUE;
} }
@ -985,7 +991,7 @@ VOID NTAPI SignalMediaChanged(PDEVICE_OBJECT DeviceObject,
{ {
PDRIVE_INFO DriveInfo = DeviceObject->DeviceExtension; PDRIVE_INFO DriveInfo = DeviceObject->DeviceExtension;
KdPrint(("floppy: SignalMediaChanged called\n")); DPRINT(("floppy: SignalMediaChanged called\n"));
DriveInfo->DiskChangeCount++; DriveInfo->DiskChangeCount++;
@ -1038,18 +1044,18 @@ static VOID NTAPI QueueThread(PVOID Context)
if(KeReadStateEvent(&QueueThreadTerminate)) if(KeReadStateEvent(&QueueThreadTerminate))
{ {
KdPrint(("floppy: QueueThread terminating\n")); DPRINT(("floppy: QueueThread terminating\n"));
return; return;
} }
KdPrint(("floppy: QueueThread: servicing an IRP\n")); DPRINT(("floppy: QueueThread: servicing an IRP\n"));
Irp = IoCsqRemoveNextIrp(&Csq, 0); Irp = IoCsqRemoveNextIrp(&Csq, 0);
/* we won't get an irp if it was canceled */ /* we won't get an irp if it was canceled */
if(!Irp) if(!Irp)
{ {
KdPrint(("floppy: QueueThread: IRP queue empty\n")); DPRINT(("floppy: QueueThread: IRP queue empty\n"));
continue; continue;
} }
@ -1072,7 +1078,7 @@ static VOID NTAPI QueueThread(PVOID Context)
break; break;
default: default:
KdPrint(("floppy: QueueThread(): Unrecognized irp: mj: 0x%x\n", Stack->MajorFunction)); DPRINT(("floppy: QueueThread(): Unrecognized irp: mj: 0x%x\n", Stack->MajorFunction));
Irp->IoStatus.Status = STATUS_NOT_SUPPORTED; Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
Irp->IoStatus.Information = 0; Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT); IoCompleteRequest(Irp, IO_NO_INCREMENT);
@ -1149,13 +1155,13 @@ NTSTATUS NTAPI DriverEntry(PDRIVER_OBJECT DriverObject,
*/ */
if(PsCreateSystemThread(&ThreadHandle, 0, 0, 0, 0, QueueThread, 0) != STATUS_SUCCESS) if(PsCreateSystemThread(&ThreadHandle, 0, 0, 0, 0, QueueThread, 0) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: Unable to create system thread; failing init\n")); DPRINT(("floppy: Unable to create system thread; failing init\n"));
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
} }
if(ObReferenceObjectByHandle(ThreadHandle, STANDARD_RIGHTS_ALL, NULL, KernelMode, &QueueThreadObject, NULL) != STATUS_SUCCESS) if(ObReferenceObjectByHandle(ThreadHandle, STANDARD_RIGHTS_ALL, NULL, KernelMode, &QueueThreadObject, NULL) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: Unable to reference returned thread handle; failing init\n")); DPRINT(("floppy: Unable to reference returned thread handle; failing init\n"));
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }

View file

@ -35,32 +35,6 @@ int _cdecl swprintf(const WCHAR *, ...);
/* need ioctls in ddk build mode */ /* need ioctls in ddk build mode */
#include <ntdddisk.h> #include <ntdddisk.h>
/* missing from ros headers */
/* TODO: fix this right */
#ifndef KdPrint
#if 0
#define KdPrint(x) DbgPrint x
#else
#define KdPrint(x)
#endif
#endif
#ifndef ASSERT
#define ASSERT(x) { if(!(x)) __asm__("int $3\n"); }
#endif
#ifndef assert
#define assert(x) ASSERT(x)
#endif
#ifndef PAGED_CODE
#define PAGED_CODE() {ASSERT(KeGetCurrentIrql() < DISPATCH_LEVEL);}
#endif
#ifndef UNREFERENCED_PARAMETER
#define UNREFERENCED_PARAMETER(x) { (x) = (x); }
#endif
struct _CONTROLLER_INFO; struct _CONTROLLER_INFO;
typedef struct _DRIVE_INFO typedef struct _DRIVE_INFO

View file

@ -48,6 +48,8 @@
* TODO: Figure out the right delays in Send_Byte and Get_Byte * TODO: Figure out the right delays in Send_Byte and Get_Byte
*/ */
#define NDEBUG
#include <debug.h>
#include <ntddk.h> #include <ntddk.h>
#include "floppy.h" #include "floppy.h"
@ -181,7 +183,7 @@ static NTSTATUS NTAPI Send_Byte(PCONTROLLER_INFO ControllerInfo,
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
KdPrint(("floppy: Send_Byte: timed out trying to write\n")); DPRINT(("floppy: Send_Byte: timed out trying to write\n"));
HwDumpRegisters(ControllerInfo); HwDumpRegisters(ControllerInfo);
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
@ -250,7 +252,7 @@ static NTSTATUS NTAPI Get_Byte(PCONTROLLER_INFO ControllerInfo,
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
KdPrint(("floppy: Get_Byte: timed out trying to read\n")); DPRINT(("floppy: Get_Byte: timed out trying to read\n"));
HwDumpRegisters(ControllerInfo); HwDumpRegisters(ControllerInfo);
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
@ -267,7 +269,7 @@ NTSTATUS NTAPI HwSetDataRate(PCONTROLLER_INFO ControllerInfo,
* STATUS_SUCCESS * STATUS_SUCCESS
*/ */
{ {
KdPrint(("floppy: HwSetDataRate called; writing rate code 0x%x to offset 0x%x\n", DataRate, DATA_RATE_SELECT_REGISTER)); DPRINT(("floppy: HwSetDataRate called; writing rate code 0x%x to offset 0x%x\n", DataRate, DATA_RATE_SELECT_REGISTER));
WRITE_PORT_UCHAR(ControllerInfo->BaseAddress + DATA_RATE_SELECT_REGISTER, DataRate); WRITE_PORT_UCHAR(ControllerInfo->BaseAddress + DATA_RATE_SELECT_REGISTER, DataRate);
@ -288,7 +290,7 @@ NTSTATUS NTAPI HwTurnOffMotor(PCONTROLLER_INFO ControllerInfo)
* - Called at DISPATCH_LEVEL * - Called at DISPATCH_LEVEL
*/ */
{ {
KdPrint(("floppy: HwTurnOffMotor: writing byte 0x%x to offset 0x%x\n", DOR_FDC_ENABLE|DOR_DMA_IO_INTERFACE_ENABLE, DIGITAL_OUTPUT_REGISTER)); DPRINT(("floppy: HwTurnOffMotor: writing byte 0x%x to offset 0x%x\n", DOR_FDC_ENABLE|DOR_DMA_IO_INTERFACE_ENABLE, DIGITAL_OUTPUT_REGISTER));
WRITE_PORT_UCHAR(ControllerInfo->BaseAddress + DIGITAL_OUTPUT_REGISTER, DOR_FDC_ENABLE|DOR_DMA_IO_INTERFACE_ENABLE); WRITE_PORT_UCHAR(ControllerInfo->BaseAddress + DIGITAL_OUTPUT_REGISTER, DOR_FDC_ENABLE|DOR_DMA_IO_INTERFACE_ENABLE);
@ -330,7 +332,7 @@ NTSTATUS NTAPI HwTurnOnMotor(PDRIVE_INFO DriveInfo)
else if (Unit == 3) else if (Unit == 3)
Buffer |= DOR_FLOPPY_MOTOR_ON_D; Buffer |= DOR_FLOPPY_MOTOR_ON_D;
KdPrint(("floppy: HwTurnOnMotor: writing byte 0x%x to offset 0x%x\n", Buffer, DIGITAL_OUTPUT_REGISTER)); DPRINT(("floppy: HwTurnOnMotor: writing byte 0x%x to offset 0x%x\n", Buffer, DIGITAL_OUTPUT_REGISTER));
WRITE_PORT_UCHAR(ControllerInfo->BaseAddress + DIGITAL_OUTPUT_REGISTER, Buffer); WRITE_PORT_UCHAR(ControllerInfo->BaseAddress + DIGITAL_OUTPUT_REGISTER, Buffer);
return STATUS_SUCCESS; return STATUS_SUCCESS;
@ -355,7 +357,7 @@ NTSTATUS NTAPI HwSenseDriveStatus(PDRIVE_INFO DriveInfo)
PAGED_CODE(); PAGED_CODE();
KdPrint(("floppy: HwSenseDriveStatus called\n")); DPRINT(("floppy: HwSenseDriveStatus called\n"));
Buffer[0] = COMMAND_SENSE_DRIVE_STATUS; Buffer[0] = COMMAND_SENSE_DRIVE_STATUS;
Buffer[1] = DriveInfo->UnitNumber; /* hard-wired to head 0 for now */ Buffer[1] = DriveInfo->UnitNumber; /* hard-wired to head 0 for now */
@ -363,7 +365,7 @@ NTSTATUS NTAPI HwSenseDriveStatus(PDRIVE_INFO DriveInfo)
for(i = 0; i < 2; i++) for(i = 0; i < 2; i++)
if(Send_Byte(DriveInfo->ControllerInfo, Buffer[i]) != STATUS_SUCCESS) if(Send_Byte(DriveInfo->ControllerInfo, Buffer[i]) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: HwSenseDriveStatus: failed to write FIFO\n")); DPRINT(("floppy: HwSenseDriveStatus: failed to write FIFO\n"));
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
@ -429,11 +431,11 @@ NTSTATUS NTAPI HwReadWriteData(PCONTROLLER_INFO ControllerInfo,
/* Send the command */ /* Send the command */
for(i = 0; i < 9; i++) for(i = 0; i < 9; i++)
{ {
KdPrint(("floppy: HwReadWriteData: Sending a command byte to the FIFO: 0x%x\n", Buffer[i])); DPRINT(("floppy: HwReadWriteData: Sending a command byte to the FIFO: 0x%x\n", Buffer[i]));
if(Send_Byte(ControllerInfo, Buffer[i]) != STATUS_SUCCESS) if(Send_Byte(ControllerInfo, Buffer[i]) != STATUS_SUCCESS)
{ {
KdPrint(("HwReadWriteData: Unable to write to the FIFO\n")); DPRINT(("HwReadWriteData: Unable to write to the FIFO\n"));
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
} }
@ -465,19 +467,19 @@ NTSTATUS NTAPI HwRecalibrateResult(PCONTROLLER_INFO ControllerInfo)
if(Send_Byte(ControllerInfo, COMMAND_SENSE_INTERRUPT_STATUS) != STATUS_SUCCESS) if(Send_Byte(ControllerInfo, COMMAND_SENSE_INTERRUPT_STATUS) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: HwRecalibrateResult: Unable to write the controller\n")); DPRINT(("floppy: HwRecalibrateResult: Unable to write the controller\n"));
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
for(i = 0; i < 2; i++) for(i = 0; i < 2; i++)
if(Get_Byte(ControllerInfo, &Buffer[i]) != STATUS_SUCCESS) if(Get_Byte(ControllerInfo, &Buffer[i]) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: HwRecalibrateResult: unable to read FIFO\n")); DPRINT(("floppy: HwRecalibrateResult: unable to read FIFO\n"));
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
/* Validate that it did what we told it to */ /* Validate that it did what we told it to */
KdPrint(("floppy: HwRecalibrateResult results: ST0: 0x%x PCN: 0x%x\n", Buffer[0], Buffer[1])); DPRINT(("floppy: HwRecalibrateResult results: ST0: 0x%x PCN: 0x%x\n", Buffer[0], Buffer[1]));
/* /*
* Buffer[0] = ST0 * Buffer[0] = ST0
@ -487,20 +489,20 @@ NTSTATUS NTAPI HwRecalibrateResult(PCONTROLLER_INFO ControllerInfo)
/* Is the PCN 0? */ /* Is the PCN 0? */
if(Buffer[1] != 0) if(Buffer[1] != 0)
{ {
KdPrint(("floppy: HwRecalibrateResult: PCN not 0\n")); DPRINT(("floppy: HwRecalibrateResult: PCN not 0\n"));
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
/* test seek complete */ /* test seek complete */
if((Buffer[0] & SR0_SEEK_COMPLETE) != SR0_SEEK_COMPLETE) if((Buffer[0] & SR0_SEEK_COMPLETE) != SR0_SEEK_COMPLETE)
{ {
KdPrint(("floppy: HwRecalibrateResult: Failed to complete the seek\n")); DPRINT(("floppy: HwRecalibrateResult: Failed to complete the seek\n"));
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
/* Is the equipment check flag set? Could be no disk in drive... */ /* Is the equipment check flag set? Could be no disk in drive... */
if((Buffer[0] & SR0_EQUIPMENT_CHECK) == SR0_EQUIPMENT_CHECK) if((Buffer[0] & SR0_EQUIPMENT_CHECK) == SR0_EQUIPMENT_CHECK)
KdPrint(("floppy: HwRecalibrateResult: Seeked to track 0 successfully, but EC is set; returning STATUS_SUCCESS anyway\n")); DPRINT(("floppy: HwRecalibrateResult: Seeked to track 0 successfully, but EC is set; returning STATUS_SUCCESS anyway\n"));
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
@ -530,12 +532,12 @@ NTSTATUS NTAPI HwReadWriteResult(PCONTROLLER_INFO ControllerInfo)
for(i = 0; i < 7; i++) for(i = 0; i < 7; i++)
if(Get_Byte(ControllerInfo, &Buffer[i]) != STATUS_SUCCESS) if(Get_Byte(ControllerInfo, &Buffer[i]) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: HwReadWriteResult: unable to read fifo\n")); DPRINT(("floppy: HwReadWriteResult: unable to read fifo\n"));
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
/* Validate that it did what we told it to */ /* Validate that it did what we told it to */
KdPrint(("floppy: HwReadWriteResult results: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n", Buffer[0], Buffer[1], Buffer[2], Buffer[3], DPRINT(("floppy: HwReadWriteResult results: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n", Buffer[0], Buffer[1], Buffer[2], Buffer[3],
Buffer[4], Buffer[5], Buffer[6])); Buffer[4], Buffer[5], Buffer[6]));
/* Last command successful? */ /* Last command successful? */
@ -563,7 +565,7 @@ NTSTATUS NTAPI HwRecalibrate(PDRIVE_INFO DriveInfo)
UCHAR Buffer[2]; UCHAR Buffer[2];
int i; int i;
KdPrint(("floppy: HwRecalibrate called\n")); DPRINT(("floppy: HwRecalibrate called\n"));
PAGED_CODE(); PAGED_CODE();
@ -573,7 +575,7 @@ NTSTATUS NTAPI HwRecalibrate(PDRIVE_INFO DriveInfo)
for(i = 0; i < 2; i++) for(i = 0; i < 2; i++)
if(Send_Byte(ControllerInfo, Buffer[i]) != STATUS_SUCCESS) if(Send_Byte(ControllerInfo, Buffer[i]) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: HwRecalibrate: unable to write FIFO\n")); DPRINT(("floppy: HwRecalibrate: unable to write FIFO\n"));
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
@ -598,7 +600,7 @@ NTSTATUS NTAPI HwSenseInterruptStatus(PCONTROLLER_INFO ControllerInfo)
if(Send_Byte(ControllerInfo, COMMAND_SENSE_INTERRUPT_STATUS) != STATUS_SUCCESS) if(Send_Byte(ControllerInfo, COMMAND_SENSE_INTERRUPT_STATUS) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: HwSenseInterruptStatus: failed to write controller\n")); DPRINT(("floppy: HwSenseInterruptStatus: failed to write controller\n"));
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
@ -606,12 +608,12 @@ NTSTATUS NTAPI HwSenseInterruptStatus(PCONTROLLER_INFO ControllerInfo)
{ {
if(Get_Byte(ControllerInfo, &Buffer[i]) != STATUS_SUCCESS) if(Get_Byte(ControllerInfo, &Buffer[i]) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: HwSenseInterruptStatus: failed to read controller\n")); DPRINT(("floppy: HwSenseInterruptStatus: failed to read controller\n"));
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
} }
KdPrint(("floppy: HwSenseInterruptStatus returned 0x%x 0x%x\n", Buffer[0], Buffer[1])); DPRINT(("floppy: HwSenseInterruptStatus returned 0x%x 0x%x\n", Buffer[0], Buffer[1]));
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
@ -633,7 +635,7 @@ NTSTATUS NTAPI HwReadId(PDRIVE_INFO DriveInfo, UCHAR Head)
UCHAR Buffer[2]; UCHAR Buffer[2];
int i; int i;
KdPrint(("floppy: HwReadId called\n")); DPRINT(("floppy: HwReadId called\n"));
PAGED_CODE(); PAGED_CODE();
@ -643,7 +645,7 @@ NTSTATUS NTAPI HwReadId(PDRIVE_INFO DriveInfo, UCHAR Head)
for(i = 0; i < 2; i++) for(i = 0; i < 2; i++)
if(Send_Byte(DriveInfo->ControllerInfo, Buffer[i]) != STATUS_SUCCESS) if(Send_Byte(DriveInfo->ControllerInfo, Buffer[i]) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: HwReadId: unable to send bytes to fifo\n")); DPRINT(("floppy: HwReadId: unable to send bytes to fifo\n"));
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
@ -676,7 +678,7 @@ NTSTATUS NTAPI HwFormatTrack(PCONTROLLER_INFO ControllerInfo,
UCHAR Buffer[6]; UCHAR Buffer[6];
int i; int i;
KdPrint(("floppy: HwFormatTrack called\n")); DPRINT(("floppy: HwFormatTrack called\n"));
PAGED_CODE(); PAGED_CODE();
@ -690,7 +692,7 @@ NTSTATUS NTAPI HwFormatTrack(PCONTROLLER_INFO ControllerInfo,
for(i = 0; i < 6; i++) for(i = 0; i < 6; i++)
if(Send_Byte(ControllerInfo, Buffer[i]) != STATUS_SUCCESS) if(Send_Byte(ControllerInfo, Buffer[i]) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: HwFormatTrack: unable to send bytes to floppy\n")); DPRINT(("floppy: HwFormatTrack: unable to send bytes to floppy\n"));
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
@ -716,7 +718,7 @@ NTSTATUS NTAPI HwSeek(PDRIVE_INFO DriveInfo,
UCHAR Buffer[3]; UCHAR Buffer[3];
int i; int i;
KdPrint(("floppy: HwSeek called for cyl 0x%x\n", Cylinder)); DPRINT(("floppy: HwSeek called for cyl 0x%x\n", Cylinder));
PAGED_CODE(); PAGED_CODE();
@ -727,7 +729,7 @@ NTSTATUS NTAPI HwSeek(PDRIVE_INFO DriveInfo,
for(i = 0; i < 3; i++) for(i = 0; i < 3; i++)
if(Send_Byte(DriveInfo->ControllerInfo, Buffer[i]) != STATUS_SUCCESS) if(Send_Byte(DriveInfo->ControllerInfo, Buffer[i]) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: HwSeek: failed to write fifo\n")); DPRINT(("floppy: HwSeek: failed to write fifo\n"));
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
@ -767,7 +769,7 @@ NTSTATUS NTAPI HwConfigure(PCONTROLLER_INFO ControllerInfo,
UCHAR Buffer[4]; UCHAR Buffer[4];
int i; int i;
KdPrint(("floppy: HwConfigure called\n")); DPRINT(("floppy: HwConfigure called\n"));
PAGED_CODE(); PAGED_CODE();
@ -779,7 +781,7 @@ NTSTATUS NTAPI HwConfigure(PCONTROLLER_INFO ControllerInfo,
for(i = 0; i < 4; i++) for(i = 0; i < 4; i++)
if(Send_Byte(ControllerInfo, Buffer[i]) != STATUS_SUCCESS) if(Send_Byte(ControllerInfo, Buffer[i]) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: HwConfigure: failed to write the fifo\n")); DPRINT(("floppy: HwConfigure: failed to write the fifo\n"));
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
@ -807,17 +809,17 @@ NTSTATUS NTAPI HwGetVersion(PCONTROLLER_INFO ControllerInfo)
if(Send_Byte(ControllerInfo, COMMAND_VERSION) != STATUS_SUCCESS) if(Send_Byte(ControllerInfo, COMMAND_VERSION) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: HwGetVersion: unable to write fifo\n")); DPRINT(("floppy: HwGetVersion: unable to write fifo\n"));
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
if(Get_Byte(ControllerInfo, &Buffer) != STATUS_SUCCESS) if(Get_Byte(ControllerInfo, &Buffer) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: HwGetVersion: unable to write fifo\n")); DPRINT(("floppy: HwGetVersion: unable to write fifo\n"));
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
KdPrint(("floppy: HwGetVersion returning version 0x%x\n", Buffer)); DPRINT(("floppy: HwGetVersion returning version 0x%x\n", Buffer));
return Buffer; return Buffer;
} }
@ -841,18 +843,18 @@ NTSTATUS NTAPI HwDiskChanged(PDRIVE_INFO DriveInfo,
Buffer = READ_PORT_UCHAR(ControllerInfo->BaseAddress + DIGITAL_INPUT_REGISTER); Buffer = READ_PORT_UCHAR(ControllerInfo->BaseAddress + DIGITAL_INPUT_REGISTER);
KdPrint(("floppy: HwDiskChanged: read 0x%x from DIR\n", Buffer)); DPRINT(("floppy: HwDiskChanged: read 0x%x from DIR\n", Buffer));
if(ControllerInfo->Model30) if(ControllerInfo->Model30)
{ {
if(!(Buffer & DIR_DISKETTE_CHANGE)) if(!(Buffer & DIR_DISKETTE_CHANGE))
{ {
KdPrint(("floppy: HdDiskChanged - Model30 - returning TRUE\n")); DPRINT(("floppy: HdDiskChanged - Model30 - returning TRUE\n"));
*DiskChanged = TRUE; *DiskChanged = TRUE;
} }
else else
{ {
KdPrint(("floppy: HdDiskChanged - Model30 - returning FALSE\n")); DPRINT(("floppy: HdDiskChanged - Model30 - returning FALSE\n"));
*DiskChanged = FALSE; *DiskChanged = FALSE;
} }
} }
@ -860,12 +862,12 @@ NTSTATUS NTAPI HwDiskChanged(PDRIVE_INFO DriveInfo,
{ {
if(Buffer & DIR_DISKETTE_CHANGE) if(Buffer & DIR_DISKETTE_CHANGE)
{ {
KdPrint(("floppy: HdDiskChanged - PS2 - returning TRUE\n")); DPRINT(("floppy: HdDiskChanged - PS2 - returning TRUE\n"));
*DiskChanged = TRUE; *DiskChanged = TRUE;
} }
else else
{ {
KdPrint(("floppy: HdDiskChanged - PS2 - returning FALSE\n")); DPRINT(("floppy: HdDiskChanged - PS2 - returning FALSE\n"));
*DiskChanged = FALSE; *DiskChanged = FALSE;
} }
} }
@ -891,11 +893,11 @@ NTSTATUS NTAPI HwSenseDriveStatusResult(PCONTROLLER_INFO ControllerInfo,
if(Get_Byte(ControllerInfo, Status) != STATUS_SUCCESS) if(Get_Byte(ControllerInfo, Status) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: HwSenseDriveStatus: unable to read fifo\n")); DPRINT(("floppy: HwSenseDriveStatus: unable to read fifo\n"));
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
KdPrint(("floppy: HwSenseDriveStatusResult: ST3: 0x%x\n", *Status)); DPRINT(("floppy: HwSenseDriveStatusResult: ST3: 0x%x\n", *Status));
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
@ -929,25 +931,25 @@ NTSTATUS NTAPI HwReadIdResult(PCONTROLLER_INFO ControllerInfo,
for(i = 0; i < 7; i++) for(i = 0; i < 7; i++)
if(Get_Byte(ControllerInfo, &Buffer[i]) != STATUS_SUCCESS) if(Get_Byte(ControllerInfo, &Buffer[i]) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: ReadIdResult(): can't read from the controller\n")); DPRINT(("floppy: ReadIdResult(): can't read from the controller\n"));
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
/* Validate that it did what we told it to */ /* Validate that it did what we told it to */
KdPrint(("floppy: ReadId results: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n", Buffer[0], Buffer[1], Buffer[2], Buffer[3], DPRINT(("floppy: ReadId results: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n", Buffer[0], Buffer[1], Buffer[2], Buffer[3],
Buffer[4], Buffer[5], Buffer[6])); Buffer[4], Buffer[5], Buffer[6]));
/* Last command successful? */ /* Last command successful? */
if((Buffer[0] & SR0_LAST_COMMAND_STATUS) != SR0_LCS_SUCCESS) if((Buffer[0] & SR0_LAST_COMMAND_STATUS) != SR0_LCS_SUCCESS)
{ {
KdPrint(("floppy: ReadId didn't return last command success\n")); DPRINT(("floppy: ReadId didn't return last command success\n"));
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
/* ID mark found? */ /* ID mark found? */
if(Buffer[1] & SR1_CANNOT_FIND_ID_ADDRESS) if(Buffer[1] & SR1_CANNOT_FIND_ID_ADDRESS)
{ {
KdPrint(("floppy: ReadId didn't find an address mark\n")); DPRINT(("floppy: ReadId didn't find an address mark\n"));
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
@ -994,13 +996,13 @@ NTSTATUS NTAPI HwSpecify(PCONTROLLER_INFO ControllerInfo,
Buffer[1] = 0xdf; Buffer[1] = 0xdf;
Buffer[2] = 0x2; Buffer[2] = 0x2;
//KdPrint(("HwSpecify: sending 0x%x 0x%x 0x%x to FIFO\n", Buffer[0], Buffer[1], Buffer[2])); //DPRINT(("HwSpecify: sending 0x%x 0x%x 0x%x to FIFO\n", Buffer[0], Buffer[1], Buffer[2]));
KdPrint(("FLOPPY: HWSPECIFY: FIXME - sending 0x3 0xd1 0x2 to FIFO\n")); DPRINT(("FLOPPY: HWSPECIFY: FIXME - sending 0x3 0xd1 0x2 to FIFO\n"));
for(i = 0; i < 3; i++) for(i = 0; i < 3; i++)
if(Send_Byte(ControllerInfo, Buffer[i]) != STATUS_SUCCESS) if(Send_Byte(ControllerInfo, Buffer[i]) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: HwSpecify: unable to write to controller\n")); DPRINT(("floppy: HwSpecify: unable to write to controller\n"));
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
@ -1019,7 +1021,7 @@ NTSTATUS NTAPI HwReset(PCONTROLLER_INFO ControllerInfo)
* - Generates an interrupt that must be serviced four times (one per drive) * - Generates an interrupt that must be serviced four times (one per drive)
*/ */
{ {
KdPrint(("floppy: HwReset called\n")); DPRINT(("floppy: HwReset called\n"));
/* Write the reset bit in the DRSR */ /* Write the reset bit in the DRSR */
WRITE_PORT_UCHAR(ControllerInfo->BaseAddress + DATA_RATE_SELECT_REGISTER, DRSR_SW_RESET); WRITE_PORT_UCHAR(ControllerInfo->BaseAddress + DATA_RATE_SELECT_REGISTER, DRSR_SW_RESET);
@ -1028,13 +1030,13 @@ NTSTATUS NTAPI HwReset(PCONTROLLER_INFO ControllerInfo)
if(!(READ_PORT_UCHAR(ControllerInfo->BaseAddress + DIGITAL_OUTPUT_REGISTER) & DOR_RESET)) if(!(READ_PORT_UCHAR(ControllerInfo->BaseAddress + DIGITAL_OUTPUT_REGISTER) & DOR_RESET))
{ {
HwDumpRegisters(ControllerInfo); HwDumpRegisters(ControllerInfo);
KdPrint(("floppy: HwReset: Setting Enable bit\n")); DPRINT(("floppy: HwReset: Setting Enable bit\n"));
WRITE_PORT_UCHAR(ControllerInfo->BaseAddress + DIGITAL_OUTPUT_REGISTER, DOR_DMA_IO_INTERFACE_ENABLE|DOR_RESET); WRITE_PORT_UCHAR(ControllerInfo->BaseAddress + DIGITAL_OUTPUT_REGISTER, DOR_DMA_IO_INTERFACE_ENABLE|DOR_RESET);
HwDumpRegisters(ControllerInfo); HwDumpRegisters(ControllerInfo);
if(!(READ_PORT_UCHAR(ControllerInfo->BaseAddress + DIGITAL_OUTPUT_REGISTER) & DOR_RESET)) if(!(READ_PORT_UCHAR(ControllerInfo->BaseAddress + DIGITAL_OUTPUT_REGISTER) & DOR_RESET))
{ {
KdPrint(("floppy: HwReset: failed to set the DOR enable bit!\n")); DPRINT(("floppy: HwReset: failed to set the DOR enable bit!\n"));
HwDumpRegisters(ControllerInfo); HwDumpRegisters(ControllerInfo);
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
@ -1055,7 +1057,7 @@ NTSTATUS NTAPI HwPowerOff(PCONTROLLER_INFO ControllerInfo)
* - Wake up with a hardware reset * - Wake up with a hardware reset
*/ */
{ {
KdPrint(("floppy: HwPowerOff called on controller 0x%x\n", ControllerInfo)); DPRINT(("floppy: HwPowerOff called on controller 0x%x\n", ControllerInfo));
WRITE_PORT_UCHAR(ControllerInfo->BaseAddress + DATA_RATE_SELECT_REGISTER, DRSR_POWER_DOWN); WRITE_PORT_UCHAR(ControllerInfo->BaseAddress + DATA_RATE_SELECT_REGISTER, DRSR_POWER_DOWN);
@ -1071,11 +1073,11 @@ VOID NTAPI HwDumpRegisters(PCONTROLLER_INFO ControllerInfo)
{ {
UNREFERENCED_PARAMETER(ControllerInfo); UNREFERENCED_PARAMETER(ControllerInfo);
KdPrint(("floppy: STATUS: ")); DPRINT(("floppy: STATUS: "));
KdPrint(("STATUS_REGISTER_A = 0x%x ", READ_PORT_UCHAR(ControllerInfo->BaseAddress + STATUS_REGISTER_A))); DPRINT(("STATUS_REGISTER_A = 0x%x ", READ_PORT_UCHAR(ControllerInfo->BaseAddress + STATUS_REGISTER_A)));
KdPrint(("STATUS_REGISTER_B = 0x%x ", READ_PORT_UCHAR(ControllerInfo->BaseAddress + STATUS_REGISTER_B))); DPRINT(("STATUS_REGISTER_B = 0x%x ", READ_PORT_UCHAR(ControllerInfo->BaseAddress + STATUS_REGISTER_B)));
KdPrint(("DIGITAL_OUTPUT_REGISTER = 0x%x ", READ_PORT_UCHAR(ControllerInfo->BaseAddress + DIGITAL_OUTPUT_REGISTER))); DPRINT(("DIGITAL_OUTPUT_REGISTER = 0x%x ", READ_PORT_UCHAR(ControllerInfo->BaseAddress + DIGITAL_OUTPUT_REGISTER)));
KdPrint(("MAIN_STATUS_REGISTER =0x%x ", READ_PORT_UCHAR(ControllerInfo->BaseAddress + MAIN_STATUS_REGISTER))); DPRINT(("MAIN_STATUS_REGISTER =0x%x ", READ_PORT_UCHAR(ControllerInfo->BaseAddress + MAIN_STATUS_REGISTER)));
KdPrint(("DIGITAL_INPUT_REGISTER = 0x%x\n", READ_PORT_UCHAR(ControllerInfo->BaseAddress + DIGITAL_INPUT_REGISTER))); DPRINT(("DIGITAL_INPUT_REGISTER = 0x%x\n", READ_PORT_UCHAR(ControllerInfo->BaseAddress + DIGITAL_INPUT_REGISTER)));
} }

View file

@ -31,6 +31,8 @@
* TODO: Implement format * TODO: Implement format
*/ */
#define NDEBUG
#include <debug.h>
#include <ntddk.h> #include <ntddk.h>
#include "floppy.h" #include "floppy.h"
@ -79,7 +81,7 @@ VOID NTAPI DeviceIoctlPassive(PDRIVE_INFO DriveInfo,
ULONG Code = Stack->Parameters.DeviceIoControl.IoControlCode; ULONG Code = Stack->Parameters.DeviceIoControl.IoControlCode;
BOOLEAN DiskChanged; BOOLEAN DiskChanged;
KdPrint(("floppy: DeviceIoctl called\n")); DPRINT(("floppy: DeviceIoctl called\n"));
Irp->IoStatus.Status = STATUS_SUCCESS; Irp->IoStatus.Status = STATUS_SUCCESS;
Irp->IoStatus.Information = 0; Irp->IoStatus.Information = 0;
@ -89,11 +91,11 @@ VOID NTAPI DeviceIoctlPassive(PDRIVE_INFO DriveInfo,
if(Code == IOCTL_DISK_GET_MEDIA_TYPES) if(Code == IOCTL_DISK_GET_MEDIA_TYPES)
{ {
PDISK_GEOMETRY Geometry = OutputBuffer; PDISK_GEOMETRY Geometry = OutputBuffer;
KdPrint(("floppy: IOCTL_DISK_GET_MEDIA_TYPES Called\n")); DPRINT(("floppy: IOCTL_DISK_GET_MEDIA_TYPES Called\n"));
if(OutputLength < sizeof(DISK_GEOMETRY)) if(OutputLength < sizeof(DISK_GEOMETRY))
{ {
KdPrint(("floppy: IOCTL_DISK_GET_MEDIA_TYPES: insufficient buffer; returning STATUS_INVALID_PARAMETER\n")); DPRINT(("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;
@ -110,7 +112,7 @@ VOID NTAPI DeviceIoctlPassive(PDRIVE_INFO DriveInfo,
Irp->IoStatus.Status = STATUS_SUCCESS; Irp->IoStatus.Status = STATUS_SUCCESS;
Irp->IoStatus.Information = sizeof(DISK_GEOMETRY); Irp->IoStatus.Information = sizeof(DISK_GEOMETRY);
KdPrint(("floppy: Ioctl: completing with STATUS_SUCCESS\n")); DPRINT(("floppy: Ioctl: completing with STATUS_SUCCESS\n"));
IoCompleteRequest(Irp, IO_NO_INCREMENT); IoCompleteRequest(Irp, IO_NO_INCREMENT);
return; return;
@ -127,7 +129,7 @@ VOID NTAPI DeviceIoctlPassive(PDRIVE_INFO DriveInfo,
*/ */
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))
{ {
KdPrint(("floppy: DeviceIoctl(): completing with STATUS_VERIFY_REQUIRED\n")); DPRINT(("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);
@ -144,7 +146,7 @@ VOID NTAPI DeviceIoctlPassive(PDRIVE_INFO DriveInfo,
*/ */
if(HwDiskChanged(DriveInfo, &DiskChanged) != STATUS_SUCCESS) if(HwDiskChanged(DriveInfo, &DiskChanged) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: DeviceIoctl(): unable to sense disk change; completing with STATUS_UNSUCCESSFUL\n")); DPRINT(("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);
@ -154,7 +156,7 @@ VOID NTAPI DeviceIoctlPassive(PDRIVE_INFO DriveInfo,
if(DiskChanged) if(DiskChanged)
{ {
KdPrint(("floppy: DeviceIoctl(): detected disk changed; signalling media change and completing\n")); DPRINT(("floppy: DeviceIoctl(): detected disk changed; signalling media change and completing\n"));
SignalMediaChanged(DriveInfo->DeviceObject, Irp); SignalMediaChanged(DriveInfo->DeviceObject, Irp);
/* /*
@ -177,14 +179,14 @@ VOID NTAPI DeviceIoctlPassive(PDRIVE_INFO DriveInfo,
{ {
UCHAR Status; UCHAR Status;
KdPrint(("floppy: IOCTL_DISK_IS_WRITABLE Called\n")); DPRINT(("floppy: IOCTL_DISK_IS_WRITABLE Called\n"));
/* This IRP always has 0 information */ /* This IRP always has 0 information */
Irp->IoStatus.Information = 0; Irp->IoStatus.Information = 0;
if(HwSenseDriveStatus(DriveInfo) != STATUS_SUCCESS) if(HwSenseDriveStatus(DriveInfo) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: IoctlDiskIsWritable(): unable to sense drive status\n")); DPRINT(("floppy: IoctlDiskIsWritable(): unable to sense drive status\n"));
Irp->IoStatus.Status = STATUS_IO_DEVICE_ERROR; Irp->IoStatus.Status = STATUS_IO_DEVICE_ERROR;
break; break;
} }
@ -192,7 +194,7 @@ VOID NTAPI DeviceIoctlPassive(PDRIVE_INFO DriveInfo,
/* 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)
{ {
KdPrint(("floppy: IoctlDiskIsWritable(): unable to read drive status result\n")); DPRINT(("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;
} }
@ -200,7 +202,7 @@ VOID NTAPI DeviceIoctlPassive(PDRIVE_INFO DriveInfo,
/* 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)
{ {
KdPrint(("floppy: IOCTL_DISK_IS_WRITABLE: disk is write protected\n")); DPRINT(("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
@ -209,7 +211,7 @@ VOID NTAPI DeviceIoctlPassive(PDRIVE_INFO DriveInfo,
break; break;
case IOCTL_DISK_CHECK_VERIFY: case IOCTL_DISK_CHECK_VERIFY:
KdPrint(("floppy: IOCTL_DISK_CHECK_VERIFY called\n")); DPRINT(("floppy: IOCTL_DISK_CHECK_VERIFY called\n"));
if (OutputLength != 0) if (OutputLength != 0)
{ {
if (OutputLength < sizeof(ULONG)) if (OutputLength < sizeof(ULONG))
@ -233,7 +235,7 @@ VOID NTAPI DeviceIoctlPassive(PDRIVE_INFO DriveInfo,
case IOCTL_DISK_GET_DRIVE_GEOMETRY: case IOCTL_DISK_GET_DRIVE_GEOMETRY:
{ {
KdPrint(("floppy: IOCTL_DISK_GET_DRIVE_GEOMETRY Called\n")); DPRINT(("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;
@ -248,23 +250,23 @@ VOID NTAPI DeviceIoctlPassive(PDRIVE_INFO DriveInfo,
case IOCTL_DISK_FORMAT_TRACKS: case IOCTL_DISK_FORMAT_TRACKS:
case IOCTL_DISK_FORMAT_TRACKS_EX: case IOCTL_DISK_FORMAT_TRACKS_EX:
KdPrint(("floppy: Format called; not supported yet\n")); DPRINT(("floppy: Format called; not supported yet\n"));
break; break;
case IOCTL_DISK_GET_PARTITION_INFO: case IOCTL_DISK_GET_PARTITION_INFO:
KdPrint(("floppy: IOCTL_DISK_GET_PARTITION_INFO Called; not supported\n")); DPRINT(("floppy: IOCTL_DISK_GET_PARTITION_INFO Called; not supported\n"));
Irp->IoStatus.Status = STATUS_NOT_SUPPORTED; Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
Irp->IoStatus.Information = 0; Irp->IoStatus.Information = 0;
break; break;
default: default:
KdPrint(("floppy: UNKNOWN IOCTL CODE: 0x%x\n", Code)); DPRINT(("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;
} }
KdPrint(("floppy: ioctl: completing with status 0x%x\n", Irp->IoStatus.Status)); DPRINT(("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);

View file

@ -51,6 +51,9 @@
* TODO: Figure out perf issue - waiting after call to read/write for about a second each time * TODO: Figure out perf issue - waiting after call to read/write for about a second each time
* TODO: Figure out specify timings * TODO: Figure out specify timings
*/ */
#define NDEBUG
#include <debug.h>
#include <ntddk.h> #include <ntddk.h>
#include "floppy.h" #include "floppy.h"
@ -79,7 +82,7 @@ static IO_ALLOCATION_ACTION NTAPI MapRegisterCallback(PDEVICE_OBJECT DeviceObjec
UNREFERENCED_PARAMETER(DeviceObject); UNREFERENCED_PARAMETER(DeviceObject);
UNREFERENCED_PARAMETER(Irp); UNREFERENCED_PARAMETER(Irp);
KdPrint(("floppy: MapRegisterCallback Called\n")); DPRINT(("floppy: MapRegisterCallback Called\n"));
ControllerInfo->MapRegisterBase = MapRegisterBase; ControllerInfo->MapRegisterBase = MapRegisterBase;
KeSetEvent(&ControllerInfo->SynchEvent, 0, FALSE); KeSetEvent(&ControllerInfo->SynchEvent, 0, FALSE);
@ -105,14 +108,14 @@ NTSTATUS NTAPI ReadWrite(PDEVICE_OBJECT DeviceObject,
* it onto the irp queue * it onto the irp queue
*/ */
{ {
KdPrint(("floppy: ReadWrite called\n")); DPRINT(("floppy: ReadWrite called\n"));
ASSERT(DeviceObject); ASSERT(DeviceObject);
ASSERT(Irp); ASSERT(Irp);
if(!Irp->MdlAddress) if(!Irp->MdlAddress)
{ {
KdPrint(("floppy: ReadWrite(): MDL not found in IRP - Completing with STATUS_INVALID_PARAMETER\n")); DPRINT(("floppy: ReadWrite(): MDL not found in IRP - Completing with STATUS_INVALID_PARAMETER\n"));
Irp->IoStatus.Status = STATUS_INVALID_PARAMETER; Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
Irp->IoStatus.Information = 0; Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT); IoCompleteRequest(Irp, IO_NO_INCREMENT);
@ -173,7 +176,7 @@ static NTSTATUS NTAPI RWDetermineMediaType(PDRIVE_INFO DriveInfo)
PAGED_CODE(); PAGED_CODE();
KdPrint(("floppy: RWDetermineMediaType called\n")); DPRINT(("floppy: RWDetermineMediaType called\n"));
/* /*
* This algorithm assumes that a 1.44MB floppy is in the drive. If it's not, * This algorithm assumes that a 1.44MB floppy is in the drive. If it's not,
@ -188,7 +191,7 @@ static NTSTATUS NTAPI RWDetermineMediaType(PDRIVE_INFO DriveInfo)
/* Program data rate */ /* Program data rate */
if(HwSetDataRate(DriveInfo->ControllerInfo, DRSR_DSEL_500KBPS) != STATUS_SUCCESS) if(HwSetDataRate(DriveInfo->ControllerInfo, DRSR_DSEL_500KBPS) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: RWDetermineMediaType(): unable to set data rate\n")); DPRINT(("floppy: RWDetermineMediaType(): unable to set data rate\n"));
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
@ -200,7 +203,7 @@ static NTSTATUS NTAPI RWDetermineMediaType(PDRIVE_INFO DriveInfo)
/* Don't disable DMA --> enable dma (dumb & confusing) */ /* Don't disable DMA --> enable dma (dumb & confusing) */
if(HwSpecify(DriveInfo->ControllerInfo, HeadLoadTime, HeadUnloadTime, StepRateTime, FALSE) != STATUS_SUCCESS) if(HwSpecify(DriveInfo->ControllerInfo, HeadLoadTime, HeadUnloadTime, StepRateTime, FALSE) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: RWDetermineMediaType(): specify failed\n")); DPRINT(("floppy: RWDetermineMediaType(): specify failed\n"));
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
@ -214,7 +217,7 @@ static NTSTATUS NTAPI RWDetermineMediaType(PDRIVE_INFO DriveInfo)
if(HwRecalibrate(DriveInfo) != STATUS_SUCCESS) if(HwRecalibrate(DriveInfo) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: RWDetermineMediaType(): Recalibrate failed\n")); DPRINT(("floppy: RWDetermineMediaType(): Recalibrate failed\n"));
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
@ -228,7 +231,7 @@ static NTSTATUS NTAPI RWDetermineMediaType(PDRIVE_INFO DriveInfo)
if(i == 1) /* failed for 2nd time */ if(i == 1) /* failed for 2nd time */
{ {
KdPrint(("floppy: RWDetermineMediaType(): RecalibrateResult failed\n")); DPRINT(("floppy: RWDetermineMediaType(): RecalibrateResult failed\n"));
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
} }
@ -239,7 +242,7 @@ static NTSTATUS NTAPI RWDetermineMediaType(PDRIVE_INFO DriveInfo)
/* Try to read an ID */ /* Try to read an ID */
if(HwReadId(DriveInfo, 0) != STATUS_SUCCESS) /* read the first ID we find, from head 0 */ if(HwReadId(DriveInfo, 0) != STATUS_SUCCESS) /* read the first ID we find, from head 0 */
{ {
KdPrint(("floppy: RWDetermineMediaType(): ReadId failed\n")); DPRINT(("floppy: RWDetermineMediaType(): ReadId failed\n"));
return STATUS_UNSUCCESSFUL; /* if we can't even write to the controller, it's hopeless */ return STATUS_UNSUCCESSFUL; /* if we can't even write to the controller, it's hopeless */
} }
@ -248,13 +251,13 @@ static NTSTATUS NTAPI RWDetermineMediaType(PDRIVE_INFO DriveInfo)
if(HwReadIdResult(DriveInfo->ControllerInfo, NULL, NULL) != STATUS_SUCCESS) if(HwReadIdResult(DriveInfo->ControllerInfo, NULL, NULL) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: RWDetermineMediaType(): ReadIdResult failed; continuing\n")); DPRINT(("floppy: RWDetermineMediaType(): ReadIdResult failed; continuing\n"));
continue; continue;
} }
/* Found the media; populate the geometry now */ /* Found the media; populate the geometry now */
KdPrint(("FIXME: Hardcoded media type!\n")); DPRINT(("FIXME: Hardcoded media type!\n"));
KdPrint(("floppy: RWDetermineMediaType(): Found 1.44 media; returning success\n")); DPRINT(("floppy: RWDetermineMediaType(): Found 1.44 media; returning success\n"));
DriveInfo->DiskGeometry.MediaType = GEOMETRY_144_MEDIATYPE; DriveInfo->DiskGeometry.MediaType = GEOMETRY_144_MEDIATYPE;
DriveInfo->DiskGeometry.Cylinders.QuadPart = GEOMETRY_144_CYLINDERS; DriveInfo->DiskGeometry.Cylinders.QuadPart = GEOMETRY_144_CYLINDERS;
DriveInfo->DiskGeometry.TracksPerCylinder = GEOMETRY_144_TRACKSPERCYLINDER; DriveInfo->DiskGeometry.TracksPerCylinder = GEOMETRY_144_TRACKSPERCYLINDER;
@ -265,7 +268,7 @@ static NTSTATUS NTAPI RWDetermineMediaType(PDRIVE_INFO DriveInfo)
} }
while(FALSE); while(FALSE);
KdPrint(("floppy: RWDetermineMediaType(): failed to find media\n")); DPRINT(("floppy: RWDetermineMediaType(): failed to find media\n"));
return STATUS_UNRECOGNIZED_MEDIA; return STATUS_UNRECOGNIZED_MEDIA;
} }
@ -288,7 +291,7 @@ static NTSTATUS NTAPI RWSeekToCylinder(PDRIVE_INFO DriveInfo,
PAGED_CODE(); PAGED_CODE();
KdPrint(("floppy: RWSeekToCylinder called drive 0x%x cylinder %d\n", DriveInfo, Cylinder)); DPRINT(("floppy: RWSeekToCylinder called drive 0x%x cylinder %d\n", DriveInfo, Cylinder));
/* Clear any spurious interrupts */ /* Clear any spurious interrupts */
KeClearEvent(&DriveInfo->ControllerInfo->SynchEvent); KeClearEvent(&DriveInfo->ControllerInfo->SynchEvent);
@ -296,7 +299,7 @@ static NTSTATUS NTAPI RWSeekToCylinder(PDRIVE_INFO DriveInfo,
/* queue seek command */ /* queue seek command */
if(HwSeek(DriveInfo, Cylinder) != STATUS_SUCCESS) if(HwSeek(DriveInfo, Cylinder) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: RWSeekToTrack(): unable to seek\n")); DPRINT(("floppy: RWSeekToTrack(): unable to seek\n"));
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
@ -304,14 +307,14 @@ static NTSTATUS NTAPI RWSeekToCylinder(PDRIVE_INFO DriveInfo,
if(HwSenseInterruptStatus(DriveInfo->ControllerInfo) != STATUS_SUCCESS) if(HwSenseInterruptStatus(DriveInfo->ControllerInfo) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: RWSeekToTrack(): unable to get seek results\n")); DPRINT(("floppy: RWSeekToTrack(): unable to get seek results\n"));
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
/* read ID mark from head 0 to verify */ /* read ID mark from head 0 to verify */
if(HwReadId(DriveInfo, 0) != STATUS_SUCCESS) if(HwReadId(DriveInfo, 0) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: RWSeekToTrack(): unable to queue ReadId\n")); DPRINT(("floppy: RWSeekToTrack(): unable to queue ReadId\n"));
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
@ -319,17 +322,17 @@ static NTSTATUS NTAPI RWSeekToCylinder(PDRIVE_INFO DriveInfo,
if(HwReadIdResult(DriveInfo->ControllerInfo, &CurCylinder, NULL) != STATUS_SUCCESS) if(HwReadIdResult(DriveInfo->ControllerInfo, &CurCylinder, NULL) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: RWSeekToTrack(): unable to get ReadId result\n")); DPRINT(("floppy: RWSeekToTrack(): unable to get ReadId result\n"));
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
if(CurCylinder != Cylinder) if(CurCylinder != Cylinder)
{ {
KdPrint(("floppy: RWSeekToTrack(): Seeek to track failed; current cylinder is 0x%x\n", CurCylinder)); DPRINT(("floppy: RWSeekToTrack(): Seeek to track failed; current cylinder is 0x%x\n", CurCylinder));
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
KdPrint(("floppy: RWSeekToCylinder: returning successfully, now on cyl %d\n", Cylinder)); DPRINT(("floppy: RWSeekToCylinder: returning successfully, now on cyl %d\n", Cylinder));
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
@ -360,7 +363,7 @@ static NTSTATUS NTAPI RWComputeCHS(PDRIVE_INFO IN DriveInfo,
ULONG AbsoluteSector; ULONG AbsoluteSector;
UCHAR SectorsPerCylinder = (UCHAR)DriveInfo->DiskGeometry.SectorsPerTrack * (UCHAR)DriveInfo->DiskGeometry.TracksPerCylinder; UCHAR SectorsPerCylinder = (UCHAR)DriveInfo->DiskGeometry.SectorsPerTrack * (UCHAR)DriveInfo->DiskGeometry.TracksPerCylinder;
KdPrint(("floppy: RWComputeCHS: Called with offset 0x%x\n", DiskByteOffset)); DPRINT(("floppy: RWComputeCHS: Called with offset 0x%x\n", DiskByteOffset));
/* First calculate the 1-based "absolute sector" based on the byte offset */ /* First calculate the 1-based "absolute sector" based on the byte offset */
ASSERT(!(DiskByteOffset % DriveInfo->DiskGeometry.BytesPerSector)); /* FIXME: Only handle full sector transfers atm */ ASSERT(!(DiskByteOffset % DriveInfo->DiskGeometry.BytesPerSector)); /* FIXME: Only handle full sector transfers atm */
@ -380,7 +383,7 @@ static NTSTATUS NTAPI RWComputeCHS(PDRIVE_INFO IN DriveInfo,
*/ */
*Sector = ((UCHAR)(AbsoluteSector % SectorsPerCylinder) + 1) - ((*Head) * (UCHAR)DriveInfo->DiskGeometry.SectorsPerTrack); *Sector = ((UCHAR)(AbsoluteSector % SectorsPerCylinder) + 1) - ((*Head) * (UCHAR)DriveInfo->DiskGeometry.SectorsPerTrack);
KdPrint(("floppy: RWComputeCHS: offset 0x%x is c:0x%x h:0x%x s:0x%x\n", DiskByteOffset, *Cylinder, *Head, *Sector)); DPRINT(("floppy: RWComputeCHS: offset 0x%x is c:0x%x h:0x%x s:0x%x\n", DiskByteOffset, *Cylinder, *Head, *Sector));
/* Sanity checking */ /* Sanity checking */
ASSERT(*Cylinder <= DriveInfo->DiskGeometry.Cylinders.QuadPart); ASSERT(*Cylinder <= DriveInfo->DiskGeometry.Cylinders.QuadPart);
@ -434,7 +437,7 @@ VOID NTAPI ReadWritePassive(PDRIVE_INFO DriveInfo,
PAGED_CODE(); PAGED_CODE();
KdPrint(("floppy: ReadWritePassive called to %s 0x%x bytes from offset 0x%x\n", DPRINT(("floppy: ReadWritePassive called to %s 0x%x bytes from offset 0x%x\n",
(Stack->MajorFunction == IRP_MJ_READ ? "read" : "write"), (Stack->MajorFunction == IRP_MJ_READ ? "read" : "write"),
(Stack->MajorFunction == IRP_MJ_READ ? Stack->Parameters.Read.Length : Stack->Parameters.Write.Length), (Stack->MajorFunction == IRP_MJ_READ ? Stack->Parameters.Read.Length : Stack->Parameters.Write.Length),
(Stack->MajorFunction == IRP_MJ_READ ? Stack->Parameters.Read.ByteOffset.u.LowPart : (Stack->MajorFunction == IRP_MJ_READ ? Stack->Parameters.Read.ByteOffset.u.LowPart :
@ -450,7 +453,7 @@ VOID NTAPI ReadWritePassive(PDRIVE_INFO DriveInfo,
*/ */
if(DeviceObject->Flags & DO_VERIFY_VOLUME && !(DeviceObject->Flags & SL_OVERRIDE_VERIFY_VOLUME)) if(DeviceObject->Flags & DO_VERIFY_VOLUME && !(DeviceObject->Flags & SL_OVERRIDE_VERIFY_VOLUME))
{ {
KdPrint(("floppy: ReadWritePassive(): DO_VERIFY_VOLUME set; Completing with STATUS_VERIFY_REQUIRED\n")); DPRINT(("floppy: ReadWritePassive(): DO_VERIFY_VOLUME set; Completing with STATUS_VERIFY_REQUIRED\n"));
Irp->IoStatus.Status = STATUS_VERIFY_REQUIRED; Irp->IoStatus.Status = STATUS_VERIFY_REQUIRED;
IoCompleteRequest(Irp, IO_NO_INCREMENT); IoCompleteRequest(Irp, IO_NO_INCREMENT);
return; return;
@ -462,7 +465,7 @@ VOID NTAPI ReadWritePassive(PDRIVE_INFO DriveInfo,
StartMotor(DriveInfo); StartMotor(DriveInfo);
if(HwDiskChanged(DeviceObject->DeviceExtension, &DiskChanged) != STATUS_SUCCESS) if(HwDiskChanged(DeviceObject->DeviceExtension, &DiskChanged) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: ReadWritePassive(): unable to detect disk change; Completing with STATUS_UNSUCCESSFUL\n")); DPRINT(("floppy: ReadWritePassive(): unable to detect disk change; Completing with STATUS_UNSUCCESSFUL\n"));
IoCompleteRequest(Irp, IO_NO_INCREMENT); IoCompleteRequest(Irp, IO_NO_INCREMENT);
StopMotor(DriveInfo->ControllerInfo); StopMotor(DriveInfo->ControllerInfo);
return; return;
@ -470,7 +473,7 @@ VOID NTAPI ReadWritePassive(PDRIVE_INFO DriveInfo,
if(DiskChanged) if(DiskChanged)
{ {
KdPrint(("floppy: ReadWritePhase1(): signalling media changed; Completing with STATUS_MEDIA_CHANGED\n")); DPRINT(("floppy: ReadWritePhase1(): signalling media changed; Completing with STATUS_MEDIA_CHANGED\n"));
/* The following call sets IoStatus.Status and IoStatus.Information */ /* The following call sets IoStatus.Status and IoStatus.Information */
SignalMediaChanged(DeviceObject, Irp); SignalMediaChanged(DeviceObject, Irp);
@ -493,7 +496,7 @@ VOID NTAPI ReadWritePassive(PDRIVE_INFO DriveInfo,
{ {
if(RWDetermineMediaType(DriveInfo) != STATUS_SUCCESS) if(RWDetermineMediaType(DriveInfo) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: ReadWritePassive(): unable to determine media type; completing with STATUS_UNSUCCESSFUL\n")); DPRINT(("floppy: ReadWritePassive(): unable to determine media type; completing with STATUS_UNSUCCESSFUL\n"));
IoCompleteRequest(Irp, IO_NO_INCREMENT); IoCompleteRequest(Irp, IO_NO_INCREMENT);
StopMotor(DriveInfo->ControllerInfo); StopMotor(DriveInfo->ControllerInfo);
return; return;
@ -501,7 +504,7 @@ VOID NTAPI ReadWritePassive(PDRIVE_INFO DriveInfo,
if(DriveInfo->DiskGeometry.MediaType == Unknown) if(DriveInfo->DiskGeometry.MediaType == Unknown)
{ {
KdPrint(("floppy: ReadWritePassive(): Unknown media in drive; completing with STATUS_UNRECOGNIZED_MEDIA\n")); DPRINT(("floppy: ReadWritePassive(): Unknown media in drive; completing with STATUS_UNRECOGNIZED_MEDIA\n"));
Irp->IoStatus.Status = STATUS_UNRECOGNIZED_MEDIA; Irp->IoStatus.Status = STATUS_UNRECOGNIZED_MEDIA;
IoCompleteRequest(Irp, IO_NO_INCREMENT); IoCompleteRequest(Irp, IO_NO_INCREMENT);
StopMotor(DriveInfo->ControllerInfo); StopMotor(DriveInfo->ControllerInfo);
@ -601,7 +604,7 @@ VOID NTAPI ReadWritePassive(PDRIVE_INFO DriveInfo,
if(Status != STATUS_SUCCESS) if(Status != STATUS_SUCCESS)
{ {
KdPrint(("floppy: ReadWritePassive(): unable allocate an adapter channel; completing with STATUS_UNSUCCESSFUL\n")); DPRINT(("floppy: ReadWritePassive(): unable allocate an adapter channel; completing with STATUS_UNSUCCESSFUL\n"));
IoCompleteRequest(Irp, IO_NO_INCREMENT); IoCompleteRequest(Irp, IO_NO_INCREMENT);
StopMotor(DriveInfo->ControllerInfo); StopMotor(DriveInfo->ControllerInfo);
return ; return ;
@ -623,7 +626,7 @@ VOID NTAPI ReadWritePassive(PDRIVE_INFO DriveInfo,
ULONG CurrentTransferBytes; ULONG CurrentTransferBytes;
UCHAR CurrentTransferSectors; UCHAR CurrentTransferSectors;
KdPrint(("floppy: ReadWritePassive(): iterating in while (TransferByteOffset = 0x%x of 0x%x total) - allocating %d registers\n", DPRINT(("floppy: ReadWritePassive(): iterating in while (TransferByteOffset = 0x%x of 0x%x total) - allocating %d registers\n",
TransferByteOffset, Length, DriveInfo->ControllerInfo->MapRegisters)); TransferByteOffset, Length, DriveInfo->ControllerInfo->MapRegisters));
KeClearEvent(&DriveInfo->ControllerInfo->SynchEvent); KeClearEvent(&DriveInfo->ControllerInfo->SynchEvent);
@ -633,7 +636,7 @@ VOID NTAPI ReadWritePassive(PDRIVE_INFO DriveInfo,
*/ */
if(RWComputeCHS(DriveInfo, DiskByteOffset+TransferByteOffset, &Cylinder, &Head, &StartSector) != STATUS_SUCCESS) if(RWComputeCHS(DriveInfo, DiskByteOffset+TransferByteOffset, &Cylinder, &Head, &StartSector) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: ReadWritePassive(): unable to compute CHS; completing with STATUS_UNSUCCESSFUL\n")); DPRINT(("floppy: ReadWritePassive(): unable to compute CHS; completing with STATUS_UNSUCCESSFUL\n"));
RWFreeAdapterChannel(DriveInfo->ControllerInfo->AdapterObject); RWFreeAdapterChannel(DriveInfo->ControllerInfo->AdapterObject);
IoCompleteRequest(Irp, IO_NO_INCREMENT); IoCompleteRequest(Irp, IO_NO_INCREMENT);
StopMotor(DriveInfo->ControllerInfo); StopMotor(DriveInfo->ControllerInfo);
@ -647,7 +650,7 @@ VOID NTAPI ReadWritePassive(PDRIVE_INFO DriveInfo,
{ {
if(RWSeekToCylinder(DriveInfo, Cylinder) != STATUS_SUCCESS) if(RWSeekToCylinder(DriveInfo, Cylinder) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: ReadWritePassive(): unable to seek; completing with STATUS_UNSUCCESSFUL\n")); DPRINT(("floppy: ReadWritePassive(): unable to seek; completing with STATUS_UNSUCCESSFUL\n"));
RWFreeAdapterChannel(DriveInfo->ControllerInfo->AdapterObject); RWFreeAdapterChannel(DriveInfo->ControllerInfo->AdapterObject);
IoCompleteRequest(Irp, IO_NO_INCREMENT); IoCompleteRequest(Irp, IO_NO_INCREMENT);
StopMotor(DriveInfo->ControllerInfo); StopMotor(DriveInfo->ControllerInfo);
@ -661,7 +664,7 @@ VOID NTAPI ReadWritePassive(PDRIVE_INFO DriveInfo,
* We can only ask for a transfer up to the end of the track. Then we have to re-seek and do more. * We can only ask for a transfer up to the end of the track. Then we have to re-seek and do more.
* TODO: Support the MT bit * TODO: Support the MT bit
*/ */
KdPrint(("floppy: ReadWritePassive(): computing number of sectors to transfer (StartSector 0x%x): ", StartSector)); DPRINT(("floppy: ReadWritePassive(): computing number of sectors to transfer (StartSector 0x%x): ", StartSector));
/* 1-based sector number */ /* 1-based sector number */
if( (((DriveInfo->DiskGeometry.TracksPerCylinder - Head) * DriveInfo->DiskGeometry.SectorsPerTrack - StartSector) + 1 ) < if( (((DriveInfo->DiskGeometry.TracksPerCylinder - Head) * DriveInfo->DiskGeometry.SectorsPerTrack - StartSector) + 1 ) <
@ -674,7 +677,7 @@ VOID NTAPI ReadWritePassive(PDRIVE_INFO DriveInfo,
CurrentTransferSectors = (UCHAR)((Length - TransferByteOffset) / DriveInfo->DiskGeometry.BytesPerSector); CurrentTransferSectors = (UCHAR)((Length - TransferByteOffset) / DriveInfo->DiskGeometry.BytesPerSector);
} }
KdPrint(("0x%x\n", CurrentTransferSectors)); DPRINT(("0x%x\n", CurrentTransferSectors));
CurrentTransferBytes = CurrentTransferSectors * DriveInfo->DiskGeometry.BytesPerSector; CurrentTransferBytes = CurrentTransferSectors * DriveInfo->DiskGeometry.BytesPerSector;
@ -682,7 +685,7 @@ VOID NTAPI ReadWritePassive(PDRIVE_INFO DriveInfo,
* Adjust to map registers * Adjust to map registers
* BUG: Does this take into account page crossings? * BUG: Does this take into account page crossings?
*/ */
KdPrint(("floppy: ReadWritePassive(): Trying to transfer 0x%x bytes\n", CurrentTransferBytes)); DPRINT(("floppy: ReadWritePassive(): Trying to transfer 0x%x bytes\n", CurrentTransferBytes));
ASSERT(CurrentTransferBytes); ASSERT(CurrentTransferBytes);
@ -693,7 +696,7 @@ VOID NTAPI ReadWritePassive(PDRIVE_INFO DriveInfo,
CurrentTransferBytes = CurrentTransferSectors * DriveInfo->DiskGeometry.BytesPerSector; CurrentTransferBytes = CurrentTransferSectors * DriveInfo->DiskGeometry.BytesPerSector;
KdPrint(("floppy: ReadWritePassive: limiting transfer to 0x%x bytes (0x%x sectors) due to map registers\n", DPRINT(("floppy: ReadWritePassive: limiting transfer to 0x%x bytes (0x%x sectors) due to map registers\n",
CurrentTransferBytes, CurrentTransferSectors)); CurrentTransferBytes, CurrentTransferSectors));
} }
@ -715,14 +718,14 @@ VOID NTAPI ReadWritePassive(PDRIVE_INFO DriveInfo,
if(HwReadWriteData(DriveInfo->ControllerInfo, !WriteToDevice, DriveInfo->UnitNumber, Cylinder, Head, StartSector, if(HwReadWriteData(DriveInfo->ControllerInfo, !WriteToDevice, DriveInfo->UnitNumber, Cylinder, Head, StartSector,
DriveInfo->BytesPerSectorCode, DriveInfo->DiskGeometry.SectorsPerTrack, Gap, 0xff) != STATUS_SUCCESS) DriveInfo->BytesPerSectorCode, DriveInfo->DiskGeometry.SectorsPerTrack, Gap, 0xff) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: ReadWritePassive(): HwReadWriteData returned failure; unable to read; completing with STATUS_UNSUCCESSFUL\n")); DPRINT(("floppy: ReadWritePassive(): HwReadWriteData returned failure; unable to read; completing with STATUS_UNSUCCESSFUL\n"));
RWFreeAdapterChannel(DriveInfo->ControllerInfo->AdapterObject); RWFreeAdapterChannel(DriveInfo->ControllerInfo->AdapterObject);
IoCompleteRequest(Irp, IO_NO_INCREMENT); IoCompleteRequest(Irp, IO_NO_INCREMENT);
StopMotor(DriveInfo->ControllerInfo); StopMotor(DriveInfo->ControllerInfo);
return ; return ;
} }
KdPrint(("floppy: ReadWritePassive(): HwReadWriteData returned -- waiting on event\n")); DPRINT(("floppy: ReadWritePassive(): HwReadWriteData returned -- waiting on event\n"));
/* /*
* At this point, we block and wait for an interrupt * At this point, we block and wait for an interrupt
@ -739,7 +742,7 @@ VOID NTAPI ReadWritePassive(PDRIVE_INFO DriveInfo,
/* Read the results from the drive */ /* Read the results from the drive */
if(HwReadWriteResult(DriveInfo->ControllerInfo) != STATUS_SUCCESS) if(HwReadWriteResult(DriveInfo->ControllerInfo) != STATUS_SUCCESS)
{ {
KdPrint(("floppy: ReadWritePassive(): HwReadWriteResult returned failure; unable to read; completing with STATUS_UNSUCCESSFUL\n")); DPRINT(("floppy: ReadWritePassive(): HwReadWriteResult returned failure; unable to read; completing with STATUS_UNSUCCESSFUL\n"));
HwDumpRegisters(DriveInfo->ControllerInfo); HwDumpRegisters(DriveInfo->ControllerInfo);
RWFreeAdapterChannel(DriveInfo->ControllerInfo->AdapterObject); RWFreeAdapterChannel(DriveInfo->ControllerInfo->AdapterObject);
IoCompleteRequest(Irp, IO_NO_INCREMENT); IoCompleteRequest(Irp, IO_NO_INCREMENT);
@ -753,7 +756,7 @@ VOID NTAPI ReadWritePassive(PDRIVE_INFO DriveInfo,
RWFreeAdapterChannel(DriveInfo->ControllerInfo->AdapterObject); RWFreeAdapterChannel(DriveInfo->ControllerInfo->AdapterObject);
/* That's all folks! */ /* That's all folks! */
KdPrint(("floppy: ReadWritePassive(): success; Completing with STATUS_SUCCESS\n")); DPRINT(("floppy: ReadWritePassive(): success; Completing with STATUS_SUCCESS\n"));
Irp->IoStatus.Status = STATUS_SUCCESS; Irp->IoStatus.Status = STATUS_SUCCESS;
Irp->IoStatus.Information = Length; Irp->IoStatus.Information = Length;
IoCompleteRequest(Irp, IO_NO_INCREMENT); IoCompleteRequest(Irp, IO_NO_INCREMENT);