ReactOS 0.4.15-dev-8002-gbbb3b00
halinit.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS HAL
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)
7 */
8
9/* INCLUDES ******************************************************************/
10
11#include <hal.h>
12#define NDEBUG
13#include <debug.h>
14
15/* GLOBALS *******************************************************************/
16
18
19/* PRIVATE FUNCTIONS *********************************************************/
20
21CODE_SEG("INIT")
22VOID
25{
26 PCHAR CommandLine;
27
28 /* Make sure we have a loader block and command line */
29 if ((LoaderBlock) && (LoaderBlock->LoadOptions))
30 {
31 /* Read the command line */
32 CommandLine = LoaderBlock->LoadOptions;
33
34 /* Check if PCI is locked */
35 if (strstr(CommandLine, "PCILOCK")) HalpPciLockSettings = TRUE;
36
37 /* Check for initial breakpoint */
38 if (strstr(CommandLine, "BREAK")) DbgBreakPoint();
39 }
40}
41
42/* FUNCTIONS *****************************************************************/
43
44VOID
47 IN ULONG ProcessorNumber,
48 IN PLOADER_PARAMETER_BLOCK LoaderBlock)
49{
50 /* Hal specific initialization for this cpu */
51 HalpInitProcessor(ProcessorNumber, LoaderBlock);
52
53 /* Set default stall count */
54 KeGetPcr()->StallScaleFactor = INITIAL_STALL_COUNT;
55
56 /* Update the interrupt affinity and processor mask */
59
60 if (ProcessorNumber == 0)
61 {
62 /* Register routines for KDCOM */
64 }
65}
66
67/*
68 * @implemented
69 */
70CODE_SEG("INIT")
74 IN PLOADER_PARAMETER_BLOCK LoaderBlock)
75{
76 PKPRCB Prcb = KeGetCurrentPrcb();
78
79 /* Check the boot phase */
80 if (BootPhase == 0)
81 {
82 /* Phase 0... save bus type */
83 HalpBusType = LoaderBlock->u.I386.MachineType & 0xFF;
84
85 /* Get command-line parameters */
86 HalpGetParameters(LoaderBlock);
87
88 /* Check for PRCB version mismatch */
90 {
91 /* No match, bugcheck */
92 KeBugCheckEx(MISMATCHED_HAL, 1, Prcb->MajorVersion, PRCB_MAJOR_VERSION, 0);
93 }
94
95 /* Checked/free HAL requires checked/free kernel */
96 if (Prcb->BuildType != HalpBuildType)
97 {
98 /* No match, bugcheck */
99 KeBugCheckEx(MISMATCHED_HAL, 2, Prcb->BuildType, HalpBuildType, 0);
100 }
101
102 /* Initialize ACPI */
103 Status = HalpSetupAcpiPhase0(LoaderBlock);
104 if (!NT_SUCCESS(Status))
105 {
107 }
108
109 /* Initialize the PICs */
111
112 /* Initialize CMOS lock */
114
115 /* Initialize CMOS */
117
118 /* Fill out the dispatch tables */
123
124 HalGetInterruptTranslator = NULL; // FIXME: TODO
127
128 /* Setup I/O space */
131
132 /* Setup busy waiting */
134
135 /* Initialize the clock */
137
138 /*
139 * We could be rebooting with a pending profile interrupt,
140 * so clear it here before interrupts are enabled
141 */
143
144 /* Do some HAL-specific initialization */
145 HalpInitPhase0(LoaderBlock);
146
147 /* Initialize Phase 0 of the x86 emulator */
148 HalInitializeBios(0, LoaderBlock);
149 }
150 else if (BootPhase == 1)
151 {
152 /* Initialize bus handlers */
154
155 /* Do some HAL-specific initialization */
157
158 /* Initialize Phase 1 of the x86 emulator */
159 HalInitializeBios(1, LoaderBlock);
160 }
161
162 /* All done, return */
163 return TRUE;
164}
#define CODE_SEG(...)
unsigned char BOOLEAN
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
#define ACPI_BIOS_ERROR(plist)
Definition: acoutput.h:243
NTSTATUS NTAPI HaliInitPnpDriver(VOID)
Definition: halpnpdd.c:906
VOID NTAPI HalpInitializePICs(IN BOOLEAN EnableInterrupts)
Definition: apic.c:513
LONG NTSTATUS
Definition: precomp.h:26
const USHORT HalpBuildType
Definition: buildtype.c:14
ULONG HalpBusType
Definition: pcibus.c:18
VOID NTAPI HalpRegisterKdSupportFunctions(VOID)
Definition: busemul.c:22
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define KeInitializeSpinLock(sl)
Definition: env_spec_w32.h:604
Status
Definition: gdiplustypes.h:25
KAFFINITY HalpDefaultInterruptAffinity
Definition: processor.c:18
KAFFINITY HalpActiveProcessors
Definition: processor.c:17
NTSTATUS NTAPI HaliSetSystemInformation(IN HAL_SET_INFORMATION_CLASS InformationClass, IN ULONG BufferSize, IN OUT PVOID Buffer)
Definition: sysinfo.c:31
NTSTATUS NTAPI HaliQuerySystemInformation(IN HAL_QUERY_INFORMATION_CLASS InformationClass, IN ULONG BufferSize, IN OUT PVOID Buffer, OUT PULONG ReturnedLength)
Definition: sysinfo.c:19
VOID HalpInitializeClock(VOID)
Definition: timer.c:54
VOID NTAPI HaliHaltSystem(VOID)
Definition: processor.c:21
BOOLEAN NTAPI HalpBiosDisplayReset(VOID)
Definition: bios.c:642
VOID NTAPI HalpInitializeCmos(VOID)
Definition: cmos.c:160
PDMA_ADAPTER NTAPI HalpGetDmaAdapter(IN PVOID Context, IN PDEVICE_DESCRIPTION DeviceDescription, OUT PULONG NumberOfMapRegisters)
Definition: dma.c:852
KSPIN_LOCK HalpSystemHardwareLock
Definition: spinlock.c:25
PADDRESS_USAGE HalpAddressUsageList
Definition: usage.c:20
ADDRESS_USAGE HalpDefaultIoSpace
Definition: usage.c:42
VOID NTAPI HalpInitBusHandlers(VOID)
Definition: halacpi.c:935
NTSTATUS NTAPI HalpSetupAcpiPhase0(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: halacpi.c:792
BOOLEAN NTAPI HalInitSystem(IN ULONG BootPhase, IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: halinit.c:43
VOID NTAPI HalpGetParameters(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: halinit.c:21
VOID NTAPI HalStopProfileInterrupt(IN KPROFILE_SOURCE ProfileSource)
Definition: profil.c:22
VOID HalpInitPhase0(PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: halinit_mp.c:30
VOID HalpInitPhase1(VOID)
Definition: halinit_up.c:26
VOID NTAPI HalpInitProcessor(IN ULONG ProcessorNumber, IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: halinit.c:24
BOOLEAN HalpPciLockSettings
Definition: halinit.c:17
VOID NTAPI HalInitializeProcessor(IN ULONG ProcessorNumber, IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: halinit.c:46
NTSYSAPI void WINAPI DbgBreakPoint(void)
@ ProfileTime
Definition: winternl.h:2123
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1161
#define PRCB_MAJOR_VERSION
Definition: ketypes.h:322
#define INITIAL_STALL_COUNT
Definition: ketypes.h:336
#define HalHaltSystem
Definition: halfuncs.h:43
#define HalResetDisplay
Definition: halfuncs.h:45
#define KeGetPcr()
Definition: ketypes.h:81
FORCEINLINE BOOLEAN InterlockedBitTestAndSetAffinity(volatile KAFFINITY *Affinity, ULONG Index)
Definition: kefuncs.h:63
VOID HalpCalibrateStallExecution(VOID)
Definition: pchw.c:105
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:108
struct _HalAddressUsage * Next
Definition: halp.h:192
UCHAR BuildType
Definition: ketypes.h:683
USHORT MajorVersion
Definition: ketypes.h:682
#define NTAPI
Definition: typedefs.h:36
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
char * PCHAR
Definition: typedefs.h:51
VOID NTAPI HalInitializeBios(_In_ ULONG Phase, _In_ PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: x86bios.c:48
#define HalQuerySystemInformation
Definition: haltypes.h:294
#define HalGetDmaAdapter
Definition: haltypes.h:302
#define HalGetInterruptTranslator
Definition: haltypes.h:303
#define HalSetSystemInformation
Definition: haltypes.h:295
#define HalInitPnpDriver
Definition: haltypes.h:300