2013-03-14 21:04:13 +00:00
|
|
|
/*
|
2001-08-21 20:18:27 +00:00
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS kernel
|
2004-12-03 20:10:45 +00:00
|
|
|
* FILE: hal/halx86/mp/processor_mp.c
|
2001-08-21 20:18:27 +00:00
|
|
|
* 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 *****************************************************************/
|
|
|
|
|
2005-06-18 14:28:28 +00:00
|
|
|
#include <hal.h>
|
2005-06-19 22:53:49 +00:00
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
2001-08-21 20:18:27 +00:00
|
|
|
|
2010-06-07 20:37:19 +00:00
|
|
|
KAFFINITY HalpActiveProcessors, HalpDefaultInterruptAffinity;
|
2010-04-01 20:42:43 +00:00
|
|
|
|
2009-10-11 20:40:19 +00:00
|
|
|
/* PRIVATE FUNCTIONS *********************************************************/
|
|
|
|
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
HaliHaltSystem(VOID)
|
|
|
|
{
|
|
|
|
/* Disable interrupts and halt the CPU */
|
|
|
|
_disable();
|
|
|
|
__halt();
|
|
|
|
}
|
|
|
|
|
2001-08-21 20:18:27 +00:00
|
|
|
/* FUNCTIONS *****************************************************************/
|
|
|
|
|
2008-11-29 23:16:39 +00:00
|
|
|
VOID NTAPI
|
2004-11-28 01:30:02 +00:00
|
|
|
HalInitializeProcessor(ULONG ProcessorNumber,
|
2005-12-01 21:38:13 +00:00
|
|
|
PLOADER_PARAMETER_BLOCK LoaderBlock)
|
2004-11-01 19:01:25 +00:00
|
|
|
{
|
|
|
|
ULONG CPU;
|
2003-04-06 10:45:16 +00:00
|
|
|
|
2004-11-28 01:30:02 +00:00
|
|
|
DPRINT("HalInitializeProcessor(%x %x)\n", ProcessorNumber, LoaderBlock);
|
2002-12-26 17:36:12 +00:00
|
|
|
|
2004-11-01 19:01:25 +00:00
|
|
|
CPU = ThisCPU();
|
2004-11-28 01:30:02 +00:00
|
|
|
if (OnlineCPUs & (1 << CPU))
|
2004-11-01 19:01:25 +00:00
|
|
|
{
|
2008-08-24 15:48:05 +00:00
|
|
|
ASSERT(FALSE);
|
2004-11-01 19:01:25 +00:00
|
|
|
}
|
2001-08-21 20:18:27 +00:00
|
|
|
|
2004-11-28 01:30:02 +00:00
|
|
|
if (ProcessorNumber == 0)
|
2004-11-01 19:01:25 +00:00
|
|
|
{
|
2004-11-28 01:30:02 +00:00
|
|
|
HaliInitBSP();
|
2004-11-01 19:01:25 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-11-28 01:30:02 +00:00
|
|
|
APICSetup();
|
2001-08-21 20:18:27 +00:00
|
|
|
|
2004-11-28 01:30:02 +00:00
|
|
|
DPRINT("CPU %d says it is now booted.\n", CPU);
|
|
|
|
|
|
|
|
APICCalibrateTimer(CPU);
|
|
|
|
}
|
2001-08-21 20:18:27 +00:00
|
|
|
|
2004-11-28 01:30:02 +00:00
|
|
|
/* This processor is now booted */
|
|
|
|
CPUMap[CPU].Flags |= CPU_ENABLED;
|
|
|
|
OnlineCPUs |= (1 << CPU);
|
2001-08-21 20:18:27 +00:00
|
|
|
|
2004-11-28 01:30:02 +00:00
|
|
|
/* Setup busy waiting */
|
2006-11-29 10:19:00 +00:00
|
|
|
//HalpCalibrateStallExecution();
|
2001-08-21 20:18:27 +00:00
|
|
|
}
|
|
|
|
|
2008-11-29 23:16:39 +00:00
|
|
|
BOOLEAN NTAPI
|
2004-11-28 01:30:02 +00:00
|
|
|
HalAllProcessorsStarted (VOID)
|
2001-08-21 20:18:27 +00:00
|
|
|
{
|
2004-11-28 01:30:02 +00:00
|
|
|
ULONG CPUs = 0, i;
|
2004-12-03 20:10:45 +00:00
|
|
|
|
|
|
|
DPRINT("HalAllProcessorsStarted()\n");
|
2004-11-28 01:30:02 +00:00
|
|
|
for (i = 0; i < 32; i++)
|
|
|
|
{
|
|
|
|
if (OnlineCPUs & (1 << i))
|
|
|
|
{
|
|
|
|
CPUs++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (CPUs > CPUCount)
|
|
|
|
{
|
2008-08-24 15:48:05 +00:00
|
|
|
ASSERT(FALSE);
|
2004-11-28 01:30:02 +00:00
|
|
|
}
|
|
|
|
else if (CPUs == CPUCount)
|
|
|
|
{
|
2005-03-07 16:40:32 +00:00
|
|
|
|
|
|
|
IOAPICEnable();
|
|
|
|
IOAPICSetupIds();
|
|
|
|
if (CPUCount > 1)
|
|
|
|
{
|
|
|
|
APICSyncArbIDs();
|
|
|
|
}
|
|
|
|
IOAPICSetupIrqs();
|
|
|
|
|
2004-11-28 01:30:02 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-08-21 20:18:27 +00:00
|
|
|
|
2006-11-15 10:42:46 +00:00
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
HalStartNextProcessor(
|
|
|
|
IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock,
|
|
|
|
IN PKPROCESSOR_STATE ProcessorState)
|
2001-08-21 20:18:27 +00:00
|
|
|
{
|
2005-03-07 16:40:32 +00:00
|
|
|
ULONG CPU;
|
2001-08-21 20:18:27 +00:00
|
|
|
|
2006-11-15 10:42:46 +00:00
|
|
|
DPRINT("HalStartNextProcessor(%x %x)\n", LoaderBlock, ProcessorState);
|
2004-11-01 19:01:25 +00:00
|
|
|
|
2004-11-28 01:30:02 +00:00
|
|
|
for (CPU = 0; CPU < CPUCount; CPU++)
|
2004-11-01 19:01:25 +00:00
|
|
|
{
|
2004-11-28 01:30:02 +00:00
|
|
|
if (!(OnlineCPUs & (1<<CPU)))
|
|
|
|
{
|
2006-11-15 10:42:46 +00:00
|
|
|
break;
|
2004-11-28 01:30:02 +00:00
|
|
|
}
|
2001-08-21 20:18:27 +00:00
|
|
|
}
|
|
|
|
|
2004-11-28 01:30:02 +00:00
|
|
|
if (CPU >= CPUCount)
|
2004-11-01 19:01:25 +00:00
|
|
|
{
|
2008-08-24 15:48:05 +00:00
|
|
|
ASSERT(FALSE);
|
2004-11-28 01:30:02 +00:00
|
|
|
}
|
2004-11-01 19:01:25 +00:00
|
|
|
|
2004-11-28 01:30:02 +00:00
|
|
|
DPRINT1("Attempting to boot CPU %d\n", CPU);
|
2001-08-21 20:18:27 +00:00
|
|
|
|
2006-11-15 16:57:15 +00:00
|
|
|
HaliStartApplicationProcessor(CPU, (ULONG)ProcessorState);
|
2001-08-21 20:18:27 +00:00
|
|
|
|
2004-11-28 01:30:02 +00:00
|
|
|
return TRUE;
|
2001-08-21 20:18:27 +00:00
|
|
|
}
|
2006-09-11 14:35:46 +00:00
|
|
|
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
HalProcessorIdle(VOID)
|
|
|
|
{
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2001-08-21 20:18:27 +00:00
|
|
|
/* EOF */
|