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 Oct 18, 2024
1 parent e649e9b commit e46dcdf
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 7 deletions.
2 changes: 1 addition & 1 deletion boot/bootdata/livecd.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Options=/DEBUG /DEBUGPORT=COM1 /BAUDRATE=115200 /SOS /FASTDETECT /MININT
[LiveCD_Macpi]
BootType=Windows2003
SystemPath=\reactos
Options=/HAL=halmacpi.dll /KERNEL=ntkrnlmp.exe /DEBUG /DEBUGPORT=COM1 /BAUDRATE=115200 /SOS /FASTDETECT /MININT
Options=/HAL=halmp.dll /KERNEL=ntkrnlmp.exe /DEBUG /DEBUGPORT=COM1 /BAUDRATE=115200 /SOS /FASTDETECT /MININT

[LiveCD_Aacpi]
BootType=Windows2003
Expand Down
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
34 changes: 30 additions & 4 deletions hal/halx86/acpi/madt.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,23 @@ HALP_APIC_INFO_TABLE HalpApicInfoTable;
static PROCESSOR_IDENTITY HalpStaticProcessorIdentity[MAXIMUM_PROCESSORS];
const PPROCESSOR_IDENTITY HalpProcessorIdentity = HalpStaticProcessorIdentity;

#if 0
extern ULONG HalpPicVectorRedirect[16];
#endif
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 ******************************************************************/

Expand Down Expand Up @@ -165,12 +179,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
8 changes: 8 additions & 0 deletions hal/halx86/apic/apic.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@
ULONG ApicVersion;
UCHAR HalpVectorToIndex[256];

extern ISA_IRQ_TO_GSI_OVERRIDE HalpIRQToGSIOverride[MAX_PIC_IRQs];

ULONG
HalpGetCurrentProcessorHwID()
{
return ApicRead(APIC_ID);
}

#ifndef _M_AMD64
const UCHAR
HalpIRQLtoTPR[32] =
Expand Down
8 changes: 8 additions & 0 deletions hal/halx86/apic/halinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ ApicInitializeLocalApic(ULONG Cpu);
VOID
NTAPI
ApicInitializeIOApic(VOID);
VOID
HalpInitIrqOverride();

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

Expand All @@ -29,6 +31,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 e46dcdf

Please sign in to comment.