ReactOS 0.4.16-dev-178-g8ba6102
smp.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _PROCESSOR_IDENTITY
 
struct  _HALP_APIC_INFO_TABLE
 

Macros

#define HALP_APIC_INFO_TABLE_IOAPIC_NUMBER   256
 
#define HALP_APIC_MODE_LEGACY   0x00000010
 

Typedefs

typedef struct _PROCESSOR_IDENTITY PROCESSOR_IDENTITY
 
typedef struct _PROCESSOR_IDENTITYPPROCESSOR_IDENTITY
 
typedef struct _HALP_APIC_INFO_TABLE HALP_APIC_INFO_TABLE
 
typedef struct _HALP_APIC_INFO_TABLEPHALP_APIC_INFO_TABLE
 

Functions

VOID HalpParseApicTables (_In_ PLOADER_PARAMETER_BLOCK LoaderBlock)
 
VOID HalpSetupProcessorsTable (_In_ UINT32 NTProcessorNumber)
 
VOID HalpPrintApicTables (VOID)
 
VOID FASTCALL HalpBroadcastClockIpi (_In_ UCHAR Vector)
 
VOID ApicStartApplicationProcessor (_In_ ULONG NTProcessorNumber, _In_ PHYSICAL_ADDRESS StartupLoc)
 
VOID NTAPI HalpRequestIpi (_In_ KAFFINITY TargetProcessors)
 Requests an IPI interrupt on the specified processors.
 
VOID NTAPI HalpBroadcastIpiSpecifyVector (_In_ UCHAR Vector, _In_ BOOLEAN IncludeSelf)
 Broadcasts an IPI with a specified vector to all processors.
 
VOID NTAPI HalRequestIpiSpecifyVector (_In_ KAFFINITY TargetSet, _In_ UCHAR Vector)
 Requests an IPI with a specified vector on the specified processors.
 

Macro Definition Documentation

◆ HALP_APIC_INFO_TABLE_IOAPIC_NUMBER

#define HALP_APIC_INFO_TABLE_IOAPIC_NUMBER   256

Definition at line 21 of file smp.h.

◆ HALP_APIC_MODE_LEGACY

#define HALP_APIC_MODE_LEGACY   0x00000010

Definition at line 35 of file smp.h.

Typedef Documentation

◆ HALP_APIC_INFO_TABLE

◆ PHALP_APIC_INFO_TABLE

◆ PPROCESSOR_IDENTITY

◆ PROCESSOR_IDENTITY

Function Documentation

◆ ApicStartApplicationProcessor()

VOID ApicStartApplicationProcessor ( _In_ ULONG  NTProcessorNumber,
_In_ PHYSICAL_ADDRESS  StartupLoc 
)

Definition at line 110 of file apicsmp.c.

113{
114 ASSERT(StartupLoc.HighPart == 0);
115 ASSERT((StartupLoc.QuadPart & 0xFFF) == 0);
116 ASSERT((StartupLoc.QuadPart & 0xFFF00FFF) == 0);
117
118 /* Init IPI */
119 ApicRequestGlobalInterrupt(HalpProcessorIdentity[NTProcessorNumber].LapicId, 0,
121
122 /* De-Assert Init IPI */
123 ApicRequestGlobalInterrupt(HalpProcessorIdentity[NTProcessorNumber].LapicId, 0,
125
126 /* Stall execution for a bit to give APIC time: MPS Spec - B.4 */
128
129 /* Startup IPI */
130 ApicRequestGlobalInterrupt(HalpProcessorIdentity[NTProcessorNumber].LapicId, (StartupLoc.LowPart) >> 12,
132}
@ APIC_DSH_Destination
Definition: apicp.h:152
@ APIC_MT_INIT
Definition: apicp.h:130
@ APIC_MT_Startup
Definition: apicp.h:131
@ APIC_TGM_Level
Definition: apicp.h:139
@ APIC_TGM_Edge
Definition: apicp.h:138
FORCEINLINE VOID ApicRequestGlobalInterrupt(_In_ UCHAR DestinationProcessor, _In_ UCHAR Vector, _In_ APIC_MT MessageType, _In_ APIC_TGM TriggerMode, _In_ APIC_DSH DestinationShortHand)
Definition: apicsmp.c:63
PPROCESSOR_IDENTITY HalpProcessorIdentity
Definition: madt.c:45
#define ASSERT(a)
Definition: mode.c:44
#define KeStallExecutionProcessor(MicroSeconds)
Definition: precomp.h:27

Referenced by HalStartNextProcessor().

◆ HalpBroadcastClockIpi()

VOID FASTCALL HalpBroadcastClockIpi ( _In_ UCHAR  Vector)

Definition at line 45 of file up.c.

47{
48 NOTHING;
49}
#define NOTHING
Definition: input_list.c:10

Referenced by HalpClockInterruptHandler().

◆ HalpBroadcastIpiSpecifyVector()

VOID NTAPI HalpBroadcastIpiSpecifyVector ( _In_ UCHAR  Vector,
_In_ BOOLEAN  IncludeSelf 
)

Broadcasts an IPI with a specified vector to all processors.

Parameters
Vector- Specifies the interrupt vector to be delivered.
IncludeSelf- Specifies whether to include the current processor.

Definition at line 144 of file apicsmp.c.

147{
148 APIC_DSH DestinationShortHand = IncludeSelf ?
150
151 /* Request the interrupt targeted at all processors */
152 ApicRequestGlobalInterrupt(0, // Ignored
153 Vector,
156 DestinationShortHand);
157}
@ APIC_DSH_AllIncludingSelf
Definition: apicp.h:154
@ APIC_DSH_AllExcludingSelf
Definition: apicp.h:155
@ APIC_MT_Fixed
Definition: apicp.h:125
enum _APIC_DSH APIC_DSH

Referenced by HalpBroadcastClockIpi(), and HalRequestIpiSpecifyVector().

◆ HalpParseApicTables()

VOID HalpParseApicTables ( _In_ PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 55 of file madt.c.

57{
58 ACPI_TABLE_MADT *MadtTable;
59 ACPI_SUBTABLE_HEADER *AcpiHeader;
60 ULONG_PTR TableEnd;
61
62 MadtTable = HalAcpiGetTable(LoaderBlock, APIC_SIGNATURE);
63 if (!MadtTable)
64 {
65 DPRINT01("MADT table not found\n");
66 return;
67 }
68
69 if (MadtTable->Header.Length < sizeof(*MadtTable))
70 {
71 DPRINT01("Length is too short: %p, %u\n", MadtTable, MadtTable->Header.Length);
72 return;
73 }
74
75 DPRINT00("MADT table: Address %08X, Flags %08X\n", MadtTable->Address, MadtTable->Flags);
76
77#if 1
78
79 // TODO: We support only legacy APIC for now
81 // TODO: What about 'MadtTable->Flags & ACPI_MADT_PCAT_COMPAT'?
82
83#else // TODO: Is that correct?
84
86 {
88 }
89 else // if ((MadtTable->Flags & ACPI_MADT_PCAT_COMPAT) == ACPI_MADT_MULTIPLE_APIC)
90 {
91#if 1
92 DPRINT01("ACPI_MADT_MULTIPLE_APIC support is UNIMPLEMENTED\n");
93 return;
94#else
95 HalpApicInfoTable.ApicMode = HALP_APIC_MODE_xyz;
96#endif
97 }
98
99#endif
100
102
103 AcpiHeader = (ACPI_SUBTABLE_HEADER *)((ULONG_PTR)MadtTable + sizeof(*MadtTable));
104 TableEnd = (ULONG_PTR)MadtTable + MadtTable->Header.Length;
105 DPRINT00(" MadtTable %p, subtables %p - %p\n", MadtTable, AcpiHeader, (PVOID)TableEnd);
106
107 while ((ULONG_PTR)(AcpiHeader + 1) <= TableEnd)
108 {
109 if (AcpiHeader->Length < sizeof(*AcpiHeader))
110 {
111 DPRINT01("Length is too short: %p, %u\n", AcpiHeader, AcpiHeader->Length);
112 return;
113 }
114
115 if ((ULONG_PTR)AcpiHeader + AcpiHeader->Length > TableEnd)
116 {
117 DPRINT01("Length mismatch: %p, %u, %p\n",
118 AcpiHeader, AcpiHeader->Length, (PVOID)TableEnd);
119 return;
120 }
121
122 switch (AcpiHeader->Type)
123 {
125 {
126 ACPI_MADT_LOCAL_APIC *LocalApic = (ACPI_MADT_LOCAL_APIC *)AcpiHeader;
127
128 if (AcpiHeader->Length != sizeof(*LocalApic))
129 {
130 DPRINT01("Type/Length mismatch: %p, %u\n", AcpiHeader, AcpiHeader->Length);
131 return;
132 }
133
134 DPRINT00(" Local Apic, Processor %lu: ProcessorId %u, Id %u, LapicFlags %08X\n",
136 LocalApic->ProcessorId, LocalApic->Id, LocalApic->LapicFlags);
137
139 {
140 DPRINT00(" Ignored: unusable\n");
141 break;
142 }
143
145 {
146 DPRINT00(" Skipped: array is full\n");
147 // We assume ignoring this processor is acceptable, until proven otherwise.
148 break;
149 }
150
151 // Note: ProcessorId and Id are not validated in any way (yet).
153 LocalApic->ProcessorId;
155
157
158 break;
159 }
161 {
162 ACPI_MADT_IO_APIC *IoApic = (ACPI_MADT_IO_APIC *)AcpiHeader;
163
164 if (AcpiHeader->Length != sizeof(*IoApic))
165 {
166 DPRINT01("Type/Length mismatch: %p, %u\n", AcpiHeader, AcpiHeader->Length);
167 return;
168 }
169
170 DPRINT00(" Io Apic: Id %u, Address %08X, GlobalIrqBase %08X\n",
171 IoApic->Id, IoApic->Address, IoApic->GlobalIrqBase);
172
173 // Ensure HalpApicInfoTable.IOAPICCount consistency.
174 if (HalpApicInfoTable.IoApicPA[IoApic->Id] != 0)
175 {
176 DPRINT01("Id duplication: %p, %u\n", IoApic, IoApic->Id);
177 return;
178 }
179
180 // Note: Address and GlobalIrqBase are not validated in any way (yet).
181 HalpApicInfoTable.IoApicPA[IoApic->Id] = IoApic->Address;
183
185
186 break;
187 }
189 {
190 ACPI_MADT_INTERRUPT_OVERRIDE *InterruptOverride =
191 (ACPI_MADT_INTERRUPT_OVERRIDE *)AcpiHeader;
192
193 if (AcpiHeader->Length != sizeof(*InterruptOverride))
194 {
195 DPRINT01("Type/Length mismatch: %p, %u\n", AcpiHeader, AcpiHeader->Length);
196 return;
197 }
198
199 DPRINT00(" Interrupt Override: Bus %u, SourceIrq %u, GlobalIrq %08X, IntiFlags %04X / UNIMPLEMENTED\n",
200 InterruptOverride->Bus, InterruptOverride->SourceIrq,
201 InterruptOverride->GlobalIrq, InterruptOverride->IntiFlags);
202
203 if (InterruptOverride->Bus != 0) // 0 = ISA
204 {
205 DPRINT01("Invalid Bus: %p, %u\n", InterruptOverride, InterruptOverride->Bus);
206 return;
207 }
208
209#if 1
210 // TODO: Implement it.
211#else // TODO: Is that correct?
212 if (InterruptOverride->SourceIrq > _countof(HalpPicVectorRedirect))
213 {
214 DPRINT01("Invalid SourceIrq: %p, %u\n",
215 InterruptOverride, InterruptOverride->SourceIrq);
216 return;
217 }
218
219 // Note: GlobalIrq is not validated in any way (yet).
220 HalpPicVectorRedirect[InterruptOverride->SourceIrq] = InterruptOverride->GlobalIrq;
221 // TODO: What about 'InterruptOverride->IntiFlags'?
222#endif
223
224 break;
225 }
226 default:
227 {
228 DPRINT01(" UNIMPLEMENTED: Type %u, Length %u\n",
229 AcpiHeader->Type, AcpiHeader->Length);
230 return;
231 }
232 }
233
234 AcpiHeader = (ACPI_SUBTABLE_HEADER *)((ULONG_PTR)AcpiHeader + AcpiHeader->Length);
235 }
236
237 if ((ULONG_PTR)AcpiHeader != TableEnd)
238 {
239 DPRINT01("Length mismatch: %p, %p, %p\n", MadtTable, AcpiHeader, (PVOID)TableEnd);
240 return;
241 }
242}
@ ACPI_MADT_TYPE_IO_APIC
Definition: actbl2.h:1006
@ ACPI_MADT_TYPE_INTERRUPT_OVERRIDE
Definition: actbl2.h:1007
@ ACPI_MADT_TYPE_LOCAL_APIC
Definition: actbl2.h:1005
#define ACPI_MADT_PCAT_COMPAT
Definition: actbl2.h:993
#define ACPI_MADT_DUAL_PIC
Definition: actbl2.h:997
#define ULONG_PTR
Definition: config.h:101
ULONG HalpPicVectorRedirect[]
Definition: halacpi.c:40
PVOID NTAPI HalAcpiGetTable(IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN ULONG Signature)
Definition: halacpi.c:446
HALP_APIC_INFO_TABLE HalpApicInfoTable
Definition: madt.c:37
#define DPRINT00(...)
Definition: madt.c:31
static PROCESSOR_IDENTITY HalpStaticProcessorIdentity[MAXIMUM_PROCESSORS]
Definition: madt.c:44
const PPROCESSOR_IDENTITY HalpProcessorIdentity
Definition: madt.c:45
#define DPRINT01(...)
Definition: madt.c:30
#define LAPIC_FLAG_ENABLED
Definition: madt.c:40
#define LAPIC_FLAG_ONLINE_CAPABLE
Definition: madt.c:41
#define APIC_SIGNATURE
Definition: acpi.h:33
#define HALP_APIC_MODE_LEGACY
Definition: smp.h:35
#define _countof(array)
Definition: sndvol32.h:70
ULONG ProcessorCount
Definition: smp.h:25
ULONG IoApicPA[HALP_APIC_INFO_TABLE_IOAPIC_NUMBER]
Definition: smp.h:29
ULONG IOAPICCount
Definition: smp.h:26
ULONG ApicMode
Definition: smp.h:24
ULONG IoApicIrqBase[HALP_APIC_INFO_TABLE_IOAPIC_NUMBER]
Definition: smp.h:30
ULONG LocalApicPA
Definition: smp.h:27
UCHAR ProcessorId
Definition: smp.h:13
UCHAR LapicId
Definition: smp.h:14
UINT32 Address
Definition: actbl2.h:1057
UINT32 GlobalIrqBase
Definition: actbl2.h:1058
UINT32 Length
Definition: actbl.h:109
ACPI_TABLE_HEADER Header
Definition: actbl2.h:985
UINT32 Address
Definition: actbl2.h:986
UINT32 Flags
Definition: actbl2.h:987
uint32_t ULONG_PTR
Definition: typedefs.h:65

Referenced by HalpInitProcessor().

◆ HalpPrintApicTables()

VOID HalpPrintApicTables ( VOID  )

Definition at line 245 of file madt.c.

246{
247#if DBG
248 ULONG i;
249
250 DPRINT1("Physical processor count: %lu\n", HalpApicInfoTable.ProcessorCount);
251 for (i = 0; i < HalpApicInfoTable.ProcessorCount; i++)
252 {
253 DPRINT1(" Processor %lu: ProcessorId %u, LapicId %u, ProcessorStarted %u, BSPCheck %u, ProcessorPrcb %p\n",
254 i,
255 HalpProcessorIdentity[i].ProcessorId,
256 HalpProcessorIdentity[i].LapicId,
257 HalpProcessorIdentity[i].ProcessorStarted,
258 HalpProcessorIdentity[i].BSPCheck,
259 HalpProcessorIdentity[i].ProcessorPrcb);
260 }
261#endif
262}
#define DPRINT1
Definition: precomp.h:8
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
uint32_t ULONG
Definition: typedefs.h:59

Referenced by HalpInitPhase0().

◆ HalpRequestIpi()

VOID NTAPI HalpRequestIpi ( _In_ KAFFINITY  TargetSet)

Requests an IPI interrupt on the specified processors.

Parameters
TargetSet- Specifies the set of processors to send the IPI to.

Definition at line 223 of file apicsmp.c.

225{
226 /* Request the IPI vector */
228}
#define APIC_IPI_VECTOR
Definition: apicp.h:47
VOID NTAPI HalRequestIpiSpecifyVector(_In_ KAFFINITY TargetSet, _In_ UCHAR Vector)
Requests an IPI with a specified vector on the specified processors.
Definition: apicsmp.c:169

Referenced by HalRequestIpi().

◆ HalpSetupProcessorsTable()

VOID HalpSetupProcessorsTable ( _In_ UINT32  NTProcessorNumber)

Definition at line 37 of file up.c.

39{
40 NOTHING;
41}

Referenced by HalpInitProcessor().

◆ HalRequestIpiSpecifyVector()

VOID NTAPI HalRequestIpiSpecifyVector ( _In_ KAFFINITY  TargetSet,
_In_ UCHAR  Vector 
)

Requests an IPI with a specified vector on the specified processors.

Parameters
TargetSet- Specifies the set of processors to send the IPI to.
Vector- Specifies the interrupt vector to be delivered.
Remarks
This function is exported on Windows 10.

Definition at line 169 of file apicsmp.c.

172{
173 KAFFINITY ActiveProcessors = HalpActiveProcessors;
174 KAFFINITY RemainingSet, SetMember;
175 ULONG ProcessorIndex;
176 ULONG LApicId;
177
178 /* Sanitize the target set */
179 TargetSet &= ActiveProcessors;
180
181 /* Check if all processors are requested */
182 if (TargetSet == ActiveProcessors)
183 {
184 /* Send an IPI to all processors, including this processor */
186 return;
187 }
188
189 /* Check if all processors except the current one are requested */
190 if (TargetSet == (ActiveProcessors & ~KeGetCurrentPrcb()->SetMember))
191 {
192 /* Send an IPI to all processors, excluding this processor */
194 return;
195 }
196
197 /* Loop while we have more processors */
198 RemainingSet = TargetSet;
199 while (RemainingSet != 0)
200 {
201 NT_VERIFY(BitScanForwardAffinity(&ProcessorIndex, RemainingSet) != 0);
202 ASSERT(ProcessorIndex < KeNumberProcessors);
203 SetMember = AFFINITY_MASK(ProcessorIndex);
204 RemainingSet &= ~SetMember;
205
206 /* Send the interrupt to the target processor */
207 LApicId = HalpProcessorIdentity[ProcessorIndex].LapicId;
209 Vector,
213 }
214}
VOID NTAPI HalpBroadcastIpiSpecifyVector(_In_ UCHAR Vector, _In_ BOOLEAN IncludeSelf)
Broadcasts an IPI with a specified vector to all processors.
Definition: apicsmp.c:144
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
ULONG_PTR KAFFINITY
Definition: compat.h:85
KAFFINITY HalpActiveProcessors
Definition: processor.c:17
CCHAR KeNumberProcessors
Definition: krnlinit.c:35
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1150
FORCEINLINE KAFFINITY AFFINITY_MASK(ULONG Index)
Definition: kefuncs.h:39
FORCEINLINE BOOLEAN BitScanForwardAffinity(PULONG Index, KAFFINITY Mask)
Definition: kefuncs.h:45
#define NT_VERIFY(exp)
Definition: rtlfuncs.h:3301

Referenced by HalpRequestIpi().