ReactOS  0.4.14-dev-376-gaedba84
halinit_apic.c File Reference
#include <hal.h>
#include <debug.h>
#include "apic.h"
Include dependency graph for halinit_apic.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

VOID NTAPI ApicInitializeLocalApic (ULONG Cpu)
 
VOID NTAPI HalpInitProcessor (IN ULONG ProcessorNumber, IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
VOID HalpInitPhase0 (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
VOID HalpInitPhase1 (VOID)
 

Variables

const USHORT HalpBuildType = HAL_BUILD_TYPE
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file halinit_apic.c.

Function Documentation

◆ ApicInitializeLocalApic()

VOID NTAPI ApicInitializeLocalApic ( ULONG  Cpu)

Definition at line 259 of file apic.c.

260 {
261  APIC_BASE_ADRESS_REGISTER BaseRegister;
262  APIC_SPURIOUS_INERRUPT_REGISTER SpIntRegister;
263  LVT_REGISTER LvtEntry;
264 
265  /* Enable the APIC if it wasn't yet */
266  BaseRegister.Long = __readmsr(MSR_APIC_BASE);
267  BaseRegister.Enable = 1;
268  BaseRegister.BootStrapCPUCore = (Cpu == 0);
269  __writemsr(MSR_APIC_BASE, BaseRegister.Long);
270 
271  /* Set spurious vector and SoftwareEnable to 1 */
272  SpIntRegister.Long = ApicRead(APIC_SIVR);
273  SpIntRegister.Vector = APIC_SPURIOUS_VECTOR;
274  SpIntRegister.SoftwareEnable = 1;
275  SpIntRegister.FocusCPUCoreChecking = 0;
276  ApicWrite(APIC_SIVR, SpIntRegister.Long);
277 
278  /* Read the version and save it globally */
279  if (Cpu == 0) ApicVersion = ApicRead(APIC_VER);
280 
281  /* Set the mode to flat (max 8 CPUs supported!) */
283 
284  /* Set logical apic ID */
285  ApicWrite(APIC_LDR, ApicLogicalId(Cpu) << 24);
286 
287  /* Set the spurious ISR */
289 
290  /* Create a template LVT */
291  LvtEntry.Long = 0;
292  LvtEntry.Vector = 0xFF;
293  LvtEntry.MessageType = APIC_MT_Fixed;
294  LvtEntry.DeliveryStatus = 0;
295  LvtEntry.RemoteIRR = 0;
296  LvtEntry.TriggerMode = APIC_TGM_Edge;
297  LvtEntry.Mask = 1;
298  LvtEntry.TimerMode = 0;
299 
300  /* Initialize and mask LVTs */
301  ApicWrite(APIC_TMRLVTR, LvtEntry.Long);
302  ApicWrite(APIC_THRMLVTR, LvtEntry.Long);
303  ApicWrite(APIC_PCLVTR, LvtEntry.Long);
304  ApicWrite(APIC_EXT0LVTR, LvtEntry.Long);
305  ApicWrite(APIC_EXT1LVTR, LvtEntry.Long);
306  ApicWrite(APIC_EXT2LVTR, LvtEntry.Long);
307  ApicWrite(APIC_EXT3LVTR, LvtEntry.Long);
308 
309  /* LINT0 */
310  LvtEntry.Vector = APIC_SPURIOUS_VECTOR;
311  LvtEntry.MessageType = APIC_MT_ExtInt;
312  ApicWrite(APIC_LINT0, LvtEntry.Long);
313 
314  /* Enable LINT1 (NMI) */
315  LvtEntry.Mask = 0;
316  LvtEntry.Vector = APIC_NMI_VECTOR;
317  LvtEntry.MessageType = APIC_MT_NMI;
318  LvtEntry.TriggerMode = APIC_TGM_Level;
319  ApicWrite(APIC_LINT1, LvtEntry.Long);
320 
321  /* Enable error LVTR */
322  LvtEntry.Vector = APIC_ERROR_VECTOR;
323  LvtEntry.MessageType = APIC_MT_Fixed;
324  ApicWrite(APIC_ERRLVTR, LvtEntry.Long);
325 
326  /* Set the IRQL from the PCR */
328 #ifdef APIC_LAZY_IRQL
329  /* Save the new hard IRQL in the IRR field */
330  KeGetPcr()->IRR = KeGetPcr()->Irql;
331 #endif
332 }
#define APIC_LDR
Definition: apic.h:16
ULONG Long
Definition: apic.h:209
ULONG TriggerMode
Definition: apic.h:218
ULONG Vector
Definition: apic.h:212
ULONG ApicVersion
Definition: apic.c:27
ULONG RemoteIRR
Definition: apic.h:217
_Out_ PKIRQL Irql
Definition: csq.h:179
#define ApicLogicalId(Cpu)
Definition: apic.h:45
#define KeGetPcr()
Definition: ke.h:25
PPC_QUAL unsigned long long __readmsr()
Definition: intrin_ppc.h:741
VOID __cdecl ApicSpuriousService(VOID)
#define APIC_DFR
Definition: apic.h:17
#define APIC_ERROR_VECTOR
Definition: apic.h:32
FORCEINLINE VOID ApicWrite(ULONG Offset, ULONG Value)
Definition: apic.h:272
#define APIC_EXT1LVTR
Definition: apic.h:77
#define APIC_PCLVTR
Definition: apic.h:66
ULONG MessageType
Definition: apic.h:213
#define APIC_LINT1
Definition: apic.h:29
ULONG Mask
Definition: apic.h:219
#define APIC_SPURIOUS_VECTOR
Definition: apic.h:25
#define APIC_ERRLVTR
Definition: apic.h:69
ULONG DeliveryStatus
Definition: apic.h:215
#define MSR_APIC_BASE
Definition: apic.h:41
ULONG TimerMode
Definition: apic.h:220
PPC_QUAL void __writemsr(const unsigned long Value)
Definition: intrin_ppc.h:748
FORCEINLINE VOID KeRegisterInterruptHandler(IN ULONG Vector, IN PVOID Handler)
Definition: ke.h:242
#define APIC_VER
Definition: apic.h:11
#define APIC_EXT3LVTR
Definition: apic.h:79
#define APIC_THRMLVTR
Definition: apic.h:65
ULONG64 BootStrapCPUCore
Definition: apic.h:138
FORCEINLINE VOID ApicSetIrql(KIRQL Irql)
Definition: apic.c:189
#define APIC_EXT2LVTR
Definition: apic.h:78
#define APIC_SIVR
Definition: apic.h:18
#define APIC_LINT0
Definition: apic.h:28
#define APIC_NMI_VECTOR
Definition: apic.h:35
FORCEINLINE ULONG ApicRead(ULONG Offset)
Definition: apic.h:265
#define APIC_EXT0LVTR
Definition: apic.h:76
#define APIC_TMRLVTR
Definition: apic.h:64

Referenced by HalpInitProcessor().

◆ HalpInitPhase0()

VOID HalpInitPhase0 ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 44 of file halinit_apic.c.

45 {
46 
47  /* Enable clock interrupt handler */
49  0,
53  Latched);
54 }
VOID NTAPI HalpEnableInterruptHandler(IN UCHAR Flags, IN ULONG BusVector, IN ULONG SystemVector, IN KIRQL Irql, IN PVOID Handler, IN KINTERRUPT_MODE Mode)
Definition: usage.c:49
#define CLOCK2_LEVEL
Definition: env_spec_w32.h:700
#define IDT_INTERNAL
Definition: halp.h:21
VOID HalpClockInterrupt(VOID)
Definition: timer.c:30
#define APIC_CLOCK_VECTOR
Definition: apic.h:29

◆ HalpInitPhase1()

VOID HalpInitPhase1 ( VOID  )

Definition at line 57 of file halinit_apic.c.

58 {
59  /* Initialize DMA. NT does this in Phase 0 */
60  HalpInitDma();
61 }
VOID HalpInitDma(VOID)
Definition: dma.c:121

◆ HalpInitProcessor()

VOID NTAPI HalpInitProcessor ( IN ULONG  ProcessorNumber,
IN PLOADER_PARAMETER_BLOCK  LoaderBlock 
)

Definition at line 28 of file halinit_apic.c.

31 {
32  /* Initialize the local APIC for this cpu */
33  ApicInitializeLocalApic(ProcessorNumber);
34 
35  /* Initialize profiling data (but don't start it) */
37 
38  /* Initialize the timer */
39  //ApicInitializeTimer(ProcessorNumber);
40 
41 }
VOID NTAPI ApicInitializeLocalApic(ULONG Cpu)
Definition: apic.c:259
VOID NTAPI HalInitializeProfiling(VOID)
Definition: apictimer.c:70

Referenced by HalInitializeProcessor().

Variable Documentation

◆ HalpBuildType

const USHORT HalpBuildType = HAL_BUILD_TYPE

Definition at line 22 of file halinit_apic.c.

Referenced by HalInitSystem().