Kernel: Implement {enable,disable}_msix interrupts in PCI Device

Implement enabling and disabling MSIx interrupts for a PCI device.

Removes two TODO()s from PCI::Device.cpp :^)
This commit is contained in:
Pankaj Raghav 2023-04-29 19:09:49 +02:00 committed by Jelle Raaijmakers
parent d3bb63afff
commit bf7ac06d7b
Notes: sideshowbarker 2024-07-16 23:34:49 +09:00
2 changed files with 12 additions and 2 deletions

View file

@ -82,6 +82,8 @@ static constexpr u32 bar_address_mask = 0xfffffff0;
static constexpr u16 msix_control_table_mask = 0x07ff;
static constexpr u8 msix_table_bir_mask = 0x7;
static constexpr u16 msix_table_offset_mask = 0xfff8;
static constexpr u8 msi_control_offset = 2;
static constexpr u16 msix_control_enable = 0x8000;
// Taken from https://pcisig.com/sites/default/files/files/PCI_Code-ID_r_1_11__v24_Jan_2019.pdf
enum class ClassID {

View file

@ -44,13 +44,21 @@ void Device::disable_message_signalled_interrupts()
{
TODO();
}
void Device::enable_extended_message_signalled_interrupts()
{
TODO();
for (auto& capability : m_pci_identifier->capabilities()) {
if (capability.id().value() == PCI::Capabilities::ID::MSIX)
capability.write16(msi_control_offset, capability.read16(msi_control_offset) | msix_control_enable);
}
}
void Device::disable_extended_message_signalled_interrupts()
{
TODO();
for (auto& capability : m_pci_identifier->capabilities()) {
if (capability.id().value() == PCI::Capabilities::ID::MSIX)
capability.write16(msi_control_offset, capability.read16(msi_control_offset) & ~(msix_control_enable));
}
}
}