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)
9 /* INCLUDES ******************************************************************/
19 IN PLOADER_PARAMETER_BLOCK LoaderBlock
22 #if defined(ALLOC_PRAGMA) && !defined(_MINIHAL_)
23 #pragma alloc_text(INIT, HalInitSystem)
24 #pragma alloc_text(INIT, HalpGetParameters)
27 /* GLOBALS *******************************************************************/
29 BOOLEAN HalpPciLockSettings
;
31 /* PRIVATE FUNCTIONS *********************************************************/
36 HalpGetParameters(IN PLOADER_PARAMETER_BLOCK LoaderBlock
)
40 /* Make sure we have a loader block and command line */
41 if ((LoaderBlock
) && (LoaderBlock
->LoadOptions
))
43 /* Read the command line */
44 CommandLine
= LoaderBlock
->LoadOptions
;
46 /* Check if PCI is locked */
47 if (strstr(CommandLine
, "PCILOCK")) HalpPciLockSettings
= TRUE
;
49 /* Check for initial breakpoint */
50 if (strstr(CommandLine
, "BREAK")) DbgBreakPoint();
54 /* FUNCTIONS *****************************************************************/
58 HalInitializeProcessor(
59 IN ULONG ProcessorNumber
,
60 IN PLOADER_PARAMETER_BLOCK LoaderBlock
)
62 /* Hal specific initialization for this cpu */
63 HalpInitProcessor(ProcessorNumber
, LoaderBlock
);
65 /* Set default stall count */
66 KeGetPcr()->StallScaleFactor
= INITIAL_STALL_COUNT
;
68 /* Update the interrupt affinity and processor mask */
69 InterlockedBitTestAndSet((PLONG
)&HalpActiveProcessors
, ProcessorNumber
);
70 InterlockedBitTestAndSet((PLONG
)&HalpDefaultInterruptAffinity
,
73 /* Register routines for KDCOM */
74 HalpRegisterKdSupportFunctions();
83 HalInitSystem(IN ULONG BootPhase
,
84 IN PLOADER_PARAMETER_BLOCK LoaderBlock
)
86 PKPRCB Prcb
= KeGetCurrentPrcb();
88 /* Check the boot phase */
91 /* Phase 0... save bus type */
92 HalpBusType
= LoaderBlock
->u
.I386
.MachineType
& 0xFF;
94 /* Get command-line parameters */
95 HalpGetParameters(LoaderBlock
);
97 /* Check for PRCB version mismatch */
98 if (Prcb
->MajorVersion
!= PRCB_MAJOR_VERSION
)
100 /* No match, bugcheck */
101 KeBugCheckEx(MISMATCHED_HAL
, 1, Prcb
->MajorVersion
, PRCB_MAJOR_VERSION
, 0);
104 /* Checked/free HAL requires checked/free kernel */
105 if (Prcb
->BuildType
!= HalpBuildType
)
107 /* No match, bugcheck */
108 KeBugCheckEx(MISMATCHED_HAL
, 2, Prcb
->BuildType
, HalpBuildType
, 0);
111 /* Initialize ACPI */
112 HalpSetupAcpiPhase0(LoaderBlock
);
114 /* Initialize the PICs */
115 HalpInitializePICs(TRUE
);
117 /* Initialize CMOS lock */
118 KeInitializeSpinLock(&HalpSystemHardwareLock
);
120 /* Initialize CMOS */
121 HalpInitializeCmos();
123 /* Fill out the dispatch tables */
124 HalQuerySystemInformation
= HaliQuerySystemInformation
;
125 HalSetSystemInformation
= HaliSetSystemInformation
;
126 HalInitPnpDriver
= HaliInitPnpDriver
;
127 HalGetDmaAdapter
= HalpGetDmaAdapter
;
129 HalGetInterruptTranslator
= NULL
; // FIXME: TODO
130 HalResetDisplay
= HalpBiosDisplayReset
;
131 HalHaltSystem
= HaliHaltSystem
;
133 /* Setup I/O space */
134 HalpDefaultIoSpace
.Next
= HalpAddressUsageList
;
135 HalpAddressUsageList
= &HalpDefaultIoSpace
;
137 /* Setup busy waiting */
138 HalpCalibrateStallExecution();
140 /* Initialize the clock */
141 HalpInitializeClock();
144 * We could be rebooting with a pending profile interrupt,
145 * so clear it here before interrupts are enabled
147 HalStopProfileInterrupt(ProfileTime
);
149 /* Do some HAL-specific initialization */
150 HalpInitPhase0(LoaderBlock
);
152 else if (BootPhase
== 1)
154 /* Initialize bus handlers */
155 HalpInitBusHandlers();
157 /* Do some HAL-specific initialization */
161 /* All done, return */