From bda39ef16ccc77dbbcaec79c91ae0b27aba2c985 Mon Sep 17 00:00:00 2001 From: valentinbreiz Date: Tue, 26 Dec 2023 17:18:29 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20IRQ=20handling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/Cosmos.Core/INTs.cs | 2 +- source/Cosmos.Core/IOAPIC.cs | 14 ++++++-------- source/Cosmos.HAL2/Drivers/Network/AMDPCNetII.cs | 1 - 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/source/Cosmos.Core/INTs.cs b/source/Cosmos.Core/INTs.cs index 169524dfc0..c07ad280da 100644 --- a/source/Cosmos.Core/INTs.cs +++ b/source/Cosmos.Core/INTs.cs @@ -283,7 +283,7 @@ public static void SetIntHandler(byte aIntNo, IRQDelegate aHandler) { /// IRQ index. /// IRQ handler. public static void SetIrqHandler(byte aIrqNo, IRQDelegate aHandler) { - IOAPIC.SetEntry(aIrqNo); + IOAPIC.SetEntry((uint)aIrqNo + 0x20); SetIntHandler((byte)(0x20 + aIrqNo), aHandler); } diff --git a/source/Cosmos.Core/IOAPIC.cs b/source/Cosmos.Core/IOAPIC.cs index d02e797fe0..54eeddcd8d 100644 --- a/source/Cosmos.Core/IOAPIC.cs +++ b/source/Cosmos.Core/IOAPIC.cs @@ -82,22 +82,20 @@ public static uint In(byte reg) /// /// Set IO APIC Entry. /// - /// Entry index. - /// Data. - /// Local APIC Id. - public static void SetEntry(byte index, ulong data, uint lapicId = 0) + /// Irq ID. + public static void SetEntry(uint irq) { - Out((byte)(IOREDTBL + index * 2), (uint)data); - Out((byte)(IOREDTBL + index * 2 + 1), (lapicId << 24)); + SetEntry((byte)ACPI.RemapIRQ(irq - 0x20), irq); } /// /// Set IO APIC Entry. /// /// Irq ID. - public static void SetEntry(uint irq) + public static void SetEntry(byte index, ulong data) { - SetEntry((byte)ACPI.RemapIRQ(irq), 0x20 + irq); + Out((byte)(IOREDTBL + index * 2), (uint)data); + Out((byte)(IOREDTBL + index * 2 + 1), (uint)(data >> 32)); } /// diff --git a/source/Cosmos.HAL2/Drivers/Network/AMDPCNetII.cs b/source/Cosmos.HAL2/Drivers/Network/AMDPCNetII.cs index caaf1c4b6a..0102068b78 100644 --- a/source/Cosmos.HAL2/Drivers/Network/AMDPCNetII.cs +++ b/source/Cosmos.HAL2/Drivers/Network/AMDPCNetII.cs @@ -149,7 +149,6 @@ protected void HandleNetworkInterrupt(ref INTs.IRQContext aContext) } StatusRegister = cur_status; - Core.Global.PIC.EoiSlave(); } ///