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 ******************************************************************/
15 /* GLOBALS *******************************************************************/
17 BOOLEAN HalpPciLockSettings
;
19 /* PRIVATE FUNCTIONS *********************************************************/
24 HalpGetParameters(IN PLOADER_PARAMETER_BLOCK LoaderBlock
)
28 /* Make sure we have a loader block and command line */
29 if ((LoaderBlock
) && (LoaderBlock
->LoadOptions
))
31 /* Read the command line */
32 CommandLine
= LoaderBlock
->LoadOptions
;
34 /* Check if PCI is locked */
35 if (strstr(CommandLine
, "PCILOCK")) HalpPciLockSettings
= TRUE
;
37 /* Check for initial breakpoint */
38 if (strstr(CommandLine
, "BREAK")) DbgBreakPoint();
42 /* FUNCTIONS *****************************************************************/
46 HalInitializeProcessor(
47 IN ULONG ProcessorNumber
,
48 IN PLOADER_PARAMETER_BLOCK LoaderBlock
)
50 /* Hal specific initialization for this cpu */
51 HalpInitProcessor(ProcessorNumber
, LoaderBlock
);
53 /* Set default stall count */
54 KeGetPcr()->StallScaleFactor
= INITIAL_STALL_COUNT
;
56 /* Update the interrupt affinity and processor mask */
57 InterlockedBitTestAndSet((PLONG
)&HalpActiveProcessors
, ProcessorNumber
);
58 InterlockedBitTestAndSet((PLONG
)&HalpDefaultInterruptAffinity
,
61 /* Register routines for KDCOM */
62 HalpRegisterKdSupportFunctions();
71 HalInitSystem(IN ULONG BootPhase
,
72 IN PLOADER_PARAMETER_BLOCK LoaderBlock
)
74 PKPRCB Prcb
= KeGetCurrentPrcb();
76 /* Check the boot phase */
79 /* Phase 0... save bus type */
80 HalpBusType
= LoaderBlock
->u
.I386
.MachineType
& 0xFF;
82 /* Get command-line parameters */
83 HalpGetParameters(LoaderBlock
);
85 /* Check for PRCB version mismatch */
86 if (Prcb
->MajorVersion
!= PRCB_MAJOR_VERSION
)
88 /* No match, bugcheck */
89 KeBugCheckEx(MISMATCHED_HAL
, 1, Prcb
->MajorVersion
, PRCB_MAJOR_VERSION
, 0);
92 /* Checked/free HAL requires checked/free kernel */
93 if (Prcb
->BuildType
!= HalpBuildType
)
95 /* No match, bugcheck */
96 KeBugCheckEx(MISMATCHED_HAL
, 2, Prcb
->BuildType
, HalpBuildType
, 0);
100 HalpSetupAcpiPhase0(LoaderBlock
);
102 /* Initialize the PICs */
103 HalpInitializePICs(TRUE
);
105 /* Initialize CMOS lock */
106 KeInitializeSpinLock(&HalpSystemHardwareLock
);
108 /* Initialize CMOS */
109 HalpInitializeCmos();
111 /* Fill out the dispatch tables */
112 HalQuerySystemInformation
= HaliQuerySystemInformation
;
113 HalSetSystemInformation
= HaliSetSystemInformation
;
114 HalInitPnpDriver
= HaliInitPnpDriver
;
115 HalGetDmaAdapter
= HalpGetDmaAdapter
;
117 HalGetInterruptTranslator
= NULL
; // FIXME: TODO
118 HalResetDisplay
= HalpBiosDisplayReset
;
119 HalHaltSystem
= HaliHaltSystem
;
121 /* Setup I/O space */
122 HalpDefaultIoSpace
.Next
= HalpAddressUsageList
;
123 HalpAddressUsageList
= &HalpDefaultIoSpace
;
125 /* Setup busy waiting */
126 HalpCalibrateStallExecution();
128 /* Initialize the clock */
129 HalpInitializeClock();
132 * We could be rebooting with a pending profile interrupt,
133 * so clear it here before interrupts are enabled
135 HalStopProfileInterrupt(ProfileTime
);
137 /* Do some HAL-specific initialization */
138 HalpInitPhase0(LoaderBlock
);
140 else if (BootPhase
== 1)
142 /* Initialize bus handlers */
143 HalpInitBusHandlers();
145 /* Do some HAL-specific initialization */
149 /* All done, return */