Commit in reactos/drivers/storage/floppy on MAIN
csqrtns.c+19-121.1 -> 1.2
floppy.c+62-211.2 -> 1.3
floppy.h+4-71.1 -> 1.2
hardware.c+3-11.2 -> 1.3
hardware.h-21.1 -> 1.2
readwrite.c+4-191.6 -> 1.7
+92-62
6 modified files
Lots of code clean-up; correctly copies files of any size to/from disk; 
clean under prefast, lint, verifier, and checked win2k

reactos/drivers/storage/floppy
csqrtns.c 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- csqrtns.c	1 Mar 2004 06:37:26 -0000	1.1
+++ csqrtns.c	11 Mar 2004 23:12:03 -0000	1.2
@@ -56,29 +56,30 @@
  */
 
 
-VOID NTAPI CsqRemoveIrp(PIO_CSQ Csq, 
+VOID NTAPI CsqRemoveIrp(PIO_CSQ UnusedCsq, 
                         PIRP Irp)
 /*
  * FUNCTION: Remove an IRP from the queue
  * ARGUMENTS:
- *     Csq: Pointer to CSQ context structure
+ *     UnusedCsq: Pointer to CSQ context structure
  *     Irp: Pointer to the IRP to remove from the queue
  * NOTES:
  *     - Called under the protection of the queue lock
  */
 {
+  UNREFERENCED_PARAMETER(UnusedCsq);
   KdPrint(("CSQ: Removing IRP 0x%x\n", Irp));
   RemoveEntryList(&Irp->Tail.Overlay.ListEntry);
 }
 
 
-PIRP NTAPI CsqPeekNextIrp(PIO_CSQ Csq, 
+PIRP NTAPI CsqPeekNextIrp(PIO_CSQ UnusedCsq, 
                           PIRP Irp, 
                           PVOID PeekContext)
 /*
  * FUNCTION: Remove the next IRP from the queue
  * 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)
  *     PeekContext: Unused
  * RETURNS:
@@ -88,6 +89,8 @@
  *     - Called under the protection of the queue lock
  */
 {
+  UNREFERENCED_PARAMETER(UnusedCsq);
+  UNREFERENCED_PARAMETER(PeekContext);
   KdPrint(("CSQ: Peeking for next IRP\n"));
 
   if(Irp)
@@ -100,46 +103,49 @@
 }
 
 
-VOID NTAPI CsqAcquireLock(PIO_CSQ Csq, 
+VOID NTAPI CsqAcquireLock(PIO_CSQ UnusedCsq, 
                           PKIRQL Irql)
 /*
  * FUNCTION: Acquire the queue lock
  * ARGUMENTS:
- *     Csq: Pointer to CSQ context structure
+ *     UnusedCsq: Pointer to CSQ context structure
  *     Irql: Pointer to a variable to store the old irql into
  */
 {
+  UNREFERENCED_PARAMETER(UnusedCsq);
   KdPrint(("CSQ: Acquiring spin lock\n"));
   KeAcquireSpinLock(&IrpQueueLock, Irql);
 }
 
 
-VOID NTAPI CsqReleaseLock(PIO_CSQ Csq, 
+VOID NTAPI CsqReleaseLock(PIO_CSQ UnusedCsq, 
                           KIRQL Irql)
 /*
  * FUNCTION: Release the queue lock
  * ARGUMENTS:
- *     Csq: Pointer to CSQ context structure
+ *     UnusedCsq: Pointer to CSQ context structure
  *     Irql: IRQL to lower to on release
  */
 {
+  UNREFERENCED_PARAMETER(UnusedCsq);
   KdPrint(("CSQ: Releasing spin lock\n"));
   KeReleaseSpinLock(&IrpQueueLock, Irql);
 }
 
 
-VOID NTAPI CsqCompleteCanceledIrp(PIO_CSQ Csq, 
+VOID NTAPI CsqCompleteCanceledIrp(PIO_CSQ UnusedCsq, 
                                   PIRP Irp)
 /*
  * FUNCTION: Complete a canceled IRP
  * ARGUMENTS:
- *    Csq: Pointer to CSQ context structure
+ *    UnusedCsq: Pointer to CSQ context structure
  *    Irp: IRP to complete
  * NOTES:
  *    - Perhaps we should complete with something besides NO_INCREMENT
  *    - MS misspelled CANCELLED... sigh...
  */
 {
+  UNREFERENCED_PARAMETER(UnusedCsq);
   KdPrint(("CSQ: Canceling irp 0x%x\n", Irp));
   Irp->IoStatus.Status = STATUS_CANCELLED;
   Irp->IoStatus.Information = 0;
@@ -147,12 +153,12 @@
 }
 
 
-VOID NTAPI CsqInsertIrp(PIO_CSQ Csq, 
+VOID NTAPI CsqInsertIrp(PIO_CSQ UnusedCsq, 
                         PIRP Irp)
 /*
  * FUNCTION: Queue an IRP
  * ARGUMENTS:
- *     Csq: Unused
+ *     UnusedCsq: Unused
  *     Irp: IRP to add to the queue
  * NOTES:
  *     - Called under the protection of the queue lock
@@ -164,6 +170,7 @@
  *       that at least one IRP is canceled at some point
  */
 {
+  UNREFERENCED_PARAMETER(UnusedCsq);
   KdPrint(("CSQ: Inserting IRP 0x%x\n", Irp));
   InsertTailList(&IrpQueue, &Irp->Tail.Overlay.ListEntry);
   KeReleaseSemaphore(&QueueSemaphore, 0, 1, FALSE);

reactos/drivers/storage/floppy
floppy.c 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- floppy.c	11 Mar 2004 06:24:44 -0000	1.2
+++ floppy.c	11 Mar 2004 23:12:03 -0000	1.3
@@ -64,25 +64,22 @@
  * will probably have only one, with four being a very unlikely maximum, a static
  * global array is easiest to deal with.
  */
-CONTROLLER_INFO gControllerInfo[MAX_CONTROLLERS];
-ULONG gNumberOfControllers = 0;
+static CONTROLLER_INFO gControllerInfo[MAX_CONTROLLERS];
+static ULONG gNumberOfControllers = 0;
 
 /* Queue thread management */
-KEVENT QueueThreadTerminate;
-PVOID ThreadObject;
-
-/* ISR DPC */
-KDPC Dpc;
+static KEVENT QueueThreadTerminate;
+static PVOID ThreadObject;
 
 
-static VOID NTAPI MotorStopDpcFunc(PKDPC Dpc,
+static VOID NTAPI MotorStopDpcFunc(PKDPC UnusedDpc,
 			    PVOID DeferredContext,
 			    PVOID SystemArgument1,
 			    PVOID SystemArgument2)
 /*
  * FUNCTION: Stop the floppy motor
  * 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
  *     SystemArgument1: unused
  *     SystemArgument2: unused
@@ -93,6 +90,10 @@
 {
   PCONTROLLER_INFO ControllerInfo = (PCONTROLLER_INFO)DeferredContext;
 
+  UNREFERENCED_PARAMETER(SystemArgument1);
+  UNREFERENCED_PARAMETER(SystemArgument2);
+  UNREFERENCED_PARAMETER(UnusedDpc);
+
   ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL);
   ASSERT(ControllerInfo);
 
@@ -133,7 +134,8 @@
       DriveInfo->ControllerInfo->StopDpcQueued = FALSE;
     }
 
-  HwTurnOnMotor(DriveInfo);
+  if(HwTurnOnMotor(DriveInfo) != STATUS_SUCCESS)
+    KdPrint(("floppy: StartMotor(): warning: HwTurnOnMotor failed\n"));
 }
 
 
@@ -203,6 +205,8 @@
  * 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"));
 
   Irp->IoStatus.Status = STATUS_SUCCESS;
@@ -239,7 +243,11 @@
 
   /* set the data rate */
   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 */
   KeClearEvent(&DriveInfo->ControllerInfo->SynchEvent);
@@ -313,7 +321,11 @@
 
   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 */
   if(HwSeek(DriveInfo, 1) != STATUS_SUCCESS)
@@ -324,7 +336,11 @@
 
   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 */
   if(HwDiskChanged(DriveInfo, &DiskChanged) != STATUS_SUCCESS)
@@ -354,6 +370,7 @@
   ULONG i,j;
 
   PAGED_CODE();
+  UNREFERENCED_PARAMETER(DriverObject);
 
   KdPrint(("floppy: unloading\n"));
 
@@ -380,7 +397,8 @@
       IoDisconnectInterrupt(gControllerInfo[i].InterruptObject);
 
       /* Power down the controller */
-      HwPowerOff(&gControllerInfo[i]);
+      if(HwPowerOff(&gControllerInfo[i]) != STATUS_SUCCESS)
+	KdPrint(("floppy: unload: warning: HwPowerOff failed\n"));
     }
 }
 
@@ -440,6 +458,13 @@
   UCHAR i;
 
   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));
 
@@ -471,12 +496,19 @@
           ULONG AddressSpace = 0x1; /* I/O Port Range */
 
           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)
-            gControllerInfo[gNumberOfControllers].BaseAddress = MmMapIoSpace(TranslatedAddress, 8, FALSE); // symbolic constant?
+	    {
+              gControllerInfo[gNumberOfControllers].BaseAddress = MmMapIoSpace(TranslatedAddress, 8, MmNonCached); // symbolic constant?
+	    }
           else
-            gControllerInfo[gNumberOfControllers].BaseAddress = (PUCHAR)TranslatedAddress.u.LowPart;
+	    {
+              gControllerInfo[gNumberOfControllers].BaseAddress = (PUCHAR)TranslatedAddress.u.LowPart;
+	    }
         }
 
       else if(PartialDescriptor->Type == CmResourceTypeDma)
@@ -558,6 +590,8 @@
 {
   PCONTROLLER_INFO ControllerInfo = (PCONTROLLER_INFO)ServiceContext;
 
+  UNREFERENCED_PARAMETER(Interrupt);
+
   ASSERT(ControllerInfo);
 
   KdPrint(("floppy: ISR called\n"));
@@ -575,14 +609,14 @@
 }
 
 
-VOID NTAPI DpcForIsr(PKDPC Dpc,
+VOID NTAPI DpcForIsr(PKDPC UnusedDpc,
                      PVOID Context,
                      PVOID SystemArgument1,
                      PVOID SystemArgument2)
 /*
  * FUNCTION: This DPC gets queued by every ISR.  Does the real per-interrupt work.
  * 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
  *     Irp: Unused
  *     Context: Pointer to our ControllerInfo struct 
@@ -598,6 +632,10 @@
 {
   PCONTROLLER_INFO ControllerInfo = (PCONTROLLER_INFO)Context;
 
+  UNREFERENCED_PARAMETER(UnusedDpc);
+  UNREFERENCED_PARAMETER(SystemArgument1);
+  UNREFERENCED_PARAMETER(SystemArgument2);
+
   ASSERT(ControllerInfo);
 
   KdPrint(("floppy: DpcForIsr called\n"));
@@ -868,7 +906,7 @@
 	   * 14: 3,2
 	   * 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);
           RtlInitUnicodeString(&DeviceName, DeviceNameBuf);
@@ -962,7 +1000,7 @@
 }
 
 
-VOID NTAPI QueueThread(PVOID Context)
+static VOID NTAPI QueueThread(PVOID Context)
 /*
  * FUNCTION: Thread that manages the queue and dispatches any queued requests
  * ARGUMENTS:
@@ -975,6 +1013,7 @@
   PVOID Objects[2];
 
   PAGED_CODE();
+  UNREFERENCED_PARAMETER(Context);
 
   Objects[0] = &QueueSemaphore;
   Objects[1] = &QueueThreadTerminate;
@@ -1043,6 +1082,8 @@
 {
   HANDLE ThreadHandle;
 
+  UNREFERENCED_PARAMETER(RegistryPath);
+
   /*
    * Set up dispatch routines
    */

reactos/drivers/storage/floppy
floppy.h 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- floppy.h	1 Mar 2004 06:37:26 -0000	1.1
+++ floppy.h	11 Mar 2004 23:12:03 -0000	1.2
@@ -55,6 +55,10 @@
 #define PAGED_CODE() {ASSERT(KeGetCurrentIrql() < DISPATCH_LEVEL);}
 #endif
 
+#ifndef UNREFERENCED_PARAMETER
+#define UNREFERENCED_PARAMETER(x) { (x) = (x); }
+#endif
+
 struct _CONTROLLER_INFO;
 
 typedef struct _DRIVE_INFO
@@ -101,13 +105,6 @@
   BOOLEAN          StopDpcQueued;
 } 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,
                            PUNICODE_STRING RegistryPath);
 

reactos/drivers/storage/floppy
hardware.c 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- hardware.c	10 Mar 2004 19:35:04 -0000	1.2
+++ hardware.c	11 Mar 2004 23:12:03 -0000	1.3
@@ -846,7 +846,7 @@
   if(Send_Byte(ControllerInfo, COMMAND_VERSION) != STATUS_SUCCESS)
     {
       KdPrint(("floppy: HwGetVersion: unable to write fifo\n"));
-      return STATUS_UNSUCCESSFUL;;
+      return STATUS_UNSUCCESSFUL;
     }
 
   if(Get_Byte(ControllerInfo, &Buffer) != STATUS_SUCCESS)
@@ -1108,6 +1108,8 @@
  *     ControllerInfo: Controller to dump registers from
  */
 {
+  UNREFERENCED_PARAMETER(ControllerInfo);
+
   KdPrint(("floppy: STATUS: "));
   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)));

reactos/drivers/storage/floppy
hardware.h 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- hardware.h	1 Mar 2004 06:37:26 -0000	1.1
+++ hardware.h	11 Mar 2004 23:12:03 -0000	1.2
@@ -324,8 +324,6 @@
 NTSTATUS NTAPI HwSetDataRate(PCONTROLLER_INFO ControllerInfo, 
                              UCHAR DataRate);
 
-NTSTATUS NTAPI HwRecalibrateResult(PCONTROLLER_INFO ControllerInfo);
-
 NTSTATUS NTAPI HwReset(PCONTROLLER_INFO Controller);
 
 NTSTATUS NTAPI HwPowerOff(PCONTROLLER_INFO ControllerInfo);

reactos/drivers/storage/floppy
readwrite.c 1.6 -> 1.7
diff -u -r1.6 -r1.7
--- readwrite.c	11 Mar 2004 07:01:58 -0000	1.6
+++ readwrite.c	11 Mar 2004 23:12:03 -0000	1.7
@@ -77,6 +77,8 @@
  */
 {
   PCONTROLLER_INFO ControllerInfo = (PCONTROLLER_INFO)Context;
+  UNREFERENCED_PARAMETER(DeviceObject);
+  UNREFERENCED_PARAMETER(Irp);
 
   KdPrint(("floppy: MapRegisterCallback Called\n"));
 
@@ -104,14 +106,11 @@
  *       it onto the irp queue
  */
 {
-  PIO_STACK_LOCATION Stack;
   KdPrint(("floppy: ReadWrite called\n"));
 
   ASSERT(DeviceObject);
   ASSERT(Irp);
 
-  Stack = IoGetCurrentIrpStackLocation(Irp);
-
   if(!Irp->MdlAddress)
     {
       KdPrint(("floppy: ReadWrite(): MDL not found in IRP - Completing with STATUS_INVALID_PARAMETER\n"));
@@ -502,26 +501,12 @@
   /* Set up parameters for read or write */
   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;
       DiskByteOffset = Stack->Parameters.Read.ByteOffset.u.LowPart;
       WriteToDevice = FALSE;
     }
   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;
       DiskByteOffset = Stack->Parameters.Write.ByteOffset.u.LowPart;
       WriteToDevice = TRUE;
@@ -660,10 +645,10 @@
       KdPrint(("floppy: ReadWritePassive(): computing number of sectors to transfer (StartSector 0x%x): ", StartSector));
 
       /* 1-based sector number */
-      if( (DriveInfo->DiskGeometry.SectorsPerTrack - StartSector + 1) < 
+      if( ((DriveInfo->DiskGeometry.SectorsPerTrack - StartSector) + 1) < 
 	  (Length - TransferByteOffset) / DriveInfo->DiskGeometry.BytesPerSector)
 	{
-	  CurrentTransferSectors = (UCHAR)DriveInfo->DiskGeometry.SectorsPerTrack - StartSector + 1;
+	  CurrentTransferSectors = (UCHAR)(DriveInfo->DiskGeometry.SectorsPerTrack - StartSector) + 1;
 	}
       else
 	{
CVSspam 0.2.8