[USBSTOR] Do not print device descriptor by default.

Add SrbGetCdb macro
This commit is contained in:
Victor Perevertkin 2019-06-25 19:04:20 +03:00
parent 10260f40d9
commit e831f8530b
No known key found for this signature in database
GPG key ID: C750B7222E9C7830
3 changed files with 35 additions and 31 deletions

View file

@ -14,25 +14,28 @@
#include <debug.h>
#if DBG
static
VOID
USBSTOR_DumpDeviceDescriptor(PUSB_DEVICE_DESCRIPTOR DeviceDescriptor)
{
DPRINT1("Dumping Device Descriptor %p\n", DeviceDescriptor);
DPRINT1("bLength %x\n", DeviceDescriptor->bLength);
DPRINT1("bDescriptorType %x\n", DeviceDescriptor->bDescriptorType);
DPRINT1("bcdUSB %x\n", DeviceDescriptor->bcdUSB);
DPRINT1("bDeviceClass %x\n", DeviceDescriptor->bDeviceClass);
DPRINT1("bDeviceSubClass %x\n", DeviceDescriptor->bDeviceSubClass);
DPRINT1("bDeviceProtocol %x\n", DeviceDescriptor->bDeviceProtocol);
DPRINT1("bMaxPacketSize0 %x\n", DeviceDescriptor->bMaxPacketSize0);
DPRINT1("idVendor %x\n", DeviceDescriptor->idVendor);
DPRINT1("idProduct %x\n", DeviceDescriptor->idProduct);
DPRINT1("bcdDevice %x\n", DeviceDescriptor->bcdDevice);
DPRINT1("iManufacturer %x\n", DeviceDescriptor->iManufacturer);
DPRINT1("iProduct %x\n", DeviceDescriptor->iProduct);
DPRINT1("iSerialNumber %x\n", DeviceDescriptor->iSerialNumber);
DPRINT1("bNumConfigurations %x\n", DeviceDescriptor->bNumConfigurations);
DPRINT("Dumping Device Descriptor %p\n", DeviceDescriptor);
DPRINT("bLength %x\n", DeviceDescriptor->bLength);
DPRINT("bDescriptorType %x\n", DeviceDescriptor->bDescriptorType);
DPRINT("bcdUSB %x\n", DeviceDescriptor->bcdUSB);
DPRINT("bDeviceClass %x\n", DeviceDescriptor->bDeviceClass);
DPRINT("bDeviceSubClass %x\n", DeviceDescriptor->bDeviceSubClass);
DPRINT("bDeviceProtocol %x\n", DeviceDescriptor->bDeviceProtocol);
DPRINT("bMaxPacketSize0 %x\n", DeviceDescriptor->bMaxPacketSize0);
DPRINT("idVendor %x\n", DeviceDescriptor->idVendor);
DPRINT("idProduct %x\n", DeviceDescriptor->idProduct);
DPRINT("bcdDevice %x\n", DeviceDescriptor->bcdDevice);
DPRINT("iManufacturer %x\n", DeviceDescriptor->iManufacturer);
DPRINT("iProduct %x\n", DeviceDescriptor->iProduct);
DPRINT("iSerialNumber %x\n", DeviceDescriptor->iSerialNumber);
DPRINT("bNumConfigurations %x\n", DeviceDescriptor->bNumConfigurations);
}
#endif
NTSTATUS
USBSTOR_FdoHandleDeviceRelations(
@ -184,8 +187,9 @@ USBSTOR_FdoHandleStartDevice(
return Status;
}
#if DBG
USBSTOR_DumpDeviceDescriptor(DeviceExtension->DeviceDescriptor);
#endif
// Check that this device uses bulk transfers and is SCSI

View file

@ -81,17 +81,17 @@ USBSTOR_IssueBulkOrInterruptRequest(
Context->Urb.UrbBulkOrInterruptTransfer.TransferBuffer = TransferBuffer;
Context->Urb.UrbBulkOrInterruptTransfer.TransferBufferMDL = TransferBufferMDL;
NextStack = IoGetNextIrpStackLocation(Irp);
NextStack->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL;
NextStack->Parameters.DeviceIoControl.IoControlCode = IOCTL_INTERNAL_USB_SUBMIT_URB;
NextStack->Parameters.Others.Argument1 = &Context->Urb;
NextStack = IoGetNextIrpStackLocation(Irp);
NextStack->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL;
NextStack->Parameters.DeviceIoControl.IoControlCode = IOCTL_INTERNAL_USB_SUBMIT_URB;
NextStack->Parameters.Others.Argument1 = &Context->Urb;
IoSetCompletionRoutine(Irp,
CompletionRoutine,
Context,
TRUE,
TRUE,
TRUE);
TRUE);
return IoCallDriver(FDODeviceExtension->LowerDeviceObject, Irp);
}
@ -210,7 +210,7 @@ USBSTOR_CSWCompletionRoutine(
DPRINT("USBSTOR_CSWCompletionRoutine: CSW_STATUS_COMMAND_FAILED\n");
ASSERT(FDODeviceExtension->ActiveSrb == Request);
// setting a generic error status, additional information
// should be read by higher-level driver from SenseInfoBuffer
Request->SrbStatus = SRB_STATUS_ERROR;
@ -410,7 +410,7 @@ USBSTOR_CBWCompletionRoutine(
FALSE,
FALSE,
NULL);
if (Mdl)
{
IoBuildPartialMdl(Irp->MdlAddress,
@ -526,7 +526,6 @@ USBSTOR_IssueRequestSense(
PIO_STACK_LOCATION IoStack;
PSCSI_REQUEST_BLOCK CurrentSrb;
PSCSI_REQUEST_BLOCK SenseSrb;
PCDB pCDB;
DPRINT("USBSTOR_IssueRequestSense: \n");
@ -551,9 +550,8 @@ USBSTOR_IssueRequestSense(
SenseSrb->DataTransferLength = CurrentSrb->SenseInfoBufferLength;
SenseSrb->DataBuffer = CurrentSrb->SenseInfoBuffer;
pCDB = (PCDB)SenseSrb->Cdb;
pCDB->CDB6GENERIC.OperationCode = SCSIOP_REQUEST_SENSE;
pCDB->AsByte[4] = CurrentSrb->SenseInfoBufferLength;
SrbGetCdb(SenseSrb)->CDB6GENERIC.OperationCode = SCSIOP_REQUEST_SENSE;
SrbGetCdb(SenseSrb)->AsByte[4] = CurrentSrb->SenseInfoBufferLength;
return USBSTOR_SendCBWRequest(FDODeviceExtension, Irp, Context);
}
@ -563,7 +561,6 @@ USBSTOR_HandleExecuteSCSI(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
PCDB pCDB;
NTSTATUS Status;
PIO_STACK_LOCATION IoStack;
PSCSI_REQUEST_BLOCK Request;
@ -575,12 +572,11 @@ USBSTOR_HandleExecuteSCSI(
IoStack = IoGetCurrentIrpStackLocation(Irp);
Request = IoStack->Parameters.Scsi.Srb;
pCDB = (PCDB)Request->Cdb;
DPRINT("USBSTOR_HandleExecuteSCSI Operation Code %x, Length %lu\n", pCDB->CDB10.OperationCode, Request->DataTransferLength);
DPRINT("USBSTOR_HandleExecuteSCSI Operation Code %x, Length %lu\n", SrbGetCdb(Request)->CDB10.OperationCode, Request->DataTransferLength);
// check that we're sending to the right LUN
ASSERT(pCDB->CDB10.LogicalUnitNumber == (PDODeviceExtension->LUN & MAX_LUN));
ASSERT(SrbGetCdb(Request)->CDB10.LogicalUnitNumber == (PDODeviceExtension->LUN & MAX_LUN));
Context = ExAllocatePoolWithTag(NonPagedPool, sizeof(IRP_CONTEXT), USB_STOR_TAG);
if (!Context)

View file

@ -29,6 +29,10 @@
#define BooleanFlagOn(Flags, SingleFlag) ((BOOLEAN)((((Flags) & (SingleFlag)) != 0)))
#endif
#ifndef SrbGetCdb
#define SrbGetCdb(srb) ((PCDB)(srb->Cdb))
#endif
#define USB_RECOVERABLE_ERRORS (USBD_STATUS_STALL_PID | USBD_STATUS_DEV_NOT_RESPONDING \
| USBD_STATUS_ENDPOINT_HALTED | USBD_STATUS_NO_BANDWIDTH)