Multiport serial driver design queries

Hi,

I have read some posts in this forum about this topic but i still have some specific questions.

i am new to driver development and i am designing a driver for a PCI-E based multi port serial controller. This controller has 4 UART ports to which target devices may be connected. The UART ports need to be exposed as COM ports to the user applications.

  1. My current design idea for initializing the driver given below. Please suggest if this design has any problems.

I will have only one driver. I will create a functional device object for the controller in the driver. For the 4 UARTs, i will create 4 PDOs and keep them as RAW. I will create device interfaces for all the PDOs and attach symbolic links to these. These symbolic links will be exposed to the user applications.

  1. I read about the windows component MF.sys in MSDN. What is the role of MF.sys driver in this case ? Do i need to be concerned about this while designing my driver?

  2. While creating the device interfaces for the PDOs for UART ports, what is the GUID that i need to use?

There are two basic approaches you can do for this problem:

  1. Create a bus driver to enumerate the PDO’s for each UART. If your
    device has totally separate register spaces, and unique interrupts for the
    devices, the MF.sys is the bus driver of choice. Otherwise, if you have
    any shared registers or interrupts create a simple bus driver with KMDF with
    access to any shared resources being controlled by the bus driver.

Once you have the individual devices, you should take the serial
sample from the WDK and modify it for your needs. If you UART’s look like
16550’s then this is pretty easy. If you are sharing some resources, those
areas of the driver as well as the adddevice/removedevice need some support.

  1. Create a monolithic driver for all four UART’s. This would create four
    FDO’s that attach to the one PCI device PDO for the system. This is
    typically more work since the serial driver sample needs a lot of tweaking.

I’ve done this type of work for multiple customers, it is not hard, but the
learning curve for Windows drivers will keep you going for a few months on
this one.

Don Burn
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@gmail.com
Sent: Monday, May 12, 2014 12:56 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Multiport serial driver design queries

Hi,

I have read some posts in this forum about this topic but i still have some
specific questions.

i am new to driver development and i am designing a driver for a PCI-E based
multi port serial controller. This controller has 4 UART ports to which
target devices may be connected. The UART ports need to be exposed as COM
ports to the user applications.

  1. My current design idea for initializing the driver given below. Please
    suggest if this design has any problems.

I will have only one driver. I will create a functional device object for
the controller in the driver. For the 4 UARTs, i will create 4 PDOs and keep
them as RAW. I will create device interfaces for all the PDOs and attach
symbolic links to these. These symbolic links will be exposed to the user
applications.

  1. I read about the windows component MF.sys in MSDN. What is the role of
    MF.sys driver in this case ? Do i need to be concerned about this while
    designing my driver?

  2. While creating the device interfaces for the PDOs for UART ports, what is
    the GUID that i need to use?


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

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

by the way, i am required to use KMDF model.

The serial sample is KMDF.

Don Burn
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@gmail.com
Sent: Monday, May 12, 2014 1:08 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Multiport serial driver design queries

by the way, i am required to use KMDF model.


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

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 for responding Don.

by the way, i am using KMDF framework.

i think my device has separate register spaces and unique interrupts. However i have a few questions.

  1. how do i make MF.sys as a bus driver to my driver? what are the files that i need to edit and what settings do it need to make?

  2. What changes do i need to make in the serial sample from MSDN?

  3. in this case, the only driver that i will be writing would be the tweaked serial driver. Am i correct?

For how to use mf.sys see
http://msdn.microsoft.com/en-us/library/windows/hardware/ff542778(v=vs.85).a
spx You need four interrupts one for each UART. If the register set for
the UART’s matches a 16550 exactly there will be no need for changes in the
serial driver, otherwise it is dependent on the differences in the hardware.

Don Burn
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@gmail.com
Sent: Monday, May 12, 2014 1:16 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Multiport serial driver design queries

Thanks for responding Don.

by the way, i am using KMDF framework.

i think my device has separate register spaces and unique interrupts.
However i have a few questions.

  1. how do i make MF.sys as a bus driver to my driver? what are the files
    that i need to edit and what settings do it need to make?

  2. What changes do i need to make in the serial sample from MSDN?

  3. in this case, the only driver that i will be writing would be the tweaked
    serial driver. Am i correct?


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

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

You can get away without bothering with PDOs (and cluttering the Device Manager with extra ports).

Call IoRegisterDeviceInterface for the standard comport GUID with different ReferenceString arguments (for example, PORT1, PORT2, etc). In your CREATE handles, you’ll get those ReferenceString as the file name. Your FDO needs to be non-exclusive. You have to reject duplicate opens for the same port by yourself.

When you create symbolic links, use the interface name (including the reference string) as the link target.

xxxxx@gmail.com wrote:

i am new to driver development and i am designing a driver for a PCI-E based multi port serial controller. This controller has 4 UART ports to which target devices may be connected. The UART ports need to be exposed as COM ports to the user applications.

WHY would any company in the 21st Century design a NEW product based on
serial ports? Do we all not realize that the RS-232 standard is **50**
years old? There is no clocking. There are no protocols. There is no
error correction. The speeds are limited. The voltage requirements are
very loose. The application interfaces are dreadful.

I have almost never heard of a serial port application that could not be
handled far better, much faster, and way more reliably with USB.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Tim,

There is a heck of a lot of legacy hardware out there controlling
various devices. I asked the same question the first time I was approached
to do a bus driver/serial driver combination, now I’ve done three of them
for clients. One wants to think why not just update the interface, but for
a lot of these devices that is going to take years, and in the mean time
they need a quick solution now!

It may sound weird, but I am getting a lot of queries for serial ports
(which I have an easily customizable solution for), LPT and even weird
things like ATM. Whether we like it or no old hardware take a long time to
die.

Don Burn
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
Sent: Monday, May 12, 2014 2:12 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Multiport serial driver design queries

xxxxx@gmail.com wrote:

i am new to driver development and i am designing a driver for a PCI-E
based multi port serial controller. This controller has 4 UART ports to
which target devices may be connected. The UART ports need to be exposed as
COM ports to the user applications.

WHY would any company in the 21st Century design a NEW product based on
serial ports? Do we all not realize that the RS-232 standard is **50**
years old? There is no clocking. There are no protocols. There is no
error correction. The speeds are limited. The voltage requirements are
very loose. The application interfaces are dreadful.

I have almost never heard of a serial port application that could not be
handled far better, much faster, and way more reliably with USB.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

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

Hi Tim,

I agree that serial, and RS-232, are antiquated. But serial is still very
much alive in industrial applications. Very simple devices can provide
RS-232 (easily convertible to RS-485), and the multi-drop friendly Modbus
protocol to provide data up to a mile away. There are alternatives, but
serial Modbus is the de-facto standard and does a good job for many
applications.

Thanks,
David Cravey

On Mon, May 12, 2014 at 1:12 PM, Tim Roberts wrote:

> xxxxx@gmail.com wrote:
> > i am new to driver development and i am designing a driver for a PCI-E
> based multi port serial controller. This controller has 4 UART ports to
> which target devices may be connected. The UART ports need to be exposed as
> COM ports to the user applications.
>
> WHY would any company in the 21st Century design a NEW product based on
> serial ports? Do we all not realize that the RS-232 standard is 50
> years old? There is no clocking. There are no protocols. There is no
> error correction. The speeds are limited. The voltage requirements are
> very loose. The application interfaces are dreadful.
>
> I have almost never heard of a serial port application that could not be
> handled far better, much faster, and way more reliably with USB.
>
> –
> Tim Roberts, xxxxx@probo.com
> Providenza & Boekelheide, Inc.
>
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev
>
> OSR is HIRING!! See http://www.osr.com/careers
>
> 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
>

Alex,

Thanks for responding.

You mean i don’t need to create any PDO’s at all? Just an FDO for my controller?

Don,

Just want to confirm my understanding.

if i use mf.sys as the bus driver, then i will get an EvtAddDevice call once for each of the UART ports i have on the controller?

In this case, how do i know if this EvtAddDevice is called in response to PDO created for the controller or the PDO created for the UART port by MF.sys for UART?

>You mean i don’t need to create any PDO’s at all? Just an FDO for my controller?

  1. You create an FDO, make sure it’s non-exclusive (allows multiple opens: pass FALSE as Exclusive in IoCreateDevice).
  2. To avoid user’s confusion, the friendly name in DeviceManager needs to say it’s Multi-port controller.
  3. Call IoRegisterDeviceInterface once per port you support, each time passing a different ReferenceString. Then create legacy COMx symbolic links for them, using the returned interface link names as targets.
    In your IRP_MJ_CREATE handler, use StackLocation->FileObject->FileName to tell which port is being open. If that port is already open, fail the IRP with STATUS_ACCESS_DENIED.

xxxxx@gmail.com wrote:

Just want to confirm my understanding.

if i use mf.sys as the bus driver, then i will get an EvtAddDevice call once for each of the UART ports i have on the controller?

Yes, assuming your device meets the requirements for MF.SYS.

In this case, how do i know if this EvtAddDevice is called in response to PDO created for the controller or the PDO created for the UART port by MF.sys for UART?

The PDO for the controller will trigger the loading of MF.SYS, not your
driver. MF.SYS will create the additional PDOs that will trigger the
loading of your driver.

http://msdn.microsoft.com/en-us/library/windows/hardware/ff542778.aspx


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

The one problem with this approach is that the system will not assign 4 com port names to your device. They can easily be assigned elsewhere. You could have a device coinstaller claim 4 pot number as a mitigation

d

Bent from my phone


From: xxxxx@broadcom.commailto:xxxxx
Sent: ?5/?12/?2014 11:06 AM
To: Windows System Software Devs Interest Listmailto:xxxxx
Subject: RE:[ntdev] Multiport serial driver design queries

You can get away without bothering with PDOs (and cluttering the Device Manager with extra ports).

Call IoRegisterDeviceInterface for the standard comport GUID with different ReferenceString arguments (for example, PORT1, PORT2, etc). In your CREATE handles, you’ll get those ReferenceString as the file name. Your FDO needs to be non-exclusive. You have to reject duplicate opens for the same port by yourself.

When you create symbolic links, use the interface name (including the reference string) as the link target.


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

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</mailto:xxxxx></mailto:xxxxx>

Alex’s approach was my #2 in the initial response. This is a monolithic
driver, definitely doable, but if your device looks like a 16550 also a lot
of work.

Don Burn
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@gmail.com
Sent: Monday, May 12, 2014 2:27 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Multiport serial driver design queries

Alex,

Thanks for responding.

You mean i don’t need to create any PDO’s at all? Just an FDO for my
controller?


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

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 for all your responses.

here is my actual configuration. I have 5 PCI-E based controllers on the system, one with 4 UART ports and 4 with 8 UART ports each.

In this configuration, using MF.sys file for enumerating each of these ports individually will work the same way?

Also please let me know how to confirm that my device meets the requirements of MF.sys? i have the specification of the controller. What points to do i need to check in that specification to make sure it fits the requirements of MF.sys?

First mf.sys litmus test is if each com port has a clear, distinct set of hw resources that can represent the individual com port. If there is a shared interrupt, port, register, memory window, etc, you can’t use mf.sys since there is no way to share that resource across the PDOs.

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Monday, May 12, 2014 12:41 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Multiport serial driver design queries

Thanks for all your responses.

here is my actual configuration. I have 5 PCI-E based controllers on the system, one with 4 UART ports and 4 with 8 UART ports each.

In this configuration, using MF.sys file for enumerating each of these ports individually will work the same way?

Also please let me know how to confirm that my device meets the requirements of MF.sys? i have the specification of the controller. What points to do i need to check in that specification to make sure it fits the requirements of MF.sys?


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

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

Just want to confirm this.

each of the UART has a separate register block(of 512 bytes) in memory as per the spec.These register blocks are located contiguously at different offsets from the address specified in BAR1.

these registers control the interrupts, FIFOs etc. I hope this is good enough for MF.sys. Please confirm.

Also in the scenario like 5 Controllers each one with 8 ports, MF.sys can be used without any problems?

1 Like