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 *******************************************************************/
18 BOOLEAN HalpPciLockSettings
;
20 /* 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 *****************************************************************/
49 HalInitSystem(IN ULONG BootPhase
,
50 IN PLOADER_PARAMETER_BLOCK LoaderBlock
)
52 PKPRCB Prcb
= KeGetCurrentPrcb();
54 /* Check the boot phase */
57 /* Phase 0... save bus type */
58 HalpBusType
= LoaderBlock
->u
.I386
.MachineType
& 0xFF;
60 /* Get command-line parameters */
61 HalpGetParameters(LoaderBlock
);
63 /* Checked HAL requires checked kernel */
65 if (!(Prcb
->BuildType
& PRCB_BUILD_DEBUG
))
67 /* No match, bugcheck */
68 KeBugCheckEx(MISMATCHED_HAL
, 2, Prcb
->BuildType
, 1, 0);
71 /* Release build requires release HAL */
72 if (Prcb
->BuildType
& PRCB_BUILD_DEBUG
)
74 /* No match, bugcheck */
75 KeBugCheckEx(MISMATCHED_HAL
, 2, Prcb
->BuildType
, 0, 0);
80 /* SMP HAL requires SMP kernel */
81 if (Prcb
->BuildType
& PRCB_BUILD_UNIPROCESSOR
)
83 /* No match, bugcheck */
84 KeBugCheckEx(MISMATCHED_HAL
, 2, Prcb
->BuildType
, 0, 0);
88 /* Validate the PRCB */
89 if (Prcb
->MajorVersion
!= PRCB_MAJOR_VERSION
)
91 /* Validation failed, bugcheck */
92 KeBugCheckEx(MISMATCHED_HAL
, 1, Prcb
->MajorVersion
, 1, 0);
95 /* Initialize the PICs */
98 /* Force initial PIC state */
99 KfRaiseIrql(KeGetCurrentIrql());
101 /* Initialize the clock */
102 HalpInitializeClock();
104 /* Setup busy waiting */
105 //HalpCalibrateStallExecution();
107 /* Fill out the dispatch tables */
108 HalQuerySystemInformation
= HaliQuerySystemInformation
;
109 HalSetSystemInformation
= HaliSetSystemInformation
;
110 HalInitPnpDriver
= NULL
; // FIXME: TODO
111 HalGetDmaAdapter
= HalpGetDmaAdapter
;
112 HalGetInterruptTranslator
= NULL
; // FIXME: TODO
114 /* Initialize the hardware lock (CMOS) */
115 KeInitializeSpinLock(&HalpSystemHardwareLock
);
117 /* Do some HAL-specific initialization */
118 HalpInitPhase0(LoaderBlock
);
120 else if (BootPhase
== 1)
122 /* Initialize the default HAL stubs for bus handling functions */
123 HalpInitNonBusHandler();
125 /* Enable the clock interrupt */
126 ((PKIPCR
)KeGetPcr())->IDT
[0x30].ExtendedOffset
=
127 (USHORT
)(((ULONG_PTR
)HalpClockInterrupt
>> 16) & 0xFFFF);
128 ((PKIPCR
)KeGetPcr())->IDT
[0x30].Offset
=
129 (USHORT
)((ULONG_PTR
)HalpClockInterrupt
);
130 HalEnableSystemInterrupt(0x30, CLOCK2_LEVEL
, Latched
);
132 /* Initialize DMA. NT does this in Phase 0 */
135 /* Do some HAL-specific initialization */
139 /* All done, return */
148 HalReportResourceUsage(VOID
)
150 /* Initialize PCI bus. */
151 HalpInitializePciBus();
153 /* FIXME: This is done in ReactOS MP HAL only*/
154 //HaliReconfigurePciInterrupts();
156 /* FIXME: Report HAL Usage to kernel */