mirror of
https://github.com/reactos/reactos.git
synced 2024-11-10 00:34:39 +00:00
406dfdbc87
Sync trunk (rr49606) svn path=/branches/cmake-bringup/; revision=49607
189 lines
5.2 KiB
C
189 lines
5.2 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 *********************************************************/
|
|
|
|
VOID
|
|
NTAPI
|
|
INIT_FUNCTION
|
|
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 *****************************************************************/
|
|
|
|
/*
|
|
* @implemented
|
|
*/
|
|
BOOLEAN
|
|
NTAPI
|
|
INIT_FUNCTION
|
|
HalInitSystem(IN ULONG BootPhase,
|
|
IN PLOADER_PARAMETER_BLOCK LoaderBlock)
|
|
{
|
|
PKPRCB Prcb = KeGetCurrentPrcb();
|
|
|
|
/* Check the boot phase */
|
|
if (!BootPhase)
|
|
{
|
|
/* Phase 0... save bus type */
|
|
HalpBusType = LoaderBlock->u.I386.MachineType & 0xFF;
|
|
|
|
/* Get command-line parameters */
|
|
HalpGetParameters(LoaderBlock);
|
|
|
|
/* Checked HAL requires checked kernel */
|
|
#if DBG
|
|
if (!(Prcb->BuildType & PRCB_BUILD_DEBUG))
|
|
{
|
|
/* No match, bugcheck */
|
|
KeBugCheckEx(MISMATCHED_HAL, 2, Prcb->BuildType, 1, 0);
|
|
}
|
|
#else
|
|
/* Release build requires release HAL */
|
|
if (Prcb->BuildType & PRCB_BUILD_DEBUG)
|
|
{
|
|
/* No match, bugcheck */
|
|
KeBugCheckEx(MISMATCHED_HAL, 2, Prcb->BuildType, 0, 0);
|
|
}
|
|
#endif
|
|
|
|
#ifdef CONFIG_SMP
|
|
/* SMP HAL requires SMP kernel */
|
|
if (Prcb->BuildType & PRCB_BUILD_UNIPROCESSOR)
|
|
{
|
|
/* No match, bugcheck */
|
|
KeBugCheckEx(MISMATCHED_HAL, 2, Prcb->BuildType, 0, 0);
|
|
}
|
|
#endif
|
|
|
|
/* Validate the PRCB */
|
|
if (Prcb->MajorVersion != PRCB_MAJOR_VERSION)
|
|
{
|
|
/* Validation failed, bugcheck */
|
|
KeBugCheckEx(MISMATCHED_HAL, 1, Prcb->MajorVersion, 1, 0);
|
|
}
|
|
|
|
#ifndef _MINIHAL_
|
|
/* Initialize ACPI */
|
|
HalpSetupAcpiPhase0(LoaderBlock);
|
|
|
|
/* Initialize the PICs */
|
|
HalpInitializePICs(TRUE);
|
|
#endif
|
|
|
|
/* Force initial PIC state */
|
|
KfRaiseIrql(KeGetCurrentIrql());
|
|
|
|
/* Initialize CMOS lock */
|
|
KeInitializeSpinLock(&HalpSystemHardwareLock);
|
|
|
|
/* Initialize CMOS */
|
|
HalpInitializeCmos();
|
|
|
|
/* Fill out the dispatch tables */
|
|
HalQuerySystemInformation = HaliQuerySystemInformation;
|
|
HalSetSystemInformation = HaliSetSystemInformation;
|
|
HalInitPnpDriver = HaliInitPnpDriver;
|
|
#ifndef _MINIHAL_
|
|
HalGetDmaAdapter = HalpGetDmaAdapter;
|
|
#else
|
|
HalGetDmaAdapter = NULL;
|
|
#endif
|
|
HalGetInterruptTranslator = NULL; // FIXME: TODO
|
|
#ifndef _MINIHAL_
|
|
HalResetDisplay = HalpBiosDisplayReset;
|
|
#else
|
|
HalResetDisplay = NULL;
|
|
#endif
|
|
HalHaltSystem = HaliHaltSystem;
|
|
|
|
/* Register IRQ 2 */
|
|
HalpRegisterVector(IDT_INTERNAL,
|
|
PRIMARY_VECTOR_BASE + 2,
|
|
PRIMARY_VECTOR_BASE + 2,
|
|
HIGH_LEVEL);
|
|
|
|
/* Setup I/O space */
|
|
HalpDefaultIoSpace.Next = HalpAddressUsageList;
|
|
HalpAddressUsageList = &HalpDefaultIoSpace;
|
|
|
|
/* Setup busy waiting */
|
|
HalpCalibrateStallExecution();
|
|
|
|
#ifndef _MINIHAL_
|
|
/* Initialize the clock */
|
|
HalpInitializeClock();
|
|
#endif
|
|
|
|
/*
|
|
* 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);
|
|
}
|
|
else if (BootPhase == 1)
|
|
{
|
|
/* Initialize bus handlers */
|
|
HalpInitBusHandlers();
|
|
|
|
#ifndef _MINIHAL_
|
|
/* Enable IRQ 0 */
|
|
HalpEnableInterruptHandler(IDT_DEVICE,
|
|
0,
|
|
PRIMARY_VECTOR_BASE,
|
|
CLOCK2_LEVEL,
|
|
HalpClockInterrupt,
|
|
Latched);
|
|
|
|
/* Enable IRQ 8 */
|
|
HalpEnableInterruptHandler(IDT_DEVICE,
|
|
0,
|
|
PRIMARY_VECTOR_BASE + 8,
|
|
PROFILE_LEVEL,
|
|
HalpProfileInterrupt,
|
|
Latched);
|
|
|
|
/* Initialize DMA. NT does this in Phase 0 */
|
|
HalpInitDma();
|
|
#endif
|
|
|
|
/* Do some HAL-specific initialization */
|
|
HalpInitPhase1();
|
|
}
|
|
|
|
/* All done, return */
|
|
return TRUE;
|
|
}
|