ReactOS 0.4.15-dev-6052-g2626c72
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 ProcessorNumber);
60
61 /* Register routines for KDCOM */
63}
64
65/*
66 * @implemented
67 */
68CODE_SEG("INIT")
72 IN PLOADER_PARAMETER_BLOCK LoaderBlock)
73{
74 PKPRCB Prcb = KeGetCurrentPrcb();
75
76 /* Check the boot phase */
77 if (BootPhase == 0)
78 {
79 /* Phase 0... save bus type */
80 HalpBusType = LoaderBlock->u.I386.MachineType & 0xFF;
81
82 /* Get command-line parameters */
83 HalpGetParameters(LoaderBlock);
84
85 /* Check for PRCB version mismatch */
87 {
88 /* No match, bugcheck */
89 KeBugCheckEx(MISMATCHED_HAL, 1, Prcb->MajorVersion, PRCB_MAJOR_VERSION, 0);
90 }
91
92 /* Checked/free HAL requires checked/free kernel */
93 if (Prcb->BuildType != HalpBuildType)
94 {
95 /* No match, bugcheck */
96 KeBugCheckEx(MISMATCHED_HAL, 2, Prcb->BuildType, HalpBuildType, 0);
97 }
98
99 /* Initialize ACPI */
100 HalpSetupAcpiPhase0(LoaderBlock);
101
102 /* Initialize the PICs */
104
105 /* Initialize CMOS lock */
107
108 /* Initialize CMOS */
110
111 /* Fill out the dispatch tables */
116
117 HalGetInterruptTranslator = NULL; // FIXME: TODO
120
121 /* Setup I/O space */
124
125 /* Setup busy waiting */
127
128 /* Initialize the clock */
130
131 /*
132 * We could be rebooting with a pending profile interrupt,
133 * so clear it here before interrupts are enabled
134 */
136
137 /* Do some HAL-specific initialization */
138 HalpInitPhase0(LoaderBlock);
139
140#ifdef _M_AMD64
141 HalInitializeBios(0, LoaderBlock);
142#endif
143 }
144 else if (BootPhase == 1)
145 {
146 /* Initialize bus handlers */
148
149 /* Do some HAL-specific initialization */
151
152#ifdef _M_AMD64
153 HalInitializeBios(1, LoaderBlock);
154#endif
155 }
156
157 /* All done, return */
158 return TRUE;
159}
unsigned char BOOLEAN
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
NTSTATUS NTAPI HaliInitPnpDriver(VOID)
Definition: halpnpdd.c:906
VOID NTAPI HalpInitializePICs(IN BOOLEAN EnableInterrupts)
Definition: apic.c:513
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 KeInitializeSpinLock(sl)
Definition: env_spec_w32.h:604
KAFFINITY HalpDefaultInterruptAffinity
Definition: processor.c:18
LONG 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
VOID NTAPI HalpInitializeCmos(VOID)
Definition: cmos.c:159
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
#define InterlockedBitTestAndSet
Definition: interlocked.h:30
static CODE_SEG("PAGE")
Definition: isapnp.c:1482
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1080
#define PRCB_MAJOR_VERSION
Definition: ketypes.h:246
#define INITIAL_STALL_COUNT
Definition: ketypes.h:260
#define HalHaltSystem
Definition: halfuncs.h:43
#define HalResetDisplay
Definition: halfuncs.h:45
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
#define KeGetPcr()
Definition: ke.h:26
struct _HalAddressUsage * Next
Definition: halp.h:178
UCHAR BuildType
Definition: ketypes.h:604
USHORT MajorVersion
Definition: ketypes.h:603
#define NTAPI
Definition: typedefs.h:36
#define IN
Definition: typedefs.h:39
int32_t * PLONG
Definition: typedefs.h:58
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
BOOLEAN NTAPI HalpBiosDisplayReset(VOID)
Definition: x86bios.c:498
#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