[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ms-smartcardddk
Subject:    Re: Device path exerciser in HCT
From:       Winston Tsai <winstontsai () EARTHLINK ! NET>
Date:       2003-03-23 6:20:16
[Download RAW message or body]

> Clients have run several of my drivers through WHQL recently
> without encountering this problem. Like you, I delegate every
> IOCTL to SMCLIB. What is the nature of the test failure
> you're seeing, exactly?
It's unhandled kernel exception. It breaks in my SoftICE with bugcheck
message saying IRP is not completed, or IRP is not marked pending. I had
to run the device path exerciser repeatly to figure out (or it at least
appears to me) when SMCLIB actually completes the IRP and when it doesn't.
It appears to me that it completes the IRP in most of the cases, except
when the error is STATUS_INVALID_PARAMETER, and the IOCTLs are not valid
smard card IOCTLs(e.g. IOCTL_SMARTCARD_POWER).
It makes wonder now since your driver passed the HCT without a problem.
On second thought--do you what version of HCT is your driver running
against? The device path exerciser is only included in the HCT since
version 11.0 onwards.
Here's the complete listing for my DeviceControl routine:
NTSTATUS
XXXDeviceControl(
    PDEVICE_OBJECT DeviceObject,
    PIRP Irp
    )
/*++

Routine Description:
    This is our IOCTL dispatch function

--*/
{
    PDEVICE_EXTENSION deviceExtension = DeviceObject->DeviceExtension;
    PSMARTCARD_EXTENSION smartcardExtension = &deviceExtension-
>SmartcardExtension;
    NTSTATUS status = STATUS_SUCCESS;
    KIRQL   irql;
    ULONG   ioctlCode;

    ioctlCode =
        IoGetCurrentIrpStackLocation(Irp)-
>Parameters.DeviceIoControl.IoControlCode;
    //SmartcardDebug(DEBUG_TRACE, ( "%s!IDTDeviceControl: Enter\n",
DRIVER_NAME));
    SmartcardDebug(DEBUG_SP1, ( "IoCtlCode = 0x%X\n", ioctlCode));

    if (smartcardExtension->ReaderExtension-
>SerialConfigData.SerialWaitMask == 0) {

        //
        // the wait mask is set to 0 whenever the device was either
        // surprise-removed or politely removed
        //
        status = STATUS_DEVICE_REMOVED;
    }

    if (status == STATUS_SUCCESS) {

        KeAcquireSpinLock(&deviceExtension->SpinLock, &irql);
        if (deviceExtension->IoCount == 0) {

            KeReleaseSpinLock(&deviceExtension->SpinLock, irql);
            status = KeWaitForSingleObject(
                      &deviceExtension->ReaderStarted,
                      Executive,
                      KernelMode,
                      FALSE,
                      NULL
                    );
            ASSERT(status == STATUS_SUCCESS);

            KeAcquireSpinLock(&deviceExtension->SpinLock, &irql);
        }

        ASSERT(deviceExtension->IoCount >= 0);
        deviceExtension->IoCount++;
        KeReleaseSpinLock(&deviceExtension->SpinLock, irql);

        status = SmartcardAcquireRemoveLockWithTag
(smartcardExtension, 'tcoI');
    }

    if (status != STATUS_SUCCESS) {

        // the device has been removed. Fail the call
        Irp->IoStatus.Information = 0;
        Irp->IoStatus.Status = STATUS_DEVICE_REMOVED;
        IoCompleteRequest(Irp, IO_NO_INCREMENT);
        return STATUS_DEVICE_REMOVED;
    }

    ASSERT(smartcardExtension->ReaderExtension->ReaderPowerState ==
         PowerReaderWorking);

    status = SmartcardDeviceControl(smartcardExtension, Irp);

    SmartcardReleaseRemoveLockWithTag(smartcardExtension, 'tcoI');

    if (status == STATUS_INVALID_PARAMETER) {
        switch (ioctlCode) {
        case IOCTL_SMARTCARD_POWER:
        case IOCTL_SMARTCARD_GET_ATTRIBUTE:
        case IOCTL_SMARTCARD_SET_ATTRIBUTE:
        case IOCTL_SMARTCARD_CONFISCATE:
        case IOCTL_SMARTCARD_TRANSMIT:
        case IOCTL_SMARTCARD_EJECT:
        case IOCTL_SMARTCARD_SWALLOW:
        case IOCTL_SMARTCARD_IS_PRESENT:
        case IOCTL_SMARTCARD_IS_ABSENT:
        case IOCTL_SMARTCARD_SET_PROTOCOL:
        case IOCTL_SMARTCARD_GET_STATE:
        case IOCTL_SMARTCARD_GET_LAST_ERROR:
        case IOCTL_SMARTCARD_GET_PERF_CNTR:
            break;
        default:
            // Hack, hack!!
            // Somehow, for this error return code we need to complete the
IRP
            // this fix is needed to pass HCT 11.0 "device path exercise"
            SmartcardDebug(DEBUG_SP1, ( "%s!IDTDeviceControl: ret IRP,
ioctl = %lx, rc = %lx\n",
                                        DRIVER_NAME, ioctlCode, status));
            Irp->IoStatus.Information = 0;
            Irp->IoStatus.Status = status;
            IoCompleteRequest(Irp, IO_NO_INCREMENT);
            return status;
        }
    }

    KeAcquireSpinLock(&deviceExtension->SpinLock, &irql);
    deviceExtension->IoCount--;
    ASSERT(deviceExtension->IoCount >= 0);
    KeReleaseSpinLock(&deviceExtension->SpinLock, irql);

    SmartcardDebug(DEBUG_SP1, ( "%s!IDTDeviceControl: Exit %lx\n",
DRIVER_NAME, status));

    return status;
}
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic