In WDM, IoCreateDevice can be called many times in DriverEntry to create multiple device objects. How do I do this in KMDF? I cannot call WdfDeviceCreate repeatedly in DeviceAdd because it looks like the DeviceInit struct is free after the first call.
Will be there problems if I create a device object in DeviceAdd, then call WdfPdoInitAllocate on this object to get more DeviceInit structs to create more device objects? And this is for a very simple software only device.
What are you going to use these other devices for? Will they have fixed names? Even in a wdm driver, you should not create devobjs in DriverEntry, so please explain what your end goal is instead asking of what you think the answer to your problem is.
Thx
d
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@yahoo.com
Sent: Thursday, January 08, 2009 4:24 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Create multiple device objects in KMDF
In WDM, IoCreateDevice can be called many times in DriverEntry to create multiple device objects. How do I do this in KMDF? I cannot call WdfDeviceCreate repeatedly in DeviceAdd because it looks like the DeviceInit struct is free after the first call.
Will be there problems if I create a device object in DeviceAdd, then call WdfPdoInitAllocate on this object to get more DeviceInit structs to create more device objects? And this is for a very simple software only device.
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
In this exercise I need to write a simple driver that handle an unknown number of devices (less than 10). When a user mode program sends a request “A new device has been plugged in. Device name: ABC, Device ID: 123, …”, I’ll need to create a new device with the given characteristics. The device will need to be able to reply to IOCTLs like “Query name”, “Query ID”, “unplugged”, …
At first I tried to create a dozen of dev obj in Device Add then each time a request comes, pick up one and set it to “active”, but got stuck. Then I found the other idea in the sample code (/src/kmdf/toaster/bus/static/buspdo.c) but not sure it will work. Anyway, I’m trying it now.
You want dynambus, not staticbus, since you want to dynamically unplug them. Static bus is for enumerating a fixed set of children that change after you initially add them
d
Sent from my phone with no t9, all spilling mistakes are not intentional.
-----Original Message-----
From: xxxxx@yahoo.com
Sent: Friday, January 09, 2009 9:49 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Create multiple device objects in KMDF
In this exercise I need to write a simple driver that handle an unknown number of devices (less than 10). When a user mode program sends a request “A new device has been plugged in. Device name: ABC, Device ID: 123, …”, I’ll need to create a new device with the given characteristics. The device will need to be able to reply to IOCTLs like “Query name”, “Query ID”, “unplugged”, …
At first I tried to create a dozen of dev obj in Device Add then each time a request comes, pick up one and set it to “active”, but got stuck. Then I found the other idea in the sample code (/src/kmdf/toaster/bus/static/buspdo.c) but not sure it will work. Anyway, I’m trying it now.
—
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
Thanks.
I looked at the sample code and the help pages for dynamic enumeration. The method is rather complicated and I may not have enough time to learn and implement it. Is there anything fundamentally wrong with using WdfPdoInitAllocate+WdfDeviceCreate and WdfPdoMarkMissing to add and remove device dynamically?
Just look at the source for dynambus, it is not that hard. You essentially define 2 callbacks and an identity structure. The issue with Create/MarkMissing for static enumeration is when you mark a pdo as missing and then create a new pdo with the same identity right afterward. You have to make sure that you are not creating 2 PDOs with the same identity at the same time, if you do, pnp will bugcheck with duplicate children being reported. The dynamic way to enumerate avoids this problem. You already have the concept of PDO identity in your create request, all you need to do is put this in a structure and write a function which compares 2 identities against each other.
d
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@yahoo.com
Sent: Friday, January 09, 2009 11:54 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Create multiple device objects in KMDF
Thanks.
I looked at the sample code and the help pages for dynamic enumeration. The method is rather complicated and I may not have enough time to learn and implement it. Is there anything fundamentally wrong with using WdfPdoInitAllocate+WdfDeviceCreate and WdfPdoMarkMissing to add and remove device dynamically?
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
Thanks again. I think I have enough ideas to complete this exercise.