From 25d36eecf29962ec6bb0a2adb8e508ad128ff83b Mon Sep 17 00:00:00 2001 From: Justin Miller Date: Sat, 28 Sep 2024 06:14:11 -0700 Subject: [PATCH] Address some comments --- hal/halx86/acpi/madt.c | 32 ++++++++++++++++---------------- hal/halx86/apic/apic.c | 2 +- hal/halx86/apic/apicsmp.c | 2 +- hal/halx86/apic/halinit.c | 3 +-- hal/halx86/pic/pic.c | 2 +- 5 files changed, 20 insertions(+), 21 deletions(-) diff --git a/hal/halx86/acpi/madt.c b/hal/halx86/acpi/madt.c index 174ff4cbec5d5..80754a3b10ff5 100644 --- a/hal/halx86/acpi/madt.c +++ b/hal/halx86/acpi/madt.c @@ -26,13 +26,12 @@ HALP_APIC_INFO_TABLE HalpApicInfoTable; #define LAPIC_FLAG_ONLINE_CAPABLE 0x00000002 // Bits 2-31 are reserved. -static PROCESSOR_IDENTITY HalpStaticProcessorIdentity[MAXIMUM_PROCESSORS]; -PPROCESSOR_IDENTITY HalpProcessorIdentity; +PROCESSOR_IDENTITY HalpProcessorIdentity[MAXIMUM_PROCESSORS]; extern ULONG HalpPicVectorRedirect[16]; ULONG -HalpGetCurrentProcessorHwID(); +HalpGetCurrentProcessorHwID(VOID); /* FUNCTIONS ******************************************************************/ @@ -45,17 +44,16 @@ HalpParseApicTables( ACPI_SUBTABLE_HEADER *AcpiHeader; ULONG_PTR TableEnd; - HalpProcessorIdentity = HalpStaticProcessorIdentity; MadtTable = HalAcpiGetTable(LoaderBlock, APIC_SIGNATURE); if (!MadtTable) { - DPRINT("MADT table not found\n"); + DPRINT1("MADT table not found\n"); return; } if (MadtTable->Header.Length < sizeof(*MadtTable)) { - DPRINT("Length is too short: %p, %u\n", MadtTable, MadtTable->Header.Length); + DPRINT1("Length is too short: %p, %u\n", MadtTable, MadtTable->Header.Length); return; } @@ -71,13 +69,13 @@ HalpParseApicTables( { if (AcpiHeader->Length < sizeof(*AcpiHeader)) { - DPRINT("Length is too short: %p, %u\n", AcpiHeader, AcpiHeader->Length); + DPRINT1("Length is too short: %p, %u\n", AcpiHeader, AcpiHeader->Length); return; } if ((ULONG_PTR)AcpiHeader + AcpiHeader->Length > TableEnd) { - DPRINT("Length mismatch: %p, %u, %p\n", + DPRINT1("Length mismatch: %p, %u, %p\n", AcpiHeader, AcpiHeader->Length, (PVOID)TableEnd); return; } @@ -90,7 +88,7 @@ HalpParseApicTables( if (AcpiHeader->Length != sizeof(*LocalApic)) { - DPRINT("Type/Length mismatch: %p, %u\n", AcpiHeader, AcpiHeader->Length); + DPRINT1("Type/Length mismatch: %p, %u\n", AcpiHeader, AcpiHeader->Length); return; } @@ -104,9 +102,9 @@ HalpParseApicTables( break; } - if (HalpApicInfoTable.ProcessorCount == _countof(HalpStaticProcessorIdentity)) + if (HalpApicInfoTable.ProcessorCount == MAXIMUM_PROCESSORS) { - DPRINT(" Skipped: array is full\n"); + DPRINT1(" Skipped: array is full\n"); // We assume ignoring this processor is acceptable, until proven otherwise. break; } @@ -133,7 +131,7 @@ HalpParseApicTables( if (AcpiHeader->Length != sizeof(*IoApic)) { - DPRINT("Type/Length mismatch: %p, %u\n", AcpiHeader, AcpiHeader->Length); + DPRINT1("Type/Length mismatch: %p, %u\n", AcpiHeader, AcpiHeader->Length); return; } @@ -143,7 +141,7 @@ HalpParseApicTables( // Ensure HalpApicInfoTable.IOAPICCount consistency. if (HalpApicInfoTable.IoApicPA[IoApic->Id] != 0) { - DPRINT("Id duplication: %p, %u\n", IoApic, IoApic->Id); + DPRINT1("Id duplication: %p, %u\n", IoApic, IoApic->Id); return; } @@ -162,7 +160,7 @@ HalpParseApicTables( if (AcpiHeader->Length != sizeof(*InterruptOverride)) { - DPRINT("Type/Length mismatch: %p, %u\n", AcpiHeader, AcpiHeader->Length); + DPRINT1("Type/Length mismatch: %p, %u\n", AcpiHeader, AcpiHeader->Length); return; } @@ -176,7 +174,7 @@ HalpParseApicTables( if (InterruptOverride->Bus != 0) // 0 = ISA { - DPRINT("Invalid Bus: %p, %u\n", InterruptOverride, InterruptOverride->Bus); + DPRINT1("Invalid Bus: %p, %u\n", InterruptOverride, InterruptOverride->Bus); return; } @@ -184,7 +182,7 @@ HalpParseApicTables( } default: { - DPRINT(" UNIMPLEMENTED: Type %u, Length %u\n", + DPRINT1(" UNIMPLEMENTED: Type %u, Length %u\n", AcpiHeader->Type, AcpiHeader->Length); return; } @@ -198,6 +196,8 @@ HalpParseApicTables( DPRINT("Length mismatch: %p, %p, %p\n", MadtTable, AcpiHeader, (PVOID)TableEnd); return; } + + HalpPrintApicTables(); } VOID diff --git a/hal/halx86/apic/apic.c b/hal/halx86/apic/apic.c index 5e3b9ef13061f..3d49bf0e46b56 100644 --- a/hal/halx86/apic/apic.c +++ b/hal/halx86/apic/apic.c @@ -28,7 +28,7 @@ ULONG ApicVersion; UCHAR HalpVectorToIndex[256]; ULONG -HalpGetCurrentProcessorHwID() +HalpGetCurrentProcessorHwID(VOID) { return ApicRead(APIC_ID); } diff --git a/hal/halx86/apic/apicsmp.c b/hal/halx86/apic/apicsmp.c index 5165a367156c0..ffb7f00d9370b 100644 --- a/hal/halx86/apic/apicsmp.c +++ b/hal/halx86/apic/apicsmp.c @@ -16,7 +16,7 @@ #include -extern PPROCESSOR_IDENTITY HalpProcessorIdentity; +extern PROCESSOR_IDENTITY HalpProcessorIdentity[MAXIMUM_PROCESSORS]; /* INTERNAL FUNCTIONS *********************************************************/ diff --git a/hal/halx86/apic/halinit.c b/hal/halx86/apic/halinit.c index 9461b6d8f1a26..b0521ddb47d56 100644 --- a/hal/halx86/apic/halinit.c +++ b/hal/halx86/apic/halinit.c @@ -44,9 +44,8 @@ HalpInitPhase0(IN PLOADER_PARAMETER_BLOCK LoaderBlock) (HalpBuildType & PRCB_BUILD_UNIPROCESSOR) ? "UP" : "SMP", (HalpBuildType & PRCB_BUILD_DEBUG) ? "DBG" : "REL"); - /* This works as InitPhase0 happens before secondary processors are spun-up.*/ + /* This works because InitPhase0 happens before secondary processors are spun-up */ HalpParseApicTables(LoaderBlock); - HalpPrintApicTables(); /* Enable clock interrupt handler */ HalpEnableInterruptHandler(IDT_INTERNAL, diff --git a/hal/halx86/pic/pic.c b/hal/halx86/pic/pic.c index 663ab85f23aa4..616843db4196f 100644 --- a/hal/halx86/pic/pic.c +++ b/hal/halx86/pic/pic.c @@ -18,7 +18,7 @@ HalpEndSoftwareInterrupt(IN KIRQL OldIrql, IN PKTRAP_FRAME TrapFrame); ULONG -HalpGetCurrentProcessorHwID() +HalpGetCurrentProcessorHwID(VOID) { return 0; }