Skip to content

Commit

Permalink
[HALX86] Start trying to get Interrupt Override support
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkFire01 committed Sep 28, 2024
1 parent 49a1970 commit 2ce16c5
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 4 deletions.
20 changes: 18 additions & 2 deletions hal/halx86/acpi/busemul.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

/* GLOBALS ********************************************************************/

ISA_IRQ_TO_GSI_OVERRIDE HalpIRQToGSIOverride[MAX_PIC_IRQs];

/* PRIVATE FUNCTIONS **********************************************************/

CODE_SEG("INIT")
Expand Down Expand Up @@ -239,9 +241,23 @@ HalGetInterruptVector(IN INTERFACE_TYPE InterfaceType,
OUT PKIRQL Irql,
OUT PKAFFINITY Affinity)
{
ULONG Vector;
ULONG Level;

if (InterfaceType == Isa && BusInterruptVector <= MAX_PIC_IRQs)
{
Vector = HalpIRQToGSIOverride[BusInterruptVector].GlobalIRQ;
Level = HalpIRQToGSIOverride[BusInterruptLevel].GlobalIRQ;
}
else
{
Vector = BusInterruptVector;
Level = BusInterruptLevel;
}

/* Call the system bus translator */
return HalpGetRootInterruptVector(BusInterruptLevel,
BusInterruptVector,
return HalpGetRootInterruptVector(Level,
Vector,
Irql,
Affinity);
}
Expand Down
29 changes: 27 additions & 2 deletions hal/halx86/acpi/madt.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,24 @@ HALP_APIC_INFO_TABLE HalpApicInfoTable;
static PROCESSOR_IDENTITY HalpStaticProcessorIdentity[MAXIMUM_PROCESSORS];
PPROCESSOR_IDENTITY HalpProcessorIdentity;

extern ULONG HalpPicVectorRedirect[16];
ISA_IRQ_TO_GSI_OVERRIDE HalpIRQToGSIOverride[MAX_PIC_IRQs];


ULONG
HalpGetCurrentProcessorHwID();

VOID
HalpInitIrqOverride()
{
for(ULONG i = 0; i < MAX_PIC_IRQs; i++)
{
HalpIRQToGSIOverride[i].SourceIRQ = i;
HalpIRQToGSIOverride[i].Flags = 0;
HalpIRQToGSIOverride[i].GlobalIRQ = i;
}
}


/* FUNCTIONS ******************************************************************/

// Note: HalpParseApicTables() is called early, so its DPRINT*() do nothing.
Expand Down Expand Up @@ -174,12 +187,24 @@ HalpParseApicTables(
InterruptOverride->Bus, InterruptOverride->SourceIrq,
InterruptOverride->GlobalIrq, InterruptOverride->IntiFlags);

if (InterruptOverride->Bus != 0) // 0 = ISA
if (InterruptOverride->Bus != 0) // 0 = ISA, actbl2.h, line-1068
{
DPRINT("Invalid Bus: %p, %u\n", InterruptOverride, InterruptOverride->Bus);
return;
}

if (InterruptOverride->SourceIrq > MAX_PIC_IRQs)
{
DPRINT("Invalid SourceIrq: %p, %u\n",
InterruptOverride, InterruptOverride->SourceIrq);
return;
}

if (InterruptOverride->GlobalIrq)
{
HalpIRQToGSIOverride[InterruptOverride->SourceIrq].GlobalIRQ = InterruptOverride->GlobalIrq;
}

break;
}
default:
Expand Down
2 changes: 2 additions & 0 deletions hal/halx86/apic/apic.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
ULONG ApicVersion;
UCHAR HalpVectorToIndex[256];

extern ISA_IRQ_TO_GSI_OVERRIDE HalpIRQToGSIOverride[MAX_PIC_IRQs];

ULONG
HalpGetCurrentProcessorHwID()
{
Expand Down
9 changes: 9 additions & 0 deletions hal/halx86/apic/halinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ VOID
NTAPI
ApicInitializeLocalApic(ULONG Cpu);

VOID
HalpInitIrqOverride();

/* FUNCTIONS ****************************************************************/

VOID
Expand All @@ -25,6 +28,12 @@ HalpInitProcessor(
IN ULONG ProcessorNumber,
IN PLOADER_PARAMETER_BLOCK LoaderBlock)
{
if (ProcessorNumber == 0)
{
/* Setup IRQ ovveride for use with MADT table logic. */
HalpInitIrqOverride();
}

HalpSetupProcessorsTable(ProcessorNumber);

/* Initialize the local APIC for this cpu */
Expand Down
9 changes: 9 additions & 0 deletions hal/halx86/include/halacpi.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
#pragma once

#define MAX_PIC_IRQs 16

typedef struct _ISA_IRQ_TO_GSI_OVERRIDE {
ULONG SourceIRQ;
ULONG GlobalIRQ;
ULONG Flags;
ULONG HandledIrq;
} ISA_IRQ_TO_GSI_OVERRIDE, *PISA_IRQ_TO_GSI_OVERRIDE;

//
// Internal HAL structure
//
Expand Down
12 changes: 12 additions & 0 deletions hal/halx86/smp/mps/mps.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,21 @@ ULONG PhysicalProcessorCount;

static PROCESSOR_IDENTITY HalpStaticProcessorIdentity[MAXIMUM_PROCESSORS];
const PPROCESSOR_IDENTITY HalpProcessorIdentity = HalpStaticProcessorIdentity;
ISA_IRQ_TO_GSI_OVERRIDE HalpIRQToGSIOverride[MAX_PIC_IRQs];

/* FUNCTIONS ******************************************************************/

VOID
HalpInitIrqOverride()
{
for(ULONG i = 0; i < MAX_PIC_IRQs; i++)
{
HalpIRQToGSIOverride[i].SourceIRQ = i;
HalpIRQToGSIOverride[i].Flags = 0;
HalpIRQToGSIOverride[i].GlobalIRQ = i;
}
}

VOID
HalpParseApicTables(
_In_ PLOADER_PARAMETER_BLOCK LoaderBlock)
Expand Down

0 comments on commit 2ce16c5

Please sign in to comment.