0

I am writing a serial driver for UART in windows just for learning purpose. More specifically in WDM. I will write both the bus driver and function driver.

Currently i am writing the bus driver. So my question is from where i can come to know in my driver that how many serial ports i have in my system, so that i can expose that number of PDO's from my bus driver?? And resources allocated to each port. Do i have to check some kind of registry or windows will provide some kind of structure.

Please help me!! Thanks in advance

Amit Bhaira
  • 1,687
  • 6
  • 18
  • 31
  • This is a chicken-and-egg question. You are the egg, it is up to you to recognize the hardware. You get no help from UARTs themselves, they've never been plug & play devices. It is up to you to negotiate with the bus interface to discover the I/O addresses and interrupt request numbers. A fictitious bus interface, just make it up. – Hans Passant Jan 01 '14 at 13:05
  • ok i can find the resources on my system and hard code it in my driver(may be i am not much familiar with windows drivers yet) , but what if i want to make my driver portable?? Does windows HAL provide any API's that can provide me what i am looking for ? – Amit Bhaira Jan 01 '14 at 13:35
  • and how does standard serial driver that comes with windows does this?? i have xp installed on my VMWare, and when ever create a serial port on VMWare using pipes, the xp inside it detects it and enumerate it com1, if i create one more, it names it com2 and so on.. how that driver achieve it? – Amit Bhaira Jan 01 '14 at 13:39

1 Answers1

1

Assuming your UARTs are part of the PC, there's already a bus driver which will enumerate them. ACPI.SYS gets information from the platform BIOS, which includes the number and resource assignments for built-in components like UARTs.

If you're writing your driver for an add-in multi-port serial board, then you would need to look at the documentation for the board to determine how you find the number of UARTs. It might be as simple as looking at the PCI Product ID and having a hard-coded count for the type of board you have.

When ACPI enumerates the device, your driver's AddDevice routine will be called to load on it, and you'll receive the assigned resources when handling the PNP START message.