using WDF from a non-WDF driver

  • Thread starter Thread starter pgruebele
  • Start date Start date
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
 
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
 
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);
 
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);
 
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
 
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
 
Back
Top