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 ******************************************************************/
18 IN PLOADER_PARAMETER_BLOCK LoaderBlock
21 #if defined(ALLOC_PRAGMA) && !defined(_MINIHAL_)
22 #pragma alloc_text(INIT, HalInitSystem)
23 #pragma alloc_text(INIT, HalpGetParameters)
26 /* GLOBALS *******************************************************************/
28 BOOLEAN HalpPciLockSettings
;
30 /* PRIVATE FUNCTIONS *********************************************************/
35 HalpGetParameters(IN PLOADER_PARAMETER_BLOCK LoaderBlock
)
39 /* Make sure we have a loader block and command line */
40 if ((LoaderBlock
) && (LoaderBlock
->LoadOptions
))
42 /* Read the command line */
43 CommandLine
= LoaderBlock
->LoadOptions
;
45 /* Check if PCI is locked */
46 if (strstr(CommandLine
, "PCILOCK")) HalpPciLockSettings
= TRUE
;
48 /* Check for initial breakpoint */
49 if (strstr(CommandLine
, "BREAK")) DbgBreakPoint();
53 /* FUNCTIONS *****************************************************************/
57 HalInitializeProcessor(
58 IN ULONG ProcessorNumber
,
59 IN PLOADER_PARAMETER_BLOCK LoaderBlock
)
61 /* Hal specific initialization for this cpu */
62 HalpInitProcessor(ProcessorNumber
, LoaderBlock
);
64 /* Set default stall count */
65 KeGetPcr()->StallScaleFactor
= INITIAL_STALL_COUNT
;
67 /* Update the interrupt affinity and processor mask */
68 InterlockedBitTestAndSet((PLONG
)&HalpActiveProcessors
, ProcessorNumber
);
69 InterlockedBitTestAndSet((PLONG
)&HalpDefaultInterruptAffinity
,
72 /* Register routines for KDCOM */
73 HalpRegisterKdSupportFunctions();
82 HalInitSystem(IN ULONG BootPhase
,
83 IN PLOADER_PARAMETER_BLOCK LoaderBlock
)
85 PKPRCB Prcb
= KeGetCurrentPrcb();
87 /* Check the boot phase */
90 /* Phase 0... save bus type */
91 HalpBusType
= LoaderBlock
->u
.I386
.MachineType
& 0xFF;
93 /* Get command-line parameters */
94 HalpGetParameters(LoaderBlock
);
96 /* Check for PRCB version mismatch */
97 if (Prcb
->MajorVersion
!= PRCB_MAJOR_VERSION
)
99 /* No match, bugcheck */
100 KeBugCheckEx(MISMATCHED_HAL
, 1, Prcb
->MajorVersion
, PRCB_MAJOR_VERSION
, 0);
103 /* Checked/free HAL requires checked/free kernel */
104 if (Prcb
->BuildType
!= HalpBuildType
)
106 /* No match, bugcheck */
107 KeBugCheckEx(MISMATCHED_HAL
, 2, Prcb
->BuildType
, HalpBuildType
, 0);
110 /* Initialize ACPI */
111 HalpSetupAcpiPhase0(LoaderBlock
);
113 /* Initialize the PICs */
114 HalpInitializePICs(TRUE
);
116 /* Initialize CMOS lock */
117 KeInitializeSpinLock(&HalpSystemHardwareLock
);
119 /* Initialize CMOS */
120 HalpInitializeCmos();
122 /* Fill out the dispatch tables */
123 HalQuerySystemInformation
= HaliQuerySystemInformation
;
124 HalSetSystemInformation
= HaliSetSystemInformation
;
125 HalInitPnpDriver
= HaliInitPnpDriver
;
126 HalGetDmaAdapter
= HalpGetDmaAdapter
;
128 HalGetInterruptTranslator
= NULL
; // FIXME: TODO
129 HalResetDisplay
= HalpBiosDisplayReset
;
130 HalHaltSystem
= HaliHaltSystem
;
132 /* Setup I/O space */
133 HalpDefaultIoSpace
.Next
= HalpAddressUsageList
;
134 HalpAddressUsageList
= &HalpDefaultIoSpace
;
136 /* Setup busy waiting */
137 HalpCalibrateStallExecution();
139 /* Initialize the clock */
140 HalpInitializeClock();
143 * We could be rebooting with a pending profile interrupt,
144 * so clear it here before interrupts are enabled
146 HalStopProfileInterrupt(ProfileTime
);
148 /* Do some HAL-specific initialization */
149 HalpInitPhase0(LoaderBlock
);
151 else if (BootPhase
== 1)
153 /* Initialize bus handlers */
154 HalpInitBusHandlers();
156 /* Do some HAL-specific initialization */
160 /* All done, return */