Need some enlight for smartcard reader multiSlot

Hello everybody,

I have two questions about an USB device smartcard reader multislot.
This reader have 3 slot ( interface ) that use the same USB pipe ( Interrupt )
It’s full compliance CCID ( class smartcard reader ).
This reader work fine with usbccid.sys driver provides by Microsoft, problem is this driver enumerate just one Slot ( the first interface ).

I have already developped 2 WDM driver ( one for the USB bus, and the second for smartcard readers interface ).

First, I would like to know if it’s possible to develop just ONE .sys driver file for use the reader ( ioCreateDevice(FILE_DEVICE_BUS_EXTENDER) for usb bus and ioCreateDevice(FILE_DEVICE_SMARTCARD) for each reader slot interface) .

If it’s possible to create “just one” .sys file for implement 4 ioCreateDevice, someone can explain me how to proceed.

And second question, I have read some articles from MSDN for determine if WDM, UMDF or KMDF is more appropriate for a smart card reader multislot, but informations are not very convincing.
Someone could enlight me.

Thanks by advance,

Best regards,

Moulefrite

xxxxx@hotmail.com wrote:

I have two questions about an USB device smartcard reader multislot.
This reader have 3 slot ( interface ) that use the same USB pipe ( Interrupt )

I assume you mean the same pipe TYPE. A single pipe can only belong to
one interface.

It’s full compliance CCID ( class smartcard reader ).
This reader work fine with usbccid.sys driver provides by Microsoft, problem is this driver enumerate just one Slot ( the first interface ).

That suggests a problem in your descriptors. With a proper multiple
interface design, the usbccgp driver will automatically create three
devices for you. The CCID driver won’t even know it’s talking to one of
several interfaces.

If you would like to post your device descriptor and configuration
descriptor, we can take a look at them.

First, I would like to know if it’s possible to develop just ONE .sys driver file for use the reader ( ioCreateDevice(FILE_DEVICE_BUS_EXTENDER) for usb bus and ioCreateDevice(FILE_DEVICE_SMARTCARD) for each reader slot interface) .

It is possible, although it is probably more trouble than it is worth.
You would still need two INF files, because the two thing belong to
different device classes.

If it’s possible to create “just one” .sys file for implement 4 ioCreateDevice, someone can explain me how to proceed.

You will get a call to AddDevice for each device you are asked to
support. That routine can determine the hardware ID for its device, and
from that you can determine how to proceed.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Thanks Tim for your help,

When I say one pipe, means in reality 3 pipe, one for catch usb interrupt, and two other for bulk IN/OUT.

My deviceDesc and configDesc caught with USB Trace at plug :
##################################################
##################################################
device descriptor
Urb Field Value
Length 0x50
USBD Status USBD_STATUS_SUCCESS (0x0)
EndpointAddress 0x0
PipeHandle 0x879FA2F8
TransferFlags 0xB ( USBD_TRANSFER_DIRECTION_IN USBD_SHORT_TRANSFER_OK )
TransferBufferLength 0x12
TransferBuffer 0x879E0128
TransferBufferMDL 0x879EAE70
UrbLink 0x0
SetupPacket 0x80 0x6 0x3 0x3 0x9 0x4 0xFF 0x0
RequestType 0x80 (Direction: Device-to-host, Type: Standard, Recipient: Device)
Request 0x6 (GET_DESCRIPTOR)
Value 0x303 (USB_STRING_DESCRIPTOR_TYPE)
Index 0x409
Length 0xFF

String Descriptor
bLength 0x12
bString 4AD5B759
##################################################
Urb Field Value
Length 0x50
USBD Status USBD_STATUS_SUCCESS (0x0)
EndpointAddress 0x0
PipeHandle 0x879FA2F8
TransferFlags 0xB ( USBD_TRANSFER_DIRECTION_IN USBD_SHORT_TRANSFER_OK )
TransferBufferLength 0x5D
TransferBuffer 0x87A92130
TransferBufferMDL 0x87A8B250
UrbLink 0x0
SetupPacket 0x80 0x6 0x0 0x2 0x0 0x0 0xFF 0x0
RequestType 0x80 (Direction: Device-to-host, Type: Standard, Recipient: Device)
Request 0x6 (GET_DESCRIPTOR)
Value 0x200 (USB_CONFIGURATION_DESCRIPTOR_TYPE)
Index 0x0
Length 0xFF
##################################################
Configuration Descriptor
bLength 0x9
bDescriptorType USB_CONFIGURATION_DESCRIPTOR_TYPE
wTotalLength 0x5D
bNumInterfaces 0x1
iConfiguration 0x4
bmAttributes 0x80 ( Bus_Powered )
MaxPower 0xC8
##################################################
Interface Descriptor
bLength 0x9
bInterfaceNumber 0x0
bAlternateSetting 0x0
bNumEndpoints 0x3
bInterfaceClass 0xB (Smart Card)
bInterfaceSubClass 0x0
bInterfaceProtocol 0x0
iInterface 0x0
##################################################
Endpoint Descriptor
bLength 0x7
bEndpointAddress 0x81 [IN]
bmAttributes 0x2 (USB_ENDPOINT_TYPE_BULK)
wMaxPacketSize 0x40
bInterval 0x0
##################################################
Endpoint Descriptor
bLength 0x7
bEndpointAddress 0x2 [OUT]
bmAttributes 0x2 (USB_ENDPOINT_TYPE_BULK)
wMaxPacketSize 0x40
bInterval 0x0
##################################################
Endpoint Descriptor
bLength 0x7
bEndpointAddress 0x83 [IN]
bmAttributes 0x3 (USB_ENDPOINT_TYPE_INTERRUPT)
wMaxPacketSize 0x8
bInterval 0x80
##################################################
##################################################

If you confirm me that this driver can be developped with just one .sys and two .inf.
When I plug the reader, in first time the bus.inf file must be loaded for create “ioCreateDevice(FILE_DEVICE_BUS_EXTENDER)”, and get descriptor for extract slot number and loop for create slot smartcard reader “ioCreateDevice(FILE_DEVICE_SMARTCARD)”.
But at this step how to proceed for call the second slot.inf file ?
When addDevice is called for the bus in same time I recall ioCreateDevice for smartcard.
Or call ioCreateDevice when I receive IRP_MN_START_DEVICE ?

Thanks in advance,

Regards,

Kamel

xxxxx@hotmail.com wrote:

Thanks Tim for your help,

When I say one pipe, means in reality 3 pipe, one for catch usb interrupt, and two other for bulk IN/OUT.

My deviceDesc and configDesc caught with USB Trace at plug :

This is not a multiple interface device. These descriptors only show
one interface. If you are a multi-slot device, shouldn’t there be
multiple interfaces?

It does show that you have selected configuration #4. Is this a
multi-configuration device? Do some of the other configurations have
multiple interfaces?


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Thank you Tim for your reply,

Yes your all right, I have just one interface and four configuration.
But for my first driver coded with two .sys (one bus file and other for slot file) I have recovered the configuration number for define the number of slot has instantiate.

And after, I would like to know if I can initialize smartcard instance with dispatchPnp routine IRP_MN_START_DEVICE ?

Could you please validate me this process :

  1. plug reader, need driver ( new version with one sys file and two .inf file )
  2. Bus_AddDevice(
    IN PDRIVER_OBJECT DriverObject,
    IN PDEVICE_OBJECT PhysicalDeviceObject
    )
    {
    ioCreateDevice(FILE_DEVICE_BUS_EXTENDER)
    bus_deviceExtension->TopOfStackDriver = IoAttachDeviceToDeviceStack (
    deviceObject,
    PhysicalDeviceObject);
    }
  3. Bus_pnp
    {
    case IRP_MN_START_DEVICE :
    // Use configuration descriptor
    // loop
    // ioCreateDevice(FILE_DEVICE_SMARTCARD)
    // Initialize all smartcard process (callBack RDF_TRANSMIT, RDF_CARD_POWER, …)
    slot_deviceExtension->TopOfStackDriver = IoAttachDeviceToDeviceStack (
    deviceObject,
    bus_deviceExtension->TopOfStackDriver); // Can work ???
    // end loop
  4. Dispatch pnp routine to slotExtension for IRP_MN_START_DEVICE

Thanks by advance,

Best regards,

Kamel

xxxxx@hotmail.com wrote:

Yes your all right, I have just one interface and four configuration.
But for my first driver coded with two .sys (one bus file and other for slot file) I have recovered the configuration number for define the number of slot has instantiate.

And after, I would like to know if I can initialize smartcard instance with dispatchPnp routine IRP_MN_START_DEVICE ?

Could you please validate me this process :

  1. plug reader, need driver ( new version with one sys file and two .inf file )
  2. Bus_AddDevice(
    IN PDRIVER_OBJECT DriverObject,
    IN PDEVICE_OBJECT PhysicalDeviceObject
    )
  3. Bus_pnp
  4. Dispatch pnp routine to slotExtension for IRP_MN_START_DEVICE

No, this is not correct. In your START_DEVICE handler, you will create
the PDOs for your child devices, and call IoInvalidateDeviceRelations.
That causes the PnP manager to send you an IRP_MN_QUERY_DEVICE_RELATIONS
request. In that handler, your bus driver tells the operating system
what its child devices are. The PnP manager will then go searching for
an INF that matches each of your child devices. Assuming the INF points
back to your sys file, you will now get AddDevice calls for each of
child device.

So, you will be getting calls for (1) the bus driver FDO, (2) the child
device PDO that your bus driver created, and (3) the child device FDO.
Each one will come in on the same entry points, but require different
handling. You’ll need a way to tell them apart. That’s complicated. I
really think it is silly of you to try to do the bus handling and child
handling in a single INF. There is no gain.

KMDF makes it much easier to write bus drivers. Is there a reason
you’re not using KMDF?


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Thanks Tim for your appreciate help,

That’s complicated. I really think it is silly of you to try to do the bus handling and child
handling in a single INF. There is no gain.

So you think it’s very difficult to process bus and slot in same .sys file (with one/and/or two inf file) ?

precisely my boss suggest me to develop this new driver in KMDF.
But I’m afraid to start a development without KMDF knowledge.
But if you said me it’s easier to develop it I can try :slight_smile: .

My boss want to have just one .sys file for bus and slot
For the moment I try to find a maximum of information for know if it’s possible.
And found a way to create this driver as easily as possible.

Best regards,

Kamel

Implementing both the bus and slot in KMDF in one driver is going to be much easier than in WDM. KMDF makes it easier to isolate functionality between 2 devices via the WDFDEVICE object vs having global dispatch pointers in your driver object

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@hotmail.com
Sent: Thursday, November 04, 2010 12:17 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Need some enlight for smartcard reader multiSlot

Thanks Tim for your appreciate help,

That’s complicated. I really think it is silly of you to try to do the
bus handling and child handling in a single INF. There is no gain.

So you think it’s very difficult to process bus and slot in same .sys file (with one/and/or two inf file) ?

precisely my boss suggest me to develop this new driver in KMDF.
But I’m afraid to start a development without KMDF knowledge.
But if you said me it’s easier to develop it I can try :slight_smile: .

My boss want to have just one .sys file for bus and slot For the moment I try to find a maximum of information for know if it’s possible.
And found a way to create this driver as easily as possible.

Best regards,

Kamel


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

Thank you Doron for your reply.
So could you advise me some good books on KMDF that can help me.
For understand feature of KMDF.

Thanks by advance,

Regards,

Kamel

xxxxx@hotmail.com wrote:

precisely my boss suggest me to develop this new driver in KMDF.
But I’m afraid to start a development without KMDF knowledge.
But if you said me it’s easier to develop it I can try :slight_smile: .

Although KMDF makes all kinds of drivers easier, filter drivers and bus
drivers are two places where KMDF is HUGE win

My boss want to have just one .sys file for bus and slot

This is diverting the conversation off-topic, but why would a boss care
about this? There’s no fee that depends on the number of files you
ship. There’s no security benefit. It doesn’t make maintenance any
easier. It is a trivial implementation detail. I can understand
wanting to try this as an intellectual exercise, but I do NOT understand
how this becomes a management bullet item.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

even me I don’t understand why, I guess it’s a request from a customer …
I have two books ( oney second edition for WDM and developing drivers with the WDF for KMDF).
I will read the second book to understand the basics of KMDF.

Thanks a lot Tim and Doron for your advice very helpful

Best regard,

Kamel

Hi Moulefrite

Yeah its very much possible to have multiple slot implementation in one sys file. As doron suggested I would strongly recommend to use KMDF as it makes your life much simple. You don’t have to worry abt most of the PNP or Power management handling this will help you a lot during later point when you plan to get your drivers signed (Passing DTM tests will b easy). You don’t need to have bus client architecture to implement this you can implement multiple slots by creating multiple interfaces.