diff --git a/kernel/include/kernel/PIC.h b/kernel/include/kernel/PIC.h index 31193a35..d93e0d89 100644 --- a/kernel/include/kernel/PIC.h +++ b/kernel/include/kernel/PIC.h @@ -29,7 +29,7 @@ namespace Kernel private: SpinLock m_lock; - uint16_t m_reserved_irqs { 0 }; + uint16_t m_reserved_irqs { 1u << 2 }; friend class InterruptController; }; diff --git a/kernel/kernel/PCI.cpp b/kernel/kernel/PCI.cpp index e2ea2b3d..cc94ea1a 100644 --- a/kernel/kernel/PCI.cpp +++ b/kernel/kernel/PCI.cpp @@ -362,7 +362,16 @@ namespace Kernel::PCI BAN::ErrorOr PCI::Device::reserve_irqs(uint8_t count) { - if (m_offset_msi_x.has_value()) + if (!InterruptController::get().is_using_apic()) + { + if (count > 1) + { + dwarnln("PIC: could not allocate {} interrupts, (currently) only {} supported", count, 1); + return BAN::Error::from_errno(EFAULT); + } + enable_pin_interrupts(); + } + else if (m_offset_msi_x.has_value()) { uint16_t msg_ctrl = read_word(*m_offset_msi_x + 0x02); if (count > (msg_ctrl & 0x7FF) + 1) @@ -387,15 +396,6 @@ namespace Kernel::PCI write_word(*m_offset_msi + 0x02, msg_ctrl); disable_pin_interrupts(); } - else if (!InterruptController::get().is_using_apic()) - { - if (count > 1) - { - dwarnln("PIC: could not allocate {} interrupts, (currently) only {} supported", count, 1); - return BAN::Error::from_errno(EFAULT); - } - enable_pin_interrupts(); - } else { dwarnln("Could not reserve interrupt for PCI device. No MSI, MSI-X or interrupt line is used");