[FLOPPY] Don't wait forever while trying to determine media type.
[reactos.git] / hal / halx86 / mp / processor_mp.c
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
20 KAFFINITY HalpActiveProcessors, HalpDefaultInterruptAffinity;
21
22 /* PRIVATE FUNCTIONS *********************************************************/
23
24 VOID
25 NTAPI
26 HaliHaltSystem(VOID)
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
70 BOOLEAN NTAPI
71 HalAllProcessorsStarted (VOID)
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();
91 IOAPICSetupIds();
92 if (CPUCount > 1)
93 {
94 APICSyncArbIDs();
95 }
96 IOAPICSetupIrqs();
97
98 return TRUE;
99 }
100 return FALSE;
101 }
102
103 BOOLEAN
104 NTAPI
105 HalStartNextProcessor(
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
135 HalProcessorIdle(VOID)
136 {
137 UNIMPLEMENTED;
138 }
139
140 /* EOF */