mirror of
https://github.com/reactos/reactos.git
synced 2024-11-19 13:33:42 +00:00
ce2d4740a6
This will be needed for compatibility with x86 Windows Vista/7 videoprt.sys builds. Might be also useful in future for platforms (x86 , ...) where V86 mode is not available or buggy. CORE-11954, CORE-18185
162 lines
4.5 KiB
C
162 lines
4.5 KiB
C
/*
|
|
* PROJECT: ReactOS HAL
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
|
* FILE: hal/halx86/generic/halinit.c
|
|
* PURPOSE: HAL Entrypoint and Initialization
|
|
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
|
|
*/
|
|
|
|
/* INCLUDES ******************************************************************/
|
|
|
|
#include <hal.h>
|
|
#define NDEBUG
|
|
#include <debug.h>
|
|
|
|
/* GLOBALS *******************************************************************/
|
|
|
|
BOOLEAN HalpPciLockSettings;
|
|
|
|
/* PRIVATE FUNCTIONS *********************************************************/
|
|
|
|
CODE_SEG("INIT")
|
|
VOID
|
|
NTAPI
|
|
HalpGetParameters(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
|
|
{
|
|
PCHAR CommandLine;
|
|
|
|
/* Make sure we have a loader block and command line */
|
|
if ((LoaderBlock) && (LoaderBlock->LoadOptions))
|
|
{
|
|
/* Read the command line */
|
|
CommandLine = LoaderBlock->LoadOptions;
|
|
|
|
/* Check if PCI is locked */
|
|
if (strstr(CommandLine, "PCILOCK")) HalpPciLockSettings = TRUE;
|
|
|
|
/* Check for initial breakpoint */
|
|
if (strstr(CommandLine, "BREAK")) DbgBreakPoint();
|
|
}
|
|
}
|
|
|
|
/* FUNCTIONS *****************************************************************/
|
|
|
|
VOID
|
|
NTAPI
|
|
HalInitializeProcessor(
|
|
IN ULONG ProcessorNumber,
|
|
IN PLOADER_PARAMETER_BLOCK LoaderBlock)
|
|
{
|
|
/* Hal specific initialization for this cpu */
|
|
HalpInitProcessor(ProcessorNumber, LoaderBlock);
|
|
|
|
/* Set default stall count */
|
|
KeGetPcr()->StallScaleFactor = INITIAL_STALL_COUNT;
|
|
|
|
/* Update the interrupt affinity and processor mask */
|
|
InterlockedBitTestAndSet((PLONG)&HalpActiveProcessors, ProcessorNumber);
|
|
InterlockedBitTestAndSet((PLONG)&HalpDefaultInterruptAffinity,
|
|
ProcessorNumber);
|
|
|
|
/* Register routines for KDCOM */
|
|
HalpRegisterKdSupportFunctions();
|
|
}
|
|
|
|
/*
|
|
* @implemented
|
|
*/
|
|
CODE_SEG("INIT")
|
|
BOOLEAN
|
|
NTAPI
|
|
HalInitSystem(IN ULONG BootPhase,
|
|
IN PLOADER_PARAMETER_BLOCK LoaderBlock)
|
|
{
|
|
PKPRCB Prcb = KeGetCurrentPrcb();
|
|
NTSTATUS Status;
|
|
|
|
/* Check the boot phase */
|
|
if (BootPhase == 0)
|
|
{
|
|
/* Phase 0... save bus type */
|
|
HalpBusType = LoaderBlock->u.I386.MachineType & 0xFF;
|
|
|
|
/* Get command-line parameters */
|
|
HalpGetParameters(LoaderBlock);
|
|
|
|
/* Check for PRCB version mismatch */
|
|
if (Prcb->MajorVersion != PRCB_MAJOR_VERSION)
|
|
{
|
|
/* No match, bugcheck */
|
|
KeBugCheckEx(MISMATCHED_HAL, 1, Prcb->MajorVersion, PRCB_MAJOR_VERSION, 0);
|
|
}
|
|
|
|
/* Checked/free HAL requires checked/free kernel */
|
|
if (Prcb->BuildType != HalpBuildType)
|
|
{
|
|
/* No match, bugcheck */
|
|
KeBugCheckEx(MISMATCHED_HAL, 2, Prcb->BuildType, HalpBuildType, 0);
|
|
}
|
|
|
|
/* Initialize ACPI */
|
|
Status = HalpSetupAcpiPhase0(LoaderBlock);
|
|
if (!NT_SUCCESS(Status))
|
|
{
|
|
KeBugCheckEx(ACPI_BIOS_ERROR, Status, 0, 0, 0);
|
|
}
|
|
|
|
/* Initialize the PICs */
|
|
HalpInitializePICs(TRUE);
|
|
|
|
/* Initialize CMOS lock */
|
|
KeInitializeSpinLock(&HalpSystemHardwareLock);
|
|
|
|
/* Initialize CMOS */
|
|
HalpInitializeCmos();
|
|
|
|
/* Fill out the dispatch tables */
|
|
HalQuerySystemInformation = HaliQuerySystemInformation;
|
|
HalSetSystemInformation = HaliSetSystemInformation;
|
|
HalInitPnpDriver = HaliInitPnpDriver;
|
|
HalGetDmaAdapter = HalpGetDmaAdapter;
|
|
|
|
HalGetInterruptTranslator = NULL; // FIXME: TODO
|
|
HalResetDisplay = HalpBiosDisplayReset;
|
|
HalHaltSystem = HaliHaltSystem;
|
|
|
|
/* Setup I/O space */
|
|
HalpDefaultIoSpace.Next = HalpAddressUsageList;
|
|
HalpAddressUsageList = &HalpDefaultIoSpace;
|
|
|
|
/* Setup busy waiting */
|
|
HalpCalibrateStallExecution();
|
|
|
|
/* Initialize the clock */
|
|
HalpInitializeClock();
|
|
|
|
/*
|
|
* We could be rebooting with a pending profile interrupt,
|
|
* so clear it here before interrupts are enabled
|
|
*/
|
|
HalStopProfileInterrupt(ProfileTime);
|
|
|
|
/* Do some HAL-specific initialization */
|
|
HalpInitPhase0(LoaderBlock);
|
|
|
|
/* Initialize Phase 0 of the x86 emulator */
|
|
HalInitializeBios(0, LoaderBlock);
|
|
}
|
|
else if (BootPhase == 1)
|
|
{
|
|
/* Initialize bus handlers */
|
|
HalpInitBusHandlers();
|
|
|
|
/* Do some HAL-specific initialization */
|
|
HalpInitPhase1();
|
|
|
|
/* Initialize Phase 1 of the x86 emulator */
|
|
HalInitializeBios(1, LoaderBlock);
|
|
}
|
|
|
|
/* All done, return */
|
|
return TRUE;
|
|
}
|