Kernel: Fix correct IOAPIC lookup based on gsi

This commit is contained in:
Bananymous 2025-07-18 19:08:24 +03:00
parent 5874fd640e
commit d27891c79f
1 changed files with 4 additions and 4 deletions

View File

@ -470,7 +470,7 @@ namespace Kernel
IOAPIC* ioapic = nullptr; IOAPIC* ioapic = nullptr;
for (IOAPIC& io : m_io_apics) for (IOAPIC& io : m_io_apics)
{ {
if (io.gsi_base <= gsi && gsi <= io.gsi_base + io.max_redirs) if (io.gsi_base <= gsi && gsi < io.gsi_base + io.max_redirs)
{ {
ioapic = &io; ioapic = &io;
break; break;
@ -512,7 +512,7 @@ namespace Kernel
bool found_ioapic = false; bool found_ioapic = false;
for (const auto& io : m_io_apics) for (const auto& io : m_io_apics)
{ {
if (io.gsi_base <= gsi && gsi <= io.gsi_base + io.max_redirs) if (io.gsi_base <= gsi && gsi < io.gsi_base + io.max_redirs)
{ {
found_ioapic = true; found_ioapic = true;
break; break;
@ -529,7 +529,7 @@ namespace Kernel
int bit = gsi % 8; int bit = gsi % 8;
if (m_reserved_gsis[byte] & (1 << bit)) if (m_reserved_gsis[byte] & (1 << bit))
{ {
dwarnln("GSI {} is already reserved", gsi); dwarnln("GSI {} is already reserved (IRQ {})", gsi, irq);
return BAN::Error::from_errno(EFAULT); return BAN::Error::from_errno(EFAULT);
} }
m_reserved_gsis[byte] |= 1 << bit; m_reserved_gsis[byte] |= 1 << bit;
@ -566,7 +566,7 @@ namespace Kernel
IOAPIC* ioapic = nullptr; IOAPIC* ioapic = nullptr;
for (IOAPIC& io : m_io_apics) for (IOAPIC& io : m_io_apics)
{ {
if (io.gsi_base <= gsi && gsi <= io.gsi_base + io.max_redirs) if (io.gsi_base <= gsi && gsi < io.gsi_base + io.max_redirs)
{ {
ioapic = &io; ioapic = &io;
break; break;