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?

Re: Multiport PCI driver under WDM by Mark

Mark
Tue Feb 15 06:43:44 CST 2005

rolandbennett@gmail.com wrote:
> 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?
>


You need a bus driver. Your bus driver enumerates the PCI function and
then creates child PDOs for each 'port' on some bus type that you
invent. You then write a function driver too handle all of the port
devices. IO is sent by your function driver to your bus driver PDOs
(Where a typical approach is to then route the request to the bus driver
FDO for its PCI device.) Your bus driver does whatever is required to
put data into the common buffer with the appropriate header information,
and handle interrupts etc. and get data back to the port stack.

See the toaster sample driver for clues on how to play the bus driver role.

--

=====================
Mark Roddy DDK MVP
Windows 2003/XP/2000 Consulting
Hollis Technology Solutions 603-321-1032
www.hollistech.com

Re: Multiport PCI driver under WDM by Maxim

Maxim
Tue Feb 15 08:03:07 CST 2005

> 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

Read MSDN about mf.sys.
The sample INF files can be taken from Aureal souncard (its INFs are in Windows
itself).

Hope your UARTs have no BAR or interrupt line dependencies.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com



Re: Multiport PCI driver under WDM by Calvin

Calvin
Tue Feb 15 10:06:53 CST 2005

You have received excellent answers from Mr. Roddy. One thing I want to add:

> How can I create a device object per port for the adapter and still
> assign the PCI resources?

You can not subdivide the parent's PCI resources (I/O,MEM) and assign to the
child(ren). Resource arbitration is done by the OS/pci driver and there's no
documented interface available for us.

--
Calvin Guan Software Engineer/Radeon NT Drivers
ATI Technologies Inc. Markham ON, Canada www.ati.com


<rolandbennett@gmail.com> wrote in message
news:1108469066.516127.325590@l41g2000cwc.googlegroups.com...
> 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?
>



Re: Multiport PCI driver under WDM by Maxim

Maxim
Tue Feb 15 10:32:29 CST 2005

> You can not subdivide the parent's PCI resources (I/O,MEM) and assign to the
> child(ren). Resource arbitration is done by the OS/pci driver and there's no
> documented interface available for us.

MF.SYS contains the arbiter in it and has some limited functionality to do
this. I would suggest the OP to read MSDN about MF.SYS and its capabilities.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com



RE: Multiport PCI driver under WDM by JimE

JimE
Tue Feb 15 14:41:05 CST 2005

Get Walter Oney's "Programming the Windows Driver Model" 2nd edition and pay
particular attention to chapter 10. You will need to write two drivers, one
which will provide the user interface to your serial ports, and another to
act as the "bus driver" for them, i.e. the PCI card itself. This "bus driver"
will get the assigned resources and you will need to figure out some method
of communicating them to it's child devices, which it will create in response
to a IRP_MN_START_DEVICE ioctl. You will also need to figure out a method of
handling a common interrupt in the "bus driver" and passing the events to the
appropriate serial ports. Although the book is geared to a multi-function
device, it shows most of what is needed for a controller device. Instead of
detecting multiple functions, you will just create a known number of
identical devices.

"rolandbennett@gmail.com" wrote:

> 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?
>
>

Re: Multiport PCI driver under WDM by Mark

Mark
Tue Feb 15 19:48:16 CST 2005

Maxim S. Shatskih wrote:
>>You can not subdivide the parent's PCI resources (I/O,MEM) and assign to the
>>child(ren). Resource arbitration is done by the OS/pci driver and there's no
>>documented interface available for us.
>
>
> MF.SYS contains the arbiter in it and has some limited functionality to do
> this. I would suggest the OP to read MSDN about MF.SYS and its capabilities.
>
I could be wrong but I think the OP has a completely non-standard port
arrangement, with some protocol that puts port address information along
with data packets into a comman buffer. My guess is that he then rings a
doorbell mechanism and the hardware sucks out the contents of the common
buffer. I think when he said "all ports share the same resources" he
really meant the same resources, not portions of these resources that
could be parceled out by mf.sys. Otherwise I would certainly have
suggested the mf route.

--

=====================
Mark Roddy DDK MVP
Windows 2003/XP/2000 Consulting
Hollis Technology Solutions 603-321-1032
www.hollistech.com