Skip to content

Commit

Permalink
[HALX86] Address code review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkFire01 committed Nov 14, 2023
1 parent 07bc773 commit 680ba0b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
11 changes: 11 additions & 0 deletions hal/halx86/apic/apicsmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ ApicRequestGlobalInterrupt(
_In_ APIC_DSH DestinationShortHand)
{
APIC_INTERRUPT_COMMAND_REGISTER Icr;
APIC_INTERRUPT_COMMAND_REGISTER IcrStatus;

/* Wait for the APIC to be idle */
do
{
IcrStatus.Long0 = ApicRead(APIC_ICR0);
} while (IcrStatus.DeliveryStatus);

/* Setup the command register */
Icr.LongLong = 0;
Expand Down Expand Up @@ -107,6 +114,10 @@ ApicStartApplicationProcessor(ULONG NTProcessorNumber, PHYSICAL_ADDRESS StartupL
ApicRequestGlobalInterrupt(HalpProcessorIdentity[NTProcessorNumber].LapicId, 0,
APIC_MT_INIT, APIC_TGM_Edge, APIC_DSH_Destination);

/* De-Assert Init IPI */
ApicRequestGlobalInterrupt(HalpProcessorIdentity[NTProcessorNumber].LapicId, 0,
APIC_MT_INIT, APIC_TGM_Level, APIC_DSH_Destination);

/* Stall execution for a bit to give APIC time: MPS Spec - B.4 */
KeStallExecutionProcessor(200);

Expand Down
1 change: 0 additions & 1 deletion hal/halx86/smp/i386/spinup.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ HalStartNextProcessor(
_In_ PLOADER_PARAMETER_BLOCK LoaderBlock,
_In_ PKPROCESSOR_STATE ProcessorState)
{

/* Write KeLoaderBlock into Stack */
ProcessorState->ContextFrame.Esp = (ULONG)((ULONG_PTR)ProcessorState->ContextFrame.Esp - sizeof(AP_SETUP_STACK));
PAP_SETUP_STACK ApStack = (PAP_SETUP_STACK)ProcessorState->ContextFrame.Esp;
Expand Down
2 changes: 1 addition & 1 deletion ntoskrnl/ke/i386/mproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ KeStartAllProcessors(VOID)
KeLoaderBlock->Thread = (ULONG_PTR)&APInfo->Pcr.Prcb->IdleThread;

// Start the CPU
DPRINT("Starting CPU: #%u\n", ProcessorCount);
DPRINT("Attempting to Start a CPU with number: %u\n", ProcessorCount);
if (!HalStartNextProcessor(KeLoaderBlock, ProcessorState))
{
break;
Expand Down

0 comments on commit 680ba0b

Please sign in to comment.