How to know which COM triggered the interrupt

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
tretornesp
Posts: 18
Joined: Mon Aug 15, 2022 12:30 pm

How to know which COM triggered the interrupt

Post by tretornesp »

Hello there.

I'm writing my serial driver and my initial approach was to detect the port where the serial interrupt comes from
by registering 4 different interrupt handlers.


The problem is that, afaik COM1 uses the same IRQ (4) as COM3 and COM2 uses the same (3) as COM4, so my method plainly wont work
as two COM ports would use the same IRQ.

How would you approach this? Perhaps there is some reference to the serial device interrupting inside the interrupt frame?

Thank you so much in advance!
User avatar
iansjack
Member
Member
Posts: 4703
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: How to know which COM triggered the interrupt

Post by iansjack »

How about polling each serial port after an interrupt to see which one(s) have data ready?
Octocontrabass
Member
Member
Posts: 5560
Joined: Mon Mar 25, 2013 7:01 pm

Re: How to know which COM triggered the interrupt

Post by Octocontrabass »

The ISA serial port that triggered the interrupt will be the one that you have enabled, because you can't enable IRQs for two ISA serial ports on a single ISA IRQ line at once. Attempting to do so may damage your hardware.

PCI(e) serial ports don't have this limitation, but they're not really standardized. If your PCI(e) serial port uses an 8250-compatible UART, you'll probably need to read the interrupt identification register to see if it's responsible for the IRQ.
Gigasoft
Member
Member
Posts: 856
Joined: Sat Nov 21, 2009 5:11 pm

Re: How to know which COM triggered the interrupt

Post by Gigasoft »

That would be true of an actual ISA adapter card that goes into an ISA slot on an early eighties computer, such as the original IBM PC. Today's PCs have built in serial ports, and there is no problem.
rdos
Member
Member
Posts: 3296
Joined: Wed Oct 01, 2008 1:55 pm

Re: How to know which COM triggered the interrupt

Post by rdos »

It's a bit complicated when several serial ports share the same IRQ. At least with typical sharing when the IRQ handlers run after each other. That's because the hardware interface was not designed for sharing.
Octocontrabass
Member
Member
Posts: 5560
Joined: Mon Mar 25, 2013 7:01 pm

Re: How to know which COM triggered the interrupt

Post by Octocontrabass »

Gigasoft wrote:That would be true of an actual ISA adapter card that goes into an ISA slot on an early eighties computer, such as the original IBM PC. Today's PCs have built in serial ports, and there is no problem.
Maybe, but I'm not aware of any way to detect whether it will work other than trying it (which risks damaging that ISA adapter card).
Gigasoft
Member
Member
Posts: 856
Joined: Sat Nov 21, 2009 5:11 pm

Re: How to know which COM triggered the interrupt

Post by Gigasoft »

If the device was declared by ACPI or is an EISA PNP device, then the resource descriptor will indicate if it supports IRQ sharing. If it was manually declared by the user or manufacturer, then they know how the port is connected and if it supports IRQ sharing.

If a device was found through guessing, and the address is within the decode range of any PCI device whose vendor/device ID indicates a known device that does not have adapter slots, then you know it does not reside on an ISA adapter and there shouldn't be an electrical issue. Same if the host bridge is configured not to forward the address to the PCI/PCIe bus.
Post Reply