Page 1 of 1
Question about PCI IRQ assignment
Posted: Thu May 21, 2015 1:35 pm
by mohammedisam
Hi all
So I am working with ATA/ATAPI and everything goes right through PIO mode. I want to switch to DMA mode as I recently implemented multiprocessing and I can't go on with PIO as such. I understand the ATA uses IRQs 14&15 by default. But when enumerating the PCI space, I read the config space for the specified disk and try to read the Interrupt Line (byte at offset 0x3c of header 0x00) all I get is 0. Other devices (like Power management and VGA) give plausible results (like IRQ 9). Should I reprogram the IRQ line of each disk on startup to use IRQ 14/15 or what is the approach to get the right values?
P.S.: I get the same results under VirtualBox, Bochs, and QEmu.
P.S.2: Even though I get 0 as I read the interrupt line byte, still the disks fire IRQs 14 (HDD connected as primary master) and 15 (CDROM connected as secondary master).
Re: Question about PCI IRQ assignment
Posted: Thu May 21, 2015 4:36 pm
by Brendan
Hi,
mohammedisam wrote:So I am working with ATA/ATAPI and everything goes right through PIO mode. I want to switch to DMA mode as I recently implemented multiprocessing and I can't go on with PIO as such. I understand the ATA uses IRQs 14&15 by default. But when enumerating the PCI space, I read the config space for the specified disk and try to read the Interrupt Line (byte at offset 0x3c of header 0x00) all I get is 0. Other devices (like Power management and VGA) give plausible results (like IRQ 9). Should I reprogram the IRQ line of each disk on startup to use IRQ 14/15 or what is the approach to get the right values?
P.S.: I get the same results under VirtualBox, Bochs, and QEmu.
P.S.2: Even though I get 0 as I read the interrupt line byte, still the disks fire IRQs 14 (HDD connected as primary master) and 15 (CDROM connected as secondary master).
ATA/ATAPI controllers typically have 2 (or more) different modes: native PCI mode and legacy ISA emulation mode. For the native PCI mode you use PCI's IRQs and PCI's BARs to determine where the registers are. For legacy ISA emulation mode you assume IRQs 14 and 15 (and the old ISA IO ports) and don't use PCI's IRQs and PCI's BARs.
To determine what mode the controller was left in, read the "programming interface code" field (at offset 9) in the device's PCI configuration space. This contains a set of bits that tell you the current mode (for primary ATA channel and secondary ATA channel) and whether it's fixed or can be changed. If it can be changed you can write to the "programming interface code" field to change the controller's mode; however, if the BIOS left it in "legacy mode" and didn't set the interrupt number field in PCI configuration space then it's going to be a massive mess to figure out which interrupt the device would use if you do change to "native PCI mode".
Note that you're probably going to need some sort of specification that describes the controller and its modes, etc. To find it, search the web for "ATA Host Adapter Standards T13 1510D" - the search results should give you a draft of the specification; which is almost the same as the official/final standard; and should describe what I've said above (including telling you which bits of the "programming interface code" field do what, etc) in addition to a lot of other information (about DMA, etc) that you'll need.
Cheers,
Brendan
Re: Question about PCI IRQ assignment
Posted: Wed May 27, 2015 5:07 am
by mohammedisam
Hi Brendan
Thanx for the tip. I downloaded the draft spec and found the values for the ATA mode. It turns out the ATA is running in legacy ISA mode and is fixed. So I added some tests in my PCI enumerating function to handle this condition. Now I am using the standard IRQs correctly, I guess.
Thanx again
Cheers