2 Header file for Multi-Processor support.
4 Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
12 #define DEBUG_CPU_MAX_COUNT 256
15 UINT32 CpuCount
; ///< Processor count
16 UINT16 ApicID
[DEBUG_CPU_MAX_COUNT
]; ///< Record the local apic id for each processor
20 SPIN_LOCK MpContextSpinLock
; ///< Lock for writting MP context
21 SPIN_LOCK DebugPortSpinLock
; ///< Lock for access debug port
22 SPIN_LOCK MailboxSpinLock
; ///< Lock for accessing mail box
23 UINT8 CpuBreakMask
[DEBUG_CPU_MAX_COUNT
/8]; ///< Bitmask of all breaking CPUs
24 UINT8 CpuStopStatusMask
[DEBUG_CPU_MAX_COUNT
/8]; ///< Bitmask of CPU stop status
25 UINT32 ViewPointIndex
; ///< Current view point to be debugged
26 UINT32 BspIndex
; ///< Processor index value of BSP
27 UINT32 BreakAtCpuIndex
; ///< Processor index value of the current breaking CPU
28 UINT32 DebugTimerInitCount
; ///< Record BSP's init timer count
29 BOOLEAN IpiSentByAp
; ///< TRUR: IPI is sent by AP. TALSE: IPI is sent by BSP
30 BOOLEAN RunCommandSet
; ///< TRUE: RUN commmand is executing. FALSE : RUN command has been executed.
33 extern DEBUG_MP_CONTEXT
volatile mDebugMpContext
;
34 extern DEBUG_CPU_DATA
volatile mDebugCpuData
;
37 Break the other processor by send IPI.
39 @param[in] CurrentProcessorIndex Current processor index value.
44 IN UINT32 CurrentProcessorIndex
48 Get the current processor's index.
50 @return Processor index value.
59 Acquire a spin lock when Multi-processor supported.
61 It will block in the function if cannot get the access control.
62 If Multi-processor is not supported, return directly.
64 @param[in, out] MpSpinLock A pointer to the spin lock.
69 IN OUT SPIN_LOCK
*MpSpinLock
73 Release a spin lock when Multi-processor supported.
75 @param[in, out] MpSpinLock A pointer to the spin lock.
80 IN OUT SPIN_LOCK
*MpSpinLock
84 Check if the specified processor is BSP or not.
86 @param[in] ProcessorIndex Processor index value.
88 @retval TRUE It is BSP.
89 @retval FALSE It isn't BSP.
94 IN UINT32 ProcessorIndex
98 Set processor stop flag bitmask in MP context.
100 @param[in] ProcessorIndex Processor index value.
101 @param[in] StopFlag TRUE means set stop flag.
102 FALSE means clean break flag.
106 SetCpuStopFlagByIndex (
107 IN UINT32 ProcessorIndex
,
112 Set processor break flag bitmask in MP context.
114 @param[in] ProcessorIndex Processor index value.
115 @param[in] BreakFlag TRUE means set break flag.
116 FALSE means clean break flag.
120 SetCpuBreakFlagByIndex (
121 IN UINT32 ProcessorIndex
,
126 Check if processor is stopped already.
128 @param[in] ProcessorIndex Processor index value.
130 @retval TRUE Processor is stopped already.
131 @retval FALSE Processor isn't stopped.
136 IN UINT32 ProcessorIndex
140 Set the run command flag.
142 @param[in] RunningFlag TRUE means run command flag is set.
143 FALSE means run command flag is cleared.
148 IN BOOLEAN RunningFlag
152 Set the current view point to be debugged.
154 @param[in] ProcessorIndex Processor index value.
159 IN UINT32 ProcessorIndex
163 Set the IPI send by BPS/AP flag.
165 @param[in] IpiSentByApFlag TRUE means this IPI is sent by AP.
166 FALSE means this IPI is sent by BSP.
171 IN BOOLEAN IpiSentByApFlag
175 Check the next pending breaking CPU.
177 @retval others There is at least one processor broken, the minimum
178 index number of Processor returned.
179 @retval -1 No any processor broken.
183 FindNextPendingBreakCpu (
188 Check if all processors are in running status.
190 @retval TRUE All processors run.
191 @retval FALSE At least one processor does not run.
200 Check if the current processor is the first breaking processor.
202 If yes, halt other processors.
204 @param[in] ProcessorIndex Processor index value.
206 @return TRUE This processor is the first breaking processor.
207 @return FALSE This processor is not the first breaking processor.
211 IsFirstBreakProcessor (
212 IN UINT32 ProcessorIndex