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
)
53 PKPRCB Prcb
= KeGetCurrentPrcb();
55 DbgPrint("Prcb: %x BuildType %x\n", Prcb
, Prcb
->BuildType
);
57 /* Check the boot phase */
60 /* Phase 0... save bus type */
61 HalpBusType
= LoaderBlock
->u
.I386
.MachineType
& 0xFF;
63 /* Get command-line parameters */
64 HalpGetParameters(LoaderBlock
);
66 /* Checked HAL requires checked kernel */
68 if (!(Prcb
->BuildType
& PRCB_BUILD_DEBUG
))
70 /* No match, bugcheck */
71 KeBugCheckEx(MISMATCHED_HAL
, 2, Prcb
->BuildType
, 1, 0);
74 /* Release build requires release HAL */
75 if (Prcb
->BuildType
& PRCB_BUILD_DEBUG
)
77 /* No match, bugcheck */
78 KeBugCheckEx(MISMATCHED_HAL
, 2, Prcb
->BuildType
, 0, 0);
83 /* SMP HAL requires SMP kernel */
84 if (Prcb
->BuildType
& PRCB_BUILD_UNIPROCESSOR
)
86 /* No match, bugcheck */
87 KeBugCheckEx(MISMATCHED_HAL
, 2, Prcb
->BuildType
, 0, 0);
91 /* Validate the PRCB */
92 if (Prcb
->MajorVersion
!= PRCB_MAJOR_VERSION
)
94 /* Validation failed, bugcheck */
95 KeBugCheckEx(MISMATCHED_HAL
, 1, Prcb
->MajorVersion
, 1, 0);
98 /* Initialize the PICs */
101 /* Force initial PIC state */
102 KeRaiseIrql(KeGetCurrentIrql(), &CurIrql
);
104 /* Initialize the clock */
105 HalpInitializeClock();
107 /* Setup busy waiting */
108 //HalpCalibrateStallExecution();
110 /* Fill out the dispatch tables */
111 HalQuerySystemInformation
= HaliQuerySystemInformation
;
112 HalSetSystemInformation
= HaliSetSystemInformation
;
113 HalInitPnpDriver
= NULL
; // FIXME: TODO
114 HalGetDmaAdapter
= HalpGetDmaAdapter
;
115 HalGetInterruptTranslator
= NULL
; // FIXME: TODO
117 /* Initialize the hardware lock (CMOS) */
118 KeInitializeSpinLock(&HalpSystemHardwareLock
);
120 else if (BootPhase
== 1)
122 /* Initialize the default HAL stubs for bus handling functions */
123 HalpInitNonBusHandler();
126 /* Enable the clock interrupt */
127 ((PKIPCR
)KeGetPcr())->IDT
[0x30].ExtendedOffset
=
128 (USHORT
)(((ULONG_PTR
)HalpClockInterrupt
>> 16) & 0xFFFF);
129 ((PKIPCR
)KeGetPcr())->IDT
[0x30].Offset
=
130 (USHORT
)((ULONG_PTR
)HalpClockInterrupt
);
132 HalEnableSystemInterrupt(0x30, CLOCK2_LEVEL
, Latched
);
134 /* Initialize DMA. NT does this in Phase 0 */
138 /* All done, return */
147 HalReportResourceUsage(VOID
)
149 /* Initialize PCI bus. */
150 HalpInitializePciBus();
152 /* FIXME: This is done in ReactOS MP HAL only*/
153 //HaliReconfigurePciInterrupts();
155 /* FIXME: Report HAL Usage to kernel */