[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> #include <debug.h>
#if DBG
static
VOID VOID
USBSTOR_DumpDeviceDescriptor(PUSB_DEVICE_DESCRIPTOR DeviceDescriptor) USBSTOR_DumpDeviceDescriptor(PUSB_DEVICE_DESCRIPTOR DeviceDescriptor)
{ {
DPRINT1("Dumping Device Descriptor %p\n", DeviceDescriptor); DPRINT("Dumping Device Descriptor %p\n", DeviceDescriptor);
DPRINT1("bLength %x\n", DeviceDescriptor->bLength); DPRINT("bLength %x\n", DeviceDescriptor->bLength);
DPRINT1("bDescriptorType %x\n", DeviceDescriptor->bDescriptorType); DPRINT("bDescriptorType %x\n", DeviceDescriptor->bDescriptorType);
DPRINT1("bcdUSB %x\n", DeviceDescriptor->bcdUSB); DPRINT("bcdUSB %x\n", DeviceDescriptor->bcdUSB);
DPRINT1("bDeviceClass %x\n", DeviceDescriptor->bDeviceClass); DPRINT("bDeviceClass %x\n", DeviceDescriptor->bDeviceClass);
DPRINT1("bDeviceSubClass %x\n", DeviceDescriptor->bDeviceSubClass); DPRINT("bDeviceSubClass %x\n", DeviceDescriptor->bDeviceSubClass);
DPRINT1("bDeviceProtocol %x\n", DeviceDescriptor->bDeviceProtocol); DPRINT("bDeviceProtocol %x\n", DeviceDescriptor->bDeviceProtocol);
DPRINT1("bMaxPacketSize0 %x\n", DeviceDescriptor->bMaxPacketSize0); DPRINT("bMaxPacketSize0 %x\n", DeviceDescriptor->bMaxPacketSize0);
DPRINT1("idVendor %x\n", DeviceDescriptor->idVendor); DPRINT("idVendor %x\n", DeviceDescriptor->idVendor);
DPRINT1("idProduct %x\n", DeviceDescriptor->idProduct); DPRINT("idProduct %x\n", DeviceDescriptor->idProduct);
DPRINT1("bcdDevice %x\n", DeviceDescriptor->bcdDevice); DPRINT("bcdDevice %x\n", DeviceDescriptor->bcdDevice);
DPRINT1("iManufacturer %x\n", DeviceDescriptor->iManufacturer); DPRINT("iManufacturer %x\n", DeviceDescriptor->iManufacturer);
DPRINT1("iProduct %x\n", DeviceDescriptor->iProduct); DPRINT("iProduct %x\n", DeviceDescriptor->iProduct);
DPRINT1("iSerialNumber %x\n", DeviceDescriptor->iSerialNumber); DPRINT("iSerialNumber %x\n", DeviceDescriptor->iSerialNumber);
DPRINT1("bNumConfigurations %x\n", DeviceDescriptor->bNumConfigurations); DPRINT("bNumConfigurations %x\n", DeviceDescriptor->bNumConfigurations);
} }
#endif
NTSTATUS NTSTATUS
USBSTOR_FdoHandleDeviceRelations( USBSTOR_FdoHandleDeviceRelations(
@ -184,8 +187,9 @@ USBSTOR_FdoHandleStartDevice(
return Status; return Status;
} }
#if DBG
USBSTOR_DumpDeviceDescriptor(DeviceExtension->DeviceDescriptor); USBSTOR_DumpDeviceDescriptor(DeviceExtension->DeviceDescriptor);
#endif
// Check that this device uses bulk transfers and is SCSI // 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.TransferBuffer = TransferBuffer;
Context->Urb.UrbBulkOrInterruptTransfer.TransferBufferMDL = TransferBufferMDL; Context->Urb.UrbBulkOrInterruptTransfer.TransferBufferMDL = TransferBufferMDL;
NextStack = IoGetNextIrpStackLocation(Irp); NextStack = IoGetNextIrpStackLocation(Irp);
NextStack->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL; NextStack->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL;
NextStack->Parameters.DeviceIoControl.IoControlCode = IOCTL_INTERNAL_USB_SUBMIT_URB; NextStack->Parameters.DeviceIoControl.IoControlCode = IOCTL_INTERNAL_USB_SUBMIT_URB;
NextStack->Parameters.Others.Argument1 = &Context->Urb; NextStack->Parameters.Others.Argument1 = &Context->Urb;
IoSetCompletionRoutine(Irp, IoSetCompletionRoutine(Irp,
CompletionRoutine, CompletionRoutine,
Context, Context,
TRUE, TRUE,
TRUE, TRUE,
TRUE); TRUE);
return IoCallDriver(FDODeviceExtension->LowerDeviceObject, Irp); return IoCallDriver(FDODeviceExtension->LowerDeviceObject, Irp);
} }
@ -210,7 +210,7 @@ USBSTOR_CSWCompletionRoutine(
DPRINT("USBSTOR_CSWCompletionRoutine: CSW_STATUS_COMMAND_FAILED\n"); DPRINT("USBSTOR_CSWCompletionRoutine: CSW_STATUS_COMMAND_FAILED\n");
ASSERT(FDODeviceExtension->ActiveSrb == Request); ASSERT(FDODeviceExtension->ActiveSrb == Request);
// setting a generic error status, additional information // setting a generic error status, additional information
// should be read by higher-level driver from SenseInfoBuffer // should be read by higher-level driver from SenseInfoBuffer
Request->SrbStatus = SRB_STATUS_ERROR; Request->SrbStatus = SRB_STATUS_ERROR;
@ -410,7 +410,7 @@ USBSTOR_CBWCompletionRoutine(
FALSE, FALSE,
FALSE, FALSE,
NULL); NULL);
if (Mdl) if (Mdl)
{ {
IoBuildPartialMdl(Irp->MdlAddress, IoBuildPartialMdl(Irp->MdlAddress,
@ -526,7 +526,6 @@ USBSTOR_IssueRequestSense(
PIO_STACK_LOCATION IoStack; PIO_STACK_LOCATION IoStack;
PSCSI_REQUEST_BLOCK CurrentSrb; PSCSI_REQUEST_BLOCK CurrentSrb;
PSCSI_REQUEST_BLOCK SenseSrb; PSCSI_REQUEST_BLOCK SenseSrb;
PCDB pCDB;
DPRINT("USBSTOR_IssueRequestSense: \n"); DPRINT("USBSTOR_IssueRequestSense: \n");
@ -551,9 +550,8 @@ USBSTOR_IssueRequestSense(
SenseSrb->DataTransferLength = CurrentSrb->SenseInfoBufferLength; SenseSrb->DataTransferLength = CurrentSrb->SenseInfoBufferLength;
SenseSrb->DataBuffer = CurrentSrb->SenseInfoBuffer; SenseSrb->DataBuffer = CurrentSrb->SenseInfoBuffer;
pCDB = (PCDB)SenseSrb->Cdb; SrbGetCdb(SenseSrb)->CDB6GENERIC.OperationCode = SCSIOP_REQUEST_SENSE;
pCDB->CDB6GENERIC.OperationCode = SCSIOP_REQUEST_SENSE; SrbGetCdb(SenseSrb)->AsByte[4] = CurrentSrb->SenseInfoBufferLength;
pCDB->AsByte[4] = CurrentSrb->SenseInfoBufferLength;
return USBSTOR_SendCBWRequest(FDODeviceExtension, Irp, Context); return USBSTOR_SendCBWRequest(FDODeviceExtension, Irp, Context);
} }
@ -563,7 +561,6 @@ USBSTOR_HandleExecuteSCSI(
IN PDEVICE_OBJECT DeviceObject, IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp) IN PIRP Irp)
{ {
PCDB pCDB;
NTSTATUS Status; NTSTATUS Status;
PIO_STACK_LOCATION IoStack; PIO_STACK_LOCATION IoStack;
PSCSI_REQUEST_BLOCK Request; PSCSI_REQUEST_BLOCK Request;
@ -575,12 +572,11 @@ USBSTOR_HandleExecuteSCSI(
IoStack = IoGetCurrentIrpStackLocation(Irp); IoStack = IoGetCurrentIrpStackLocation(Irp);
Request = IoStack->Parameters.Scsi.Srb; 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 // 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); Context = ExAllocatePoolWithTag(NonPagedPool, sizeof(IRP_CONTEXT), USB_STOR_TAG);
if (!Context) if (!Context)

View file

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