mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 10:35:28 +00:00
[USBSTOR]
- Partly implement test unit command svn path=/branches/usb-bringup/; revision=51671
This commit is contained in:
parent
db5142f32f
commit
fc298e51a5
3 changed files with 164 additions and 19 deletions
|
@ -125,13 +125,36 @@ USBSTOR_HandleExecuteSCSI(
|
|||
else
|
||||
{
|
||||
//
|
||||
// failed to retrieve sense data
|
||||
// failed to read
|
||||
//
|
||||
Irp->IoStatus.Information = 0;
|
||||
Request->SrbStatus = SRB_STATUS_ERROR;
|
||||
}
|
||||
}
|
||||
else if (pCDB->MODE_SENSE.OperationCode == SCSIOP_TEST_UNIT_READY)
|
||||
{
|
||||
DPRINT1("SCSIOP_TEST_UNIT_READY\n");
|
||||
|
||||
//
|
||||
// send test unit command
|
||||
//
|
||||
Status = USBSTOR_SendTestUnitCmd(DeviceObject, Request);
|
||||
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
//
|
||||
// store returned info length
|
||||
//
|
||||
Request->SrbStatus = SRB_STATUS_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// test unit command failed
|
||||
//
|
||||
Request->SrbStatus = SRB_STATUS_ERROR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
|
@ -421,7 +444,7 @@ USBSTOR_HandleQueryProperty(
|
|||
DeviceDescriptor->Size = TotalLength;
|
||||
DeviceDescriptor->DeviceType = InquiryData->DeviceType;
|
||||
DeviceDescriptor->DeviceTypeModifier = (InquiryData->RMB & 0x7F);
|
||||
DeviceDescriptor->RemovableMedia = FALSE; //FIXME check if floppy
|
||||
DeviceDescriptor->RemovableMedia = TRUE;
|
||||
DeviceDescriptor->CommandQueueing = FALSE;
|
||||
DeviceDescriptor->BusType = BusTypeUsb;
|
||||
DeviceDescriptor->VendorIdOffset = sizeof(STORAGE_DEVICE_DESCRIPTOR) - sizeof(UCHAR);
|
||||
|
|
|
@ -632,7 +632,7 @@ USBSTOR_SendModeSenseCmd(
|
|||
// MODE_PARAMETER_BLOCK
|
||||
//
|
||||
//
|
||||
DbgBreakPoint();
|
||||
UNIMPLEMENTED
|
||||
|
||||
//
|
||||
// send csw
|
||||
|
@ -813,3 +813,77 @@ USBSTOR_SendReadCmd(
|
|||
//
|
||||
return Status;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
USBSTOR_SendTestUnitCmd(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN OUT PSCSI_REQUEST_BLOCK Request)
|
||||
{
|
||||
UFI_TEST_UNIT_CMD Cmd;
|
||||
CSW CSW;
|
||||
NTSTATUS Status;
|
||||
PVOID Response;
|
||||
PPDO_DEVICE_EXTENSION PDODeviceExtension;
|
||||
PCBW OutControl;
|
||||
PCDB pCDB;
|
||||
ULONG BlockCount;
|
||||
|
||||
//
|
||||
// initialize test unit cmd
|
||||
//
|
||||
RtlZeroMemory(&Cmd, sizeof(UFI_TEST_UNIT_CMD));
|
||||
Cmd.Code = SCSIOP_TEST_UNIT_READY;
|
||||
Cmd.LUN = (PDODeviceExtension->LUN & MAX_LUN);
|
||||
|
||||
//
|
||||
// no data should be transferred
|
||||
//
|
||||
ASSERT(Request->DataTransferLength == 0);
|
||||
|
||||
//
|
||||
// now send test unit cmd
|
||||
//
|
||||
Status = USBSTOR_SendCBW(DeviceObject, UFI_TEST_UNIT_CMD_LEN, (PUCHAR)&Cmd, 0, &OutControl);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
//
|
||||
// failed to send CBW
|
||||
//
|
||||
DPRINT1("USBSTOR_SendReadCmd> USBSTOR_SendCBW failed with %x\n", Status);
|
||||
FreeItem(Response);
|
||||
ASSERT(FALSE);
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// send csw
|
||||
//
|
||||
Status = USBSTOR_SendCSW(DeviceObject, OutControl, 512, &CSW);
|
||||
|
||||
DPRINT1("------------------------\n");
|
||||
DPRINT1("CSW %p\n", &CSW);
|
||||
DPRINT1("Signature %x\n", CSW.Signature);
|
||||
DPRINT1("Tag %x\n", CSW.Tag);
|
||||
DPRINT1("DataResidue %x\n", CSW.DataResidue);
|
||||
DPRINT1("Status %x\n", CSW.Status);
|
||||
|
||||
//
|
||||
// FIXME: handle error
|
||||
//
|
||||
ASSERT(CSW.Status == 0);
|
||||
ASSERT(CSW.DataResidue == 0);
|
||||
|
||||
//
|
||||
// free item
|
||||
//
|
||||
FreeItem(OutControl);
|
||||
|
||||
//
|
||||
// FIXME: read sense buffer
|
||||
//
|
||||
|
||||
//
|
||||
// done
|
||||
//
|
||||
return Status;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,22 @@
|
|||
#define USB_STOR_TAG 'sbsu'
|
||||
#define USB_MAXCHILDREN (16)
|
||||
|
||||
|
||||
|
||||
#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))
|
||||
|
||||
NTSTATUS NTAPI
|
||||
IoAttachDeviceToDeviceStackSafe(
|
||||
IN PDEVICE_OBJECT SourceDevice,
|
||||
|
@ -56,6 +72,8 @@ typedef struct
|
|||
UCHAR LUN; // lun id
|
||||
PVOID InquiryData; // USB SCSI inquiry data
|
||||
UCHAR Claimed; // indicating if it has been claimed by upper driver
|
||||
ULONG BlockLength; // length of block
|
||||
ULONG LastLogicBlockAddress; // last block address
|
||||
}PDO_DEVICE_EXTENSION, *PPDO_DEVICE_EXTENSION;
|
||||
|
||||
//
|
||||
|
@ -125,6 +143,24 @@ typedef struct
|
|||
|
||||
C_ASSERT(sizeof(UFI_INQUIRY_RESPONSE) == 36);
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// UFI read cmd
|
||||
//
|
||||
typedef struct
|
||||
{
|
||||
UCHAR Code; // operation code
|
||||
UCHAR LUN; // lun
|
||||
ULONG LogicalBlockAddress; // logical block address
|
||||
UCHAR Reserved; // reserved 0x00
|
||||
USHORT ContiguousLogicBlocks; // num of contiguous logical blocks
|
||||
UCHAR Reserved1[3]; // reserved 0x00
|
||||
}UFI_READ_CMD;
|
||||
|
||||
C_ASSERT(sizeof(UFI_READ_CMD) == 12);
|
||||
|
||||
#define UFI_READ_CMD_LEN (0xA)
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// UFI read capacity cmd
|
||||
|
@ -154,22 +190,6 @@ typedef struct
|
|||
|
||||
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))
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// UFI sense mode cmd
|
||||
|
@ -214,6 +234,22 @@ typedef struct
|
|||
}UFI_TIMER_PROTECT_PAGE, *PUFI_TIMER_PROTECT_PAGE;
|
||||
C_ASSERT(sizeof(UFI_TIMER_PROTECT_PAGE) == 8);
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// UFI test unit command
|
||||
//
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UCHAR Code; // operation code 0x00
|
||||
UCHAR LUN; // lun
|
||||
UCHAR Reserved[10]; // reserved 0x00
|
||||
}UFI_TEST_UNIT_CMD, *PUFI_TEST_UNIT_CMD;
|
||||
|
||||
C_ASSERT(sizeof(UFI_TEST_UNIT_CMD) == 12);
|
||||
|
||||
#define UFI_TEST_UNIT_CMD_LEN (6)
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
//
|
||||
// fdo.c routines
|
||||
|
@ -318,6 +354,18 @@ USBSTOR_SendModeSenseCmd(
|
|||
IN OUT PSCSI_REQUEST_BLOCK Request,
|
||||
OUT PULONG TransferBufferLength);
|
||||
|
||||
NTSTATUS
|
||||
USBSTOR_SendReadCmd(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN OUT PSCSI_REQUEST_BLOCK Request,
|
||||
OUT PULONG TransferBufferLength);
|
||||
|
||||
NTSTATUS
|
||||
USBSTOR_SendTestUnitCmd(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN OUT PSCSI_REQUEST_BLOCK Request);
|
||||
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
//
|
||||
// disk.c routines
|
||||
|
|
Loading…
Reference in a new issue