ReactOS  0.4.15-dev-2720-g5ee0925
halinit.c File Reference
#include <hal.h>
#include "apicp.h"
#include <debug.h>
Include dependency graph for halinit.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.c.

Function Documentation

◆ ApicInitializeLocalApic()

VOID NTAPI ApicInitializeLocalApic ( ULONG  Cpu)

Definition at line 256 of file apic.c.

257 {
258  APIC_BASE_ADRESS_REGISTER BaseRegister;
259  APIC_SPURIOUS_INERRUPT_REGISTER SpIntRegister;
260  LVT_REGISTER LvtEntry;
261 
262  /* Enable the APIC if it wasn't yet */
263  BaseRegister.LongLong = __readmsr(MSR_APIC_BASE);
264  BaseRegister.Enable = 1;
265  BaseRegister.BootStrapCPUCore = (Cpu == 0);
266  __writemsr(MSR_APIC_BASE, BaseRegister.LongLong);
267 
268  /* Set spurious vector and SoftwareEnable to 1 */
269  SpIntRegister.Long = ApicRead(APIC_SIVR);
270  SpIntRegister.Vector = APIC_SPURIOUS_VECTOR;
271  SpIntRegister.SoftwareEnable = 1;
272  SpIntRegister.FocusCPUCoreChecking = 0;
273  ApicWrite(APIC_SIVR, SpIntRegister.Long);
274 
275  /* Read the version and save it globally */
276  if (Cpu == 0) ApicVersion = ApicRead(APIC_VER);
277 
278  /* Set the mode to flat (max 8 CPUs supported!) */
280 
281  /* Set logical apic ID */
282  ApicWrite(APIC_LDR, ApicLogicalId(Cpu) << 24);
283 
284  /* Set the spurious ISR */
286 
287  /* Create a template LVT */
288  LvtEntry.Long = 0;
289  LvtEntry.Vector = 0xFF;
290  LvtEntry.MessageType = APIC_MT_Fixed;
291  LvtEntry.DeliveryStatus = 0;
292  LvtEntry.RemoteIRR = 0;
293  LvtEntry.TriggerMode = APIC_TGM_Edge;
294  LvtEntry.Mask = 1;
295  LvtEntry.TimerMode = 0;
296 
297  /* Initialize and mask LVTs */
298  ApicWrite(APIC_TMRLVTR, LvtEntry.Long);
299  ApicWrite(APIC_THRMLVTR, LvtEntry.Long);
300  ApicWrite(APIC_PCLVTR, LvtEntry.Long);
301  ApicWrite(APIC_EXT0LVTR, LvtEntry.Long);
302  ApicWrite(APIC_EXT1LVTR, LvtEntry.Long);
303  ApicWrite(APIC_EXT2LVTR, LvtEntry.Long);
304  ApicWrite(APIC_EXT3LVTR, LvtEntry.Long);
305 
306  /* LINT0 */
307  LvtEntry.Vector = APIC_SPURIOUS_VECTOR;
308  LvtEntry.MessageType = APIC_MT_ExtInt;
309  ApicWrite(APIC_LINT0, LvtEntry.Long);
310 
311  /* Enable LINT1 (NMI) */
312  LvtEntry.Mask = 0;
313  LvtEntry.Vector = APIC_NMI_VECTOR;
314  LvtEntry.MessageType = APIC_MT_NMI;
315  LvtEntry.TriggerMode = APIC_TGM_Level;
316  ApicWrite(APIC_LINT1, LvtEntry.Long);
317 
318  /* Enable error LVTR */
319  LvtEntry.Vector = APIC_ERROR_VECTOR;
320  LvtEntry.MessageType = APIC_MT_Fixed;
321  ApicWrite(APIC_ERRLVTR, LvtEntry.Long);
322 
323  /* Set the IRQL from the PCR */
325 #ifdef APIC_LAZY_IRQL
326  /* Save the new hard IRQL in the IRR field */
327  KeGetPcr()->IRR = KeGetPcr()->Irql;
328 #endif
329 }
#define APIC_PCLVTR
Definition: apicp.h:95
UINT32 Vector
Definition: apicp.h:252
UINT32 DeliveryStatus
Definition: apicp.h:255
#define APIC_NMI_VECTOR
Definition: apicp.h:51
ULONG ApicVersion
Definition: apic.c:27
#define APIC_EXT1LVTR
Definition: apicp.h:106
_Out_ PKIRQL Irql
Definition: csq.h:179
#define APIC_SPURIOUS_VECTOR
Definition: apicp.h:40
#define KeGetPcr()
Definition: ke.h:26
#define ApicLogicalId(Cpu)
Definition: apicp.h:113
#define APIC_VER
Definition: apic.h:11
#define APIC_LINT1
Definition: apic.h:29
UINT32 Long
Definition: apicp.h:249
#define APIC_DFR
Definition: apic.h:17
#define APIC_EXT2LVTR
Definition: apicp.h:107
#define APIC_SIVR
Definition: apic.h:18
PPC_QUAL unsigned long long __readmsr()
Definition: intrin_ppc.h:741
UINT32 TimerMode
Definition: apicp.h:260
#define APIC_EXT0LVTR
Definition: apicp.h:105
UINT32 Mask
Definition: apicp.h:259
#define MSR_APIC_BASE
Definition: apicp.h:110
UINT32 RemoteIRR
Definition: apicp.h:257
UINT32 MessageType
Definition: apicp.h:253
#define APIC_ERROR_VECTOR
Definition: apicp.h:47
#define APIC_EXT3LVTR
Definition: apicp.h:108
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:297
FORCEINLINE ULONG ApicRead(ULONG Offset)
Definition: apicp.h:307
#define APIC_LINT0
Definition: apic.h:28
#define APIC_ERRLVTR
Definition: apicp.h:98
#define APIC_THRMLVTR
Definition: apicp.h:94
FORCEINLINE VOID ApicSetIrql(KIRQL Irql)
Definition: apic.c:186
#define APIC_TMRLVTR
Definition: apicp.h:93
VOID __cdecl ApicSpuriousService(VOID)
FORCEINLINE VOID ApicWrite(ULONG Offset, ULONG Value)
Definition: apicp.h:314
UINT32 TriggerMode
Definition: apicp.h:258
#define APIC_LDR
Definition: apic.h:16

Referenced by HalpInitProcessor().

◆ HalpInitPhase0()

VOID HalpInitPhase0 ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 42 of file halinit.c.

43 {
44 
45  /* Enable clock interrupt handler */
47  0,
51  Latched);
52 }
#define APIC_CLOCK_VECTOR
Definition: apicp.h:44
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

Referenced by HalInitSystem().

◆ HalpInitPhase1()

VOID HalpInitPhase1 ( VOID  )

Definition at line 55 of file halinit.c.

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

Referenced by HalInitSystem().

◆ HalpInitProcessor()

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

Definition at line 27 of file halinit.c.

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

Referenced by HalInitializeProcessor().

Variable Documentation

◆ HalpBuildType

const USHORT HalpBuildType = HAL_BUILD_TYPE

Definition at line 21 of file halinit.c.

Referenced by HalInitSystem().