implemented some stubs needed by ClamWin
[reactos.git] / reactos / hal / halx86 / mp / processor_mp.c
1 /* $Id$
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: hal/halx86/mp/processor_mp.c
6 * PURPOSE: Intel MultiProcessor specification support
7 * PROGRAMMER: David Welch (welch@cwcom.net)
8 * Casper S. Hornstrup (chorns@users.sourceforge.net)
9 * NOTES: Parts adapted from linux SMP code
10 * UPDATE HISTORY:
11 * 22/05/1998 DW Created
12 * 12/04/2001 CSH Added MultiProcessor specification support
13 */
14
15 /* INCLUDES *****************************************************************/
16
17 #include <hal.h>
18 #define NDEBUG
19 #include <debug.h>
20
21 /* FUNCTIONS *****************************************************************/
22
23 VOID STDCALL
24 HalInitializeProcessor(ULONG ProcessorNumber,
25 PVOID /*PLOADER_PARAMETER_BLOCK*/ LoaderBlock)
26 {
27 ULONG CPU;
28
29 DPRINT("HalInitializeProcessor(%x %x)\n", ProcessorNumber, LoaderBlock);
30
31 CPU = ThisCPU();
32 if (OnlineCPUs & (1 << CPU))
33 {
34 KEBUGCHECK(0);
35 }
36
37 if (ProcessorNumber == 0)
38 {
39 HaliInitBSP();
40 }
41 else
42 {
43 APICSetup();
44
45 DPRINT("CPU %d says it is now booted.\n", CPU);
46
47 APICCalibrateTimer(CPU);
48 }
49
50 /* This processor is now booted */
51 CPUMap[CPU].Flags |= CPU_ENABLED;
52 OnlineCPUs |= (1 << CPU);
53
54 /* Setup busy waiting */
55 HalpCalibrateStallExecution();
56 }
57
58 BOOLEAN STDCALL
59 HalAllProcessorsStarted (VOID)
60 {
61 ULONG CPUs = 0, i;
62
63 DPRINT("HalAllProcessorsStarted()\n");
64 for (i = 0; i < 32; i++)
65 {
66 if (OnlineCPUs & (1 << i))
67 {
68 CPUs++;
69 }
70 }
71 if (CPUs > CPUCount)
72 {
73 KEBUGCHECK(0);
74 }
75 else if (CPUs == CPUCount)
76 {
77
78 IOAPICEnable();
79 IOAPICSetupIds();
80 if (CPUCount > 1)
81 {
82 APICSyncArbIDs();
83 }
84 IOAPICSetupIrqs();
85
86 return TRUE;
87 }
88 return FALSE;
89 }
90
91 BOOLEAN STDCALL
92 HalStartNextProcessor(ULONG Unknown1,
93 ULONG ProcessorStack)
94 {
95 ULONG CPU;
96
97 DPRINT("HalStartNextProcessor(%x %x)\n", Unknown1, ProcessorStack);
98
99 for (CPU = 0; CPU < CPUCount; CPU++)
100 {
101 if (!(OnlineCPUs & (1<<CPU)))
102 {
103 break;
104 }
105 }
106
107 if (CPU >= CPUCount)
108 {
109 KEBUGCHECK(0);
110 }
111
112 DPRINT1("Attempting to boot CPU %d\n", CPU);
113
114 HaliStartApplicationProcessor(CPU, ProcessorStack);
115
116 return TRUE;
117 }
118 /* EOF */