PCI BIOS32 SET_PCI_IRQ call fails

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.
korneliuszo
Posts: 10
Joined: Tue May 23, 2023 4:29 am

PCI BIOS32 SET_PCI_IRQ call fails

Post by korneliuszo »

I try to configure PCI IRQ on my own os.
It uses protected mode with PIC interrupt controller.

When I call PCIBIOS function 0xb10f it fails with error code 0x88 on 2 computers.

It looks like I don't configure something priror calling it.
Octocontrabass
Member
Member
Posts: 5560
Joined: Mon Mar 25, 2013 7:01 pm

Re: PCI BIOS32 SET_PCI_IRQ call fails

Post by Octocontrabass »

korneliuszo wrote:When I call PCIBIOS function 0xb10f it fails with error code 0x88 on 2 computers.
What parameters are you passing to this function?

What are the contents of the PCI IRQ routing table? (Either the table returned by function 0xB10E or the $PIR table.)
nullplan
Member
Member
Posts: 1789
Joined: Wed Aug 30, 2017 8:24 am

Re: PCI BIOS32 SET_PCI_IRQ call fails

Post by nullplan »

So I just had a look at SeaBIOS, and it does not support this function. I would therefore assume that it is not always supported, and that tells me it might not be implemented very well on the BIOSes you did test with.
Carpe diem!
korneliuszo
Posts: 10
Joined: Tue May 23, 2023 4:29 am

Re: PCI BIOS32 SET_PCI_IRQ call fails

Post by korneliuszo »

I call 0xb10f function with:
https://github.com/korneliuszo/bezbios/ ... i.cpp#L147

PIR table found by $PIR table allows routing I want to make.
Octocontrabass
Member
Member
Posts: 5560
Joined: Mon Mar 25, 2013 7:01 pm

Re: PCI BIOS32 SET_PCI_IRQ call fails

Post by Octocontrabass »

Okay, but what are the actual values in each register when you perform that call? And what are the actual contents of the $PIR table?

It may also help to disassemble the BIOS code and see if it expects anything unusual. The PCI spec says the way you're calling it should be fine, but maybe the code isn't as position-independent as it should be (or maybe it just plain doesn't work because everyone uses ACPI).
korneliuszo
Posts: 10
Joined: Tue May 23, 2023 4:29 am

Re: PCI BIOS32 SET_PCI_IRQ call fails

Post by korneliuszo »

It looks relocatable, but I'm not proficient in reverse engineering.

output from pir.py on thinkpad T235

Code: Select all

Found PIR Len: 144
checksum 0
PCI Interrupt Routing 1.0 present.
	Router Device: 00:01.0
	Exclusive IRQs:  None 
	Compatible Router: 1045:c700
	Device: 00:00,  on-board
		INTA#: Link 0x00, IRQ Bitmap  None 
		INTB#: Link 0x00, IRQ Bitmap  None 
		INTC#: Link 0x00, IRQ Bitmap  None 
		INTD#: Link 0x00, IRQ Bitmap  None 
	Device: 00:01,  on-board
		INTA#: Link 0x00, IRQ Bitmap  None 
		INTB#: Link 0x00, IRQ Bitmap  None 
		INTC#: Link 0x00, IRQ Bitmap  None 
		INTD#: Link 0x00, IRQ Bitmap  None 
	Device: 00:02,  on-board
		INTA#: Link 0x02, IRQ Bitmap 3 4 5 7 9 10 11 12 14 
		INTB#: Link 0x12, IRQ Bitmap 3 4 5 7 9 10 11 12 14 
		INTC#: Link 0x00, IRQ Bitmap  None 
		INTD#: Link 0x00, IRQ Bitmap  None 
	Device: 00:03,  on-board
		INTA#: Link 0x00, IRQ Bitmap  None 
		INTB#: Link 0x00, IRQ Bitmap  None 
		INTC#: Link 0x00, IRQ Bitmap  None 
		INTD#: Link 0x00, IRQ Bitmap  None 
	Device: 00:04,  on-board
		INTA#: Link 0x22, IRQ Bitmap 3 4 5 7 9 10 11 12 14 
		INTB#: Link 0x00, IRQ Bitmap  None 
		INTC#: Link 0x00, IRQ Bitmap  None 
		INTD#: Link 0x00, IRQ Bitmap  None 
	Device: 00:05,  on-board
		INTA#: Link 0x32, IRQ Bitmap 3 4 5 7 9 10 11 12 14 
		INTB#: Link 0x00, IRQ Bitmap  None 
		INTC#: Link 0x00, IRQ Bitmap  None 
		INTD#: Link 0x00, IRQ Bitmap  None 
	Device: 00:14,  on-board
		INTA#: Link 0x22, IRQ Bitmap 3 4 5 7 9 10 11 12 14 
		INTB#: Link 0x00, IRQ Bitmap  None 
		INTC#: Link 0x00, IRQ Bitmap  None 
		INTD#: Link 0x00, IRQ Bitmap  None 

Octocontrabass
Member
Member
Posts: 5560
Joined: Mon Mar 25, 2013 7:01 pm

Re: PCI BIOS32 SET_PCI_IRQ call fails

Post by Octocontrabass »

korneliuszo wrote:thinkpad T235
You mean 235? That should be old enough for the BIOS to handle IRQ routing. Which IRQ are you trying to route? Could there be a conflict?
korneliuszo
Posts: 10
Joined: Tue May 23, 2023 4:29 am

Re: PCI BIOS32 SET_PCI_IRQ call fails

Post by korneliuszo »

IRQ10, 00:02 link A
Octocontrabass
Member
Member
Posts: 5560
Joined: Mon Mar 25, 2013 7:01 pm

Re: PCI BIOS32 SET_PCI_IRQ call fails

Post by Octocontrabass »

What happens if you pick a different IRQ?
korneliuszo
Posts: 10
Joined: Tue May 23, 2023 4:29 am

Re: PCI BIOS32 SET_PCI_IRQ call fails

Post by korneliuszo »

IRQ 11 same effect
Octocontrabass
Member
Member
Posts: 5560
Joined: Mon Mar 25, 2013 7:01 pm

Re: PCI BIOS32 SET_PCI_IRQ call fails

Post by Octocontrabass »

Can I see the BIOS code? Maybe there's something in there to explain why it doesn't work for you.
korneliuszo
Posts: 10
Joined: Tue May 23, 2023 4:29 am

Re: PCI BIOS32 SET_PCI_IRQ call fails

Post by korneliuszo »

https://drive.google.com/file/d/1maeKH9 ... sp=sharing

I would post on forum but bin files are not allowed

Set offset as 0 (it sits in 0xf0000 but segments can be reallocated)
Octocontrabass
Member
Member
Posts: 5560
Joined: Mon Mar 25, 2013 7:01 pm

Re: PCI BIOS32 SET_PCI_IRQ call fails

Post by Octocontrabass »

I see nothing wrong with the BIOS code. Are you sure the correct values are in every register? Add "int $3\n\t" right before the call instruction and use the interrupt handler to dump the register contents.
korneliuszo
Posts: 10
Joined: Tue May 23, 2023 4:29 am

Re: PCI BIOS32 SET_PCI_IRQ call fails

Post by korneliuszo »

Code: Select all

b'INT3!!!'
b'EIP: 0x001090D2'
b'CS: 0x00000008'
b'EFLAGS: 0x00000006'
b'EAX: 0x0000B10F'
b'EBX: 0x00000010'
b'ECX: 0x00000A0A'
b'EDX: 0x00148100'
b'ESI: 0x00148108'
b'EDI: 0x001479CB'
b'EBP: 0x00147980'
b'DS: 0x00000010'
b'ES: 0x00000010'
b'FS: 0x00000010'
b'GS: 0x00000010'
b'PCI 0x000FD86C'
b'PCI 0x0000880F'
it looks correct
Octocontrabass
Member
Member
Posts: 5560
Joined: Mon Mar 25, 2013 7:01 pm

Re: PCI BIOS32 SET_PCI_IRQ call fails

Post by Octocontrabass »

Set an execute breakpoint at offset 0xD7B1 in the BIOS code. Do you hit the breakpoint when you call the BIOS? If so, what is the value of CX at that point?

Are there any unconfigured PCI-to-PCI bridges? (An unconfigured bridge will have class 6, subclass 4, and zero at either offset 0x19 or offset 0x1A in the configuration space.)
Post Reply