ReactOS  0.4.14-dev-293-g2b39b42
processor_mp.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS kernel
4  * FILE: hal/halx86/mp/processor_mp.c
5  * PURPOSE: Intel MultiProcessor specification support
6  * PROGRAMMER: David Welch (welch@cwcom.net)
7  * Casper S. Hornstrup (chorns@users.sourceforge.net)
8  * NOTES: Parts adapted from linux SMP code
9  * UPDATE HISTORY:
10  * 22/05/1998 DW Created
11  * 12/04/2001 CSH Added MultiProcessor specification support
12  */
13 
14 /* INCLUDES *****************************************************************/
15 
16 #include <hal.h>
17 #define NDEBUG
18 #include <debug.h>
19 
21 
22 /* PRIVATE FUNCTIONS *********************************************************/
23 
24 VOID
25 NTAPI
27 {
28  /* Disable interrupts and halt the CPU */
29  _disable();
30  __halt();
31 }
32 
33 /* FUNCTIONS *****************************************************************/
34 
35 VOID NTAPI
36 HalInitializeProcessor(ULONG ProcessorNumber,
37  PLOADER_PARAMETER_BLOCK LoaderBlock)
38 {
39  ULONG CPU;
40 
41  DPRINT("HalInitializeProcessor(%x %x)\n", ProcessorNumber, LoaderBlock);
42 
43  CPU = ThisCPU();
44  if (OnlineCPUs & (1 << CPU))
45  {
46  ASSERT(FALSE);
47  }
48 
49  if (ProcessorNumber == 0)
50  {
51  HaliInitBSP();
52  }
53  else
54  {
55  APICSetup();
56 
57  DPRINT("CPU %d says it is now booted.\n", CPU);
58 
59  APICCalibrateTimer(CPU);
60  }
61 
62  /* This processor is now booted */
63  CPUMap[CPU].Flags |= CPU_ENABLED;
64  OnlineCPUs |= (1 << CPU);
65 
66  /* Setup busy waiting */
67  //HalpCalibrateStallExecution();
68 }
69 
72 {
73  ULONG CPUs = 0, i;
74 
75  DPRINT("HalAllProcessorsStarted()\n");
76  for (i = 0; i < 32; i++)
77  {
78  if (OnlineCPUs & (1 << i))
79  {
80  CPUs++;
81  }
82  }
83  if (CPUs > CPUCount)
84  {
85  ASSERT(FALSE);
86  }
87  else if (CPUs == CPUCount)
88  {
89 
90  IOAPICEnable();
92  if (CPUCount > 1)
93  {
95  }
97 
98  return TRUE;
99  }
100  return FALSE;
101 }
102 
103 BOOLEAN
104 NTAPI
106  IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock,
107  IN PKPROCESSOR_STATE ProcessorState)
108 {
109  ULONG CPU;
110 
111  DPRINT("HalStartNextProcessor(%x %x)\n", LoaderBlock, ProcessorState);
112 
113  for (CPU = 0; CPU < CPUCount; CPU++)
114  {
115  if (!(OnlineCPUs & (1<<CPU)))
116  {
117  break;
118  }
119  }
120 
121  if (CPU >= CPUCount)
122  {
123  ASSERT(FALSE);
124  }
125 
126  DPRINT1("Attempting to boot CPU %d\n", CPU);
127 
128  HaliStartApplicationProcessor(CPU, (ULONG)ProcessorState);
129 
130  return TRUE;
131 }
132 
133 VOID
134 NTAPI
136 {
138 }
139 
140 /* EOF */
#define IN
Definition: typedefs.h:38
VOID IOAPICSetupIrqs(VOID)
Definition: ioapic.c:296
#define TRUE
Definition: types.h:120
VOID NTAPI HalProcessorIdle(VOID)
Definition: processor_mp.c:135
VOID HaliInitBSP(VOID)
Definition: apic.c:886
__INTRIN_INLINE void __halt(void)
Definition: intrin_x86.h:1595
#define CPU_ENABLED
Definition: apic.h:171
CPU_INFO CPUMap[MAX_CPU]
Definition: apic.c:40
BOOLEAN NTAPI HalStartNextProcessor(IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock, IN PKPROCESSOR_STATE ProcessorState)
Definition: processor_mp.c:105
VOID APICSyncArbIDs(VOID)
ULONG OnlineCPUs
Definition: apic.c:39
KAFFINITY HalpActiveProcessors
Definition: processor_mp.c:20
VOID APICCalibrateTimer(ULONG CPU)
Definition: apic.c:794
VOID IOAPICEnable(VOID)
Definition: ioapic.c:409
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
VOID HaliStartApplicationProcessor(ULONG Cpu, ULONG Stack)
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
unsigned char BOOLEAN
void DPRINT(...)
Definition: polytest.cpp:61
BOOLEAN NTAPI HalAllProcessorsStarted(VOID)
Definition: processor_mp.c:71
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
VOID NTAPI HaliHaltSystem(VOID)
Definition: processor_mp.c:26
KAFFINITY HalpDefaultInterruptAffinity
Definition: processor_mp.c:20
ULONG_PTR KAFFINITY
Definition: compat.h:75
static __inline ULONG ThisCPU(VOID)
Definition: apic.h:203
#define DPRINT1
Definition: precomp.h:8
ULONG CPUCount
Definition: apic.c:37
void __cdecl _disable(void)
Definition: intrin_arm.h:365
UCHAR Flags
Definition: apic.h:177
unsigned int ULONG
Definition: retypes.h:1
VOID NTAPI HalInitializeProcessor(ULONG ProcessorNumber, PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: processor_mp.c:36
#define UNIMPLEMENTED
Definition: debug.h:114
VOID APICSetup(VOID)
Definition: apic.c:482
VOID IOAPICSetupIds(VOID)
Definition: ioapic.c:432