using WDF from a non-WDF driver

P

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
 
D

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
 
P

pgruebele

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);
 
P

pgruebele

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);
 
P

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
 
D

Doron Holan [MSFT]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top