reactos/hal/halx86/mp/processor_mp.c

141 lines
2.7 KiB
C
Raw Normal View History

/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: hal/halx86/mp/processor_mp.c
* PURPOSE: Intel MultiProcessor specification support
* PROGRAMMER: David Welch (welch@cwcom.net)
* Casper S. Hornstrup (chorns@users.sourceforge.net)
* NOTES: Parts adapted from linux SMP code
* UPDATE HISTORY:
* 22/05/1998 DW Created
* 12/04/2001 CSH Added MultiProcessor specification support
*/
/* INCLUDES *****************************************************************/
#include <hal.h>
#define NDEBUG
#include <debug.h>
KAFFINITY HalpActiveProcessors, HalpDefaultInterruptAffinity;
/* PRIVATE FUNCTIONS *********************************************************/
VOID
NTAPI
HaliHaltSystem(VOID)
{
/* Disable interrupts and halt the CPU */
_disable();
__halt();
}
/* FUNCTIONS *****************************************************************/
VOID NTAPI
HalInitializeProcessor(ULONG ProcessorNumber,
PLOADER_PARAMETER_BLOCK LoaderBlock)
{
ULONG CPU;
2003-04-06 Casper S. Hornstrup <chorns@users.sourceforge.net> * drivers/storage/atapi/atapi.c (AtapiReadWrite): Expect an interrupt a bit sooner. * hal/halx86/isa.c (HalpGetIsaInterruptVector): Compute vector for MP. * hal/halx86/pci.c (HalpGetPciInterruptVector): Ditto. * hal/halx86/sysbus.c (HalpGetSystemInterruptVector): Ditto. * hal/halx86/mp.c (AssignIrqVector): Rewrite. (MpsTimerHandler): Disable for now. (MpsSpuriousHandler): Do not acknowledge interrupt. (HalAllProcessorsStarted): Only boot 1 CPU for now. (RescheduleDpcRoutine): New function. (RescheduleDpc): New variable. (HalpInitMPS): Initialize RescheduleDpc. Fix bug in call to memset. * hal/halx86/mpsirql.c: Rewrite. * hal/halx86/include/mps.h (VECTOR2IRQ, IRQ2VECTOR, VECTOR2IRQL, IRQL2VECTOR): New macros. * ntoskrnl/ntoskrnl.def: Add KeRescheduleThread@0. * ntoskrnl/ntoskrnl.edf: Ditto. * ntoskrnl/include/internal/ke.h (KeRescheduleThread): Prototype. * ntoskrnl/ke/kthread.c (KeRescheduleThread): New function. * ntoskrnl/ke/i386/exp.c (KeInitExceptions): Remove unneeded call to set_trap_gate(). * ntoskrnl/ke/i386/irq.c (VECTOR2IRQ, IRQ2VECTOR, VECTOR2IRQL): Correct. (IRQ_BASE): Define as FIRST_DEVICE_VECTOR. (NR_IRQS): Define using IRQ_BASE. (KeInitInterrupts): Use IRQ_BASE. (KiInterruptDispatch2): Rewrite. (KiInterruptDispatch): Ditto. (KeConnectInterrupt): Pass Vector to HalEnableSystemInterrupt() for MP. (KeDisconnectInterrupt): Pass Vector to HalDisableSystemInterrupt() for MP. * ntoskrnl/ke/i386/trap.s (_KiTrapProlog): Change 0x124 to KPCR_CURRENT_THREAD. svn path=/trunk/; revision=4505
2003-04-06 10:45:16 +00:00
DPRINT("HalInitializeProcessor(%x %x)\n", ProcessorNumber, LoaderBlock);
CPU = ThisCPU();
if (OnlineCPUs & (1 << CPU))
{
ASSERT(FALSE);
}
if (ProcessorNumber == 0)
{
HaliInitBSP();
}
else
{
APICSetup();
DPRINT("CPU %d says it is now booted.\n", CPU);
APICCalibrateTimer(CPU);
}
/* This processor is now booted */
CPUMap[CPU].Flags |= CPU_ENABLED;
OnlineCPUs |= (1 << CPU);
/* Setup busy waiting */
//HalpCalibrateStallExecution();
}
BOOLEAN NTAPI
HalAllProcessorsStarted (VOID)
{
ULONG CPUs = 0, i;
DPRINT("HalAllProcessorsStarted()\n");
for (i = 0; i < 32; i++)
{
if (OnlineCPUs & (1 << i))
{
CPUs++;
}
}
if (CPUs > CPUCount)
{
ASSERT(FALSE);
}
else if (CPUs == CPUCount)
{
IOAPICEnable();
IOAPICSetupIds();
if (CPUCount > 1)
{
APICSyncArbIDs();
}
IOAPICSetupIrqs();
return TRUE;
}
return FALSE;
}
BOOLEAN
NTAPI
HalStartNextProcessor(
IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock,
IN PKPROCESSOR_STATE ProcessorState)
{
ULONG CPU;
DPRINT("HalStartNextProcessor(%x %x)\n", LoaderBlock, ProcessorState);
for (CPU = 0; CPU < CPUCount; CPU++)
{
if (!(OnlineCPUs & (1<<CPU)))
{
break;
}
}
if (CPU >= CPUCount)
{
ASSERT(FALSE);
}
DPRINT1("Attempting to boot CPU %d\n", CPU);
HaliStartApplicationProcessor(CPU, (ULONG)ProcessorState);
return TRUE;
}
VOID
NTAPI
HalProcessorIdle(VOID)
{
UNIMPLEMENTED;
}
/* EOF */