From 89aa9d3264aa5323d30a90ca28849b58190cacd3 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Fri, 13 May 2011 14:04:38 +0000 Subject: [PATCH] [USBSTOR] - Fix bug in read command, which uses wrong format. LBA address is stored in the CDB10 struct - Don't build the mdl for nonpaged pool if the driver passes an mdl (i/o paging requests) - Usbstor can now list disk contents and browse files when used in Windows XP - Need to implement SCSIOP_WRITE to write files svn path=/branches/usb-bringup/; revision=51694 --- drivers/usb/usbstor/scsi.c | 22 ++++++++++++++-------- drivers/usb/usbstor/usbstor.h | 5 ++++- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/drivers/usb/usbstor/scsi.c b/drivers/usb/usbstor/scsi.c index 62c72cdc686..fb0d44323ee 100644 --- a/drivers/usb/usbstor/scsi.c +++ b/drivers/usb/usbstor/scsi.c @@ -507,6 +507,10 @@ USBSTOR_SendRequest( return STATUS_INSUFFICIENT_RESOURCES; } + // + // build mdl for nonpaged pool + // + MmBuildMdlForNonPagedPool(Context->TransferBufferMDL); } } else @@ -522,12 +526,12 @@ USBSTOR_SendRequest( // return STATUS_INSUFFICIENT_RESOURCES; } - } - // - // build mdl for nonpaged pool - // - MmBuildMdlForNonPagedPool(Context->TransferBufferMDL); + // + // build mdl for nonpaged pool + // + MmBuildMdlForNonPagedPool(Context->TransferBufferMDL); + } } // @@ -917,10 +921,12 @@ USBSTOR_SendReadCmd( Cmd.Code = SCSIOP_READ; Cmd.LUN = (PDODeviceExtension->LUN & MAX_LUN); Cmd.ContiguousLogicBlocks = _byteswap_ushort(BlockCount); + Cmd.LogicalBlockByte0 = pCDB->CDB10.LogicalBlockByte0; + Cmd.LogicalBlockByte1 = pCDB->CDB10.LogicalBlockByte1; + Cmd.LogicalBlockByte2 = pCDB->CDB10.LogicalBlockByte2; + Cmd.LogicalBlockByte3 = pCDB->CDB10.LogicalBlockByte3; - RtlCopyMemory(&Cmd.LogicalBlockAddress, pCDB->READ12.LogicalBlock, sizeof(UCHAR) * 4); - - DPRINT1("BlockAddress %lu BlockCount %lu BlockLength %lu\n", NTOHL(Cmd.LogicalBlockAddress), BlockCount, PDODeviceExtension->BlockLength); + DPRINT1("BlockAddress %x%x%x%x BlockCount %lu BlockLength %lu\n", Cmd.LogicalBlockByte0, Cmd.LogicalBlockByte1, Cmd.LogicalBlockByte2, Cmd.LogicalBlockByte3, BlockCount, PDODeviceExtension->BlockLength); // // send request diff --git a/drivers/usb/usbstor/usbstor.h b/drivers/usb/usbstor/usbstor.h index 71953a4adfb..7cc6d832948 100644 --- a/drivers/usb/usbstor/usbstor.h +++ b/drivers/usb/usbstor/usbstor.h @@ -151,7 +151,10 @@ typedef struct { UCHAR Code; // operation code UCHAR LUN; // lun - ULONG LogicalBlockAddress; // logical block address + UCHAR LogicalBlockByte0; // lba byte 0 + UCHAR LogicalBlockByte1; // lba byte 1 + UCHAR LogicalBlockByte2; // lba byte 2 + UCHAR LogicalBlockByte3; // lba byte 3 UCHAR Reserved; // reserved 0x00 USHORT ContiguousLogicBlocks; // num of contiguous logical blocks UCHAR Reserved1[3]; // reserved 0x00