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 *********************************************************/
23 HalpGetParameters(IN PLOADER_PARAMETER_BLOCK LoaderBlock
)
27 /* Make sure we have a loader block and command line */
28 if ((LoaderBlock
) && (LoaderBlock
->LoadOptions
))
30 /* Read the command line */
31 CommandLine
= LoaderBlock
->LoadOptions
;
33 /* Check if PCI is locked */
34 if (strstr(CommandLine
, "PCILOCK")) HalpPciLockSettings
= TRUE
;
36 /* Check for initial breakpoint */
37 if (strstr(CommandLine
, "BREAK")) DbgBreakPoint();
41 /* FUNCTIONS *****************************************************************/
48 HalInitSystem(IN ULONG BootPhase
,
49 IN PLOADER_PARAMETER_BLOCK LoaderBlock
)
51 PKPRCB Prcb
= KeGetCurrentPrcb();
53 /* Check the boot phase */
56 /* Phase 0... save bus type */
57 HalpBusType
= LoaderBlock
->u
.I386
.MachineType
& 0xFF;
59 /* Get command-line parameters */
60 HalpGetParameters(LoaderBlock
);
62 /* Checked HAL requires checked kernel */
64 if (!(Prcb
->BuildType
& PRCB_BUILD_DEBUG
))
66 /* No match, bugcheck */
67 KeBugCheckEx(MISMATCHED_HAL
, 2, Prcb
->BuildType
, 1, 0);
70 /* Release build requires release HAL */
71 if (Prcb
->BuildType
& PRCB_BUILD_DEBUG
)
73 /* No match, bugcheck */
74 KeBugCheckEx(MISMATCHED_HAL
, 2, Prcb
->BuildType
, 0, 0);
79 /* SMP HAL requires SMP kernel */
80 if (Prcb
->BuildType
& PRCB_BUILD_UNIPROCESSOR
)
82 /* No match, bugcheck */
83 KeBugCheckEx(MISMATCHED_HAL
, 2, Prcb
->BuildType
, 0, 0);
87 /* Validate the PRCB */
88 if (Prcb
->MajorVersion
!= PRCB_MAJOR_VERSION
)
90 /* Validation failed, bugcheck */
91 KeBugCheckEx(MISMATCHED_HAL
, 1, Prcb
->MajorVersion
, 1, 0);
96 HalpSetupAcpiPhase0(LoaderBlock
);
98 /* Initialize the PICs */
99 HalpInitializePICs(TRUE
);
102 /* Force initial PIC state */
103 KfRaiseIrql(KeGetCurrentIrql());
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
= NULL
; // FIXME: TODO
116 HalGetDmaAdapter
= HalpGetDmaAdapter
;
118 HalGetDmaAdapter
= NULL
;
120 HalGetInterruptTranslator
= NULL
; // FIXME: TODO
122 HalResetDisplay
= HalpBiosDisplayReset
;
124 HalResetDisplay
= NULL
;
126 HalHaltSystem
= HaliHaltSystem
;
129 HalpRegisterVector(IDT_INTERNAL
,
130 PRIMARY_VECTOR_BASE
+ 2,
131 PRIMARY_VECTOR_BASE
+ 2,
134 /* Setup I/O space */
135 HalpDefaultIoSpace
.Next
= HalpAddressUsageList
;
136 HalpAddressUsageList
= &HalpDefaultIoSpace
;
138 /* Setup busy waiting */
139 HalpCalibrateStallExecution();
142 /* Initialize the clock */
143 HalpInitializeClock();
147 * We could be rebooting with a pending profile interrupt,
148 * so clear it here before interrupts are enabled
150 HalStopProfileInterrupt(ProfileTime
);
152 /* Do some HAL-specific initialization */
153 HalpInitPhase0(LoaderBlock
);
155 else if (BootPhase
== 1)
157 /* Initialize bus handlers */
158 HalpInitBusHandlers();
162 HalpEnableInterruptHandler(IDT_DEVICE
,
170 HalpEnableInterruptHandler(IDT_DEVICE
,
172 PRIMARY_VECTOR_BASE
+ 8,
174 HalpProfileInterrupt
,
177 /* Initialize DMA. NT does this in Phase 0 */
181 /* Do some HAL-specific initialization */
185 /* All done, return */