mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
Lots of code clean-up; correctly copies files of any size to/from disk;
clean under prefast, lint, verifier, and checked win2k svn path=/trunk/; revision=8657
This commit is contained in:
parent
304ff0ba96
commit
abc17a4830
6 changed files with 92 additions and 62 deletions
|
@ -56,29 +56,30 @@ KSEMAPHORE QueueSemaphore;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
VOID NTAPI CsqRemoveIrp(PIO_CSQ Csq,
|
VOID NTAPI CsqRemoveIrp(PIO_CSQ UnusedCsq,
|
||||||
PIRP Irp)
|
PIRP Irp)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Remove an IRP from the queue
|
* FUNCTION: Remove an IRP from the queue
|
||||||
* ARGUMENTS:
|
* ARGUMENTS:
|
||||||
* Csq: Pointer to CSQ context structure
|
* UnusedCsq: Pointer to CSQ context structure
|
||||||
* Irp: Pointer to the IRP to remove from the queue
|
* Irp: Pointer to the IRP to remove from the queue
|
||||||
* NOTES:
|
* NOTES:
|
||||||
* - Called under the protection of the queue lock
|
* - Called under the protection of the queue lock
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
|
UNREFERENCED_PARAMETER(UnusedCsq);
|
||||||
KdPrint(("CSQ: Removing IRP 0x%x\n", Irp));
|
KdPrint(("CSQ: Removing IRP 0x%x\n", Irp));
|
||||||
RemoveEntryList(&Irp->Tail.Overlay.ListEntry);
|
RemoveEntryList(&Irp->Tail.Overlay.ListEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PIRP NTAPI CsqPeekNextIrp(PIO_CSQ Csq,
|
PIRP NTAPI CsqPeekNextIrp(PIO_CSQ UnusedCsq,
|
||||||
PIRP Irp,
|
PIRP Irp,
|
||||||
PVOID PeekContext)
|
PVOID PeekContext)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Remove the next IRP from the queue
|
* FUNCTION: Remove the next IRP from the queue
|
||||||
* ARGUMENTS:
|
* ARGUMENTS:
|
||||||
* Csq: Pointer to CSQ context structure
|
* UnusedCsq: Pointer to CSQ context structure
|
||||||
* Irp: Pointer to a starting IRP in the queue (i.e. start search here)
|
* Irp: Pointer to a starting IRP in the queue (i.e. start search here)
|
||||||
* PeekContext: Unused
|
* PeekContext: Unused
|
||||||
* RETURNS:
|
* RETURNS:
|
||||||
|
@ -88,6 +89,8 @@ PIRP NTAPI CsqPeekNextIrp(PIO_CSQ Csq,
|
||||||
* - Called under the protection of the queue lock
|
* - Called under the protection of the queue lock
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
|
UNREFERENCED_PARAMETER(UnusedCsq);
|
||||||
|
UNREFERENCED_PARAMETER(PeekContext);
|
||||||
KdPrint(("CSQ: Peeking for next IRP\n"));
|
KdPrint(("CSQ: Peeking for next IRP\n"));
|
||||||
|
|
||||||
if(Irp)
|
if(Irp)
|
||||||
|
@ -100,46 +103,49 @@ PIRP NTAPI CsqPeekNextIrp(PIO_CSQ Csq,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID NTAPI CsqAcquireLock(PIO_CSQ Csq,
|
VOID NTAPI CsqAcquireLock(PIO_CSQ UnusedCsq,
|
||||||
PKIRQL Irql)
|
PKIRQL Irql)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Acquire the queue lock
|
* FUNCTION: Acquire the queue lock
|
||||||
* ARGUMENTS:
|
* ARGUMENTS:
|
||||||
* Csq: Pointer to CSQ context structure
|
* UnusedCsq: Pointer to CSQ context structure
|
||||||
* 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);
|
||||||
KdPrint(("CSQ: Acquiring spin lock\n"));
|
KdPrint(("CSQ: Acquiring spin lock\n"));
|
||||||
KeAcquireSpinLock(&IrpQueueLock, Irql);
|
KeAcquireSpinLock(&IrpQueueLock, Irql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID NTAPI CsqReleaseLock(PIO_CSQ Csq,
|
VOID NTAPI CsqReleaseLock(PIO_CSQ UnusedCsq,
|
||||||
KIRQL Irql)
|
KIRQL Irql)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Release the queue lock
|
* FUNCTION: Release the queue lock
|
||||||
* ARGUMENTS:
|
* ARGUMENTS:
|
||||||
* Csq: Pointer to CSQ context structure
|
* UnusedCsq: Pointer to CSQ context structure
|
||||||
* Irql: IRQL to lower to on release
|
* Irql: IRQL to lower to on release
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
|
UNREFERENCED_PARAMETER(UnusedCsq);
|
||||||
KdPrint(("CSQ: Releasing spin lock\n"));
|
KdPrint(("CSQ: Releasing spin lock\n"));
|
||||||
KeReleaseSpinLock(&IrpQueueLock, Irql);
|
KeReleaseSpinLock(&IrpQueueLock, Irql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID NTAPI CsqCompleteCanceledIrp(PIO_CSQ Csq,
|
VOID NTAPI CsqCompleteCanceledIrp(PIO_CSQ UnusedCsq,
|
||||||
PIRP Irp)
|
PIRP Irp)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Complete a canceled IRP
|
* FUNCTION: Complete a canceled IRP
|
||||||
* ARGUMENTS:
|
* ARGUMENTS:
|
||||||
* Csq: Pointer to CSQ context structure
|
* UnusedCsq: Pointer to CSQ context structure
|
||||||
* Irp: IRP to complete
|
* Irp: IRP to complete
|
||||||
* NOTES:
|
* NOTES:
|
||||||
* - Perhaps we should complete with something besides NO_INCREMENT
|
* - Perhaps we should complete with something besides NO_INCREMENT
|
||||||
* - MS misspelled CANCELLED... sigh...
|
* - MS misspelled CANCELLED... sigh...
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
|
UNREFERENCED_PARAMETER(UnusedCsq);
|
||||||
KdPrint(("CSQ: Canceling irp 0x%x\n", Irp));
|
KdPrint(("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;
|
||||||
|
@ -147,12 +153,12 @@ VOID NTAPI CsqCompleteCanceledIrp(PIO_CSQ Csq,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID NTAPI CsqInsertIrp(PIO_CSQ Csq,
|
VOID NTAPI CsqInsertIrp(PIO_CSQ UnusedCsq,
|
||||||
PIRP Irp)
|
PIRP Irp)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Queue an IRP
|
* FUNCTION: Queue an IRP
|
||||||
* ARGUMENTS:
|
* ARGUMENTS:
|
||||||
* Csq: Unused
|
* UnusedCsq: Unused
|
||||||
* Irp: IRP to add to the queue
|
* Irp: IRP to add to the queue
|
||||||
* NOTES:
|
* NOTES:
|
||||||
* - Called under the protection of the queue lock
|
* - Called under the protection of the queue lock
|
||||||
|
@ -164,6 +170,7 @@ VOID NTAPI CsqInsertIrp(PIO_CSQ Csq,
|
||||||
* that at least one IRP is canceled at some point
|
* that at least one IRP is canceled at some point
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
|
UNREFERENCED_PARAMETER(UnusedCsq);
|
||||||
KdPrint(("CSQ: Inserting IRP 0x%x\n", Irp));
|
KdPrint(("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);
|
||||||
|
|
|
@ -64,25 +64,22 @@
|
||||||
* will probably have only one, with four being a very unlikely maximum, a static
|
* will probably have only one, with four being a very unlikely maximum, a static
|
||||||
* global array is easiest to deal with.
|
* global array is easiest to deal with.
|
||||||
*/
|
*/
|
||||||
CONTROLLER_INFO gControllerInfo[MAX_CONTROLLERS];
|
static CONTROLLER_INFO gControllerInfo[MAX_CONTROLLERS];
|
||||||
ULONG gNumberOfControllers = 0;
|
static ULONG gNumberOfControllers = 0;
|
||||||
|
|
||||||
/* Queue thread management */
|
/* Queue thread management */
|
||||||
KEVENT QueueThreadTerminate;
|
static KEVENT QueueThreadTerminate;
|
||||||
PVOID ThreadObject;
|
static PVOID ThreadObject;
|
||||||
|
|
||||||
/* ISR DPC */
|
|
||||||
KDPC Dpc;
|
|
||||||
|
|
||||||
|
|
||||||
static VOID NTAPI MotorStopDpcFunc(PKDPC Dpc,
|
static VOID NTAPI MotorStopDpcFunc(PKDPC UnusedDpc,
|
||||||
PVOID DeferredContext,
|
PVOID DeferredContext,
|
||||||
PVOID SystemArgument1,
|
PVOID SystemArgument1,
|
||||||
PVOID SystemArgument2)
|
PVOID SystemArgument2)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Stop the floppy motor
|
* FUNCTION: Stop the floppy motor
|
||||||
* ARGUMENTS:
|
* ARGUMENTS:
|
||||||
* Dpc: DPC object that's going off
|
* UnusedDpc: DPC object that's going off
|
||||||
* DeferredContext: called with DRIVE_INFO for drive to turn off
|
* DeferredContext: called with DRIVE_INFO for drive to turn off
|
||||||
* SystemArgument1: unused
|
* SystemArgument1: unused
|
||||||
* SystemArgument2: unused
|
* SystemArgument2: unused
|
||||||
|
@ -93,6 +90,10 @@ static VOID NTAPI MotorStopDpcFunc(PKDPC Dpc,
|
||||||
{
|
{
|
||||||
PCONTROLLER_INFO ControllerInfo = (PCONTROLLER_INFO)DeferredContext;
|
PCONTROLLER_INFO ControllerInfo = (PCONTROLLER_INFO)DeferredContext;
|
||||||
|
|
||||||
|
UNREFERENCED_PARAMETER(SystemArgument1);
|
||||||
|
UNREFERENCED_PARAMETER(SystemArgument2);
|
||||||
|
UNREFERENCED_PARAMETER(UnusedDpc);
|
||||||
|
|
||||||
ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL);
|
ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL);
|
||||||
ASSERT(ControllerInfo);
|
ASSERT(ControllerInfo);
|
||||||
|
|
||||||
|
@ -133,7 +134,8 @@ VOID NTAPI StartMotor(PDRIVE_INFO DriveInfo)
|
||||||
DriveInfo->ControllerInfo->StopDpcQueued = FALSE;
|
DriveInfo->ControllerInfo->StopDpcQueued = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
HwTurnOnMotor(DriveInfo);
|
if(HwTurnOnMotor(DriveInfo) != STATUS_SUCCESS)
|
||||||
|
KdPrint(("floppy: StartMotor(): warning: HwTurnOnMotor failed\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -203,6 +205,8 @@ static NTSTATUS NTAPI CreateClose(PDEVICE_OBJECT DeviceObject,
|
||||||
* TODO: Figure out why this isn't getting called any more, and remove the ASSERT once that happens
|
* TODO: Figure out why this isn't getting called any more, and remove the ASSERT once that happens
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
|
UNREFERENCED_PARAMETER(DeviceObject);
|
||||||
|
|
||||||
KdPrint(("floppy: CreateClose called\n"));
|
KdPrint(("floppy: CreateClose called\n"));
|
||||||
|
|
||||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||||
|
@ -239,7 +243,11 @@ static NTSTATUS NTAPI Recalibrate(PDRIVE_INFO DriveInfo)
|
||||||
|
|
||||||
/* set the data rate */
|
/* set the data rate */
|
||||||
KdPrint(("floppy: FIXME: UN-HARDCODE DATA RATE\n"));
|
KdPrint(("floppy: FIXME: UN-HARDCODE DATA RATE\n"));
|
||||||
HwSetDataRate(DriveInfo->ControllerInfo, 0);
|
if(HwSetDataRate(DriveInfo->ControllerInfo, 0) != STATUS_SUCCESS)
|
||||||
|
{
|
||||||
|
KdPrint(("floppy: Recalibrate: HwSetDataRate failed\n"));
|
||||||
|
return STATUS_UNSUCCESSFUL;
|
||||||
|
}
|
||||||
|
|
||||||
/* clear the event just in case the last call forgot */
|
/* clear the event just in case the last call forgot */
|
||||||
KeClearEvent(&DriveInfo->ControllerInfo->SynchEvent);
|
KeClearEvent(&DriveInfo->ControllerInfo->SynchEvent);
|
||||||
|
@ -313,7 +321,11 @@ NTSTATUS NTAPI ResetChangeFlag(PDRIVE_INFO DriveInfo)
|
||||||
|
|
||||||
WaitForControllerInterrupt(DriveInfo->ControllerInfo);
|
WaitForControllerInterrupt(DriveInfo->ControllerInfo);
|
||||||
|
|
||||||
HwSenseInterruptStatus(DriveInfo->ControllerInfo);
|
if(HwSenseInterruptStatus(DriveInfo->ControllerInfo) != STATUS_SUCCESS)
|
||||||
|
{
|
||||||
|
KdPrint(("floppy: ResetChangeFlag(): HwSenseInterruptStatus failed; bailing out\n"));
|
||||||
|
return STATUS_IO_DEVICE_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
/* Seek back to 0 */
|
/* Seek back to 0 */
|
||||||
if(HwSeek(DriveInfo, 1) != STATUS_SUCCESS)
|
if(HwSeek(DriveInfo, 1) != STATUS_SUCCESS)
|
||||||
|
@ -324,7 +336,11 @@ NTSTATUS NTAPI ResetChangeFlag(PDRIVE_INFO DriveInfo)
|
||||||
|
|
||||||
WaitForControllerInterrupt(DriveInfo->ControllerInfo);
|
WaitForControllerInterrupt(DriveInfo->ControllerInfo);
|
||||||
|
|
||||||
HwSenseInterruptStatus(DriveInfo->ControllerInfo);
|
if(HwSenseInterruptStatus(DriveInfo->ControllerInfo) != STATUS_SUCCESS)
|
||||||
|
{
|
||||||
|
KdPrint(("floppy: ResetChangeFlag(): HwSenseInterruptStatus #2 failed; bailing\n"));
|
||||||
|
return STATUS_IO_DEVICE_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
/* Check the change bit */
|
/* Check the change bit */
|
||||||
if(HwDiskChanged(DriveInfo, &DiskChanged) != STATUS_SUCCESS)
|
if(HwDiskChanged(DriveInfo, &DiskChanged) != STATUS_SUCCESS)
|
||||||
|
@ -354,6 +370,7 @@ static VOID NTAPI Unload(PDRIVER_OBJECT DriverObject)
|
||||||
ULONG i,j;
|
ULONG i,j;
|
||||||
|
|
||||||
PAGED_CODE();
|
PAGED_CODE();
|
||||||
|
UNREFERENCED_PARAMETER(DriverObject);
|
||||||
|
|
||||||
KdPrint(("floppy: unloading\n"));
|
KdPrint(("floppy: unloading\n"));
|
||||||
|
|
||||||
|
@ -380,7 +397,8 @@ static VOID NTAPI Unload(PDRIVER_OBJECT DriverObject)
|
||||||
IoDisconnectInterrupt(gControllerInfo[i].InterruptObject);
|
IoDisconnectInterrupt(gControllerInfo[i].InterruptObject);
|
||||||
|
|
||||||
/* Power down the controller */
|
/* Power down the controller */
|
||||||
HwPowerOff(&gControllerInfo[i]);
|
if(HwPowerOff(&gControllerInfo[i]) != STATUS_SUCCESS)
|
||||||
|
KdPrint(("floppy: unload: warning: HwPowerOff failed\n"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -440,6 +458,13 @@ static NTSTATUS NTAPI ConfigCallback(PVOID Context,
|
||||||
UCHAR i;
|
UCHAR i;
|
||||||
|
|
||||||
PAGED_CODE();
|
PAGED_CODE();
|
||||||
|
UNREFERENCED_PARAMETER(PeripheralType);
|
||||||
|
UNREFERENCED_PARAMETER(PeripheralNumber);
|
||||||
|
UNREFERENCED_PARAMETER(BusInformation);
|
||||||
|
UNREFERENCED_PARAMETER(Context);
|
||||||
|
UNREFERENCED_PARAMETER(ControllerType);
|
||||||
|
UNREFERENCED_PARAMETER(PathName);
|
||||||
|
|
||||||
|
|
||||||
KdPrint(("floppy: ConfigCallback called with ControllerNumber %d\n", ControllerNumber));
|
KdPrint(("floppy: ConfigCallback called with ControllerNumber %d\n", ControllerNumber));
|
||||||
|
|
||||||
|
@ -471,12 +496,19 @@ static NTSTATUS NTAPI ConfigCallback(PVOID Context,
|
||||||
ULONG AddressSpace = 0x1; /* I/O Port Range */
|
ULONG AddressSpace = 0x1; /* I/O Port Range */
|
||||||
|
|
||||||
if(!HalTranslateBusAddress(BusType, BusNumber, PartialDescriptor->u.Port.Start, &AddressSpace, &TranslatedAddress))
|
if(!HalTranslateBusAddress(BusType, BusNumber, PartialDescriptor->u.Port.Start, &AddressSpace, &TranslatedAddress))
|
||||||
ASSERT(0);
|
{
|
||||||
|
KdPrint(("floppy: HalTranslateBusAddress failed; returning\n"));
|
||||||
|
return STATUS_IO_DEVICE_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if(AddressSpace == 0)
|
if(AddressSpace == 0)
|
||||||
gControllerInfo[gNumberOfControllers].BaseAddress = MmMapIoSpace(TranslatedAddress, 8, FALSE); // symbolic constant?
|
{
|
||||||
|
gControllerInfo[gNumberOfControllers].BaseAddress = MmMapIoSpace(TranslatedAddress, 8, MmNonCached); // symbolic constant?
|
||||||
|
}
|
||||||
else
|
else
|
||||||
gControllerInfo[gNumberOfControllers].BaseAddress = (PUCHAR)TranslatedAddress.u.LowPart;
|
{
|
||||||
|
gControllerInfo[gNumberOfControllers].BaseAddress = (PUCHAR)TranslatedAddress.u.LowPart;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(PartialDescriptor->Type == CmResourceTypeDma)
|
else if(PartialDescriptor->Type == CmResourceTypeDma)
|
||||||
|
@ -558,6 +590,8 @@ static BOOLEAN NTAPI Isr(PKINTERRUPT Interrupt,
|
||||||
{
|
{
|
||||||
PCONTROLLER_INFO ControllerInfo = (PCONTROLLER_INFO)ServiceContext;
|
PCONTROLLER_INFO ControllerInfo = (PCONTROLLER_INFO)ServiceContext;
|
||||||
|
|
||||||
|
UNREFERENCED_PARAMETER(Interrupt);
|
||||||
|
|
||||||
ASSERT(ControllerInfo);
|
ASSERT(ControllerInfo);
|
||||||
|
|
||||||
KdPrint(("floppy: ISR called\n"));
|
KdPrint(("floppy: ISR called\n"));
|
||||||
|
@ -575,14 +609,14 @@ static BOOLEAN NTAPI Isr(PKINTERRUPT Interrupt,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID NTAPI DpcForIsr(PKDPC Dpc,
|
VOID NTAPI DpcForIsr(PKDPC UnusedDpc,
|
||||||
PVOID Context,
|
PVOID Context,
|
||||||
PVOID SystemArgument1,
|
PVOID SystemArgument1,
|
||||||
PVOID SystemArgument2)
|
PVOID SystemArgument2)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: This DPC gets queued by every ISR. Does the real per-interrupt work.
|
* FUNCTION: This DPC gets queued by every ISR. Does the real per-interrupt work.
|
||||||
* ARGUMENTS:
|
* ARGUMENTS:
|
||||||
* Dpc: Pointer to the DPC object that represents our function
|
* UnusedDpc: Pointer to the DPC object that represents our function
|
||||||
* DeviceObject: Device that this DPC is running for
|
* DeviceObject: Device that this DPC is running for
|
||||||
* Irp: Unused
|
* Irp: Unused
|
||||||
* Context: Pointer to our ControllerInfo struct
|
* Context: Pointer to our ControllerInfo struct
|
||||||
|
@ -598,6 +632,10 @@ VOID NTAPI DpcForIsr(PKDPC Dpc,
|
||||||
{
|
{
|
||||||
PCONTROLLER_INFO ControllerInfo = (PCONTROLLER_INFO)Context;
|
PCONTROLLER_INFO ControllerInfo = (PCONTROLLER_INFO)Context;
|
||||||
|
|
||||||
|
UNREFERENCED_PARAMETER(UnusedDpc);
|
||||||
|
UNREFERENCED_PARAMETER(SystemArgument1);
|
||||||
|
UNREFERENCED_PARAMETER(SystemArgument2);
|
||||||
|
|
||||||
ASSERT(ControllerInfo);
|
ASSERT(ControllerInfo);
|
||||||
|
|
||||||
KdPrint(("floppy: DpcForIsr called\n"));
|
KdPrint(("floppy: DpcForIsr called\n"));
|
||||||
|
@ -868,7 +906,7 @@ static BOOLEAN NTAPI AddControllers(PDRIVER_OBJECT DriverObject)
|
||||||
* 14: 3,2
|
* 14: 3,2
|
||||||
* 15: 3,3
|
* 15: 3,3
|
||||||
*/
|
*/
|
||||||
DriveNumber = i*4 + j;
|
DriveNumber = (UCHAR)(i*4 + j); /* loss of precision is OK; there are only 16 of 'em */
|
||||||
|
|
||||||
swprintf(DeviceNameBuf, L"\\Device\\Floppy%d", DriveNumber);
|
swprintf(DeviceNameBuf, L"\\Device\\Floppy%d", DriveNumber);
|
||||||
RtlInitUnicodeString(&DeviceName, DeviceNameBuf);
|
RtlInitUnicodeString(&DeviceName, DeviceNameBuf);
|
||||||
|
@ -962,7 +1000,7 @@ VOID NTAPI SignalMediaChanged(PDEVICE_OBJECT DeviceObject,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID NTAPI QueueThread(PVOID Context)
|
static VOID NTAPI QueueThread(PVOID Context)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Thread that manages the queue and dispatches any queued requests
|
* FUNCTION: Thread that manages the queue and dispatches any queued requests
|
||||||
* ARGUMENTS:
|
* ARGUMENTS:
|
||||||
|
@ -975,6 +1013,7 @@ VOID NTAPI QueueThread(PVOID Context)
|
||||||
PVOID Objects[2];
|
PVOID Objects[2];
|
||||||
|
|
||||||
PAGED_CODE();
|
PAGED_CODE();
|
||||||
|
UNREFERENCED_PARAMETER(Context);
|
||||||
|
|
||||||
Objects[0] = &QueueSemaphore;
|
Objects[0] = &QueueSemaphore;
|
||||||
Objects[1] = &QueueThreadTerminate;
|
Objects[1] = &QueueThreadTerminate;
|
||||||
|
@ -1043,6 +1082,8 @@ NTSTATUS NTAPI DriverEntry(PDRIVER_OBJECT DriverObject,
|
||||||
{
|
{
|
||||||
HANDLE ThreadHandle;
|
HANDLE ThreadHandle;
|
||||||
|
|
||||||
|
UNREFERENCED_PARAMETER(RegistryPath);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set up dispatch routines
|
* Set up dispatch routines
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -55,6 +55,10 @@ int _cdecl swprintf(const WCHAR *, ...);
|
||||||
#define PAGED_CODE() {ASSERT(KeGetCurrentIrql() < DISPATCH_LEVEL);}
|
#define PAGED_CODE() {ASSERT(KeGetCurrentIrql() < DISPATCH_LEVEL);}
|
||||||
#endif
|
#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
|
||||||
|
@ -101,13 +105,6 @@ typedef struct _CONTROLLER_INFO
|
||||||
BOOLEAN StopDpcQueued;
|
BOOLEAN StopDpcQueued;
|
||||||
} CONTROLLER_INFO, *PCONTROLLER_INFO;
|
} CONTROLLER_INFO, *PCONTROLLER_INFO;
|
||||||
|
|
||||||
NTSTATUS NTAPI ReadWrite(PDEVICE_OBJECT DeviceObject,
|
|
||||||
PIRP Irp);
|
|
||||||
|
|
||||||
VOID NTAPI QueueThread(PVOID Context);
|
|
||||||
|
|
||||||
extern KEVENT QueueThreadTerminate;
|
|
||||||
|
|
||||||
NTSTATUS NTAPI DriverEntry(PDRIVER_OBJECT DriverObject,
|
NTSTATUS NTAPI DriverEntry(PDRIVER_OBJECT DriverObject,
|
||||||
PUNICODE_STRING RegistryPath);
|
PUNICODE_STRING RegistryPath);
|
||||||
|
|
||||||
|
|
|
@ -846,7 +846,7 @@ 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"));
|
KdPrint(("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)
|
||||||
|
@ -1108,6 +1108,8 @@ VOID NTAPI HwDumpRegisters(PCONTROLLER_INFO ControllerInfo)
|
||||||
* ControllerInfo: Controller to dump registers from
|
* ControllerInfo: Controller to dump registers from
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
|
UNREFERENCED_PARAMETER(ControllerInfo);
|
||||||
|
|
||||||
KdPrint(("floppy: STATUS: "));
|
KdPrint(("floppy: STATUS: "));
|
||||||
KdPrint(("STATUS_REGISTER_A = 0x%x ", READ_PORT_UCHAR(ControllerInfo->BaseAddress + STATUS_REGISTER_A)));
|
KdPrint(("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)));
|
KdPrint(("STATUS_REGISTER_B = 0x%x ", READ_PORT_UCHAR(ControllerInfo->BaseAddress + STATUS_REGISTER_B)));
|
||||||
|
|
|
@ -324,8 +324,6 @@ NTSTATUS NTAPI HwReadIdResult(PCONTROLLER_INFO ControllerInfo,
|
||||||
NTSTATUS NTAPI HwSetDataRate(PCONTROLLER_INFO ControllerInfo,
|
NTSTATUS NTAPI HwSetDataRate(PCONTROLLER_INFO ControllerInfo,
|
||||||
UCHAR DataRate);
|
UCHAR DataRate);
|
||||||
|
|
||||||
NTSTATUS NTAPI HwRecalibrateResult(PCONTROLLER_INFO ControllerInfo);
|
|
||||||
|
|
||||||
NTSTATUS NTAPI HwReset(PCONTROLLER_INFO Controller);
|
NTSTATUS NTAPI HwReset(PCONTROLLER_INFO Controller);
|
||||||
|
|
||||||
NTSTATUS NTAPI HwPowerOff(PCONTROLLER_INFO ControllerInfo);
|
NTSTATUS NTAPI HwPowerOff(PCONTROLLER_INFO ControllerInfo);
|
||||||
|
|
|
@ -77,6 +77,8 @@ static IO_ALLOCATION_ACTION NTAPI MapRegisterCallback(PDEVICE_OBJECT DeviceObjec
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
PCONTROLLER_INFO ControllerInfo = (PCONTROLLER_INFO)Context;
|
PCONTROLLER_INFO ControllerInfo = (PCONTROLLER_INFO)Context;
|
||||||
|
UNREFERENCED_PARAMETER(DeviceObject);
|
||||||
|
UNREFERENCED_PARAMETER(Irp);
|
||||||
|
|
||||||
KdPrint(("floppy: MapRegisterCallback Called\n"));
|
KdPrint(("floppy: MapRegisterCallback Called\n"));
|
||||||
|
|
||||||
|
@ -104,14 +106,11 @@ NTSTATUS NTAPI ReadWrite(PDEVICE_OBJECT DeviceObject,
|
||||||
* it onto the irp queue
|
* it onto the irp queue
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
PIO_STACK_LOCATION Stack;
|
|
||||||
KdPrint(("floppy: ReadWrite called\n"));
|
KdPrint(("floppy: ReadWrite called\n"));
|
||||||
|
|
||||||
ASSERT(DeviceObject);
|
ASSERT(DeviceObject);
|
||||||
ASSERT(Irp);
|
ASSERT(Irp);
|
||||||
|
|
||||||
Stack = IoGetCurrentIrpStackLocation(Irp);
|
|
||||||
|
|
||||||
if(!Irp->MdlAddress)
|
if(!Irp->MdlAddress)
|
||||||
{
|
{
|
||||||
KdPrint(("floppy: ReadWrite(): MDL not found in IRP - Completing with STATUS_INVALID_PARAMETER\n"));
|
KdPrint(("floppy: ReadWrite(): MDL not found in IRP - Completing with STATUS_INVALID_PARAMETER\n"));
|
||||||
|
@ -502,26 +501,12 @@ VOID NTAPI ReadWritePassive(PDRIVE_INFO DriveInfo,
|
||||||
/* Set up parameters for read or write */
|
/* Set up parameters for read or write */
|
||||||
if(Stack->MajorFunction == IRP_MJ_READ)
|
if(Stack->MajorFunction == IRP_MJ_READ)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
if(Stack->Parameters.Read.Length > PAGE_SIZE * DriveInfo->ControllerInfo->MapRegisters)
|
|
||||||
{
|
|
||||||
KdPrint(("floppy: ReadWritePassive(): unable to transfer; would have to split\n"));
|
|
||||||
ASSERT(0);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
Length = Stack->Parameters.Read.Length;
|
Length = Stack->Parameters.Read.Length;
|
||||||
DiskByteOffset = Stack->Parameters.Read.ByteOffset.u.LowPart;
|
DiskByteOffset = Stack->Parameters.Read.ByteOffset.u.LowPart;
|
||||||
WriteToDevice = FALSE;
|
WriteToDevice = FALSE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
if(Stack->Parameters.Write.Length > PAGE_SIZE * DriveInfo->ControllerInfo->MapRegisters)
|
|
||||||
{
|
|
||||||
KdPrint(("floppy: ReadWritePassive(): unable to transfer; would have to split\n"));
|
|
||||||
ASSERT(0);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
Length = Stack->Parameters.Write.Length;
|
Length = Stack->Parameters.Write.Length;
|
||||||
DiskByteOffset = Stack->Parameters.Write.ByteOffset.u.LowPart;
|
DiskByteOffset = Stack->Parameters.Write.ByteOffset.u.LowPart;
|
||||||
WriteToDevice = TRUE;
|
WriteToDevice = TRUE;
|
||||||
|
@ -660,10 +645,10 @@ VOID NTAPI ReadWritePassive(PDRIVE_INFO DriveInfo,
|
||||||
KdPrint(("floppy: ReadWritePassive(): computing number of sectors to transfer (StartSector 0x%x): ", StartSector));
|
KdPrint(("floppy: ReadWritePassive(): computing number of sectors to transfer (StartSector 0x%x): ", StartSector));
|
||||||
|
|
||||||
/* 1-based sector number */
|
/* 1-based sector number */
|
||||||
if( (DriveInfo->DiskGeometry.SectorsPerTrack - StartSector + 1) <
|
if( ((DriveInfo->DiskGeometry.SectorsPerTrack - StartSector) + 1) <
|
||||||
(Length - TransferByteOffset) / DriveInfo->DiskGeometry.BytesPerSector)
|
(Length - TransferByteOffset) / DriveInfo->DiskGeometry.BytesPerSector)
|
||||||
{
|
{
|
||||||
CurrentTransferSectors = (UCHAR)DriveInfo->DiskGeometry.SectorsPerTrack - StartSector + 1;
|
CurrentTransferSectors = (UCHAR)(DriveInfo->DiskGeometry.SectorsPerTrack - StartSector) + 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue