ReactOS  0.4.13-dev-687-g023794c
halinit.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS HAL
3  * LICENSE: GPL - See COPYING in the top level directory
4  * FILE: hal/halx86/generic/halinit.c
5  * PURPOSE: HAL Entrypoint and Initialization
6  * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
7  */
8 
9 /* INCLUDES ******************************************************************/
10 
11 #include <hal.h>
12 #define NDEBUG
13 #include <debug.h>
14 
15 INIT_FUNCTION
16 VOID
17 NTAPI
19  IN PLOADER_PARAMETER_BLOCK LoaderBlock
20 );
21 
22 #if defined(ALLOC_PRAGMA) && !defined(_MINIHAL_)
23 #pragma alloc_text(INIT, HalInitSystem)
24 #pragma alloc_text(INIT, HalpGetParameters)
25 #endif
26 
27 /* GLOBALS *******************************************************************/
28 
30 
31 /* PRIVATE FUNCTIONS *********************************************************/
32 
33 INIT_FUNCTION
34 VOID
35 NTAPI
37 {
38  PCHAR CommandLine;
39 
40  /* Make sure we have a loader block and command line */
41  if ((LoaderBlock) && (LoaderBlock->LoadOptions))
42  {
43  /* Read the command line */
44  CommandLine = LoaderBlock->LoadOptions;
45 
46  /* Check if PCI is locked */
47  if (strstr(CommandLine, "PCILOCK")) HalpPciLockSettings = TRUE;
48 
49  /* Check for initial breakpoint */
50  if (strstr(CommandLine, "BREAK")) DbgBreakPoint();
51  }
52 }
53 
54 /* FUNCTIONS *****************************************************************/
55 
56 VOID
57 NTAPI
59  IN ULONG ProcessorNumber,
60  IN PLOADER_PARAMETER_BLOCK LoaderBlock)
61 {
62  /* Hal specific initialization for this cpu */
63  HalpInitProcessor(ProcessorNumber, LoaderBlock);
64 
65  /* Set default stall count */
66  KeGetPcr()->StallScaleFactor = INITIAL_STALL_COUNT;
67 
68  /* Update the interrupt affinity and processor mask */
71  ProcessorNumber);
72 
73  /* Register routines for KDCOM */
75 }
76 
77 /*
78  * @implemented
79  */
80 INIT_FUNCTION
81 BOOLEAN
82 NTAPI
84  IN PLOADER_PARAMETER_BLOCK LoaderBlock)
85 {
86  PKPRCB Prcb = KeGetCurrentPrcb();
87 
88  /* Check the boot phase */
89  if (BootPhase == 0)
90  {
91  /* Phase 0... save bus type */
92  HalpBusType = LoaderBlock->u.I386.MachineType & 0xFF;
93 
94  /* Get command-line parameters */
95  HalpGetParameters(LoaderBlock);
96 
97  /* Check for PRCB version mismatch */
98  if (Prcb->MajorVersion != PRCB_MAJOR_VERSION)
99  {
100  /* No match, bugcheck */
101  KeBugCheckEx(MISMATCHED_HAL, 1, Prcb->MajorVersion, PRCB_MAJOR_VERSION, 0);
102  }
103 
104  /* Checked/free HAL requires checked/free kernel */
105  if (Prcb->BuildType != HalpBuildType)
106  {
107  /* No match, bugcheck */
108  KeBugCheckEx(MISMATCHED_HAL, 2, Prcb->BuildType, HalpBuildType, 0);
109  }
110 
111  /* Initialize ACPI */
112  HalpSetupAcpiPhase0(LoaderBlock);
113 
114  /* Initialize the PICs */
116 
117  /* Initialize CMOS lock */
119 
120  /* Initialize CMOS */
122 
123  /* Fill out the dispatch tables */
128 
129  HalGetInterruptTranslator = NULL; // FIXME: TODO
132 
133  /* Setup I/O space */
136 
137  /* Setup busy waiting */
139 
140  /* Initialize the clock */
142 
143  /*
144  * We could be rebooting with a pending profile interrupt,
145  * so clear it here before interrupts are enabled
146  */
148 
149  /* Do some HAL-specific initialization */
150  HalpInitPhase0(LoaderBlock);
151  }
152  else if (BootPhase == 1)
153  {
154  /* Initialize bus handlers */
156 
157  /* Do some HAL-specific initialization */
158  HalpInitPhase1();
159  }
160 
161  /* All done, return */
162  return TRUE;
163 }
signed char * PCHAR
Definition: retypes.h:7
#define INITIAL_STALL_COUNT
Definition: processor.c:22
#define HalResetDisplay
Definition: halfuncs.h:45
LONG HalpActiveProcessors
Definition: processor.c:17
#define HalGetDmaAdapter
Definition: haltypes.h:291
#define IN
Definition: typedefs.h:38
#define TRUE
Definition: types.h:120
KAFFINITY HalpDefaultInterruptAffinity
Definition: processor.c:18
PADDRESS_USAGE HalpAddressUsageList
Definition: usage.c:59
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1062
VOID HalpCalibrateStallExecution(VOID)
Definition: hardware.c:102
#define HalGetInterruptTranslator
Definition: haltypes.h:292
NTSTATUS NTAPI HaliQuerySystemInformation(IN HAL_QUERY_INFORMATION_CLASS InformationClass, IN ULONG BufferSize, IN OUT PVOID Buffer, OUT PULONG ReturnedLength)
Definition: sysinfo.c:19
#define HalQuerySystemInformation
Definition: haltypes.h:283
BOOLEAN NTAPI HalpBiosDisplayReset(VOID)
Definition: x86bios.c:269
VOID NTAPI HaliHaltSystem(VOID)
Definition: processor.c:22
BOOLEAN HalpPciLockSettings
Definition: halinit.c:18
void DbgBreakPoint()
Definition: mach.c:558
VOID NTAPI HalpGetParameters(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: halinit.c:21
#define HalSetSystemInformation
Definition: haltypes.h:284
#define KeGetPcr()
Definition: ke.h:25
VOID HalpInitPhase1(VOID)
Definition: halinit_up.c:26
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
INIT_FUNCTION VOID NTAPI HalpInitializeCmos(VOID)
Definition: cmos.c:160
NTSTATUS NTAPI HaliSetSystemInformation(IN HAL_SET_INFORMATION_CLASS InformationClass, IN ULONG BufferSize, IN OUT PVOID Buffer)
Definition: sysinfo.c:31
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:251
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
INIT_FUNCTION VOID NTAPI HalpInitBusHandlers(VOID)
Definition: halacpi.c:935
VOID HalpInitPhase0(PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: halinit_mp.c:31
#define InterlockedBitTestAndSet
Definition: interlocked.h:30
ULONG HalpBusType
Definition: bus.c:17
VOID NTAPI HalpInitProcessor(IN ULONG ProcessorNumber, IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: halinit_apic.c:28
#define HalHaltSystem
Definition: halfuncs.h:43
VOID HalpInitializeClock(VOID)
Definition: timer.c:54
const USHORT HalpBuildType
Definition: halinit_apic.c:22
UCHAR BuildType
Definition: ketypes.h:599
VOID NTAPI HalpRegisterKdSupportFunctions(VOID)
Definition: bus.c:23
PDMA_ADAPTER NTAPI HalpGetDmaAdapter(IN PVOID Context, IN PDEVICE_DESCRIPTION DeviceDescription, OUT PULONG NumberOfMapRegisters)
Definition: dma.c:790
ADDRESS_USAGE HalpDefaultIoSpace
Definition: usage.c:81
USHORT MajorVersion
Definition: ketypes.h:598
NTSTATUS NTAPI HaliInitPnpDriver(VOID)
Definition: halpnpdd.c:902
KSPIN_LOCK HalpSystemHardwareLock
Definition: cmos.c:18
unsigned int ULONG
Definition: retypes.h:1
VOID NTAPI HalStopProfileInterrupt(IN KPROFILE_SOURCE ProfileSource)
Definition: profil.c:22
struct _HalAddressUsage * Next
Definition: halp.h:538
BOOLEAN NTAPI HalInitSystem(IN ULONG BootPhase, IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: halinit.c:43
signed int * PLONG
Definition: retypes.h:5
#define HalInitPnpDriver
Definition: haltypes.h:289
#define PRCB_MAJOR_VERSION
Definition: ketypes.h:241
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:107
VOID NTAPI HalpInitializePICs(IN BOOLEAN EnableInterrupts)
Definition: apic.c:445
VOID NTAPI HalInitializeProcessor(IN ULONG ProcessorNumber, IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: halinit.c:58
INIT_FUNCTION NTSTATUS NTAPI HalpSetupAcpiPhase0(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: halacpi.c:792