OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 9:59 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: How to know which COM triggered the interrupt
PostPosted: Fri Apr 07, 2023 1:53 am 
Offline

Joined: Mon Aug 15, 2022 12:30 pm
Posts: 18
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!


Top
 Profile  
 
 Post subject: Re: How to know which COM triggered the interrupt
PostPosted: Fri Apr 07, 2023 2:58 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
How about polling each serial port after an interrupt to see which one(s) have data ready?


Top
 Profile  
 
 Post subject: Re: How to know which COM triggered the interrupt
PostPosted: Fri Apr 07, 2023 9:50 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
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.


Top
 Profile  
 
 Post subject: Re: How to know which COM triggered the interrupt
PostPosted: Fri Apr 07, 2023 10:56 am 
Offline
Member
Member

Joined: Sat Nov 21, 2009 5:11 pm
Posts: 852
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.


Top
 Profile  
 
 Post subject: Re: How to know which COM triggered the interrupt
PostPosted: Fri Apr 07, 2023 12:19 pm 
Offline
Member
Member

Joined: Wed Oct 01, 2008 1:55 pm
Posts: 3191
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.


Top
 Profile  
 
 Post subject: Re: How to know which COM triggered the interrupt
PostPosted: Fri Apr 07, 2023 3:16 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
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).


Top
 Profile  
 
 Post subject: Re: How to know which COM triggered the interrupt
PostPosted: Tue Apr 11, 2023 2:23 pm 
Offline
Member
Member

Joined: Sat Nov 21, 2009 5:11 pm
Posts: 852
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Majestic-12 [Bot], SemrushBot [Bot] and 58 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group