Using MSI instead of APIC?

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
User avatar
mrjbom
Member
Member
Posts: 322
Joined: Sun Jul 21, 2019 7:34 am

Using MSI instead of APIC?

Post by mrjbom »

I want to know if I should use Message Signaled Interrupts as my primary way of handling interrupts, instead of IO APIC.
Is this the right solution?
How common is MSI support among devices? Among the classic x86-64 PC devices.

Can MSI be the only way to handle interrupts or do I still have to configure the IO APIC?

How do LAPIC, IO APIC and MSI fit together?

Will it be more straightforward than the IO APIC?

In general, I would like someone to explain to me whether it is worth messing around with MSI and whether it is worth replacing IO APIC with it.
rdos
Member
Member
Posts: 3311
Joined: Wed Oct 01, 2008 1:55 pm

Re: Using MSI instead of APIC?

Post by rdos »

Basically all modern PCI devices support either MSI or MSI-X or both. This includes USB 3 controllers, network controllers, HD audio, AHCI and NVMe.

It's only for various legacy devices, like PS/2 keyboard & mouse, serial ports, IDE and floppies that you need to use legacy interrupts and the IO-APIC. These are all uncommon in modern hardware.

You still need to configure the local APIC, but you don't need to mess with details of various legacy strangeness. For most legacy devices, you can assume they always use the same IRQs, so ACPI is generally not needed. The only exceptions are dated USB controllers, which people writing new OSes shouldn't need to bother with.
User avatar
GoingNuts
Posts: 4
Joined: Fri Jun 17, 2022 7:36 pm
Libera.chat IRC: GoingNuts

Re: Using MSI instead of APIC?

Post by GoingNuts »

Started xHCI months ago specifically for USB keyboard, VirtualBox on Windows 11 (host) deploying MSI, no worries with obtaining its descriptors etc... but stuck on how to implement 4ms-duration for MSI to check the keyboard buffer for user input, using HPET ?
Would deeply appreciate your guidance, thank you and Happy New Year.
nullplan
Member
Member
Posts: 1804
Joined: Wed Aug 30, 2017 8:24 am

Re: Using MSI instead of APIC?

Post by nullplan »

GoingNuts wrote: Thu Jan 02, 2025 5:23 pm but stuck on how to implement 4ms-duration for MSI to check the keyboard buffer for user input, using HPET ?
When you send the Configure Endpoint command, you set the interval field correctly. For full speed/low speed devices, you set it to the interval you want in milliseconds, and for high speed or higher devices, you set it to the correct bit shift for 125 µs. Then you create a TD with the IOC bit set. Then the xHC will notify you when the interrupt completes, and you can read out the keyboard event and, if appropriate, wake up. And you should probably re-introduce the same TD once you are done.
Carpe diem!
Post Reply