processor_mp.c

来自「一个类似windows」· C语言 代码 · 共 119 行

C
119
字号
/* $Id: processor_mp.c 21261 2006-03-08 23:26:25Z audit $
 *
 * 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>

/* FUNCTIONS *****************************************************************/

VOID STDCALL
HalInitializeProcessor(ULONG ProcessorNumber,
                       PLOADER_PARAMETER_BLOCK LoaderBlock)
{
   ULONG CPU;

   DPRINT("HalInitializeProcessor(%x %x)\n", ProcessorNumber, LoaderBlock);

   CPU = ThisCPU();
   if (OnlineCPUs & (1 << CPU))
   {
      KEBUGCHECK(0);
   }

   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 STDCALL
HalAllProcessorsStarted (VOID)
{
    ULONG CPUs = 0, i;

    DPRINT("HalAllProcessorsStarted()\n");
    for (i = 0; i < 32; i++)
    {
       if (OnlineCPUs & (1 << i))
       {
          CPUs++;
       }
    }
    if (CPUs > CPUCount)
    {
       KEBUGCHECK(0);
    }
    else if (CPUs == CPUCount)
    {

       IOAPICEnable();
       IOAPICSetupIds();
       if (CPUCount > 1)
       {
          APICSyncArbIDs();
       }
       IOAPICSetupIrqs();

       return TRUE;
    }
    return FALSE;
}

BOOLEAN STDCALL 
HalStartNextProcessor(ULONG Unknown1,
		      ULONG ProcessorStack)
{
   ULONG CPU;

   DPRINT("HalStartNextProcessor(%x %x)\n", Unknown1, ProcessorStack);

   for (CPU = 0; CPU < CPUCount; CPU++)
   {
      if (!(OnlineCPUs & (1<<CPU)))
      {
	 break;
      }
   }

   if (CPU >= CPUCount)
   {
      KEBUGCHECK(0);
   }

   DPRINT1("Attempting to boot CPU %d\n", CPU);

   HaliStartApplicationProcessor(CPU, ProcessorStack);

   return TRUE;
}
/* EOF */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?