Handle SCSIOP_INQUIRY in StorPort driver

Hi all,
I’m trying to write a StorPort driver according to example from
http://www.osronline.com/article.cfm?article=538. The difference is the
example is a virtual StorPort driver, mine is a non-virtual StorPort
driver. When I handle SCSIOP_INQUIRY, I used the following code:
case SCSIOP_INQUIRY:
{// 0x12
PCDB pCdb = (PCDB) &PSrb->Cdb;
PUCHAR pBuffer = (PUCHAR)
OsrSpGetSrbDataAddress(PSrb,DeviceExtension);
PINQUIRYDATA pInquiryData;

if(!pBuffer || PSrb->DataTransferLength < INQUIRYDATABUFFERSIZE) {
PSrb->SrbStatus = SRB_STATUS_ERROR;
return;
}

// We don’t support this, so abort the request.
//
if(pCdb->CDB6INQUIRY3.EnableVitalProductData) {
DebugPrint((1,“SCSIOP_INQUIRY: EVPD bit set, not
supported.\n”));
ProcessScsiCommandError(PSrb);
return;
}

//
// If the evpd bit is not set, PageCode better be 0.
//
if(pCdb->CDB6INQUIRY3.PageCode) {
DebugPrint((1,“SCSIOP_INQUIRY: EVPD bit not set, PageCode not
0. Error.\n”));
ProcessScsiCommandError(PSrb);
return;
}

pInquiryData = (PINQUIRYDATA) pBuffer;

//
// Zero out the buffer before filling it in.
//
memset(pInquiryData,0,PSrb->DataTransferLength);

pInquiryData->DeviceType = DIRECT_ACCESS_DEVICE;
pInquiryData->DeviceTypeQualifier = DEVICE_CONNECTED;
pInquiryData->DeviceTypeModifier = 0;
pInquiryData->RemovableMedia = TRUE;
pInquiryData->Versions = 2; // SCSI-2 support
pInquiryData->ResponseDataFormat = 2; // Same as Version??
according to SCSI book
pInquiryData->Wide32Bit = TRUE; // 32 bit wide transfers
pInquiryData->Synchronous = TRUE; // Synchronous commands
pInquiryData->CommandQueue = FALSE; // Does not support tagged
commands
pInquiryData->AdditionalLength = INQUIRYDATABUFFERSIZE-5; //
Amount of data we are returning
pInquiryData->LinkedCommands = FALSE; // No Linked Commands
StorPortMoveMemory((PUCHAR)
&pInquiryData->VendorId[0],OSR_INQUIRY_VENDOR_ID,
strlen(OSR_INQUIRY_VENDOR_ID));
StorPortMoveMemory((PUCHAR)
&pInquiryData->ProductId[0],OSR_INQUIRY_PRODUCT_ID,
strlen(OSR_INQUIRY_PRODUCT_ID));
StorPortMoveMemory((PUCHAR)
&pInquiryData->ProductRevisionLevel[0],OSR_INQUIRY_PRODUCT_REVISION,
strlen(OSR_INQUIRY_PRODUCT_REVISION));
//
// INQUIRYDATABUFFERSIZE does not account for us sending back this,
so we won’t
// if you do, you’ll overrun the buffer and get a verifier crash…
//

//Irp->IoStatus.Information = sizeof(INQUIRYDATA);
PSrb->SrbStatus = SRB_STATUS_SUCCESS;
PSrb->DataTransferLength = INQUIRYDATABUFFERSIZE;
DebugPrint((1,“Handle SCSIOP_INQUIRY successfully!\n”));
break;

}

After my driver is loaded, system create a new SCSI Disk Device in device
manager. However, there is question mark on its icon. I checked the
property of this device and the ‘Hardware Ids’ is as below:
SCSI\Disk____________________________
SCSI\Disk________________________
SCSI\Disk________
SCSI________________________
Could you let me know what the problem is ?
Thanks.
Marvin

I’m concerned that you do not support Vital Product Data. I think that that may be required for proper functionality. For an example of support, look at the StorPort Virtual Miniport sample at http://code.msdn.microsoft.com/WDKStorPortVirtualMiniport-973650f6, in scsi.c/ScsiOpVPD() specifically.

JA

The OSR virtual miniport doesn’t support VPD, so I have to believe that’s not a problem after all.

JA

You must support VPD to pass logo.

Thanks for your reply. I add the support for VPD according to your
recommended article. However, the problem is still exist. I doubt that I
fill some parameter wrong, but I can’t find it. Do you know if there is
any useful tool to monitor SCSI command correctly or why disk failed. BTW,
the SCSI sequence which I got is as following:

SRB_FUNCTION_EXECUTE_SCSI command:
SCSIOP_REPORT_LUNS(2 times)
CDB = a0 0 0 0 0 0 0 0 0 10 0 0
CDB = a0 0 0 0 0 0 0 0 0 10 0 0
SCSIOP_INQUIRY(5 times ,include VPD 3 times)
CDB = 12 0 0 0 24 0 0 0 0 0 0 0
CDB = 12 0 0 0 24 0 0 0 0 0 0 0
CDB = 12 1 0 0 ff 0 0 0 0 0 0 0
CDB = 12 1 83 0 ff 0 0 0 0 0 0 0
CDB = 12 1 80 0 ff 0 0 0 0 0 0 0
Then, I got 2 SRB_FUNCTION_PNP commands, both for StorQueryCapabilities,
and I set the status as SRB_STATUS_SUCCESS and complete it.
At last, I got 2 SRB_FUNCTION_WMI, and and I set the status as
SRB_STATUS_BAD_FUNCTION and complete it.

Marvin

On Wed, Feb 1, 2012 at 5:08 AM, wrote:

> I’m concerned that you do not support Vital Product Data. I think that
> that may be required for proper functionality. For an example of support,
> look at the StorPort Virtual Miniport sample at
> http://code.msdn.microsoft.com/WDKStorPortVirtualMiniport-973650f6, in
> scsi.c/ScsiOpVPD() specifically.
>
> JA
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

>Do you know if there is any useful tool to monitor SCSI command correctly or why disk failed.

busTrace is good tool. You could use it to trace Irp/SCSI command in the storage stack. But it would not tell you why your disk failed. You could also try to use check build versions of disk.sys and storport.sys. Analyzing debug messages from both files may give some idea what a problem is.

Igor Sharovar

Hi Sharovar,
Thanks for your suggestion! Do you know how to enable the log of disk.sys
and storport.sys? I know nt!Kd_STORMINIPORT_Mask can enable/disable log of
Stor mini port driver.
Marvin

On Thu, Feb 2, 2012 at 3:41 AM, wrote:

> >Do you know if there is any useful tool to monitor SCSI command correctly
> or why disk failed.
>
> busTrace is good tool. You could use it to trace Irp/SCSI command in the
> storage stack. But it would not tell you why your disk failed. You could
> also try to use check build versions of disk.sys and storport.sys.
> Analyzing debug messages from both files may give some idea what a problem
> is.
>
> Igor Sharovar
>
>
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

nt!Kd_STORMINIPORT_Mask = 0xF could work for storport.sys.
For disk.sys you could use nt!Kd_WIN2000_Mask = 0xFFFF. This mask is not specific for disk.sys. It works for others check build drivers also.

Igor Sharovar

Your hardware ids look very blank.

Mark Roddy

On Tue, Jan 31, 2012 at 12:01 PM, Marvin(Fan) Zhang wrote:
> Hi all,
> I’m trying to write a StorPort driver according to example
> from?http://www.osronline.com/article.cfm?article=538. The difference is the
> example is a virtual StorPort driver, mine is a non-virtual StorPort driver.
> When I handle SCSIOP_INQUIRY, ?I used the following code:
> ? ? case SCSIOP_INQUIRY:
> ? ? {// 0x12
> ? ? ? ? PCDB ? ? ? ? ? ? ? ? ? ?pCdb = (PCDB) &PSrb->Cdb;
> ? ? ? ? PUCHAR ? ? ? ? ? ? ? ? ?pBuffer = (PUCHAR)
> OsrSpGetSrbDataAddress(PSrb,DeviceExtension);
> ? ? ? ? PINQUIRYDATA ? ? ? ? ? ?pInquiryData;
>
> ? ? ? ? if(!pBuffer || PSrb->DataTransferLength < INQUIRYDATABUFFERSIZE) {
> ? ? ? ? ? ? PSrb->SrbStatus = SRB_STATUS_ERROR;
> ? ? ? ? ? ? return;
> ? ? ? ? }
>
> ? ? ? ? // We don’t support this, so abort the request.
> ? ? ? ? //
> ? ? ? ? if(pCdb->CDB6INQUIRY3.EnableVitalProductData) {
> ? ? ? ? ? ? DebugPrint((1,“SCSIOP_INQUIRY: EVPD bit set, not
> supported.\n”));
> ? ? ? ? ? ? ProcessScsiCommandError(PSrb);
> ? ? ? ? ? ? return;
> ? ? ? ? }
>
> ? ? ? ? //
> ? ? ? ? // If the evpd bit is not set, PageCode better be 0.
> ? ? ? ? //
> ? ? ? ? if(pCdb->CDB6INQUIRY3.PageCode) {
> ? ? ? ? ? ? DebugPrint((1,“SCSIOP_INQUIRY: EVPD bit not set, PageCode not 0.
> Error.\n”));
> ? ? ? ? ? ? ProcessScsiCommandError(PSrb);
> ? ? ? ? ? ? return;
> ? ? ? ? }
>
> ? ? ? ? pInquiryData = (PINQUIRYDATA) pBuffer;
>
> ? ? ? ? //
> ? ? ? ? // Zero out the buffer before filling it in.
> ? ? ? ? //
> ? ? ? ? memset(pInquiryData,0,PSrb->DataTransferLength);
>
> ? ? ? ? pInquiryData->DeviceType = DIRECT_ACCESS_DEVICE;
> ? ? ? ? pInquiryData->DeviceTypeQualifier = DEVICE_CONNECTED;
> ? ? ? ? pInquiryData->DeviceTypeModifier = 0;
> ? ? ? ? pInquiryData->RemovableMedia = TRUE;
> ? ? ? ? pInquiryData->Versions = 2; ? ? ? ? ? ? // SCSI-2 support
> ? ? ? ? pInquiryData->ResponseDataFormat = 2; ? // Same as Version??
> according to SCSI book
> ? ? ? ? pInquiryData->Wide32Bit = TRUE; ? ? ? ? // 32 bit wide transfers
> ? ? ? ? pInquiryData->Synchronous = TRUE; ? ? ? // Synchronous commands
> ? ? ? ? pInquiryData->CommandQueue = FALSE; ? ? // Does not support tagged
> commands
> ? ? ? ? pInquiryData->AdditionalLength = INQUIRYDATABUFFERSIZE-5; ?// Amount
> of data we are returning
> ? ? ? ? pInquiryData->LinkedCommands = FALSE; ? // No Linked Commands
> ? ? ? ? StorPortMoveMemory((PUCHAR)
> &pInquiryData->VendorId[0],OSR_INQUIRY_VENDOR_ID,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ?strlen(OSR_INQUIRY_VENDOR_ID));
> ? ? ? ? StorPortMoveMemory((PUCHAR)
> &pInquiryData->ProductId[0],OSR_INQUIRY_PRODUCT_ID,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ?strlen(OSR_INQUIRY_PRODUCT_ID));
> ? ? ? ? StorPortMoveMemory((PUCHAR)
> &pInquiryData->ProductRevisionLevel[0],OSR_INQUIRY_PRODUCT_REVISION,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ?strlen(OSR_INQUIRY_PRODUCT_REVISION));
> ? ? ? ? //
> ? ? ? ? // INQUIRYDATABUFFERSIZE does not account for us sending back this,
> so we won’t
> ? ? ? ? // if you do, you’ll overrun the buffer and get a verifier crash…
> ? ? ? ? //
>
> ? ? ? ? //Irp->IoStatus.Information = sizeof(INQUIRYDATA);
> ? ? ? ? PSrb->SrbStatus = SRB_STATUS_SUCCESS;
> ? ? ? ? PSrb->DataTransferLength = INQUIRYDATABUFFERSIZE;
> ? ? ? ? DebugPrint((1,“Handle SCSIOP_INQUIRY successfully!\n”));
> ? ? ? ? break;
>
> ? ? }
>
> After my driver is loaded, system create a new SCSI Disk Device in device
> manager. However, there is question mark on its icon. I checked the property
> of this device and the ‘Hardware Ids’ is as below:
> SCSI\Disk
> SCSI\Disk

> SCSI\Disk
> SCSI
____________
> Could you let me know what the?problem?is ?
> Thanks.
> Marvin
> — NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and
> other seminars visit: http://www.osr.com/seminars To unsubscribe, visit the
> List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer