OSDev.org

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

All times are UTC - 6 hours




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: PCI IRQ routing via ACPI (acpica)
PostPosted: Wed May 24, 2023 1:25 pm 
Offline
Member
Member

Joined: Sat Jan 16, 2016 10:43 am
Posts: 68
Hi all
I want to make PCI IRQ routing for IOAPIC. I understand that this isn't possible without ACPI, so I integrated ACPICA into my project. Moreover, I tried to implement getting routing table by recursively searching for PCI bridges (starting from PCI root PNP0A03) and calling _PRT method on them. This actually works on most real computers, but there were problems with B450 chipset + AMI BIOS.
There are two problems:
1. All non-root bridges without _BBN method. I solved this problem by reading bus number directly from PCI configuration space.
2. Some bridges don't have routing table (_PRT method). I don't know what to do with it. I noticed that there are devices on these buses that are connected to PCI-e expansion slots. However, routing table is present for all devices integrated into chipset.


Top
 Profile  
 
 Post subject: Re: PCI IRQ routing via ACPI (acpica)
PostPosted: Wed May 24, 2023 3:38 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
shmx wrote:
1. All non-root bridges without _BBN method. I solved this problem by reading bus number directly from PCI configuration space.

I don't think _BBN is supposed to tell you the current bus number, just the one that was in use when the ACPI tables were built. The ACPI spec seems to suggest that _BBN is only used to assist routing PCI_Config Operation Region accesses, which means it's not necessary if no such accesses will occur.

shmx wrote:
2. Some bridges don't have routing table (_PRT method). I don't know what to do with it. I noticed that there are devices on these buses that are connected to PCI-e expansion slots. However, routing table is present for all devices integrated into chipset.

If no routing table is present, use the default routing described in the PCI-to-PCI Bridge Architecture Specification.


Top
 Profile  
 
 Post subject: Re: PCI IRQ routing via ACPI (acpica)
PostPosted: Thu May 25, 2023 8:46 am 
Offline
Member
Member

Joined: Sat Jan 16, 2016 10:43 am
Posts: 68
Thk, Octocontrabass
I thought about native routing, but it seemed to me that it isn't used in modern chipsets. It mechanism is really used for buses connected to expansion slots. I read PСI spec, but all I saw was an explicit description of how IRQ rotation was within single bus. Problem is that even parent bus doesn't have routing table. My bus topology is like this:
Code:
       [0]
        |
       [1] - [6]
        |
       [2]
     /  |  \
  [3] [4] [5]

Buses 0, 1, 6 contain routing table. External devices are connected to buses 3, 4, 5. Experimentally, I managed to come up algorithm:
1. Recursively find first parent bus in chain with complete routing table for device 0.
2. Remeber IRQ for all pins (A - D).
3. irq = save_irq[(pci_dev_addr + (pci_irq_pin - 1) + parent_bus_dev_addr) % 4]

I'm not sure that this algorithm is correct.


Top
 Profile  
 
 Post subject: Re: PCI IRQ routing via ACPI (acpica)
PostPosted: Thu May 25, 2023 10:26 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
Isn't that exactly the same as the algorithm described in the PCI-to-PCI Bridge Architecture Specification?


Top
 Profile  
 
 Post subject: Re: PCI IRQ routing via ACPI (acpica)
PostPosted: Fri May 26, 2023 12:23 pm 
Offline
Member
Member

Joined: Sat Jan 16, 2016 10:43 am
Posts: 68
I have carefully read sections 9.1 and 11.2.3. It seemed to me that some actions were not described and I had to think out.


Top
 Profile  
 
 Post subject: Re: PCI IRQ routing via ACPI (acpica)
PostPosted: Mon May 29, 2023 3:25 pm 
Offline
Member
Member

Joined: Fri Feb 11, 2022 4:55 am
Posts: 435
Location: behind the keyboard
I am going through the same thing, I recently added the ACPICA to my OS to get the IRQ Pins values. Can you please provide me with the code you use to resolve interrupt pins.


Top
 Profile  
 
 Post subject: Re: PCI IRQ routing via ACPI (acpica)
PostPosted: Thu Jun 01, 2023 7:02 am 
Offline
Member
Member

Joined: Sat Jan 16, 2016 10:43 am
Posts: 68
https://github.com/i-shamukov/shmdos64/ ... outing.cpp
https://github.com/i-shamukov/shmdos64/ ... outing.cpp


Top
 Profile  
 
 Post subject: Re: PCI IRQ routing via ACPI (acpica)
PostPosted: Sat Jun 03, 2023 4:09 am 
Offline
Member
Member

Joined: Fri Feb 11, 2022 4:55 am
Posts: 435
Location: behind the keyboard
AcpiGetDevices with the PNP0A... Bridge returns nothing. And when I call it with NULL it returns _SB and _ZT on QEMU.

And how do I use AcpiGetIrqRoutingTable


Top
 Profile  
 
 Post subject: Re: PCI IRQ routing via ACPI (acpica)
PostPosted: Sun Jun 04, 2023 4:37 am 
Offline
Member
Member

Joined: Fri Feb 11, 2022 4:55 am
Posts: 435
Location: behind the keyboard
Edit : sorry I missed some initialization functions. That maybe explains why its returning nothing and triple faulting on my pc and vmware. Thanks for your reference, I can now understand alot by reading your driver.

I will try fixing this as soon as I get up from bed lol


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot], nullpointer and 63 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