Regarding DFU+ IOCTL_INTERNAL_USB_CYCLE_PORT

Posted: 01-05-2007, 11:13 AM
Hi,
I am implementing DFU support to the usb function driver.For DFU
support,I need to re enumerate the device so that while enumerating all
the other drivers are unloaded and DFU supported USB function driver
gets loaded.I have posted my piece of code down.

PAGED_CODE();
NTSTATUS status;
PDEVICE_EXTENSION pdx = (PDEVICE_EXTENSION) fdo->DeviceExtension;
KEVENT event;
KeInitializeEvent(&event, NotificationEvent, FALSE);
IO_STATUS_BLOCK iostatus;

PIRP Irp =
IoBuildDeviceIoControlRequest(IOCTL_INTERNAL_USB_C YCLE_PORT,
pdx->LowerDeviceObject, NULL, 0, NULL, 0, TRUE, &event,
&iostatus);
KdPrint((DRIVERNAME " - IoBuildDeviceIoControlRequest %X \n",
iostatus.Status));
KdPrint((DRIVERNAME " - IRP Pointer %X \n", Irp));
PIO_STACK_LOCATION stack = IoGetNextIrpStackLocation(Irp);
stack->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL;
stack->Parameters.DeviceIoControl.IoControlCode =
IOCTL_INTERNAL_USB_CYCLE_PORT;
//stack->Parameters.Others.Argument1 = (PVOID) urb;

status = IoCallDriver(pdx->LowerDeviceObject, Irp);
KdPrint((DRIVERNAME " - After IoCallDriver %X \n", status));

if (status == STATUS_PENDING)
{
KeWaitForSingleObject(&event, Executive, KernelMode, FALSE,
NULL);
status = iostatus.Status;

}
KdPrint((DRIVERNAME " - IoBuildDeviceIoControlRequest %X \n",
iostatus.Status));
if (!NT_SUCCESS(status))
{
KdPrint((DRIVERNAME " - Error %X trying to reset device\n",
status));
}
KdPrint((DRIVERNAME " - Returning DFUReset status %X \n", status));
return status;.


The problem here is my device is getting reset.But when it enumerates
again I am getting STATUS_NAME_OBJECT_COLLISION error.IoCreateDevice
fails.
The hardware device I am using is a bluetooth dongle.
Help me thru this.

Reply With Quote

Responses to "Regarding DFU+ IOCTL_INTERNAL_USB_CYCLE_PORT"

zyx
Guest
Posts: n/a
 
Re: Regarding DFU+ IOCTL_INTERNAL_USB_CYCLE_PORT
Posted: 01-05-2007, 12:07 PM
Hi,
I will also post the debug prints that I got from dbgview.

Returning DFUReset status 0
PNP Request (IRP_MN_QUERY_DEVICE_RELATIONS)
PNP Request (IRP_MN_QUERY_DEVICE_RELATIONS)
PNP Request (IRP_MN_SURPRISE_REMOVAL)
To SURPRISEREMOVED from WORKING
status IoCallDriver:103
status SendAwaitUrb:c000009d
Error C000009D trying to deconfigure device
IoDeleteSymbolic link 0
NEW Entering AddDevice: DriverObject 86268030, pdo 857D2030 (Max Dev
Count 1)
IoCreateDevice returned - c0000035
Device count - 0.
Failed to create deivce object - c0000035
IRP_MJ_CLEANUP
status :0
IRP_MJ_CLOSE
No queue elements for freeing.
PNP Request (IRP_MN_REMOVE_DEVICE)
To REMOVED from SURPRISEREMOVED
Entering DriverUnload: DriverObject 86268030
NU Entering DriverEntry: DriverObject 86268030

In the above log u can see that symbolic link is also destroyed
correctly in surprise removal function.
My application calls createfile,deviceIocontrol with custom reset
command and close file.






zyx wrote:
> Hi,
> I am implementing DFU support to the usb function driver.For DFU
> support,I need to re enumerate the device so that while enumerating all
> the other drivers are unloaded and DFU supported USB function driver
> gets loaded.I have posted my piece of code down.
>
> PAGED_CODE();
> NTSTATUS status;
> PDEVICE_EXTENSION pdx = (PDEVICE_EXTENSION) fdo->DeviceExtension;
> KEVENT event;
> KeInitializeEvent(&event, NotificationEvent, FALSE);
> IO_STATUS_BLOCK iostatus;
>
> PIRP Irp =
> IoBuildDeviceIoControlRequest(IOCTL_INTERNAL_USB_C YCLE_PORT,
> pdx->LowerDeviceObject, NULL, 0, NULL, 0, TRUE, &event,
> &iostatus);
> KdPrint((DRIVERNAME " - IoBuildDeviceIoControlRequest %X \n",
> iostatus.Status));
> KdPrint((DRIVERNAME " - IRP Pointer %X \n", Irp));
> PIO_STACK_LOCATION stack = IoGetNextIrpStackLocation(Irp);
> stack->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL;
> stack->Parameters.DeviceIoControl.IoControlCode =
> IOCTL_INTERNAL_USB_CYCLE_PORT;
> //stack->Parameters.Others.Argument1 = (PVOID) urb;
>
> status = IoCallDriver(pdx->LowerDeviceObject, Irp);
> KdPrint((DRIVERNAME " - After IoCallDriver %X \n", status));
>
> if (status == STATUS_PENDING)
> {
> KeWaitForSingleObject(&event, Executive, KernelMode, FALSE,
> NULL);
> status = iostatus.Status;
>
> }
> KdPrint((DRIVERNAME " - IoBuildDeviceIoControlRequest %X \n",
> iostatus.Status));
> if (!NT_SUCCESS(status))
> {
> KdPrint((DRIVERNAME " - Error %X trying to reset device\n",
> status));
> }
> KdPrint((DRIVERNAME " - Returning DFUReset status %X \n", status));
> return status;.
>
>
> The problem here is my device is getting reset.But when it enumerates
> again I am getting STATUS_NAME_OBJECT_COLLISION error.IoCreateDevice
> fails.
> The hardware device I am using is a bluetooth dongle.
> Help me thru this.
Reply With Quote
Doron Holan [MS]
Guest
Posts: n/a
 
Re: Regarding DFU+ IOCTL_INTERNAL_USB_CYCLE_PORT
Posted: 01-08-2007, 03:04 AM
on supriser remove you need to delete the symbolic link you created. for
the actual devobj name, if there is a collision, you need to iterate and
give it a new name (instead of \Device\Foo1, \Device\Foo2). In reality, the
best way to do this is not give your device a name at all and use device
interfaces (IoRegisterDeviceInterface/IoSetDeviceInterfaceState). If you
really need to create a NT4 symbolic link, get the PDO's name
(IoGetDeviceProperty(DevicePropertyPhysicalDeviceO bjectName )) and create a
symbolic link to it (and again delete the symbolic link during surprise
remove).

d

--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.


"zyx" <vidhya_542001@yahoo.co.in> wrote in message
news:1167998832.906269.16930@51g2000cwl.googlegrou ps.com...
> Hi,
> I will also post the debug prints that I got from dbgview.
>
> Returning DFUReset status 0
> PNP Request (IRP_MN_QUERY_DEVICE_RELATIONS)
> PNP Request (IRP_MN_QUERY_DEVICE_RELATIONS)
> PNP Request (IRP_MN_SURPRISE_REMOVAL)
> To SURPRISEREMOVED from WORKING
> status IoCallDriver:103
> status SendAwaitUrb:c000009d
> Error C000009D trying to deconfigure device
> IoDeleteSymbolic link 0
> NEW Entering AddDevice: DriverObject 86268030, pdo 857D2030 (Max Dev
> Count 1)
> IoCreateDevice returned - c0000035
> Device count - 0.
> Failed to create deivce object - c0000035
> IRP_MJ_CLEANUP
> status :0
> IRP_MJ_CLOSE
> No queue elements for freeing.
> PNP Request (IRP_MN_REMOVE_DEVICE)
> To REMOVED from SURPRISEREMOVED
> Entering DriverUnload: DriverObject 86268030
> NU Entering DriverEntry: DriverObject 86268030
>
> In the above log u can see that symbolic link is also destroyed
> correctly in surprise removal function.
> My application calls createfile,deviceIocontrol with custom reset
> command and close file.
>
>
>
>
>
>
> zyx wrote:
>> Hi,
>> I am implementing DFU support to the usb function driver.For DFU
>> support,I need to re enumerate the device so that while enumerating all
>> the other drivers are unloaded and DFU supported USB function driver
>> gets loaded.I have posted my piece of code down.
>>
>> PAGED_CODE();
>> NTSTATUS status;
>> PDEVICE_EXTENSION pdx = (PDEVICE_EXTENSION) fdo->DeviceExtension;
>> KEVENT event;
>> KeInitializeEvent(&event, NotificationEvent, FALSE);
>> IO_STATUS_BLOCK iostatus;
>>
>> PIRP Irp =
>> IoBuildDeviceIoControlRequest(IOCTL_INTERNAL_USB_C YCLE_PORT,
>> pdx->LowerDeviceObject, NULL, 0, NULL, 0, TRUE, &event,
>> &iostatus);
>> KdPrint((DRIVERNAME " - IoBuildDeviceIoControlRequest %X \n",
>> iostatus.Status));
>> KdPrint((DRIVERNAME " - IRP Pointer %X \n", Irp));
>> PIO_STACK_LOCATION stack = IoGetNextIrpStackLocation(Irp);
>> stack->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL;
>> stack->Parameters.DeviceIoControl.IoControlCode =
>> IOCTL_INTERNAL_USB_CYCLE_PORT;
>> //stack->Parameters.Others.Argument1 = (PVOID) urb;
>>
>> status = IoCallDriver(pdx->LowerDeviceObject, Irp);
>> KdPrint((DRIVERNAME " - After IoCallDriver %X \n", status));
>>
>> if (status == STATUS_PENDING)
>> {
>> KeWaitForSingleObject(&event, Executive, KernelMode, FALSE,
>> NULL);
>> status = iostatus.Status;
>>
>> }
>> KdPrint((DRIVERNAME " - IoBuildDeviceIoControlRequest %X \n",
>> iostatus.Status));
>> if (!NT_SUCCESS(status))
>> {
>> KdPrint((DRIVERNAME " - Error %X trying to reset device\n",
>> status));
>> }
>> KdPrint((DRIVERNAME " - Returning DFUReset status %X \n", status));
>> return status;.
>>
>>
>> The problem here is my device is getting reset.But when it enumerates
>> again I am getting STATUS_NAME_OBJECT_COLLISION error.IoCreateDevice
>> fails.
>> The hardware device I am using is a bluetooth dongle.
>> Help me thru this.
>

Reply With Quote
 
LinkBack Thread Tools Display Modes
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem of using IOCTL_INTERNAL_USB_CYCLE_PORT (USB composite device) on Windows 2000 . Jeth Chang Windows XP Device Drivers 0 01-15-2005 02:12 AM


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90