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 *****************************************************************/
50 HalInitSystem(IN ULONG BootPhase
,
51 IN PLOADER_PARAMETER_BLOCK LoaderBlock
)
53 PKPRCB Prcb
= KeGetCurrentPrcb();
55 /* Check the boot phase */
58 /* Phase 0... save bus type */
59 HalpBusType
= LoaderBlock
->u
.I386
.MachineType
& 0xFF;
61 /* Get command-line parameters */
62 HalpGetParameters(LoaderBlock
);
64 /* Checked HAL requires checked kernel */
66 if (!(Prcb
->BuildType
& PRCB_BUILD_DEBUG
))
68 /* No match, bugcheck */
69 KeBugCheckEx(MISMATCHED_HAL
, 2, Prcb
->BuildType
, 1, 0);
72 /* Release build requires release HAL */
73 if (Prcb
->BuildType
& PRCB_BUILD_DEBUG
)
75 /* No match, bugcheck */
76 KeBugCheckEx(MISMATCHED_HAL
, 2, Prcb
->BuildType
, 0, 0);
81 /* SMP HAL requires SMP kernel */
82 if (Prcb
->BuildType
& PRCB_BUILD_UNIPROCESSOR
)
84 /* No match, bugcheck */
85 KeBugCheckEx(MISMATCHED_HAL
, 2, Prcb
->BuildType
, 0, 0);
89 /* Validate the PRCB */
90 if (Prcb
->MajorVersion
!= PRCB_MAJOR_VERSION
)
92 /* Validation failed, bugcheck */
93 KeBugCheckEx(MISMATCHED_HAL
, 1, Prcb
->MajorVersion
, 1, 0);
98 HalpSetupAcpiPhase0(LoaderBlock
);
100 /* Initialize the PICs */
101 HalpInitializePICs(TRUE
);
104 /* Force initial PIC state */
105 KfRaiseIrql(KeGetCurrentIrql());
107 /* Initialize CMOS lock */
108 KeInitializeSpinLock(&HalpSystemHardwareLock
);
110 /* Initialize CMOS */
111 HalpInitializeCmos();
113 /* Fill out the dispatch tables */
114 HalQuerySystemInformation
= HaliQuerySystemInformation
;
115 HalSetSystemInformation
= HaliSetSystemInformation
;
116 HalInitPnpDriver
= HaliInitPnpDriver
;
118 HalGetDmaAdapter
= HalpGetDmaAdapter
;
120 HalGetDmaAdapter
= NULL
;
122 HalGetInterruptTranslator
= NULL
; // FIXME: TODO
124 HalResetDisplay
= HalpBiosDisplayReset
;
126 HalResetDisplay
= NULL
;
128 HalHaltSystem
= HaliHaltSystem
;
131 HalpRegisterVector(IDT_INTERNAL
,
132 PRIMARY_VECTOR_BASE
+ 2,
133 PRIMARY_VECTOR_BASE
+ 2,
136 /* Setup I/O space */
137 HalpDefaultIoSpace
.Next
= HalpAddressUsageList
;
138 HalpAddressUsageList
= &HalpDefaultIoSpace
;
140 /* Setup busy waiting */
141 HalpCalibrateStallExecution();
144 /* Initialize the clock */
145 HalpInitializeClock();
149 * We could be rebooting with a pending profile interrupt,
150 * so clear it here before interrupts are enabled
152 HalStopProfileInterrupt(ProfileTime
);
154 /* Do some HAL-specific initialization */
155 HalpInitPhase0(LoaderBlock
);
157 else if (BootPhase
== 1)
159 /* Initialize bus handlers */
160 HalpInitBusHandlers();
164 HalpEnableInterruptHandler(IDT_DEVICE
,
172 HalpEnableInterruptHandler(IDT_DEVICE
,
174 PRIMARY_VECTOR_BASE
+ 8,
176 HalpProfileInterrupt
,
179 /* Initialize DMA. NT does this in Phase 0 */
183 /* Do some HAL-specific initialization */
187 /* All done, return */