I have written a NT driver for a custom developed PCI card, it's a
multi-port serial adapter. Under NT when DriverEntry() was called, I
used the HAL functions to find the presence of our adapter on the bus.
Knowing beforehand how many serial ports are on the adapter I could
simply create X instances of the device. As all ports share the same
resources, I allocated interrupts and common buffer areas in
DriverEntry. Each device never assigned any resources, they all share
the same common resources.
Now I have to port this driver to the WDM model. My problem is that the
HAL functions I used to scan the bus is not available anymore.
When OnStartDevice is called, the I/O manager passes you a resource
list.
Problem is I want to create more than one device and I can't seeing as
the only time I will know what hardware resources I have been assigned
is when the device object is already created!
How can I create a device object per port for the adapter and still
assign the PCI resources? How else can I open these ports from
user-mode, if not by calling CreateFile() and using the symbolic link
of each port? That can only happen if each port is its own device
object even though there is only one physical PCI adapter.
The adapter doesn't fit into the multifunction specification.
The adapter has X logical ports in a CPU not X UARTs, but they all
share the same hardware resources. There is a common buffer and an
interrupt line. A message is then passed to and fro using this common
buffer and signalled with the interrupt. Each message in its header,
contains port information.
I wish to have X devices ( and X symbolics links ). As far as I could
find this type of driver is called a multiport driver, where there are
more than one
logical function on a device. A multifunction device is when each
function uses non-overlapping hardware resources, my adapter doesn't
fit that description. I can't find any examples for multiport drivers
however.
What structure should my driver contain? Do I need a bus driver for the
adapter and then a function driver per port? Or is there a INF section
that I am missing?