Skip to content

Commit fce9907

Browse files
committed
"Fix" IRQ routing for PCI devices
1 parent 9eb6e10 commit fce9907

File tree

2 files changed

+16
-26
lines changed

2 files changed

+16
-26
lines changed

source/Cosmos.HAL2/Drivers/PCI/Network/AMDPCNetII.cs

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -96,37 +96,19 @@ public AMDPCNetII(PCIDevice device)
9696
mTransmitBuffer = new Queue<byte[]>();
9797
mRecvBuffer = new Queue<byte[]>();
9898

99-
//INTs.SetIntHandler((byte)(0x20 + device.InterruptLine), HandleNetworkInterrupt);
100-
//IOAPIC.SetEntry(19, (byte)(0x20 + device.InterruptLine));
99+
INTs.SetIntHandler((byte)(0x20 + device.InterruptLine), HandleNetworkInterrupt);
101100

102-
/*Global.mDebugger.Send("device slot=" + device.slot);
103-
Global.mDebugger.Send("device function=" + device.function);
104-
105-
foreach (var irqRouting in ACPI.IrqRoutingTable)
101+
//Route IRQ for all IO/APIC PCI IRQ (I16-I20)
102+
//We will have to fix this if we use multiple PCI devices that requires interrupts
103+
//TODO: Use ACPI to find IRQ route
104+
for (byte i = 0; i < 4; i++)
106105
{
107-
byte slot = (byte)((irqRouting.Address >> 16) & 0xFFFF);
108-
byte function = (byte)(irqRouting.Address & 0xFFFF);
109-
110-
Global.mDebugger.Send("slot=" + slot);
111-
Global.mDebugger.Send("function=" + function);
112-
Global.mDebugger.Send("Address=0x" + (irqRouting.Address).ToString("X"));
113-
Global.mDebugger.Send("Pin=" + irqRouting.Pin);
114-
Global.mDebugger.Send("Source=" + irqRouting.Source);
115-
Global.mDebugger.Send("Source Index=" + irqRouting.SourceIndex);
116-
117-
if (device.slot == slot && device.function == function)
118-
{
119-
Global.mDebugger.Send("DEVICE FOUND SETTING CUSTOM IRQ " + irqRouting.SourceIndex);
120-
121-
122-
}
123-
}*/
106+
IOAPIC.SetEntry((byte)(16 + i), (ulong)(0x20 + device.InterruptLine));
107+
}
124108
}
125109

126110
protected void HandleNetworkInterrupt(ref INTs.IRQContext aContext)
127111
{
128-
Global.mDebugger.Send("Network IRQ!");
129-
130112
uint cur_status = StatusRegister;
131113

132114
if ((cur_status & 0x100) != 0)

source/Cosmos.HAL2/Drivers/PCI/Network/RTL8139.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,15 @@ public RTL8139(PCIDevice device)
3131
// We are handling this device
3232
pciCard.Claimed = true;
3333
// Setup interrupt handling
34-
INTs.SetIrqHandler(device.InterruptLine, HandleNetworkInterrupt);
34+
INTs.SetIntHandler((byte)(0x20 + device.InterruptLine), HandleNetworkInterrupt);
35+
36+
//Route IRQ for all IO/APIC PCI IRQ (I16-I20)
37+
//We will have to fix this if we use multiple PCI devices that requires interrupts
38+
//TODO: Use ACPI to find IRQ route
39+
for (byte i = 0; i < 4; i++)
40+
{
41+
IOAPIC.SetEntry((byte)(16 + i), (ulong)(0x20 + device.InterruptLine));
42+
}
3543
// Get IO Address from PCI Bus
3644
// Enable the card
3745
pciCard.EnableDevice();

0 commit comments

Comments
 (0)