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