Author: janderwald
Date: Sun May  8 19:33:41 2011
New Revision: 51649

URL: http://svn.reactos.org/svn/reactos?rev=51649&view=rev
Log:
[USBEHCI_NEW]
- Fix retrieving drive capacity
- Fix ufi command structures

Modified:
    branches/usb-bringup/drivers/usb/usbstor/disk.c
    branches/usb-bringup/drivers/usb/usbstor/scsi.c
    branches/usb-bringup/drivers/usb/usbstor/usbstor.h

Modified: branches/usb-bringup/drivers/usb/usbstor/disk.c
URL: 
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbstor/disk.c?rev=51649&r1=51648&r2=51649&view=diff
==============================================================================
--- branches/usb-bringup/drivers/usb/usbstor/disk.c [iso-8859-1] (original)
+++ branches/usb-bringup/drivers/usb/usbstor/disk.c [iso-8859-1] Sun May  8 
19:33:41 2011
@@ -97,7 +97,7 @@
         else
         {
             //
-            // failed to retrieve capacity
+            // failed to retrieve sense data
             //
             Irp->IoStatus.Information = 0;
             Request->SrbStatus = SRB_STATUS_ERROR;

Modified: branches/usb-bringup/drivers/usb/usbstor/scsi.c
URL: 
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbstor/scsi.c?rev=51649&r1=51648&r2=51649&view=diff
==============================================================================
--- branches/usb-bringup/drivers/usb/usbstor/scsi.c [iso-8859-1] (original)
+++ branches/usb-bringup/drivers/usb/usbstor/scsi.c [iso-8859-1] Sun May  8 
19:33:41 2011
@@ -410,7 +410,7 @@
     OUT PREAD_CAPACITY_DATA_EX CapacityDataEx,
     OUT PREAD_CAPACITY_DATA CapacityData)
 {
-    UFI_INQUIRY_CMD Cmd;
+    UFI_CAPACITY_CMD Cmd;
     CSW CSW;
     NTSTATUS Status;
     PUFI_CAPACITY_RESPONSE Response;
@@ -438,9 +438,8 @@
     // initialize capacity cmd
     //
     RtlZeroMemory(&Cmd, sizeof(UFI_INQUIRY_CMD));
-    Cmd.Code = SCSIOP_INQUIRY;
+    Cmd.Code = SCSIOP_READ_CAPACITY;
     Cmd.LUN = (PDODeviceExtension->LUN & MAX_LUN);
-    Cmd.AllocationLength = sizeof(UFI_INQUIRY_RESPONSE);
 
     //
     // now send capacity cmd
@@ -472,9 +471,9 @@
         return Status;
     }
 
-    DPRINT1("LastLogicalBlockAddress %lu\n", 
Response->LastLogicalBlockAddress);
-    DPRINT1("BlockLength %lu\n", Response->BlockLength);
-    DPRINT1("Medium Length %lu\n", Response->BlockLength * 
Response->LastLogicalBlockAddress);
+    DPRINT1("LastLogicalBlockAddress %lu\n", 
NTOHL(Response->LastLogicalBlockAddress));
+    DPRINT1("BlockLength %lu\n", NTOHL(Response->BlockLength));
+    DPRINT1("Medium Length %lu\n", NTOHL(Response->BlockLength) * 
NTOHL(Response->LastLogicalBlockAddress));
 
     //
     // store response
@@ -536,6 +535,7 @@
     PPDO_DEVICE_EXTENSION PDODeviceExtension;
     PCBW OutControl;
     PCDB pCDB;
+    PUFI_MODE_PARAMETER_HEADER Header;
 
     //
     // get SCSI command data block
@@ -558,6 +558,18 @@
         //
         return STATUS_INSUFFICIENT_RESOURCES;
     }
+
+    //
+    // sanity check
+    //
+
+
+    // Supported pages
+    // MODE_PAGE_ERROR_RECOVERY
+    // MODE_PAGE_FLEXIBILE
+    // MODE_PAGE_LUN_MAPPING
+    // MODE_PAGE_FAULT_REPORTING
+    // MODE_SENSE_RETURN_ALL
 
     //
     // initialize mode sense cmd
@@ -567,12 +579,15 @@
     Cmd.LUN = (PDODeviceExtension->LUN & MAX_LUN);
     Cmd.PageCode = pCDB->MODE_SENSE.PageCode;
     Cmd.PC = pCDB->MODE_SENSE.Pc;
-    Cmd.AllocationLength = pCDB->MODE_SENSE.AllocationLength;
+    Cmd.AllocationLength = HTONS(pCDB->MODE_SENSE.AllocationLength);
+
+    DPRINT1("PageCode %x\n", pCDB->MODE_SENSE.PageCode);
+    DPRINT1("PC %x\n", pCDB->MODE_SENSE.Pc);
 
     //
     // now send mode sense cmd
     //
-    Status = USBSTOR_SendCBW(DeviceObject, UFI_CAPACITY_CMD_LEN, (PUCHAR)&Cmd, 
Request->DataTransferLength, &OutControl);
+    Status = USBSTOR_SendCBW(DeviceObject, UFI_SENSE_CMD_LEN, (PUCHAR)&Cmd, 
Request->DataTransferLength, &OutControl);
     if (!NT_SUCCESS(Status))
     {
         //
@@ -598,6 +613,20 @@
         ASSERT(FALSE);
         return Status;
     }
+
+    Header = (PUFI_MODE_PARAMETER_HEADER)Response;
+
+    //
+    // TODO: build layout
+    //
+    // first struct is the header
+    // MODE_PARAMETER_HEADER / _MODE_PARAMETER_HEADER10
+    //
+    // followed by 
+    // MODE_PARAMETER_BLOCK
+    //
+    // 
+       DbgBreakPoint();
 
     //
     // send csw

Modified: branches/usb-bringup/drivers/usb/usbstor/usbstor.h
URL: 
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbstor/usbstor.h?rev=51649&r1=51648&r2=51649&view=diff
==============================================================================
--- branches/usb-bringup/drivers/usb/usbstor/usbstor.h [iso-8859-1] (original)
+++ branches/usb-bringup/drivers/usb/usbstor/usbstor.h [iso-8859-1] Sun May  8 
19:33:41 2011
@@ -63,7 +63,7 @@
 //
 #define USB_BULK_GET_MAX_LUN             0xFE
 
-
+#include <pshpack1.h>
 typedef struct
 {
     ULONG Signature;                                                 // CBW 
signature
@@ -75,6 +75,9 @@
     UCHAR CommandBlock[16];
 }CBW, *PCBW;
 
+C_ASSERT(sizeof(CBW) == 31);
+
+
 #define CBW_SIGNATURE 0x43425355
 #define MAX_LUN 0xF
 
@@ -114,7 +117,7 @@
     UCHAR Version;                                                   // 
contains version 0x00
     UCHAR Format;                                                    // 
response format
     UCHAR Length;                                                    // 
additional length
-    USHORT Reserved;                                                 // 
reserved
+    UCHAR Reserved[3];                                               // 
reserved
     UCHAR Vendor[8];                                                 // vendor 
identification string
     UCHAR Product[16];                                               // 
product identification string
     UCHAR Revision[4];                                               // 
product revision code
@@ -148,6 +151,24 @@
     ULONG LastLogicalBlockAddress;                                   // last 
logical block address
     ULONG BlockLength;                                               // block 
length in bytes
 }UFI_CAPACITY_RESPONSE, *PUFI_CAPACITY_RESPONSE;
+
+C_ASSERT(sizeof(UFI_CAPACITY_RESPONSE) == 8);
+
+#define HTONS(n) (((((unsigned short)(n) & 0xFF)) << 8) | (((unsigned 
short)(n) & 0xFF00) >> 8))
+#define NTOHS(n) (((((unsigned short)(n) & 0xFF)) << 8) | (((unsigned 
short)(n) & 0xFF00) >> 8))
+
+#define HTONL(n) (((((unsigned long)(n) & 0xFF)) << 24) | \
+                  ((((unsigned long)(n) & 0xFF00)) << 8) | \
+                  ((((unsigned long)(n) & 0xFF0000)) >> 8) | \
+                  ((((unsigned long)(n) & 0xFF000000)) >> 24))
+
+
+#define NTOHL(n) (((((unsigned long)(n) & 0xFF)) << 24) | \
+                  ((((unsigned long)(n) & 0xFF00)) << 8) | \
+                  ((((unsigned long)(n) & 0xFF0000)) >> 8) | \
+                  ((((unsigned long)(n) & 0xFF000000)) >> 24))
+
+
 
 
//--------------------------------------------------------------------------------------------------------------------------------------------
 //
@@ -164,7 +185,34 @@
     UCHAR Reserved1[3];
 }UFI_SENSE_CMD, *PUFI_SENSE_CMD;
 
-C_ASSERT(sizeof(UFI_CAPACITY_CMD) == 12);
+C_ASSERT(sizeof(UFI_SENSE_CMD) == 12);
+
+#define UFI_SENSE_CMD_LEN (6)
+
+typedef struct
+{
+    USHORT ModeDataLength;                                           // length 
of parameters for sense cmd
+    UCHAR MediumTypeCode;                                            // 00 for 
mass storage, 0x94 for floppy
+    UCHAR WP:1;                                                      // write 
protect bit
+    UCHAR Reserved1:2;                                                // 
reserved 00
+    UCHAR DPOFUA:1;                                                  // should 
be zero
+    UCHAR Reserved2:4;                                               // 
reserved
+    UCHAR Reserved[4];                                               // 
reserved
+}UFI_MODE_PARAMETER_HEADER, *PUFI_MODE_PARAMETER_HEADER;
+
+
+C_ASSERT(sizeof(UFI_MODE_PARAMETER_HEADER) == 8);
+
+typedef struct
+{
+    UCHAR PC;
+    UCHAR PageLength;
+    UCHAR Reserved1;
+    UCHAR ITM;
+    UCHAR Flags;
+    UCHAR Reserved[3];
+}UFI_TIMER_PROTECT_PAGE, *PUFI_TIMER_PROTECT_PAGE;
+C_ASSERT(sizeof(UFI_TIMER_PROTECT_PAGE) == 8);
 
 //---------------------------------------------------------------------
 //


Reply via email to