ReactOS 0.4.15-dev-7942-gd23573b
spinup.c File Reference
#include <hal.h>
#include <smp.h>
#include <debug.h>
Include dependency graph for spinup.c:

Go to the source code of this file.

Classes

struct  _AP_ENTRY_DATA
 

Macros

#define NDEBUG
 
#define Add2Ptr(P, I)   ((PVOID)((PUCHAR)(P) + (I)))
 
#define PtrOffset(B, O)   ((ULONG)((ULONG_PTR)(O) - (ULONG_PTR)(B)))
 

Typedefs

typedef struct _AP_ENTRY_DATA AP_ENTRY_DATA
 
typedef struct _AP_ENTRY_DATAPAP_ENTRY_DATA
 

Functions

static ULONG HalpSetupTemporaryMappings (_In_ PKPROCESSOR_STATE ProcessorState)
 
BOOLEAN NTAPI HalStartNextProcessor (_In_ PLOADER_PARAMETER_BLOCK LoaderBlock, _In_ PKPROCESSOR_STATE ProcessorState)
 

Variables

PPROCESSOR_IDENTITY HalpProcessorIdentity
 
PHYSICAL_ADDRESS HalpLowStubPhysicalAddress
 
PVOID HalpLowStub
 
PVOID HalpAPEntry16
 
PVOID HalpAPEntryData
 
PVOID HalpAPEntry32
 
PVOID HalpAPEntry16End
 
HALP_APIC_INFO_TABLE HalpApicInfoTable
 
ULONG HalpStartedProcessorCount = 1
 

Macro Definition Documentation

◆ Add2Ptr

#define Add2Ptr (   P,
  I 
)    ((PVOID)((PUCHAR)(P) + (I)))

Definition at line 33 of file spinup.c.

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file spinup.c.

◆ PtrOffset

#define PtrOffset (   B,
  O 
)    ((ULONG)((ULONG_PTR)(O) - (ULONG_PTR)(B)))

Definition at line 36 of file spinup.c.

Typedef Documentation

◆ AP_ENTRY_DATA

◆ PAP_ENTRY_DATA

Function Documentation

◆ HalpSetupTemporaryMappings()

static ULONG HalpSetupTemporaryMappings ( _In_ PKPROCESSOR_STATE  ProcessorState)
static

Definition at line 54 of file spinup.c.

56{
57 PMMPDE RootPageTable = Add2Ptr(HalpLowStub, PAGE_SIZE);
58 PMMPDE LowMapPde = Add2Ptr(HalpLowStub, 2 * PAGE_SIZE);
59 PMMPTE LowStubPte = MiAddressToPte(HalpLowStub);
61 ULONG StartPti;
62
63 /* Copy current mappings */
65
66 /* Set up low PDE */
69 RootPageTable[0].u.Hard.Valid = 1;
70 RootPageTable[0].u.Hard.Write = 1;
71
72 /* Copy low stub PTEs */
74 ASSERT(StartPti + HALP_LOW_STUB_SIZE_IN_PAGES < 1024);
75 for (ULONG i = 0; i < HALP_LOW_STUB_SIZE_IN_PAGES; i++)
76 {
77 LowMapPde[StartPti + i] = LowStubPte[i];
78 }
79
81 ASSERT(PhysicalAddress.QuadPart < 0x100000000);
83}
#define NULL
Definition: types.h:112
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define HALP_LOW_STUB_SIZE_IN_PAGES
Definition: halp.h:67
#define Add2Ptr(P, I)
Definition: spinup.c:33
PVOID HalpLowStub
Definition: halacpi.c:32
PHYSICAL_ADDRESS HalpLowStubPhysicalAddress
Definition: halacpi.c:29
#define MiAddressToPte(x)
Definition: mmx86.c:19
#define MiAddressToPteOffset(x)
Definition: mmx86.c:21
#define MiAddressToPde(x)
Definition: mmx86.c:20
#define ASSERT(a)
Definition: mode.c:44
PHYSICAL_ADDRESS NTAPI MmGetPhysicalAddress(IN PVOID Address)
Definition: stubs.c:685
ULONG64 Valid
Definition: mmtypes.h:150
ULONG64 Write
Definition: mmtypes.h:170
ULONG64 PageFrameNumber
Definition: mmtypes.h:171
union _MMPTE::@2330 u
MMPTE_HARDWARE Hard
Definition: mmtypes.h:217
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint32_t ULONG
Definition: typedefs.h:59
LONGLONG QuadPart
Definition: typedefs.h:114
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS PhysicalAddress
Definition: iotypes.h:1098

Referenced by HalStartNextProcessor().

◆ HalStartNextProcessor()

BOOLEAN NTAPI HalStartNextProcessor ( _In_ PLOADER_PARAMETER_BLOCK  LoaderBlock,
_In_ PKPROCESSOR_STATE  ProcessorState 
)

Definition at line 87 of file spinup.c.

90{
92 return FALSE;
93
94 // Initalize the temporary page table
95 // TODO: clean it up after an AP boots successfully
96 ULONG initialCr3 = HalpSetupTemporaryMappings(ProcessorState);
97 if (!initialCr3)
98 return FALSE;
99
100 // Put the bootstrap code into low memory
102
103 // Get a pointer to apEntryData
105
106 *apEntryData = (AP_ENTRY_DATA){
108 .Jump32Segment = (ULONG)ProcessorState->ContextFrame.SegCs,
109 .SelfPtr = (PVOID)apEntryData,
110 .PageTableRoot = initialCr3,
111 .ProcessorState = ProcessorState,
112 .Gdtr = ProcessorState->SpecialRegisters.Gdtr,
113 .Idtr = ProcessorState->SpecialRegisters.Idtr,
114 };
115
117
119
120 return TRUE;
121}
VOID ApicStartApplicationProcessor(_In_ ULONG NTProcessorNumber, _In_ PHYSICAL_ADDRESS StartupLoc)
Definition: apicsmp.c:110
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ULONG_PTR
Definition: config.h:101
ULONG HalpStartedProcessorCount
Definition: spinup.c:30
struct _AP_ENTRY_DATA AP_ENTRY_DATA
PVOID HalpAPEntryData
PVOID HalpAPEntry32
HALP_APIC_INFO_TABLE HalpApicInfoTable
Definition: madt.c:22
PVOID HalpAPEntry16
PVOID HalpAPEntry16End
static ULONG HalpSetupTemporaryMappings(_In_ PKPROCESSOR_STATE ProcessorState)
Definition: spinup.c:54
Definition: spinup.c:40
UINT32 Jump32Offset
Definition: spinup.c:41
ULONG ProcessorCount
Definition: smp.h:25
void * PVOID
Definition: typedefs.h:50
uint32_t ULONG_PTR
Definition: typedefs.h:65

Variable Documentation

◆ HalpAPEntry16

PVOID HalpAPEntry16
extern

Referenced by HalStartNextProcessor().

◆ HalpAPEntry16End

PVOID HalpAPEntry16End
extern

Referenced by HalStartNextProcessor().

◆ HalpAPEntry32

PVOID HalpAPEntry32
extern

Referenced by HalStartNextProcessor().

◆ HalpAPEntryData

PVOID HalpAPEntryData
extern

Referenced by HalStartNextProcessor().

◆ HalpApicInfoTable

HALP_APIC_INFO_TABLE HalpApicInfoTable
extern

Definition at line 22 of file madt.c.

Referenced by HalpParseApicTables(), HalpPrintApicTables(), and HalStartNextProcessor().

◆ HalpLowStub

PVOID HalpLowStub
extern

◆ HalpLowStubPhysicalAddress

PHYSICAL_ADDRESS HalpLowStubPhysicalAddress
extern

◆ HalpProcessorIdentity

PPROCESSOR_IDENTITY HalpProcessorIdentity
extern

Definition at line 21 of file madt.c.

◆ HalpStartedProcessorCount

ULONG HalpStartedProcessorCount = 1

Definition at line 30 of file spinup.c.

Referenced by HalStartNextProcessor().