- Cleanup HAL initialization code:
[reactos.git] / reactos / hal / halx86 / generic / halinit.c
1 /*
2 * PROJECT: ReactOS HAL
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: ntoskrnl/hal/halx86/generic/processor.c
5 * PURPOSE: HAL Processor Routines
6 * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
7 */
8
9 /* INCLUDES ******************************************************************/
10
11 #include <hal.h>
12 #define NDEBUG
13 #include <debug.h>
14
15 /* GLOBALS *******************************************************************/
16
17 PVOID HalpZeroPageMapping = NULL;
18 HALP_HOOKS HalpHooks;
19 BOOLEAN HalpPciLockSettings;
20
21 /* PRIVATE FUNCTIONS *********************************************************/
22
23 VOID
24 NTAPI
25 HalpGetParameters(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
26 {
27 PCHAR CommandLine;
28
29 /* Make sure we have a loader block and command line */
30 if ((LoaderBlock) && (LoaderBlock->LoadOptions))
31 {
32 /* Read the command line */
33 CommandLine = LoaderBlock->LoadOptions;
34
35 /* Check if PCI is locked */
36 if (strstr(CommandLine, "PCILOCK")) HalpPciLockSettings = TRUE;
37
38 /* Check for initial breakpoint */
39 if (strstr(CommandLine, "BREAK")) DbgBreakPoint();
40 }
41 }
42
43 /* FUNCTIONS *****************************************************************/
44
45 /*
46 * @implemented
47 */
48 BOOLEAN
49 NTAPI
50 HalInitSystem(IN ULONG BootPhase,
51 IN PLOADER_PARAMETER_BLOCK LoaderBlock)
52 {
53 PHYSICAL_ADDRESS Null = {{0}};
54 PKPRCB Prcb = KeGetCurrentPrcb();
55
56 /* Check the boot phase */
57 if (!BootPhase)
58 {
59 /* Phase 0... save bus type */
60 HalpBusType = LoaderBlock->u.I386.MachineType & 0xFF;
61
62 /* Get command-line parameters */
63 HalpGetParameters(LoaderBlock);
64
65 /* Checked HAL requires checked kernel */
66 #if DBG
67 if (!(Prcb->BuildType & PRCB_BUILD_DEBUG))
68 {
69 /* No match, bugcheck */
70 KeBugCheckEx(MISMATCHED_HAL, 2, Prcb->BuildType, 1, 0);
71 }
72 #else
73 /* Release build requires release HAL */
74 if (Prcb->BuildType & PRCB_BUILD_DEBUG)
75 {
76 /* No match, bugcheck */
77 KeBugCheckEx(MISMATCHED_HAL, 2, Prcb->BuildType, 0, 0);
78 }
79 #endif
80
81 #ifdef CONFIG_SMP
82 /* SMP HAL requires SMP kernel */
83 if (Prcb->BuildType & PRCB_BUILD_UNIPROCESSOR)
84 {
85 /* No match, bugcheck */
86 KeBugCheckEx(MISMATCHED_HAL, 2, Prcb->BuildType, 0, 0);
87 }
88 #endif
89
90 /* Validate the PRCB */
91 if (Prcb->MajorVersion != PRCB_MAJOR_VERSION)
92 {
93 /* Validation failed, bugcheck */
94 KeBugCheckEx(MISMATCHED_HAL, 1, Prcb->MajorVersion, 1, 0);
95 }
96
97 /* Continue with HAL-specific initialization */
98 HalpInitPhase0(LoaderBlock);
99
100 /* Fill out the dispatch tables */
101 HalQuerySystemInformation = HaliQuerySystemInformation;
102 HalSetSystemInformation = HaliSetSystemInformation;
103 HalInitPnpDriver = NULL; // FIXME: TODO
104 HalGetDmaAdapter = HalpGetDmaAdapter;
105 HalGetInterruptTranslator = NULL; // FIXME: TODO
106
107 /* Initialize the hardware lock (CMOS) */
108 KeInitializeSpinLock(&HalpSystemHardwareLock);
109 }
110 else if (BootPhase == 1)
111 {
112 /* Initialize the default HAL stubs for bus handling functions */
113 HalpInitNonBusHandler();
114
115 /* Initialize the clock interrupt */
116 //HalpInitPhase1();
117
118 /* Initialize DMA. NT does this in Phase 0 */
119 HalpInitDma();
120 }
121 else if (BootPhase == 2)
122 {
123 HalpZeroPageMapping = MmMapIoSpace(Null, PAGE_SIZE, MmNonCached);
124 }
125
126 /* All done, return */
127 return TRUE;
128 }
129
130 /*
131 * @implemented
132 */
133 VOID
134 NTAPI
135 HalReportResourceUsage(VOID)
136 {
137 /* Initialize PCI bus. */
138 HalpInitializePciBus();
139
140 /* FIXME: This is done in ReactOS MP HAL only*/
141 //HaliReconfigurePciInterrupts();
142
143 /* FIXME: Report HAL Usage to kernel */
144 }
145
146
147 /* EOF */