PCI Serial card, mf.sys and serial.sys

Hi,

I am pretty new to Windows driver development, I would appreciate if
you can provide some feedback on the below approach before I branch
off into some wrong direction.

I am on Windows 7 x64.

I have a PCI card that has 12 UARTs (16650 compatible) exposed via
single BAR1. There are no shared registers/other resources, except for
the interrupt. So I would like to use mf.sys and serial.sys (to
minimize the amount of code I need to maintain).

Questions:

  1. Is in-box “mf.sys” and “serial.sys” supported for the above
    hardware scenario?

  2. In case I want to write my own “myserial.sys”, can I host it with
    mf.sys? (i.e., mf.sys + myserial.sys). Is resource arbitration
    work-flow between them is defined?

  3. What is the alternative?

mybus.sys + myserial.sys: mybus.sys would enumerate 12 children,
each of which would be loaded with myserial.sys. mybus.sys and
myserial.sys would have “private” interface between them for
communication.

Does it make sense? Would I need to stick in any other driver
object in the stack?


For the option 1 above, I tried:

From what I read on MSDN and on ntdev list here, I have written two
INF files, one for mf.sys that breaks BAR1 into 12 children using
“VaryingResourceMap” and then each of them would load “serial.sys”.
Using these two INF files, the devices are enumerated and shown
properly in the “Device Manager”.

But when I try sending/receiving some data (using hyperterminal or
powershell script), nothing happens (open etc succeeds).

I observed the following things:

  • There are high no. of interrupts.

  • Using xperf.exe, I verified that serial.sys is the one executing,
    specifically in “SerialIntervalReadTimeout”.

  • I verified using windbg, !devnode etc that the resources
    types/values are allocated/set as expected.

  • Enabled debug logs, nothing useful is coming out of serial.sys.

As a next step, I am thinking of using “wdfserial.sys” example and
load it with mf.sys. Is this supported?

Thanks for your time.

PS: INF files

--------------INF1----------------------

[Version]
Signature=“$Windows NT$”
Class=MultiFunction
ClassGUID={4d36e971-e325-11ce-bfc1-08002be10318}
Provider=%MyComp%
DriverVer=08/19/2013

[ControlFlags]
ExcludeFromSelect=*

[Manufacturer]
%MyComp%=MyComp, NTamd64

; Replace xxxx with proper VEN DEV IDs
[MyComp.NTamd64]
%MyCompFPGA%=MyCompFPGA_inst, PCI\VEN_xxxx&DEV_xxxx
%MyCompFPGA%=MyCompFPGA_inst, PCI\VEN_xxxx&DEV_xxxx&SUBSYS_xxxxxxxx

[MyCompFPGA_inst.NTamd64]
Include = mf.inf
Needs = MFINSTALL.mf

[MyCompFPGA_inst.NTamd64.HW]
AddReg=MyCompFPGA_inst.NTamd64.RegHW

[MyCompFPGA_inst.NTamd64.Services]
Include = mf.inf
Needs = MFINSTALL.mf.Services

[MyCompFPGA_inst.NTamd64.RegHW]
HKR,Child0000,HardwareID,MF\MYCOMPFPGA_UART_COM
HKR,Child0000,VaryingResourceMap,1,02, 00,00,00,00, 08,00,00,00
HKR,Child0000,ResourceMap,1,8
HKR,Child0001,HardwareID,MF\MYCOMPFPGA_UART_COM
HKR,Child0001,VaryingResourceMap,1,02, 10,00,00,00, 08,00,00,00
HKR,Child0001,ResourceMap,1,8
HKR,Child0002,HardwareID,MF\MYCOMPFPGA_UART_COM
HKR,Child0002,VaryingResourceMap,1,02, 20,00,00,00, 08,00,00,00
HKR,Child0002,ResourceMap,1,8
HKR,Child0003,HardwareID,MF\MYCOMPFPGA_UART_COM
HKR,Child0003,VaryingResourceMap,1,02, 30,00,00,00, 08,00,00,00
HKR,Child0003,ResourceMap,1,8
HKR,Child0004,HardwareID,MF\MYCOMPFPGA_UART_COM
HKR,Child0004,VaryingResourceMap,1,02, 40,00,00,00, 08,00,00,00
HKR,Child0004,ResourceMap,1,8
HKR,Child0005,HardwareID,MF\MYCOMPFPGA_UART_COM
HKR,Child0005,VaryingResourceMap,1,02, 50,00,00,00, 08,00,00,00
HKR,Child0005,ResourceMap,1,8
HKR,Child0006,HardwareID,MF\MYCOMPFPGA_UART_COM
HKR,Child0006,VaryingResourceMap,1,02, 60,00,00,00, 08,00,00,00
HKR,Child0006,ResourceMap,1,8
HKR,Child0007,HardwareID,MF\MYCOMPFPGA_UART_COM
HKR,Child0007,VaryingResourceMap,1,02, 70,00,00,00, 08,00,00,00
HKR,Child0007,ResourceMap,1,8
HKR,Child0008,HardwareID,MF\MYCOMPFPGA_UART_COM
HKR,Child0008,VaryingResourceMap,1,02, 80,00,00,00, 08,00,00,00
HKR,Child0008,ResourceMap,1,8
HKR,Child0009,HardwareID,MF\MYCOMPFPGA_UART_COM
HKR,Child0009,VaryingResourceMap,1,02, 90,00,00,00, 08,00,00,00
HKR,Child0009,ResourceMap,1,8
HKR,Child0010,HardwareID,MF\MYCOMPFPGA_UART_COM
HKR,Child0010,VaryingResourceMap,1,02, A0,00,00,00, 08,00,00,00
HKR,Child0010,ResourceMap,1,8
HKR,Child0011,HardwareID,MF\MYCOMPFPGA_UART_COM
HKR,Child0011,VaryingResourceMap,1,02, B0,00,00,00, 08,00,00,00
HKR,Child0011,ResourceMap,1,8

[Strings]
MyComp= “MyComp”
MyCompFPGA = “MyComp PCI FPGA Device (12 UARTs)”

--------------INF2----------------------

[Version]
signature=“$Windows NT$”
Class=Ports
ClassGUID={4d36e978-e325-11ce-bfc1-08002be10318}
Provider=%MyComp%
DriverVer=08/19/2013

[ControlFlags]
ExcludeFromSelect=*

[Manufacturer]
%MyComp%=MyCompFPGAUARTPort, NTamd64

[MyCompFPGAUARTPort.NTamd64]
%MyCompFPGAUARTPort.ComPortName%=ComPort,MF\MYCOMPFPGA_UART_COM

[ComPort.NTamd64]
Include = msports.inf
Needs = ComPort.NT

[ComPort.NTamd64.HW]
Include = msports.inf
Needs = ComPort.NT.HW.AddReg

[ComPort.NTamd64.Services]
Include = msports.inf
Needs = ComPort.NT.Services

[Strings]
MyComp= “MyComp”
MyCompFPGAUARTPort.ComPortName = “MyComp PCI FPGA UART Port (16550A compatible)”

You are going to need a bus driver. You can take the serial.sys sample in
the WDK and modify it. You need to have the bus driver provide the
resources and to support the interrupt handler, plus a replacement for
KeSynchronizeExecution.

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 Surki
Sent: Monday, August 26, 2013 11:25 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] PCI Serial card, mf.sys and serial.sys

Hi,

I am pretty new to Windows driver development, I would appreciate if you can
provide some feedback on the below approach before I branch off into some
wrong direction.

I am on Windows 7 x64.

I have a PCI card that has 12 UARTs (16650 compatible) exposed via single
BAR1. There are no shared registers/other resources, except for the
interrupt. So I would like to use mf.sys and serial.sys (to minimize the
amount of code I need to maintain).

Questions:

  1. Is in-box “mf.sys” and “serial.sys” supported for the above
    hardware scenario?

  2. In case I want to write my own “myserial.sys”, can I host it with
    mf.sys? (i.e., mf.sys + myserial.sys). Is resource arbitration
    work-flow between them is defined?

  3. What is the alternative?

mybus.sys + myserial.sys: mybus.sys would enumerate 12 children,
each of which would be loaded with myserial.sys. mybus.sys and
myserial.sys would have “private” interface between them for
communication.

Does it make sense? Would I need to stick in any other driver
object in the stack?


For the option 1 above, I tried:

From what I read on MSDN and on ntdev list here, I have written two INF
files, one for mf.sys that breaks BAR1 into 12 children using
“VaryingResourceMap” and then each of them would load “serial.sys”.
Using these two INF files, the devices are enumerated and shown properly in
the “Device Manager”.

But when I try sending/receiving some data (using hyperterminal or
powershell script), nothing happens (open etc succeeds).

I observed the following things:

  • There are high no. of interrupts.

  • Using xperf.exe, I verified that serial.sys is the one executing,
    specifically in “SerialIntervalReadTimeout”.

  • I verified using windbg, !devnode etc that the resources
    types/values are allocated/set as expected.

  • Enabled debug logs, nothing useful is coming out of serial.sys.

As a next step, I am thinking of using “wdfserial.sys” example and load it
with mf.sys. Is this supported?

Thanks for your time.

PS: INF files

--------------INF1----------------------

[Version]
Signature=“$Windows NT$”
Class=MultiFunction
ClassGUID={4d36e971-e325-11ce-bfc1-08002be10318}
Provider=%MyComp%
DriverVer=08/19/2013

[ControlFlags]
ExcludeFromSelect=*

[Manufacturer]
%MyComp%=MyComp, NTamd64

; Replace xxxx with proper VEN DEV IDs
[MyComp.NTamd64]
%MyCompFPGA%=MyCompFPGA_inst, PCI\VEN_xxxx&DEV_xxxx
%MyCompFPGA%=MyCompFPGA_inst, PCI\VEN_xxxx&DEV_xxxx&SUBSYS_xxxxxxxx

[MyCompFPGA_inst.NTamd64]
Include = mf.inf
Needs = MFINSTALL.mf

[MyCompFPGA_inst.NTamd64.HW]
AddReg=MyCompFPGA_inst.NTamd64.RegHW

[MyCompFPGA_inst.NTamd64.Services]
Include = mf.inf
Needs = MFINSTALL.mf.Services

[MyCompFPGA_inst.NTamd64.RegHW]
HKR,Child0000,HardwareID,MF\MYCOMPFPGA_UART_COM
HKR,Child0000,VaryingResourceMap,1,02, 00,00,00,00, 08,00,00,00
HKR,Child0000,ResourceMap,1,8
HKR,Child0001,HardwareID,MF\MYCOMPFPGA_UART_COM
HKR,Child0001,VaryingResourceMap,1,02, 10,00,00,00, 08,00,00,00
HKR,Child0001,ResourceMap,1,8
HKR,Child0002,HardwareID,MF\MYCOMPFPGA_UART_COM
HKR,Child0002,VaryingResourceMap,1,02, 20,00,00,00, 08,00,00,00
HKR,Child0002,ResourceMap,1,8
HKR,Child0003,HardwareID,MF\MYCOMPFPGA_UART_COM
HKR,Child0003,VaryingResourceMap,1,02, 30,00,00,00, 08,00,00,00
HKR,Child0003,ResourceMap,1,8
HKR,Child0004,HardwareID,MF\MYCOMPFPGA_UART_COM
HKR,Child0004,VaryingResourceMap,1,02, 40,00,00,00, 08,00,00,00
HKR,Child0004,ResourceMap,1,8
HKR,Child0005,HardwareID,MF\MYCOMPFPGA_UART_COM
HKR,Child0005,VaryingResourceMap,1,02, 50,00,00,00, 08,00,00,00
HKR,Child0005,ResourceMap,1,8
HKR,Child0006,HardwareID,MF\MYCOMPFPGA_UART_COM
HKR,Child0006,VaryingResourceMap,1,02, 60,00,00,00, 08,00,00,00
HKR,Child0006,ResourceMap,1,8
HKR,Child0007,HardwareID,MF\MYCOMPFPGA_UART_COM
HKR,Child0007,VaryingResourceMap,1,02, 70,00,00,00, 08,00,00,00
HKR,Child0007,ResourceMap,1,8
HKR,Child0008,HardwareID,MF\MYCOMPFPGA_UART_COM
HKR,Child0008,VaryingResourceMap,1,02, 80,00,00,00, 08,00,00,00
HKR,Child0008,ResourceMap,1,8
HKR,Child0009,HardwareID,MF\MYCOMPFPGA_UART_COM
HKR,Child0009,VaryingResourceMap,1,02, 90,00,00,00, 08,00,00,00
HKR,Child0009,ResourceMap,1,8
HKR,Child0010,HardwareID,MF\MYCOMPFPGA_UART_COM
HKR,Child0010,VaryingResourceMap,1,02, A0,00,00,00, 08,00,00,00
HKR,Child0010,ResourceMap,1,8
HKR,Child0011,HardwareID,MF\MYCOMPFPGA_UART_COM
HKR,Child0011,VaryingResourceMap,1,02, B0,00,00,00, 08,00,00,00
HKR,Child0011,ResourceMap,1,8

[Strings]
MyComp= “MyComp”
MyCompFPGA = “MyComp PCI FPGA Device (12 UARTs)”

--------------INF2----------------------

[Version]
signature=“$Windows NT$”
Class=Ports
ClassGUID={4d36e978-e325-11ce-bfc1-08002be10318}
Provider=%MyComp%
DriverVer=08/19/2013

[ControlFlags]
ExcludeFromSelect=*

[Manufacturer]
%MyComp%=MyCompFPGAUARTPort, NTamd64

[MyCompFPGAUARTPort.NTamd64]
%MyCompFPGAUARTPort.ComPortName%=ComPort,MF\MYCOMPFPGA_UART_COM

[ComPort.NTamd64]
Include = msports.inf
Needs = ComPort.NT

[ComPort.NTamd64.HW]
Include = msports.inf
Needs = ComPort.NT.HW.AddReg

[ComPort.NTamd64.Services]
Include = msports.inf
Needs = ComPort.NT.Services

[Strings]
MyComp= “MyComp”
MyCompFPGAUARTPort.ComPortName = “MyComp PCI FPGA UART Port (16550A
compatible)”


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 Don. I will start with a bus driver. Should toaster example be
sufficient to start with?

On a related note, I am wondering why mf.sys won’t be sufficient. Only
thing shared between these UARTs is interrupt.
So assuming that I am okay with every one waking up to check for data on
every interrupt, won’t mf.sys be sufficient?
(FWIW: I have a similar driver working in Linux for the same PCI card).

On Mon, Aug 26, 2013 at 9:15 PM, Don Burn wrote:

> You are going to need a bus driver. You can take the serial.sys sample in
> the WDK and modify it. You need to have the bus driver provide the
> resources and to support the interrupt handler, plus a replacement for
> KeSynchronizeExecution.
>
>
> 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 Surki
> Sent: Monday, August 26, 2013 11:25 AM
> To: Windows System Software Devs Interest List
> Subject: [ntdev] PCI Serial card, mf.sys and serial.sys
>
> Hi,
>
> I am pretty new to Windows driver development, I would appreciate if you
> can
> provide some feedback on the below approach before I branch off into some
> wrong direction.
>
> I am on Windows 7 x64.
>
> I have a PCI card that has 12 UARTs (16650 compatible) exposed via single
> BAR1. There are no shared registers/other resources, except for the
> interrupt. So I would like to use mf.sys and serial.sys (to minimize the
> amount of code I need to maintain).
>
> Questions:
>
> 1. Is in-box “mf.sys” and “serial.sys” supported for the above
> hardware scenario?
>
> 2. In case I want to write my own “myserial.sys”, can I host it with
> mf.sys? (i.e., mf.sys + myserial.sys). Is resource arbitration
> work-flow between them is defined?
>
> 3. What is the alternative?
>
> mybus.sys + myserial.sys: mybus.sys would enumerate 12 children,
> each of which would be loaded with myserial.sys. mybus.sys and
> myserial.sys would have “private” interface between them for
> communication.
>
> Does it make sense? Would I need to stick in any other driver
> object in the stack?
>
> ----------
>
> For the option 1 above, I tried:
>
> From what I read on MSDN and on ntdev list here, I have written two INF
> files, one for mf.sys that breaks BAR1 into 12 children using
> “VaryingResourceMap” and then each of them would load “serial.sys”.
> Using these two INF files, the devices are enumerated and shown properly in
> the “Device Manager”.
>
> But when I try sending/receiving some data (using hyperterminal or
> powershell script), nothing happens (open etc succeeds).
>
> I observed the following things:
>
> - There are high no. of interrupts.
>
> - Using xperf.exe, I verified that serial.sys is the one executing,
> specifically in “SerialIntervalReadTimeout”.
>
> - I verified using windbg, !devnode etc that the resources
> types/values are allocated/set as expected.
>
> - Enabled debug logs, nothing useful is coming out of serial.sys.
>
> As a next step, I am thinking of using “wdfserial.sys” example and load it
> with mf.sys. Is this supported?
>
> Thanks for your time.
>
>
> PS: INF files
>
> --------------INF1----------------------
>
> [Version]
> Signature=“$Windows NT$”
> Class=MultiFunction
> ClassGUID={4d36e971-e325-11ce-bfc1-08002be10318}
> Provider=%MyComp%
> DriverVer=08/19/2013
>
> [ControlFlags]
> ExcludeFromSelect=
>
> [Manufacturer]
> %MyComp%=MyComp, NTamd64
>
> ; Replace xxxx with proper VEN DEV IDs
> [MyComp.NTamd64]
> %MyCompFPGA%=MyCompFPGA_inst, PCI\VEN_xxxx&DEV_xxxx
> %MyCompFPGA%=MyCompFPGA_inst, PCI\VEN_xxxx&DEV_xxxx&SUBSYS_xxxxxxxx
>
> [MyCompFPGA_inst.NTamd64]
> Include = mf.inf
> Needs = MFINSTALL.mf
>
> [MyCompFPGA_inst.NTamd64.HW]
> AddReg=MyCompFPGA_inst.NTamd64.RegHW
>
> [MyCompFPGA_inst.NTamd64.Services]
> Include = mf.inf
> Needs = MFINSTALL.mf.Services
>
> [MyCompFPGA_inst.NTamd64.RegHW]
> HKR,Child0000,HardwareID,MF\MYCOMPFPGA_UART_COM
> HKR,Child0000,VaryingResourceMap,1,02, 00,00,00,00, 08,00,00,00
> HKR,Child0000,ResourceMap,1,8
> HKR,Child0001,HardwareID,MF\MYCOMPFPGA_UART_COM
> HKR,Child0001,VaryingResourceMap,1,02, 10,00,00,00, 08,00,00,00
> HKR,Child0001,ResourceMap,1,8
> HKR,Child0002,HardwareID,MF\MYCOMPFPGA_UART_COM
> HKR,Child0002,VaryingResourceMap,1,02, 20,00,00,00, 08,00,00,00
> HKR,Child0002,ResourceMap,1,8
> HKR,Child0003,HardwareID,MF\MYCOMPFPGA_UART_COM
> HKR,Child0003,VaryingResourceMap,1,02, 30,00,00,00, 08,00,00,00
> HKR,Child0003,ResourceMap,1,8
> HKR,Child0004,HardwareID,MF\MYCOMPFPGA_UART_COM
> HKR,Child0004,VaryingResourceMap,1,02, 40,00,00,00, 08,00,00,00
> HKR,Child0004,ResourceMap,1,8
> HKR,Child0005,HardwareID,MF\MYCOMPFPGA_UART_COM
> HKR,Child0005,VaryingResourceMap,1,02, 50,00,00,00, 08,00,00,00
> HKR,Child0005,ResourceMap,1,8
> HKR,Child0006,HardwareID,MF\MYCOMPFPGA_UART_COM
> HKR,Child0006,VaryingResourceMap,1,02, 60,00,00,00, 08,00,00,00
> HKR,Child0006,ResourceMap,1,8
> HKR,Child0007,HardwareID,MF\MYCOMPFPGA_UART_COM
> HKR,Child0007,VaryingResourceMap,1,02, 70,00,00,00, 08,00,00,00
> HKR,Child0007,ResourceMap,1,8
> HKR,Child0008,HardwareID,MF\MYCOMPFPGA_UART_COM
> HKR,Child0008,VaryingResourceMap,1,02, 80,00,00,00, 08,00,00,00
> HKR,Child0008,ResourceMap,1,8
> HKR,Child0009,HardwareID,MF\MYCOMPFPGA_UART_COM
> HKR,Child0009,VaryingResourceMap,1,02, 90,00,00,00, 08,00,00,00
> HKR,Child0009,ResourceMap,1,8
> HKR,Child0010,HardwareID,MF\MYCOMPFPGA_UART_COM
> HKR,Child0010,VaryingResourceMap,1,02, A0,00,00,00, 08,00,00,00
> HKR,Child0010,ResourceMap,1,8
> HKR,Child0011,HardwareID,MF\MYCOMPFPGA_UART_COM
> HKR,Child0011,VaryingResourceMap,1,02, B0,00,00,00, 08,00,00,00
> HKR,Child0011,ResourceMap,1,8
>
> [Strings]
> MyComp= “MyComp”
> MyCompFPGA = “MyComp PCI FPGA Device (12 UARTs)”
>
>
> --------------INF2----------------------
>
> [Version]
> signature=“$Windows NT$”
> Class=Ports
> ClassGUID={4d36e978-e325-11ce-bfc1-08002be10318}
> Provider=%MyComp%
> DriverVer=08/19/2013
>
> [ControlFlags]
> ExcludeFromSelect=

>
> [Manufacturer]
> %MyComp%=MyCompFPGAUARTPort, NTamd64
>
> [MyCompFPGAUARTPort.NTamd64]
> %MyCompFPGAUARTPort.ComPortName%=ComPort,MF\MYCOMPFPGA_UART_COM
>
> [ComPort.NTamd64]
> Include = msports.inf
> Needs = ComPort.NT
>
> [ComPort.NTamd64.HW]
> Include = msports.inf
> Needs = ComPort.NT.HW.AddReg
>
> [ComPort.NTamd64.Services]
> Include = msports.inf
> Needs = ComPort.NT.Services
>
> [Strings]
> MyComp= “MyComp”
> MyCompFPGAUARTPort.ComPortName = “MyComp PCI FPGA UART Port (16550A
> compatible)”
>
>
>
> —
> 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
>
>
> —
> 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
>

According to the experts having MF.sys split provide the same interrupt to N
drivers is not a recommended approach. I’ve done the bus driver, plus
modify the serial driver for several clients and all of them are working
fine. Toaster is probably as good a starting point as any for the bus
driver, the actual driver you need is a lot simpler than the toaster bus
which is trying to show many capabilities. I used a device interface for
each PDO to allow the bus driver to provide resources and pointers to the
KeSynchroinizaExecution support for the device.

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 Surkii :slight_smile:
Sent: Monday, August 26, 2013 2:02 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] PCI Serial card, mf.sys and serial.sys

Thanks Don. I will start with a bus driver. Should toaster example be
sufficient to start with?

On a related note, I am wondering why mf.sys won’t be sufficient. Only thing
shared between these UARTs is interrupt.
So assuming that I am okay with every one waking up to check for data on
every interrupt, won’t mf.sys be sufficient?
(FWIW: I have a similar driver working in Linux for the same PCI card).

On Mon, Aug 26, 2013 at 9:15 PM, Don Burn wrote:

You are going to need a bus driver. You can take the serial.sys
sample in
the WDK and modify it. You need to have the bus driver provide the
resources and to support the interrupt handler, plus a replacement
for
KeSynchronizeExecution.

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 Surki
Sent: Monday, August 26, 2013 11:25 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] PCI Serial card, mf.sys and serial.sys

Hi,

I am pretty new to Windows driver development, I would appreciate if
you can
provide some feedback on the below approach before I branch off into
some
wrong direction.

I am on Windows 7 x64.

I have a PCI card that has 12 UARTs (16650 compatible) exposed via
single
BAR1. There are no shared registers/other resources, except for the
interrupt. So I would like to use mf.sys and serial.sys (to minimize
the
amount of code I need to maintain).

Questions:

1. Is in-box “mf.sys” and “serial.sys” supported for the above
hardware scenario?

2. In case I want to write my own “myserial.sys”, can I host it
with
mf.sys? (i.e., mf.sys + myserial.sys). Is resource arbitration
work-flow between them is defined?

3. What is the alternative?

mybus.sys + myserial.sys: mybus.sys would enumerate 12
children,
each of which would be loaded with myserial.sys. mybus.sys and
myserial.sys would have “private” interface between them for
communication.

Does it make sense? Would I need to stick in any other driver
object in the stack?

----------

For the option 1 above, I tried:

From what I read on MSDN and on ntdev list here, I have written two
INF
files, one for mf.sys that breaks BAR1 into 12 children using
“VaryingResourceMap” and then each of them would load “serial.sys”.
Using these two INF files, the devices are enumerated and shown
properly in
the “Device Manager”.

But when I try sending/receiving some data (using hyperterminal or
powershell script), nothing happens (open etc succeeds).

I observed the following things:

- There are high no. of interrupts.

- Using xperf.exe, I verified that serial.sys is the one
executing,
specifically in “SerialIntervalReadTimeout”.

- I verified using windbg, !devnode etc that the resources
types/values are allocated/set as expected.

- Enabled debug logs, nothing useful is coming out of serial.sys.

As a next step, I am thinking of using “wdfserial.sys” example and
load it
with mf.sys. Is this supported?

Thanks for your time.

PS: INF files

--------------INF1----------------------

[Version]
Signature=“$Windows NT$”
Class=MultiFunction
ClassGUID={4d36e971-e325-11ce-bfc1-08002be10318}
Provider=%MyComp%
DriverVer=08/19/2013

[ControlFlags]
ExcludeFromSelect=

[Manufacturer]
%MyComp%=MyComp, NTamd64

; Replace xxxx with proper VEN DEV IDs
[MyComp.NTamd64]
%MyCompFPGA%=MyCompFPGA_inst, PCI\VEN_xxxx&DEV_xxxx
%MyCompFPGA%=MyCompFPGA_inst, PCI\VEN_xxxx&DEV_xxxx&SUBSYS_xxxxxxxx

[MyCompFPGA_inst.NTamd64]
Include = mf.inf
Needs = MFINSTALL.mf

[MyCompFPGA_inst.NTamd64.HW]
AddReg=MyCompFPGA_inst.NTamd64.RegHW

[MyCompFPGA_inst.NTamd64.Services]
Include = mf.inf
Needs = MFINSTALL.mf.Services

[MyCompFPGA_inst.NTamd64.RegHW]
HKR,Child0000,HardwareID,MF\MYCOMPFPGA_UART_COM
HKR,Child0000,VaryingResourceMap,1,02, 00,00,00,00, 08,00,00,00
HKR,Child0000,ResourceMap,1,8
HKR,Child0001,HardwareID,MF\MYCOMPFPGA_UART_COM
HKR,Child0001,VaryingResourceMap,1,02, 10,00,00,00, 08,00,00,00
HKR,Child0001,ResourceMap,1,8
HKR,Child0002,HardwareID,MF\MYCOMPFPGA_UART_COM
HKR,Child0002,VaryingResourceMap,1,02, 20,00,00,00, 08,00,00,00
HKR,Child0002,ResourceMap,1,8
HKR,Child0003,HardwareID,MF\MYCOMPFPGA_UART_COM
HKR,Child0003,VaryingResourceMap,1,02, 30,00,00,00, 08,00,00,00
HKR,Child0003,ResourceMap,1,8
HKR,Child0004,HardwareID,MF\MYCOMPFPGA_UART_COM
HKR,Child0004,VaryingResourceMap,1,02, 40,00,00,00, 08,00,00,00
HKR,Child0004,ResourceMap,1,8
HKR,Child0005,HardwareID,MF\MYCOMPFPGA_UART_COM
HKR,Child0005,VaryingResourceMap,1,02, 50,00,00,00, 08,00,00,00
HKR,Child0005,ResourceMap,1,8
HKR,Child0006,HardwareID,MF\MYCOMPFPGA_UART_COM
HKR,Child0006,VaryingResourceMap,1,02, 60,00,00,00, 08,00,00,00
HKR,Child0006,ResourceMap,1,8
HKR,Child0007,HardwareID,MF\MYCOMPFPGA_UART_COM
HKR,Child0007,VaryingResourceMap,1,02, 70,00,00,00, 08,00,00,00
HKR,Child0007,ResourceMap,1,8
HKR,Child0008,HardwareID,MF\MYCOMPFPGA_UART_COM
HKR,Child0008,VaryingResourceMap,1,02, 80,00,00,00, 08,00,00,00
HKR,Child0008,ResourceMap,1,8
HKR,Child0009,HardwareID,MF\MYCOMPFPGA_UART_COM
HKR,Child0009,VaryingResourceMap,1,02, 90,00,00,00, 08,00,00,00
HKR,Child0009,ResourceMap,1,8
HKR,Child0010,HardwareID,MF\MYCOMPFPGA_UART_COM
HKR,Child0010,VaryingResourceMap,1,02, A0,00,00,00, 08,00,00,00
HKR,Child0010,ResourceMap,1,8
HKR,Child0011,HardwareID,MF\MYCOMPFPGA_UART_COM
HKR,Child0011,VaryingResourceMap,1,02, B0,00,00,00, 08,00,00,00
HKR,Child0011,ResourceMap,1,8

[Strings]
MyComp= “MyComp”
MyCompFPGA = “MyComp PCI FPGA Device (12 UARTs)”

--------------INF2----------------------

[Version]
signature=“$Windows NT$”
Class=Ports
ClassGUID={4d36e978-e325-11ce-bfc1-08002be10318}
Provider=%MyComp%
DriverVer=08/19/2013

[ControlFlags]
ExcludeFromSelect=


[Manufacturer]
%MyComp%=MyCompFPGAUARTPort, NTamd64

[MyCompFPGAUARTPort.NTamd64]
%MyCompFPGAUARTPort.ComPortName%=ComPort,MF\MYCOMPFPGA_UART_COM

[ComPort.NTamd64]
Include = msports.inf
Needs = ComPort.NT

[ComPort.NTamd64.HW]
Include = msports.inf
Needs = ComPort.NT.HW.AddReg

[ComPort.NTamd64.Services]
Include = msports.inf
Needs = ComPort.NT.Services

[Strings]
MyComp= “MyComp”
MyCompFPGAUARTPort.ComPortName = “MyComp PCI FPGA UART Port (16550A
compatible)”


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


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

— 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

An update in case somebody needs it in the future:

I was able to bring up the mf.sys and wdfserial.sys. (had to modify the
divisor latch table for our custom uart clock rate).
In addition to this, my.sys also enumerates 3 more children with custom
drivers (they are memory like devices, used to read certain peripheral
statuses, exposed to user space via IOCTLs).

Thanks everyone for the help.

On Mon, Aug 26, 2013 at 11:39 PM, Don Burn wrote:

> According to the experts having MF.sys split provide the same interrupt to
> N
> drivers is not a recommended approach. I’ve done the bus driver, plus
> modify the serial driver for several clients and all of them are working
> fine. Toaster is probably as good a starting point as any for the bus
> driver, the actual driver you need is a lot simpler than the toaster bus
> which is trying to show many capabilities. I used a device interface for
> each PDO to allow the bus driver to provide resources and pointers to the
> KeSynchroinizaExecution support for the device.
>
>
> 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 Surkii :slight_smile:
> Sent: Monday, August 26, 2013 2:02 PM
> To: Windows System Software Devs Interest List
> Subject: Re: [ntdev] PCI Serial card, mf.sys and serial.sys
>
> Thanks Don. I will start with a bus driver. Should toaster example be
> sufficient to start with?
>
> On a related note, I am wondering why mf.sys won’t be sufficient. Only
> thing
> shared between these UARTs is interrupt.
> So assuming that I am okay with every one waking up to check for data on
> every interrupt, won’t mf.sys be sufficient?
> (FWIW: I have a similar driver working in Linux for the same PCI card).
>
>
> On Mon, Aug 26, 2013 at 9:15 PM, Don Burn wrote:
>
>
> You are going to need a bus driver. You can take the serial.sys
> sample in
> the WDK and modify it. You need to have the bus driver provide
> the
> resources and to support the interrupt handler, plus a replacement
> for
> KeSynchronizeExecution.
>
>
> 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 Surki
> Sent: Monday, August 26, 2013 11:25 AM
> To: Windows System Software Devs Interest List
> Subject: [ntdev] PCI Serial card, mf.sys and serial.sys
>
> Hi,
>
> I am pretty new to Windows driver development, I would appreciate
> if
> you can
> provide some feedback on the below approach before I branch off
> into
> some
> wrong direction.
>
> I am on Windows 7 x64.
>
> I have a PCI card that has 12 UARTs (16650 compatible) exposed via
> single
> BAR1. There are no shared registers/other resources, except for the
> interrupt. So I would like to use mf.sys and serial.sys (to
> minimize
> the
> amount of code I need to maintain).
>
> Questions:
>
> 1. Is in-box “mf.sys” and “serial.sys” supported for the above
> hardware scenario?
>
> 2. In case I want to write my own “myserial.sys”, can I host it
> with
> mf.sys? (i.e., mf.sys + myserial.sys). Is resource arbitration
> work-flow between them is defined?
>
> 3. What is the alternative?
>
> mybus.sys + myserial.sys: mybus.sys would enumerate 12
> children,
> each of which would be loaded with myserial.sys. mybus.sys and
> myserial.sys would have “private” interface between them for
> communication.
>
> Does it make sense? Would I need to stick in any other driver
> object in the stack?
>
> ----------
>
> For the option 1 above, I tried:
>
> From what I read on MSDN and on ntdev list here, I have written two
> INF
> files, one for mf.sys that breaks BAR1 into 12 children using
> “VaryingResourceMap” and then each of them would load “serial.sys”.
> Using these two INF files, the devices are enumerated and shown
> properly in
> the “Device Manager”.
>
> But when I try sending/receiving some data (using hyperterminal or
> powershell script), nothing happens (open etc succeeds).
>
> I observed the following things:
>
> - There are high no. of interrupts.
>
> - Using xperf.exe, I verified that serial.sys is the one
> executing,
> specifically in “SerialIntervalReadTimeout”.
>
> - I verified using windbg, !devnode etc that the resources
> types/values are allocated/set as expected.
>
> - Enabled debug logs, nothing useful is coming out of serial.sys.
>
> As a next step, I am thinking of using “wdfserial.sys” example and
> load it
> with mf.sys. Is this supported?
>
> Thanks for your time.
>
>
> PS: INF files
>
> --------------INF1----------------------
>
> [Version]
> Signature=“$Windows NT$”
> Class=MultiFunction
> ClassGUID={4d36e971-e325-11ce-bfc1-08002be10318}
> Provider=%MyComp%
> DriverVer=08/19/2013
>
> [ControlFlags]
> ExcludeFromSelect=
>
> [Manufacturer]
> %MyComp%=MyComp, NTamd64
>
> ; Replace xxxx with proper VEN DEV IDs
> [MyComp.NTamd64]
> %MyCompFPGA%=MyCompFPGA_inst, PCI\VEN_xxxx&DEV_xxxx
> %MyCompFPGA%=MyCompFPGA_inst, PCI\VEN_xxxx&DEV_xxxx&SUBSYS_xxxxxxxx
>
> [MyCompFPGA_inst.NTamd64]
> Include = mf.inf
> Needs = MFINSTALL.mf
>
> [MyCompFPGA_inst.NTamd64.HW]
> AddReg=MyCompFPGA_inst.NTamd64.RegHW
>
> [MyCompFPGA_inst.NTamd64.Services]
> Include = mf.inf
> Needs = MFINSTALL.mf.Services
>
> [MyCompFPGA_inst.NTamd64.RegHW]
> HKR,Child0000,HardwareID,MF\MYCOMPFPGA_UART_COM
> HKR,Child0000,VaryingResourceMap,1,02, 00,00,00,00, 08,00,00,00
> HKR,Child0000,ResourceMap,1,8
> HKR,Child0001,HardwareID,MF\MYCOMPFPGA_UART_COM
> HKR,Child0001,VaryingResourceMap,1,02, 10,00,00,00, 08,00,00,00
> HKR,Child0001,ResourceMap,1,8
> HKR,Child0002,HardwareID,MF\MYCOMPFPGA_UART_COM
> HKR,Child0002,VaryingResourceMap,1,02, 20,00,00,00, 08,00,00,00
> HKR,Child0002,ResourceMap,1,8
> HKR,Child0003,HardwareID,MF\MYCOMPFPGA_UART_COM
> HKR,Child0003,VaryingResourceMap,1,02, 30,00,00,00, 08,00,00,00
> HKR,Child0003,ResourceMap,1,8
> HKR,Child0004,HardwareID,MF\MYCOMPFPGA_UART_COM
> HKR,Child0004,VaryingResourceMap,1,02, 40,00,00,00, 08,00,00,00
> HKR,Child0004,ResourceMap,1,8
> HKR,Child0005,HardwareID,MF\MYCOMPFPGA_UART_COM
> HKR,Child0005,VaryingResourceMap,1,02, 50,00,00,00, 08,00,00,00
> HKR,Child0005,ResourceMap,1,8
> HKR,Child0006,HardwareID,MF\MYCOMPFPGA_UART_COM
> HKR,Child0006,VaryingResourceMap,1,02, 60,00,00,00, 08,00,00,00
> HKR,Child0006,ResourceMap,1,8
> HKR,Child0007,HardwareID,MF\MYCOMPFPGA_UART_COM
> HKR,Child0007,VaryingResourceMap,1,02, 70,00,00,00, 08,00,00,00
> HKR,Child0007,ResourceMap,1,8
> HKR,Child0008,HardwareID,MF\MYCOMPFPGA_UART_COM
> HKR,Child0008,VaryingResourceMap,1,02, 80,00,00,00, 08,00,00,00
> HKR,Child0008,ResourceMap,1,8
> HKR,Child0009,HardwareID,MF\MYCOMPFPGA_UART_COM
> HKR,Child0009,VaryingResourceMap,1,02, 90,00,00,00, 08,00,00,00
> HKR,Child0009,ResourceMap,1,8
> HKR,Child0010,HardwareID,MF\MYCOMPFPGA_UART_COM
> HKR,Child0010,VaryingResourceMap,1,02, A0,00,00,00, 08,00,00,00
> HKR,Child0010,ResourceMap,1,8
> HKR,Child0011,HardwareID,MF\MYCOMPFPGA_UART_COM
> HKR,Child0011,VaryingResourceMap,1,02, B0,00,00,00, 08,00,00,00
> HKR,Child0011,ResourceMap,1,8
>
> [Strings]
> MyComp= “MyComp”
> MyCompFPGA = “MyComp PCI FPGA Device (12 UARTs)”
>
>
> --------------INF2----------------------
>
> [Version]
> signature=“$Windows NT$”
> Class=Ports
> ClassGUID={4d36e978-e325-11ce-bfc1-08002be10318}
> Provider=%MyComp%
> DriverVer=08/19/2013
>
> [ControlFlags]
> ExcludeFromSelect=

>
> [Manufacturer]
> %MyComp%=MyCompFPGAUARTPort, NTamd64
>
> [MyCompFPGAUARTPort.NTamd64]
> %MyCompFPGAUARTPort.ComPortName%=ComPort,MF\MYCOMPFPGA_UART_COM
>
> [ComPort.NTamd64]
> Include = msports.inf
> Needs = ComPort.NT
>
> [ComPort.NTamd64.HW]
> Include = msports.inf
> Needs = ComPort.NT.HW.AddReg
>
> [ComPort.NTamd64.Services]
> Include = msports.inf
> Needs = ComPort.NT.Services
>
> [Strings]
> MyComp= “MyComp”
> MyCompFPGAUARTPort.ComPortName = “MyComp PCI FPGA UART Port (16550A
> compatible)”
>
>
>
>
> —
> 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
>
>
> —
> 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
>
>
>
> — 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
>
>
> —
> 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
>