Kernel: Fix IOAPIC max redirection entry fetching

Also max redirection entry is an index, not count so comparisons should
check for equality :)
This commit is contained in:
Bananymous 2025-08-25 17:14:17 +03:00
parent 9a6eae69ba
commit a4698f0bde
1 changed files with 6 additions and 6 deletions

View File

@ -22,7 +22,7 @@
#define LAPIC_TIMER_CURRENT_REG 0x390 #define LAPIC_TIMER_CURRENT_REG 0x390
#define LAPIC_TIMER_DIVIDE_REG 0x3E0 #define LAPIC_TIMER_DIVIDE_REG 0x3E0
#define IOAPIC_MAX_REDIRS 0x01 #define IOAPIC_APICVER 0x01
#define IOAPIC_REDIRS 0x10 #define IOAPIC_REDIRS 0x10
// https://uefi.org/specs/ACPI/6.5/05_ACPI_Software_Programming_Model.html#multiple-apic-description-table-madt-format // https://uefi.org/specs/ACPI/6.5/05_ACPI_Software_Programming_Model.html#multiple-apic-description-table-madt-format
@ -238,7 +238,7 @@ namespace Kernel
io_apic.vaddr & PAGE_ADDR_MASK, io_apic.vaddr & PAGE_ADDR_MASK,
PageTable::Flags::ReadWrite | PageTable::Flags::Present PageTable::Flags::ReadWrite | PageTable::Flags::Present
); );
io_apic.max_redirs = io_apic.read(IOAPIC_MAX_REDIRS); io_apic.max_redirs = (io_apic.read(IOAPIC_APICVER) >> 16) & 0xFF;
} }
// Enable local apic // Enable local apic
@ -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;
@ -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;