#include "usbstor.h"
+#define NDEBUG
+#include <debug.h>
+
NTSTATUS
USBSTOR_BuildCBW(
IN ULONG Tag,
NTAPI
USBSTOR_CSWCompletionRoutine(
PDEVICE_OBJECT DeviceObject,
- PIRP Irp,
+ PIRP Irp,
PVOID Ctx)
{
PIRP_CONTEXT Context;
PREAD_CAPACITY_DATA_EX CapacityDataEx;
PREAD_CAPACITY_DATA CapacityData;
PUFI_CAPACITY_RESPONSE Response;
-
NTSTATUS Status;
- PURB Urb;
//
// access context
ASSERT(Request);
Status = Irp->IoStatus.Status;
- Urb = &Context->Urb;
//
// get SCSI command data block
NTAPI
USBSTOR_DataCompletionRoutine(
PDEVICE_OBJECT DeviceObject,
- PIRP Irp,
+ PIRP Irp,
PVOID Ctx)
{
PIRP_CONTEXT Context;
NTAPI
USBSTOR_CBWCompletionRoutine(
PDEVICE_OBJECT DeviceObject,
- PIRP Irp,
+ PIRP Irp,
PVOID Ctx)
{
PIRP_CONTEXT Context;
{
//
// write request use bulk out pipe
- //
+ //
PipeHandle = Context->FDODeviceExtension->InterfaceInformation->Pipes[Context->FDODeviceExtension->BulkOutPipeIndex].PipeHandle;
}
else
DumpCBW(
PUCHAR Block)
{
- DPRINT1("%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
+ DPRINT("%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
Block[0] & 0xFF, Block[1] & 0xFF, Block[2] & 0xFF, Block[3] & 0xFF, Block[4] & 0xFF, Block[5] & 0xFF, Block[6] & 0xFF, Block[7] & 0xFF, Block[8] & 0xFF, Block[9] & 0xFF,
Block[10] & 0xFF, Block[11] & 0xFF, Block[12] & 0xFF, Block[13] & 0xFF, Block[14] & 0xFF, Block[15] & 0xFF, Block[16] & 0xFF, Block[17] & 0xFF, Block[18] & 0xFF, Block[19] & 0xFF,
- Block[20] & 0xFF, Block[21] & 0xFF, Block[22] & 0xFF, Block[23] & 0xFF, Block[24] & 0xFF, Block[25] & 0xFF, Block[26] & 0xFF, Block[27] & 0xFF, Block[28] & 0xFF, Block[29] & 0xFF,
+ Block[20] & 0xFF, Block[21] & 0xFF, Block[22] & 0xFF, Block[23] & 0xFF, Block[24] & 0xFF, Block[25] & 0xFF, Block[26] & 0xFF, Block[27] & 0xFF, Block[28] & 0xFF, Block[29] & 0xFF,
Block[30] & 0xFF);
}
//
// failed to allocate MDL
//
+ FreeItem(Context->cbw);
+ FreeItem(Context);
return STATUS_INSUFFICIENT_RESOURCES;
}
//
// failed to allocate MDL
//
+ FreeItem(Context->cbw);
+ FreeItem(Context);
return STATUS_INSUFFICIENT_RESOURCES;
}
//
// failed to allocate MDL
//
+ FreeItem(Context->cbw);
+ FreeItem(Context);
return STATUS_INSUFFICIENT_RESOURCES;
}
// first struct is the header
// MODE_PARAMETER_HEADER / _MODE_PARAMETER_HEADER10
//
- // followed by
+ // followed by
// MODE_PARAMETER_BLOCK
//
- //
- UNIMPLEMENTED
+ //
+ UNIMPLEMENTED;
//
// send csw
// sanity check
//
Temp = (Cmd.ContiguousLogicBlocksByte0 << 8 | Cmd.ContiguousLogicBlocksByte1);
- ASSERT(NTOHL(Temp == BlockCount));
+ ASSERT(Temp == BlockCount);
DPRINT("USBSTOR_SendReadWrite BlockAddress %x%x%x%x BlockCount %lu BlockLength %lu\n", Cmd.LogicalBlockByte0, Cmd.LogicalBlockByte1, Cmd.LogicalBlockByte2, Cmd.LogicalBlockByte3, BlockCount, PDODeviceExtension->BlockLength);
return USBSTOR_SendRequest(DeviceObject, Irp, UFI_TEST_UNIT_CMD_LEN, (PUCHAR)&Cmd, 0, NULL, RetryCount);
}
+NTSTATUS
+USBSTOR_SendUnknownRequest(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN OUT PIRP Irp,
+ IN ULONG RetryCount)
+{
+ PPDO_DEVICE_EXTENSION PDODeviceExtension;
+ PIO_STACK_LOCATION IoStack;
+ PSCSI_REQUEST_BLOCK Request;
+ UFI_UNKNOWN_CMD Cmd;
+
+ //
+ // get current stack location
+ //
+ IoStack = IoGetCurrentIrpStackLocation(Irp);
+
+ //
+ // get request block
+ //
+ Request = IoStack->Parameters.Others.Argument1;
+
+ //
+ // get PDO device extension
+ //
+ PDODeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+
+ //
+ // check that we're sending to the right LUN
+ //
+ ASSERT(Request->Cdb[1] == (PDODeviceExtension->LUN & MAX_LUN));
+
+ //
+ // sanity check
+ //
+ ASSERT(Request->CdbLength <= sizeof(UFI_UNKNOWN_CMD));
+
+ //
+ // initialize test unit cmd
+ //
+ RtlCopyMemory(&Cmd, Request->Cdb, Request->CdbLength);
+
+ //
+ // send the request
+ //
+ return USBSTOR_SendRequest(DeviceObject, Irp, Request->CdbLength, (PUCHAR)&Cmd, Request->DataTransferLength, Request->DataBuffer, RetryCount);
+}
NTSTATUS
USBSTOR_HandleExecuteSCSI(
}
else
{
- DPRINT1("UNIMPLEMENTED Operation Code %x\n", pCDB->AsByte[0]);
- Request->SrbStatus = SRB_STATUS_ERROR;
- Status = STATUS_NOT_SUPPORTED;
- DbgBreakPoint();
+ // Unknown request. Simply forward
+ DPRINT1("Forwarding unknown Operation Code %x\n", pCDB->AsByte[0]);
+ Status = USBSTOR_SendUnknownRequest(DeviceObject, Irp, RetryCount);
}
return Status;