Skip to content

Conversation

@IanSeyler
Copy link
Member

This pull request refactors the way Message Signaled Interrupts (MSI and MSI-X) are initialized and managed for PCI devices, especially for the xHCI USB and Virtio-Net drivers. The main improvement is the introduction of a unified MSI/MSI-X initialization routine in a new driver file, which replaces duplicated code in device-specific drivers. Additionally, interrupt handling and configuration for Virtio-Net is streamlined and improved.

Interrupt Initialization and Handling

  • Added a new unified driver file msi.asm containing routines for initializing MSI and MSI-X (msix_init and msi_init), which are now used by both xHCI and Virtio-Net drivers to configure interrupts more cleanly and with less duplicated code. [1] [2]
  • Removed device-specific MSI-X initialization code from xhci_init: in bus/xhci.asm and from Virtio-Net capability parsing, replacing it with calls to the new msix_init routine. [1] [2]
  • Added a new interrupt handler net_virtio_int and logic to create an IDT gate for Virtio-Net, enabling hardware interrupts for the device when MSI-X is available. [1] [2]

Capability Detection and Abstraction

  • Added a new syscall os_bus_cap_check for generic PCI capability detection, used by the new MSI/MSI-X initialization routines to simplify and standardize capability checks.

Virtio-Net Driver Improvements

  • Updated Virtio-Net initialization to use the new MSI-X routine, set an interrupt-enabled flag in net_table, and properly configure queue MSI-X vectors and config interrupts. This improves interrupt management and device configuration. [1] [2] [3] [4]

Codebase Cleanup

  • Removed duplicated MSI-X initialization logic from Virtio-Net capability parsing, further reducing code duplication and improving maintainability.

These changes collectively improve interrupt support for PCI devices, reduce code duplication, and make the drivers easier to maintain and extend.

@IanSeyler IanSeyler self-assigned this Dec 3, 2025
@IanSeyler IanSeyler merged commit 9642fc4 into master Dec 3, 2025
6 checks passed
@IanSeyler IanSeyler deleted the virtio-net_int branch December 3, 2025 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants