]> git.proxmox.com Git - mirror_edk2.git/blob - SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugMp.h
Import SourceLevelDebugPkg.
[mirror_edk2.git] / SourceLevelDebugPkg / Library / DebugAgent / DebugAgentCommon / DebugMp.h
1 /** @file
2 Header file for Multi-Processor support.
3
4 Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php.
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #ifndef _DEBUG_MP_H_
16 #define _DEBUG_MP_H_
17
18 #define DEBUG_CPU_MAX_COUNT 256
19
20 typedef struct {
21 UINT32 CpuCount; ///< Processor count
22 UINT16 ApicID[DEBUG_CPU_MAX_COUNT]; ///< Record the local apic id for each processor
23 } DEBUG_CPU_DATA;
24
25 typedef struct {
26 SPIN_LOCK MpContextSpinLock; ///< Lock for writting MP context
27 SPIN_LOCK DebugPortSpinLock; ///< Lock for access debug port
28 UINT8 CpuBreakMask[DEBUG_CPU_MAX_COUNT/8]; ///< Bitmask of all breaking CPUs
29 UINT8 CpuStopStatusMask[DEBUG_CPU_MAX_COUNT/8]; ///< Bitmask of CPU stop status
30 UINT32 ViewPointIndex; ///< Current view point to be debugged
31 UINT32 BspIndex; ///< Processor index value of BSP
32 UINT32 BreakAtCpuIndex; ///< Processor index value of the current breaking CPU
33 UINT32 DebugTimerInitCount; ///< Record BSP's init timer count
34 BOOLEAN IpiSentByAp; ///< TRUR: IPI is sent by AP. TALSE: IPI is sent by BSP
35 BOOLEAN RunCommandSet; ///< TRUE: RUN commmand is not executed. FALSE : RUN command is executed.
36 } DEBUG_MP_CONTEXT;
37
38 extern CONST BOOLEAN MultiProcessorDebugSupport;
39 extern DEBUG_MP_CONTEXT volatile mDebugMpContext;
40 extern DEBUG_CPU_DATA volatile mDebugCpuData;
41
42 /**
43 Break the other processor by send IPI.
44
45 @param[in] CurrentProcessorIndex Current processor index value.
46
47 **/
48 VOID
49 HaltOtherProcessors (
50 IN UINT32 CurrentProcessorIndex
51 );
52
53 /**
54 Get the current processor's index.
55
56 @return Processor index value.
57
58 **/
59 UINT32
60 GetProcessorIndex (
61 VOID
62 );
63
64 /**
65 Acquire access control on MP context.
66
67 It will block in the function if cannot get the access control.
68
69 **/
70 VOID
71 AcquireMpContextControl (
72 VOID
73 );
74
75 /**
76 Release access control on MP context.
77
78 **/
79 VOID
80 ReleaseMpContextControl (
81 VOID
82 );
83
84 /**
85 Acquire access control on debug port.
86
87 It will block in the function if cannot get the access control.
88
89 **/
90 VOID
91 AcquireDebugPortControl (
92 VOID
93 );
94
95 /**
96 Release access control on debug port.
97
98 **/
99 VOID
100 ReleaseDebugPortControl (
101 VOID
102 );
103
104 /**
105 Check if the specified processor is BSP or not.
106
107 @param[in] ProcessorIndex Processor index value.
108
109 @retval TRUE It is BSP.
110 @retval FALSE It isn't BSP.
111
112 **/
113 BOOLEAN
114 IsBsp (
115 IN UINT32 ProcessorIndex
116 );
117
118 /**
119 Set processor stop flag bitmask in MP context.
120
121 @param[in] ProcessorIndex Processor index value.
122 @param[in] StopFlag TRUE means set stop flag.
123 FALSE means clean break flag.
124
125 **/
126 VOID
127 SetCpuStopFlagByIndex (
128 IN UINT32 ProcessorIndex,
129 IN BOOLEAN StopFlag
130 );
131
132 /**
133 Set processor break flag bitmask in MP context.
134
135 @param[in] ProcessorIndex Processor index value.
136 @param[in] BreakFlag TRUE means set break flag.
137 FALSE means clean break flag.
138
139 **/
140 VOID
141 SetCpuBreakFlagByIndex (
142 IN UINT32 ProcessorIndex,
143 IN BOOLEAN BreakFlag
144 );
145
146 /**
147 Check if processor is stopped already.
148
149 @param[in] ProcessorIndex Processor index value.
150
151 @retval TRUE Processor is stopped already.
152 @retval FALSE Processor isn't stopped.
153
154 **/
155 BOOLEAN
156 IsCpuStopped (
157 IN UINT32 ProcessorIndex
158 );
159
160 /**
161 Set the run command flag.
162
163 @param[in] RunningFlag TRUE means run command flag is set.
164 FALSE means run command flag is cleared.
165
166 **/
167 VOID
168 SetCpuRunningFlag (
169 IN BOOLEAN RunningFlag
170 );
171
172 /**
173 Set the current view point to be debugged.
174
175 @param[in] ProcessorIndex Processor index value.
176
177 **/
178 VOID
179 SetDebugViewPoint (
180 IN UINT32 ProcessorIndex
181 );
182
183 /**
184 Initialize debug timer.
185
186 @param[in] IpiSentByApFlag TRUE means this IPI is sent by AP.
187 FALSE means this IPI is sent by BSP.
188
189 **/
190 VOID
191 SetIpiSentByApFlag (
192 IN BOOLEAN IpiSentByApFlag
193 );
194
195 /**
196 Check if any processor breaks.
197
198 @retval others There is at least one processor broken, the minimum
199 index number of Processor returned.
200 @retval -1 No any processor broken.
201
202 **/
203 UINT32
204 FindCpuNotRunning (
205 VOID
206 );
207
208 /**
209 Check if all processors are in running status.
210
211 @retval TRUE All processors run.
212 @retval FALSE At least one processor does not run.
213
214 **/
215 BOOLEAN
216 IsAllCpuRunning (
217 VOID
218 );
219
220 #endif
221