Multiple Serial COM Port Design

I have a task or rewriting/adapting an old WDM driver for a PCI multi serial port custom board. I did a search to find and existing relevant threads on the forum and found below to be closest.

My custom board uses plx chip to local bus which has interface to UARTS(up to 64 ports) via FPGA. The existing driver sets up bridge(under system device) as FDO and then device nodes for each available serial port identifying itself as serial mouse and enumerated by SERENUM. Each port gets listed under ports in device manager in same way as standard COM ports with incrementing numbers.

Device has one set of BAR address where each port regs are mapped.
I have modified enough to build and load on windows 10, but devices are not enumerated.

1)Should I stick with old design and try fixing it OR is there a better way to approach ?
2)Are there any example(kmdf toaster bus, PLX9x5x, serial..?) that I should look at specifically.
3) Has anyone worked on development of driver with similar application/issues recently.

Thanks!

Not saying it's a bad idea, but why are you rewriting/adapting the old driver, if it works?

Thank you for your response.

The driver functions correctly on Windows XP, and I’ve implemented the necessary fixes and modifications to enable it to build for Windows 10. However, despite these efforts, it fails during the enumeration of device nodes. This has led me to consider whether the older design might no longer be suitable for modern WDM driver architectures on Windows 10. I would greatly appreciate guidance or confirmation from the expertise available on this forum to help navigate this challenge.

how does it fail? barring relying on undocumented behavior, the XP driver should run and enumerate correctly on win10 / 11. Have you attached a debugger and looked at the device tree and failure codes?

The bridge gets listed under "System devices" as expected with list of all com ports in its "Bus relations"
Serenum\Mouse....1
Serenum\Mouse....2
......
...............................n

Unlike XP, all the com ports gets listed under "Mice and other pointing devices"
with a Device status
"This device cannot find enough free resources that it can use.(code12)"

IRP_MN_QUERY_RESOURCE_REQUIREMENTS for serial dispatch uses default handler in the inherited code.

Default handler

  • do IoskipCurrentIrpStackLocation
  • if pDeviceExtension is null
    return StatusInvalidState
  • if pLowerDeviceObject are true
    do IoCallDriver()
    else
    Complete Irp with success.

I can access target with windbg, below is the crash stack text

ERROR_CODE: (NTSTATUS) 0xc0000005 - The instruction at 0x%p referenced memory at 0x%p. The memory could not be %s.

nt!RtlCompareMemory+0x36
nt!PnpBusTypeGuidGetIndex+0x4d
nt!PnpQueryBusInformation+0x74
nt!PiProcessNewDeviceNode+0x911
nt!PipProcessDevNodeTree+0x380
nt!PiRestartDevice+0xba
nt!PnpDeviceActionWorker+0x46a
nt!ExpWorkerThread+0x105
nt!PspSystemThreadStartup+0x55
nt!KiStartSystemThread+0x28

I can avoid the crash by returning STATUS_INVALID_DEVICE_STATE if pDeviceExtension->pLowerDeviceObject == NULL but then it only lists com ports with error as mentioned at the start.

Thank you

This is caused by a filter driver that detects serial mice (yes, in 21th century). Your device behaves like it has something connected to the ports.

Appreciate all comments.

I can replace Serenum\mouse with

  1. PNP0501, but then I want my driver to handle the IOCTL_SERIAL's which are already implemented including the interface with UARTS in my custom driver.

or

  1. provide unique hardwareIDs, compatibleIDs, deviceIDs which uses the same .sys file. Is it possible to do this with single .inf file?
    I can create 2nd .inf file with class = ports with custom hardware id but not sure how would OS find it during installation.

I want the bridge to be listed under system devices and serial devices under Ports in device manager with com port numbering in order with system provide ports.
com1,com2 => on board ports
com3, com4, com5.... => Multiport custom device

@Pavel_A1 I am reading your book to understand drivers better but seems multiport/layer design is probably out of scope.

Thanks

Only use PNP0501 if you want serial.sys to load on the port stack. So you want option 2. You will need two infs since the class is bound to the inf and you want different device classes for the parent and children. You deploy the two INFs the same way you deploy one, just repeat the process.

1 Like

@londonrulz I am not Pavel Yosifovich ))

Would be nice if Microsoft provided in-box driver for multiport serial adapters, if the usb.org had such function class defined. But Microsoft is big enough to propose the class spec for usb.org.

/* It could be very simple: one USB function/interface, same endpoints as for CDC ACM - but the first byte of every data packet is the port index. And the requests also contain the port index. So that it will be easy on the adapter firmware side. The main point is not to increase the number of required endpoints, they are scarce */

2 Likes

As suggested, I am going ahead with option-2

-Loading INF for bridge, it installs fine, creates serial devices which gets listed under "system".
-Providing .inf for each serial device, it does move under "Port" but has an error
"Windows cannot load the device driver for this hardware because a previous instance of the device driver is still in memory. (CODE 38)"

Manually cleaned all old .inf's, .sys and registry entries to make sure there were no stray instances and rebooted the system and did a fresh install but still getting same error.

Is it mandatory to handle "BusQueryContainerID" for both bridge and child devices?
.