[ros-diffs] [arty] 13336: Suggested fix for atapi. The atapi driver wants whole sectors, but the

arty at svn.reactos.com arty at svn.reactos.com
Thu Jan 27 09:16:44 CET 2005


Suggested fix for atapi.  The atapi driver wants whole sectors, but the 
ext2 driver sometimes attempts an incomplete write.  Here we fill the 
remaineder of the sector with zeros.  This isn't the most elegant way to
do it but illustrates the problem.  I'm committing this here because
it's
a branch.
Modified: branches/ext2/reactos/drivers/storage/atapi/atapi.c
  _____  

Modified: branches/ext2/reactos/drivers/storage/atapi/atapi.c
--- branches/ext2/reactos/drivers/storage/atapi/atapi.c	2005-01-27
04:15:14 UTC (rev 13335)
+++ branches/ext2/reactos/drivers/storage/atapi/atapi.c	2005-01-27
08:16:42 UTC (rev 13336)
@@ -2000,12 +2000,12 @@

   UCHAR CylinderLow;
   UCHAR DrvHead;
   UCHAR SectorNumber;
-  UCHAR Command;
+  UCHAR Command = 0;
   ULONG Retries;
   UCHAR Status;
   BOOLEAN FASTCALL (*Handler)(PATAPI_MINIPORT_EXTENSION DevExt);
 
-  DPRINT("AtapiReadWrite() called!\n");
+  DPRINT("AtaiReadWrite() called!\n");
   DPRINT("SCSIOP_WRITE: TargetId: %lu\n",
 	 Srb->TargetId);
 
@@ -2144,13 +2144,16 @@
       if (DeviceExtension->DeviceFlags[Srb->TargetId] &
DEVICE_MULTI_SECTOR_CMD)
         {
           Command = Srb->SrbFlags & SRB_FLAGS_DATA_IN ?
IDE_CMD_READ_MULTIPLE : IDE_CMD_WRITE_MULTIPLE;
+          DPRINT("Command = %x\n", Command);
 	}
       else
         {
           Command = Srb->SrbFlags & SRB_FLAGS_DATA_IN ? IDE_CMD_READ :
IDE_CMD_WRITE;
+          DPRINT("Command = %x\n", Command);
 	}
     }
 
+  DPRINT("Executing Command = %x\n", Command);
   AtapiExecuteCommand(DeviceExtension, Command, Handler);
 
 #ifdef ENABLE_DMA
@@ -2182,7 +2185,7 @@
 	    }
           if (Retries >= IDE_MAX_WRITE_RETRIES)
 	    {
-	      DPRINT1("Drive is BUSY for too long after sending write
command\n");
+	      DPRINT("Drive is BUSY for too long after sending write
command\n");
 	      return(SRB_STATUS_BUSY);
 	    }
 
@@ -2200,12 +2203,47 @@
           /* Write data block */
           if (DeviceExtension->DeviceFlags[Srb->TargetId] &
DEVICE_DWORD_IO)
 	    {
-	      IDEWriteBlock32(DeviceExtension->CommandPortBase,
-			      TargetAddress,
-			      TransferSize);
+                UINT Temp = 0;
+                UINT ExtraWord = TransferSize & (sizeof(UINT)-1);
+                UINT EndOfBlock;
+
+                DPRINT("IDEWriteBlock32(%x, %d)\n", 
+                        DeviceExtension->CommandPortBase,
+                        TransferSize);
+                IDEWriteBlock32(DeviceExtension->CommandPortBase,
+                                TargetAddress,
+                                TransferSize);
+                if( ExtraWord ) {
+                    RtlCopyMemory( &Temp, 
+                                   TargetAddress + 
+                                   (TransferSize & (sizeof(UINT)-1)),
+                                   ExtraWord );
+                    IDEWriteBlock32(DeviceExtension->CommandPortBase,
+                                     &Temp,
+                                     sizeof(Temp));
+                    TransferSize = (TransferSize + sizeof(UINT)) &
+                        ~(sizeof(UINT) - 1);
+                }
+
+                Temp = 0;
+
+                DPRINT("TransferSize = %d (BPS %d)\n", 
+                        TransferSize, DeviceParams->BytesPerSector);
+
+                EndOfBlock = DeviceParams->BytesPerSector - 
+                    (TransferSize & (DeviceParams->BytesPerSector -
1));
+
+                while( EndOfBlock ) {
+                    DPRINT("Zeros Remaining %d\n", EndOfBlock);
+                    IDEWriteBlock32(DeviceExtension->CommandPortBase,
+                                    &Temp,
+                                    sizeof(Temp));
+                    EndOfBlock -= sizeof(Temp);
+                }
 	    }
           else
 	    {
+                DPRINT1("IDEWriteBlock(%x)\n",
DeviceExtension->CommandPortBase);
 	      IDEWriteBlock(DeviceExtension->CommandPortBase,
 			    TargetAddress,
 			    TransferSize);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.reactos.org/pipermail/ros-diffs/attachments/20050127/9e18e40c/attachment.html


More information about the Ros-diffs mailing list