forked from reactos/reactos
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NTOS:KE][HALX86] Implement AP startup code
Co-authored-by: Victor Perevertkin <[email protected]>
- Loading branch information
1 parent
e627c3b
commit 9151d44
Showing
30 changed files
with
782 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,23 @@ | ||
/* | ||
* PROJECT: ReactOS HAL | ||
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later) | ||
* FILE: hal/halx86/apic/apicsmp.c | ||
* PURPOSE: SMP specific APIC code | ||
* PROGRAMMERS: Copyright 2021 Timo Kreuzer ([email protected]) | ||
* COPYRIGHT: Copyright 2021 Timo Kreuzer <[email protected]> | ||
* Copyright 2023 Justin Miller <[email protected]> | ||
*/ | ||
|
||
/* INCLUDES *******************************************************************/ | ||
|
||
#include <hal.h> | ||
#include "apicp.h" | ||
#include <smp.h> | ||
|
||
#define NDEBUG | ||
#include <debug.h> | ||
|
||
|
||
extern PPROCESSOR_IDENTITY HalpProcessorIdentity; | ||
|
||
/* INTERNAL FUNCTIONS *********************************************************/ | ||
|
||
/*! | ||
|
@@ -36,7 +41,7 @@ | |
local APIC(s) specified in Destination field. Vector specifies | ||
the startup address. | ||
APIC_MT_ExtInt - Delivers an external interrupt to the target local | ||
APIC specified in Destination field. | ||
APIC specified in Destination field. | ||
\param TriggerMode - The trigger mode of the interrupt. Can be: | ||
APIC_TGM_Edge - The interrupt is edge triggered. | ||
|
@@ -64,6 +69,12 @@ ApicRequestGlobalInterrupt( | |
{ | ||
APIC_INTERRUPT_COMMAND_REGISTER Icr; | ||
|
||
/* Wait for the APIC to be idle */ | ||
do | ||
{ | ||
Icr.Long0 = ApicRead(APIC_ICR0); | ||
} while (Icr.DeliveryStatus); | ||
|
||
/* Setup the command register */ | ||
Icr.LongLong = 0; | ||
Icr.Vector = Vector; | ||
|
@@ -84,13 +95,35 @@ ApicRequestGlobalInterrupt( | |
|
||
/* SMP SUPPORT FUNCTIONS ******************************************************/ | ||
|
||
// Should be called by SMP version of HalRequestIpi | ||
VOID | ||
NTAPI | ||
HalpRequestIpi(KAFFINITY TargetProcessors) | ||
HalpRequestIpi(_In_ KAFFINITY TargetProcessors) | ||
{ | ||
UNIMPLEMENTED; | ||
__debugbreak(); | ||
} | ||
|
||
// APIC specific SMP code here | ||
VOID | ||
ApicStartApplicationProcessor( | ||
_In_ ULONG NTProcessorNumber, | ||
_In_ PHYSICAL_ADDRESS StartupLoc) | ||
{ | ||
ASSERT(StartupLoc.HighPart == 0); | ||
ASSERT((StartupLoc.QuadPart & 0xFFF) == 0); | ||
ASSERT((StartupLoc.QuadPart & 0xFFF00FFF) == 0); | ||
|
||
/* Init IPI */ | ||
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); | ||
|
||
/* Startup IPI */ | ||
ApicRequestGlobalInterrupt(HalpProcessorIdentity[NTProcessorNumber].LapicId, (StartupLoc.LowPart) >> 12, | ||
APIC_MT_Startup, APIC_TGM_Edge, APIC_DSH_Destination); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* PROJECT: ReactOS Kernel | ||
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later) | ||
* PURPOSE: Core source file for Uniprocessor (UP) alternative functions | ||
* COPYRIGHT: Copyright 2021 Justin Miller <[email protected]> | ||
*/ | ||
|
||
/* INCLUDES ******************************************************************/ | ||
|
||
#include <hal.h> | ||
|
||
#define NDEBUG | ||
#include <debug.h> | ||
|
||
/* FUNCTIONS *****************************************************************/ | ||
|
||
VOID | ||
NTAPI | ||
HalRequestIpi( | ||
_In_ KAFFINITY TargetProcessors) | ||
{ | ||
/* This should never be called in UP mode */ | ||
__debugbreak(); | ||
} | ||
|
||
BOOLEAN | ||
NTAPI | ||
HalStartNextProcessor( | ||
_In_ PLOADER_PARAMETER_BLOCK LoaderBlock, | ||
_In_ PKPROCESSOR_STATE ProcessorState) | ||
{ | ||
/* Always return false on UP systems */ | ||
return FALSE; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* PROJECT: ReactOS Kernel | ||
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later) | ||
* PURPOSE: AMD64 Application Processor (AP) spinup setup | ||
* COPYRIGHT: Copyright 2021 Justin Miller <[email protected]> | ||
*/ | ||
|
||
#include <asm.inc> | ||
|
||
PUBLIC APEntry16 | ||
PUBLIC APEntry16End | ||
PUBLIC APEntry32 | ||
PUBLIC APEntryJump32Offset | ||
PUBLIC APEntryJump32Segment | ||
PUBLIC TempPageTableAddr | ||
PUBLIC APEntryCpuState | ||
|
||
.code | ||
APEntry16: | ||
cli | ||
|
||
xor ax, ax | ||
mov ds, ax | ||
mov ss, ax | ||
mov fs, ax | ||
mov gs, ax | ||
|
||
hlt | ||
|
||
APEntry16End: | ||
.long HEX(0) | ||
APEntry32: | ||
.long HEX(0) | ||
APEntryJump32Offset: | ||
.long HEX(0) | ||
APEntryJump32Segment: | ||
.long HEX(0) | ||
TempPageTableAddr: | ||
.long HEX(0) | ||
APEntryCpuState: | ||
.long HEX(0) | ||
|
||
END |
Oops, something went wrong.