Discussion:
using WDF from a non-WDF driver
(too old to reply)
pgruebele
2009-08-26 08:12:01 UTC
Permalink
Hi.

I have a PortCLS audio driver (non-WDF) and would like to use
WdfUsbTargetDeviceCreate() and related functionality in order to take
advantage of WDF usb abstraction.

Is this possible? WdfUsbTargetDeviceCreate() itself requires a pointer to
the parent WDF device, but of course the parent is PortCls and not WDF...

Thanks

Philip
Doron Holan [MSFT]
2009-08-26 19:55:23 UTC
Permalink
this can be done. you must use KMDF in miniport mode.
1) in DriverEntry, set WdfDriverInitNoDispatchOverride in
WDF_DRIVER_CONFIG.Flags
2) in the portcls callback which you initialize the device, call
WdfDeviceMiniportCreate. this gives you a WDFDEVICE

now you can call WdfUsbTargetDeviceCreate

d
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Post by pgruebele
Hi.
I have a PortCLS audio driver (non-WDF) and would like to use
WdfUsbTargetDeviceCreate() and related functionality in order to take
advantage of WDF usb abstraction.
Is this possible? WdfUsbTargetDeviceCreate() itself requires a pointer to
the parent WDF device, but of course the parent is PortCls and not WDF...
Thanks
Philip
pgruebele
2009-08-27 22:55:01 UTC
Permalink
Thanks d

I got compiling with WDF and loading the driver to work.

But, how do I call WdfDeviceMiniportCreate? I don't know how to get the
DeviceObject and AttachedDeviceObject parameters. Is the code below correct?


ntStatus = WdfDeviceMiniportCreate(WdfGetDriver(),
&attributes,
PhysicalDeviceObject->AttachedDevice,
PhysicalDeviceObject->AttachedDevice,
PhysicalDeviceObject,
&WdfDevice);
Post by Doron Holan [MSFT]
this can be done. you must use KMDF in miniport mode.
1) in DriverEntry, set WdfDriverInitNoDispatchOverride in
WDF_DRIVER_CONFIG.Flags
2) in the portcls callback which you initialize the device, call
WdfDeviceMiniportCreate. this gives you a WDFDEVICE
now you can call WdfUsbTargetDeviceCreate
d
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Post by pgruebele
Hi.
I have a PortCLS audio driver (non-WDF) and would like to use
WdfUsbTargetDeviceCreate() and related functionality in order to take
advantage of WDF usb abstraction.
Is this possible? WdfUsbTargetDeviceCreate() itself requires a pointer to
the parent WDF device, but of course the parent is PortCls and not WDF...
Thanks
Philip
pgruebele
2009-08-27 22:58:01 UTC
Permalink
Here is more complete code to be clear...

// Tell the class driver to add the device.
ntStatus = PcAddAdapterDevice(DriverObject, PhysicalDeviceObject,
PCPFNSTARTDEVICE(StartDevice), MAX_MINIPORTS, 0);

WDF_OBJECT_ATTRIBUTES attributes;
WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attributes, WDF_DEVICE_INFO);
WDFDEVICE WdfDevice;
ntStatus = WdfDeviceMiniportCreate(WdfGetDriver(),
&attributes,
PhysicalDeviceObject->AttachedDevice,
PhysicalDeviceObject->AttachedDevice,
PhysicalDeviceObject,
&WdfDevice);
pgruebele
2009-08-28 01:15:01 UTC
Permalink
Hi D,

I am kind of lost so I have another question for you.

How does WdfUsbTargetDeviceCreate() know which USB device to connect to and
receive the USB device descriptor from? I can't see anywhere to specify
this. Looking at the usbnwifi sample I still can't figure it out.

Thanks for you help,

Philip
Doron Holan [MSFT]
2009-09-08 18:46:54 UTC
Permalink
the PDO you are attached to describes the device instance to talk to. the
bus driver which created the PDO then knows how to route the IO to the
device

d
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Post by pgruebele
Hi D,
I am kind of lost so I have another question for you.
How does WdfUsbTargetDeviceCreate() know which USB device to connect to and
receive the USB device descriptor from? I can't see anywhere to specify
this. Looking at the usbnwifi sample I still can't figure it out.
Thanks for you help,
Philip
Loading...