URB_SELECT_CONFIGURATION

Hi,

In my USB KMDF driver, i dont have implemented, the select configuration through control endpoint.

I have seen one URB, URB_SELECT_CONFIGURATION in usb.h file of DDK.
Can i use this one to implement the set configuration request?

Nisheedh

You don’t need to use the URB, call WdfUsbTargetDeviceSelectConfig instead

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@yahoo.co.in
Sent: Friday, March 20, 2009 6:10 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] URB_SELECT_CONFIGURATION

Hi,

In my USB KMDF driver, i dont have implemented, the select configuration through control endpoint.

I have seen one URB, URB_SELECT_CONFIGURATION in usb.h file of DDK.
Can i use this one to implement the set configuration request?

Nisheedh


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

xxxxx@yahoo.co.in wrote:

In my USB KMDF driver, i dont have implemented, the select configuration through control endpoint.

I have seen one URB, URB_SELECT_CONFIGURATION in usb.h file of DDK.
Can i use this one to implement the set configuration request?

No, you would use WdfUsbTargetDeviceSelectConfig. Have you read through
the KMDF USB functions?

Actually, that doesn’t “implement” the request, it “submits” the
request, which is what you really meant.


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

I am using a WDM driver. Shall i use the function WdfUsbTargetDeviceSelectConfig() in the WDM driver?

In my driver most of the features are implemented by submitting URB through control endpoint.
Can i use the URB, URB_SELECT_CONFIGURATION in the driver to implement the select configuration feature?

Regards
Nisheedh

Which is it? You said it was a kmdf driver. If it is wdm, i strongly recommend you go back and use kmdf or umdf or winusb. You need to select a config only if you have additional endpoints you want to use

What kind of device is this that operates mostly over control? It is going to be damn slow…

d

Sent from my phone with no t9, all spilling mistakes are not intentional.

-----Original Message-----
From: xxxxx@yahoo.co.in
Sent: Friday, March 20, 2009 11:11 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] URB_SELECT_CONFIGURATION

I am using a WDM driver. Shall i use the function WdfUsbTargetDeviceSelectConfig() in the WDM driver?

In my driver most of the features are implemented by submitting URB through control endpoint.
Can i use the URB, URB_SELECT_CONFIGURATION in the driver to implement the select configuration feature?

Regards
Nisheedh


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

Hi,

it’s a WDM driver which we are having as a generic USB driver.

Now , what we are doing is, selects a particular URB according to the usbrequest code and bmrequesttype and submitting the URB to bus driver by calling IoBuildDeviceIoControlRequest and iocalldriver() functions.

In this case, can i use URB_FUNCTION_SELECT_CONFIGURATION for selecting a configuration?

Nisheedh

You do not need to build the control packet header yourself, just use the select config urb build macro and send the irp. I would suggest you look at a wdm usb sample in the wdk, but again, nothing you have described so far precludes you from using kmdf. Using it will make your life much simpler

d

Sent from my phone with no t9, all spilling mistakes are not intentional.

-----Original Message-----
From: xxxxx@yahoo.co.in
Sent: Saturday, March 21, 2009 12:03 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] URB_SELECT_CONFIGURATION

Hi,

it’s a WDM driver which we are having as a generic USB driver.

Now , what we are doing is, selects a particular URB according to the usbrequest code and bmrequesttype and submitting the URB to bus driver by calling IoBuildDeviceIoControlRequest and iocalldriver() functions.

In this case, can i use URB_FUNCTION_SELECT_CONFIGURATION for selecting a configuration?

Nisheedh


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

Hi,

Did you mean, we don’t have to collect the complete configuration descriptors and select one with our needs(config number=X)?

What are all the steps involved to use the URb URB_FUNCTION_SELECT_CONFIGURATION in WDM driver?

Can you help me?

In the wdm samples of 3790 DDK i have seen a function ConfigureDevice(). In a similar manner can i implement it?

regards
Nisheedh

3790 is a very old kit. Download a new wdk and look at the samples there. ConfigureDevice() is probably what you want…query for the config desc, perhaps parse it, and then select it. Note that windows really only has support for a single config device (although it can have multiple interfaces). Again, since you are at the starting point, let me say this one final time: use kmdf instead (as an added bonus it comes as a part the latest wdk i told you to download). Configuring your device is just the tip of the iceburg here, if you are having so much trouble with that, the rest of pnp, power and io queueing rules are going to be much worse for you.

d

Sent from my phone with no t9, all spilling mistakes are not intentional.

-----Original Message-----
From: xxxxx@yahoo.co.in
Sent: Tuesday, March 24, 2009 6:08 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] URB_SELECT_CONFIGURATION

Hi,

Did you mean, we don’t have to collect the complete configuration descriptors and select one with our needs(config number=X)?

What are all the steps involved to use the URb URB_FUNCTION_SELECT_CONFIGURATION in WDM driver?

Can you help me?

In the wdm samples of 3790 DDK i have seen a function ConfigureDevice(). In a similar manner can i implement it?

regards
Nisheedh


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

From:
> What are all the steps involved to use the URb
> URB_FUNCTION_SELECT_CONFIGURATION in WDM driver?

All of the steps are explained in complete detail in ch. 12 of my WDM book.
I imagine there is also a very easy way to do it in a KMDF driver, too.

Walter Oney
Consulting and Training
www.oneysoft.com

Hi,

Did you meant to say we need to get device descriptor,all the configuration descriptors from the device as like that has been done in the ConfigureDevice() function and select what ever configuration we need?

Can you help me in resolving my doubt?
i am attaching my code for URB_FUCTION_SELECT_INTERFACE, which results a status unsuccessful and USBDSTATUS of Invalid configuration.

case URB_FUNCTION_SELECT_CONFIGURATION:

//Allocate memory for configuration descriptor
pConfigurationDescriptor = CYWDM_AllocateNonPagedPool(sizeof(USB_CONFIGURATION_DESCRIPTOR), “CYUSBIF_SendControlTransfer: urb”);
RtlZeroMemory(pConfigurationDescriptor, sizeof(USB_CONFIGURATION_DESCRIPTOR));
if(!pConfigurationDescriptor)
{
CYWDM_KdPrint(CYWDM_DBG_PNP_INFO, (szBuffer, “Memory allocation error for pConfigurationDescriptor in CYUSBIF_SendControlTransfer\n”));
goto CYUSBIF_SendControlTransferDone;
}

pConfigurationDescriptor = CYUSBIF_GetCurrentConfigDescriptor(DeviceObject);

//Allocate memory for Interface descriptor
pInterfaceDescriptor = CYWDM_AllocateNonPagedPool(sizeof(USB_INTERFACE_DESCRIPTOR), “CYUSBIF_SendControlTransfer: urb”);
RtlZeroMemory(pInterfaceDescriptor, sizeof(USB_INTERFACE_DESCRIPTOR));
if(!pInterfaceDescriptor)
{
CYWDM_KdPrint(CYWDM_DBG_PNP_INFO, (szBuffer, “Memory allocation error for pInterfaceDescriptor in CYUSBIF_SendControlTransfer\n”));
goto CYUSBIF_SendControlTransferDone;
}

//Allocate memory for USBD_INTERFACE_LIST_ENTRY
NumInterfaces = pConfigurationDescriptor->bNumInterfaces+1;
pInterfaceList = CYWDM_AllocateNonPagedPool(NumInterfaces * sizeof(USBD_INTERFACE_LIST_ENTRY), “CYUSBIF_SendControlTransfer: urb”);
RtlZeroMemory(pInterfaceList, (NumInterfaces * sizeof(USBD_INTERFACE_LIST_ENTRY)));
if(!pInterfaceList)
{
CYWDM_KdPrint(CYWDM_DBG_PNP_INFO, (szBuffer, “Memory allocation error for pInterfaceList in CYUSBIF_SendControlTransfer\n”));
goto CYUSBIF_SendControlTransferDone;
}

/*pConfigurationDescriptor->bConfigurationValue = (UCHAR)SingleTransfer->SetupPacket.wValue;
pConfigurationDescriptor->bLength = 0x09;
pConfigurationDescriptor->bDescriptorType = 0x02;
pConfigurationDescriptor->bNumInterfaces = 0x01;

//NumInterfaces = pConfigurationDescriptor->bNumInterfaces;

pInterfaceDescriptor->bLength = 0x09;
pInterfaceDescriptor->bDescriptorType = 0x04;
pInterfaceDescriptor->bInterfaceNumber = 0x00;*/

for (InterfaceNumber = 0;InterfaceNumber < NumInterfaces;InterfaceNumber++)
{

//searches a given configuration descriptor and returns a pointer to an interface that matches the given search criteria.
pInterfaceList[InterfaceNumber].InterfaceDescriptor = USBD_ParseConfigurationDescriptorEx (
pConfigurationDescriptor,
pInterfaceDescriptor,
InterfaceNumber,
0, // alternate setting
-1,//select any class
-1,//select any sub class
-1//select any protocol
);

//pInterfaceList->InterfaceDescriptor = pInterfaceDescriptor;
pInterfaceList->InterfaceDescriptor = pInterfaceDescriptor;
pInterfaceList->InterfaceDescriptor++;

}

//Get the select config request size
size = (USHORT)GET_SELECT_CONFIGURATION_REQUEST_SIZE(NumInterfaces, pInterfaceList->InterfaceDescriptor->bNumEndpoints);
//Allocate non paged pool for urb
urb = CYWDM_AllocateNonPagedPool(size, “CYUSBIF_SendControlTransfer: urb”);

if (urb == NULL)
goto CYUSBIF_SendControlTransferDone;

RtlZeroMemory(urb,size);

//Allocates and formats an URB to select a configuration for a USB device. return PURB
urb = USBD_CreateConfigurationRequestEx(pConfigurationDescriptor,pInterfaceList);

urb->UrbHeader.Function = urbFunction;
urb->UrbHeader.Length = size;

//urb->UrbSelectConfiguration.ConfigurationDescriptor->bConfigurationValue = (UCHAR)SingleTransfer->SetupPacket.wValue;

pConfigurationDescriptor->bConfigurationValue = (UCHAR)SingleTransfer->SetupPacket.wValue;
pConfigurationDescriptor->bLength = 0x09;
pConfigurationDescriptor->bDescriptorType = 0x02;
pConfigurationDescriptor->bNumInterfaces = 0x01;

//Formats a URB with the parameters necessary to select a configuration on a USB device. returns void.
UsbBuildSelectConfigurationRequest(urb,sizeof(struct _URB_SELECT_CONFIGURATION),pConfigurationDescriptor );

//Submiting the URB
ntStatus = SynchSubmitUrb(DeviceObject, urb, SingleTransfer->SetupPacket.ulTimeOut);

break;

This makes very little sense to me. first off you have some logical errors

pConfigurationDescriptor = CYWDM_AllocateNonPagedPool(sizeof(USB_CONFIGURATION_DESCRIPTOR),
A config descriptor is going to be much larger than the initial header. You usually query for the descriptor size and then allocate the bigger descriptor based on the reported sdize

RtlZeroMemory(pConfigurationDescriptor, sizeof(USB_CONFIGURATION_DESCRIPTOR));
if(!pConfigurationDescriptor)

You check for null after you zero out the buffer. If it were null, you would blow up first

pConfigurationDescriptor = CYUSBIF_GetCurrentConfigDescriptor(DeviceObject);
You are now leaking the pConfigurationDescriptor allocation by overwriting the pointer value with the return value

I think you need to take a step back, WAY WAY back, and rethink what you are trying to do and if you have enough skills to do the job assigned.

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@yahoo.co.in
Sent: Wednesday, March 25, 2009 5:46 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] URB_SELECT_CONFIGURATION

Hi,

Did you meant to say we need to get device descriptor,all the configuration descriptors from the device as like that has been done in the ConfigureDevice() function and select what ever configuration we need?

Can you help me in resolving my doubt?
i am attaching my code for URB_FUCTION_SELECT_INTERFACE, which results a status unsuccessful and USBDSTATUS of Invalid configuration.

case URB_FUNCTION_SELECT_CONFIGURATION:

//Allocate memory for configuration descriptor
pConfigurationDescriptor = CYWDM_AllocateNonPagedPool(sizeof(USB_CONFIGURATION_DESCRIPTOR), “CYUSBIF_SendControlTransfer: urb”);
RtlZeroMemory(pConfigurationDescriptor, sizeof(USB_CONFIGURATION_DESCRIPTOR));
if(!pConfigurationDescriptor)
{
CYWDM_KdPrint(CYWDM_DBG_PNP_INFO, (szBuffer, “Memory allocation error for pConfigurationDescriptor in CYUSBIF_SendControlTransfer\n”));
goto CYUSBIF_SendControlTransferDone;
}

pConfigurationDescriptor = CYUSBIF_GetCurrentConfigDescriptor(DeviceObject);

//Allocate memory for Interface descriptor
pInterfaceDescriptor = CYWDM_AllocateNonPagedPool(sizeof(USB_INTERFACE_DESCRIPTOR), “CYUSBIF_SendControlTransfer: urb”);
RtlZeroMemory(pInterfaceDescriptor, sizeof(USB_INTERFACE_DESCRIPTOR));
if(!pInterfaceDescriptor)
{
CYWDM_KdPrint(CYWDM_DBG_PNP_INFO, (szBuffer, “Memory allocation error for pInterfaceDescriptor in CYUSBIF_SendControlTransfer\n”));
goto CYUSBIF_SendControlTransferDone;
}

//Allocate memory for USBD_INTERFACE_LIST_ENTRY
NumInterfaces = pConfigurationDescriptor->bNumInterfaces+1;
pInterfaceList = CYWDM_AllocateNonPagedPool(NumInterfaces * sizeof(USBD_INTERFACE_LIST_ENTRY), “CYUSBIF_SendControlTransfer: urb”);
RtlZeroMemory(pInterfaceList, (NumInterfaces * sizeof(USBD_INTERFACE_LIST_ENTRY)));
if(!pInterfaceList)
{
CYWDM_KdPrint(CYWDM_DBG_PNP_INFO, (szBuffer, “Memory allocation error for pInterfaceList in CYUSBIF_SendControlTransfer\n”));
goto CYUSBIF_SendControlTransferDone;
}

/*pConfigurationDescriptor->bConfigurationValue = (UCHAR)SingleTransfer->SetupPacket.wValue;
pConfigurationDescriptor->bLength = 0x09;
pConfigurationDescriptor->bDescriptorType = 0x02;
pConfigurationDescriptor->bNumInterfaces = 0x01;

//NumInterfaces = pConfigurationDescriptor->bNumInterfaces;

pInterfaceDescriptor->bLength = 0x09;
pInterfaceDescriptor->bDescriptorType = 0x04;
pInterfaceDescriptor->bInterfaceNumber = 0x00;*/

for (InterfaceNumber = 0;InterfaceNumber < NumInterfaces;InterfaceNumber++)
{

//searches a given configuration descriptor and returns a pointer to an interface that matches the given search criteria.
pInterfaceList[InterfaceNumber].InterfaceDescriptor = USBD_ParseConfigurationDescriptorEx (
pConfigurationDescriptor,
pInterfaceDescriptor,
InterfaceNumber,
0, // alternate setting
-1,//select any class
-1,//select any sub class
-1//select any protocol
);

//pInterfaceList->InterfaceDescriptor = pInterfaceDescriptor;
pInterfaceList->InterfaceDescriptor = pInterfaceDescriptor;
pInterfaceList->InterfaceDescriptor++;

}

//Get the select config request size
size = (USHORT)GET_SELECT_CONFIGURATION_REQUEST_SIZE(NumInterfaces, pInterfaceList->InterfaceDescriptor->bNumEndpoints);
//Allocate non paged pool for urb
urb = CYWDM_AllocateNonPagedPool(size, “CYUSBIF_SendControlTransfer: urb”);

if (urb == NULL)
goto CYUSBIF_SendControlTransferDone;

RtlZeroMemory(urb,size);

//Allocates and formats an URB to select a configuration for a USB device. return PURB
urb = USBD_CreateConfigurationRequestEx(pConfigurationDescriptor,pInterfaceList);

urb->UrbHeader.Function = urbFunction;
urb->UrbHeader.Length = size;

//urb->UrbSelectConfiguration.ConfigurationDescriptor->bConfigurationValue = (UCHAR)SingleTransfer->SetupPacket.wValue;

pConfigurationDescriptor->bConfigurationValue = (UCHAR)SingleTransfer->SetupPacket.wValue;
pConfigurationDescriptor->bLength = 0x09;
pConfigurationDescriptor->bDescriptorType = 0x02;
pConfigurationDescriptor->bNumInterfaces = 0x01;

//Formats a URB with the parameters necessary to select a configuration on a USB device. returns void.
UsbBuildSelectConfigurationRequest(urb,sizeof(struct _URB_SELECT_CONFIGURATION),pConfigurationDescriptor );

//Submiting the URB
ntStatus = SynchSubmitUrb(DeviceObject, urb, SingleTransfer->SetupPacket.ulTimeOut);

break;


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

xxxxx@yahoo.co.in wrote:

Did you meant to say we need to get device descriptor,all the configuration descriptors from the device as like that has been done in the ConfigureDevice() function and select what ever configuration we need?

Can you help me in resolving my doubt?

I don’t understand what you’re asking. Every USB driver should do a
“select configuration” at some point early in its processing. The
ConfigureDevice() function shows an example of how to do that. The URB
requires a set of interface and endpoint descriptors, which are
constructed from the configuration descriptor for the configuration you
want.

i am attaching my code for URB_FUCTION_SELECT_INTERFACE, which results a status unsuccessful and USBDSTATUS of Invalid configuration.

case URB_FUNCTION_SELECT_CONFIGURATION:

This is not really your code for URB_FUNCTION_SELECT_INTERFACE, is it?

What kind of driver is this? I don’t understand why you would have a
switch statement for URB_FUNCTION_SELECT_CONFIGURATION, unless this was
a filter driver. Is that what it is?

Have you dumped the information in your _USB_SELECT_CONFIGURATION
request in the debugger to make sure it all makes sense?


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

Hi,

I have implemented the select configuration request taking the configuredevice function as a refernce and is working fine!

Thanks for your reply!

Regards
Nisheedh