diff --git a/reactos/hal/halx86/generic/generic.rbuild b/reactos/hal/halx86/generic/generic.rbuild index 453ed5e5199..5f0f00bf818 100644 --- a/reactos/hal/halx86/generic/generic.rbuild +++ b/reactos/hal/halx86/generic/generic.rbuild @@ -9,7 +9,6 @@ cmos.c dma.c drive.c - halinit.c misc.c pci.c portio.c @@ -26,6 +25,7 @@ irql.c + halinit.c processor.c spinlock.c diff --git a/reactos/hal/halx86/generic/halinit.c b/reactos/hal/halx86/generic/halinit.c index 637b2067d69..ca2faf5d1fc 100644 --- a/reactos/hal/halx86/generic/halinit.c +++ b/reactos/hal/halx86/generic/halinit.c @@ -93,7 +93,7 @@ HalInitSystem(IN ULONG BootPhase, } /* Initialize the PICs */ - //HalpInitPICs(); + HalpInitPICs(); /* Force initial PIC state */ KfRaiseIrql(KeGetCurrentIrql()); diff --git a/reactos/hal/halx86/generic/timer.c b/reactos/hal/halx86/generic/timer.c index fe8938e0d14..df96244c0b6 100644 --- a/reactos/hal/halx86/generic/timer.c +++ b/reactos/hal/halx86/generic/timer.c @@ -116,7 +116,7 @@ HalSetTimeIncrement(IN ULONG Increment) /* Normalize between our minimum (1 ms) and maximum (variable) setting */ if (Increment > HalpLargestClockMS) Increment = HalpLargestClockMS; - if (Increment < 0) Increment = 1; + if (Increment <= 0) Increment = 1; /* Set the rate and tell HAL we want to change it */ HalpNextMSRate = Increment; diff --git a/reactos/hal/halx86/mp/halinit.c b/reactos/hal/halx86/mp/halinit.c new file mode 100644 index 00000000000..efa87bf9e35 --- /dev/null +++ b/reactos/hal/halx86/mp/halinit.c @@ -0,0 +1,153 @@ +/* + * 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 +#define NDEBUG +#include + +/* GLOBALS *******************************************************************/ + +HALP_HOOKS HalpHooks; +BOOLEAN HalpPciLockSettings; + +/* PRIVATE FUNCTIONS *********************************************************/ + +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 *****************************************************************/ + +/* + * @implemented + */ +BOOLEAN +NTAPI +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); + } + + /* Initialize the PICs */ + HalpInitPICs(); + + /* Force initial PIC state */ + KfRaiseIrql(KeGetCurrentIrql()); + + /* Initialize the clock */ + HalpInitializeClock(); + + /* Setup busy waiting */ + //HalpCalibrateStallExecution(); + + /* Fill out the dispatch tables */ + HalQuerySystemInformation = HaliQuerySystemInformation; + HalSetSystemInformation = HaliSetSystemInformation; + HalInitPnpDriver = NULL; // FIXME: TODO + HalGetDmaAdapter = HalpGetDmaAdapter; + HalGetInterruptTranslator = NULL; // FIXME: TODO + + /* Initialize the hardware lock (CMOS) */ + KeInitializeSpinLock(&HalpSystemHardwareLock); + } + else if (BootPhase == 1) + { + /* Initialize the default HAL stubs for bus handling functions */ + HalpInitNonBusHandler(); + + /* Enable the clock interrupt */ + ((PKIPCR)KeGetPcr())->IDT[0x30].ExtendedOffset = + (USHORT)(((ULONG_PTR)HalpClockInterrupt >> 16) & 0xFFFF); + ((PKIPCR)KeGetPcr())->IDT[0x30].Offset = + (USHORT)HalpClockInterrupt; + HalEnableSystemInterrupt(0x30, CLOCK2_LEVEL, Latched); + + /* Initialize DMA. NT does this in Phase 0 */ + HalpInitDma(); + } + + /* All done, return */ + return TRUE; +} + +/* + * @unimplemented + */ +VOID +NTAPI +HalReportResourceUsage(VOID) +{ + /* Initialize PCI bus. */ + HalpInitializePciBus(); + + /* FIXME: This is done in ReactOS MP HAL only*/ + //HaliReconfigurePciInterrupts(); + + /* FIXME: Report HAL Usage to kernel */ +} + +/* EOF */ diff --git a/reactos/hal/halx86/mp/halmp.rbuild b/reactos/hal/halx86/mp/halmp.rbuild index 1cd533591f7..00e0f8aecc3 100644 --- a/reactos/hal/halx86/mp/halmp.rbuild +++ b/reactos/hal/halx86/mp/halmp.rbuild @@ -11,6 +11,7 @@ hal_generic_pc ntoskrnl apic.c + halinit.c halinit_mp.c ioapic.c ipi_mp.c