2 Header file for Multi-Processor support.
4 Copyright (c) 2010 - 2018, 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.
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.
18 #define DEBUG_CPU_MAX_COUNT 256
21 UINT32 CpuCount
; ///< Processor count
22 UINT16 ApicID
[DEBUG_CPU_MAX_COUNT
]; ///< Record the local apic id for each processor
26 SPIN_LOCK MpContextSpinLock
; ///< Lock for writting MP context
27 SPIN_LOCK DebugPortSpinLock
; ///< Lock for access debug port
28 SPIN_LOCK MailboxSpinLock
; ///< Lock for accessing mail box
29 UINT8 CpuBreakMask
[DEBUG_CPU_MAX_COUNT
/8]; ///< Bitmask of all breaking CPUs
30 UINT8 CpuStopStatusMask
[DEBUG_CPU_MAX_COUNT
/8]; ///< Bitmask of CPU stop status
31 UINT32 ViewPointIndex
; ///< Current view point to be debugged
32 UINT32 BspIndex
; ///< Processor index value of BSP
33 UINT32 BreakAtCpuIndex
; ///< Processor index value of the current breaking CPU
34 UINT32 DebugTimerInitCount
; ///< Record BSP's init timer count
35 BOOLEAN IpiSentByAp
; ///< TRUR: IPI is sent by AP. TALSE: IPI is sent by BSP
36 BOOLEAN RunCommandSet
; ///< TRUE: RUN commmand is executing. FALSE : RUN command has been executed.
39 extern DEBUG_MP_CONTEXT
volatile mDebugMpContext
;
40 extern DEBUG_CPU_DATA
volatile mDebugCpuData
;
43 Break the other processor by send IPI.
45 @param[in] CurrentProcessorIndex Current processor index value.
50 IN UINT32 CurrentProcessorIndex
54 Get the current processor's index.
56 @return Processor index value.
65 Acquire a spin lock when Multi-processor supported.
67 It will block in the function if cannot get the access control.
68 If Multi-processor is not supported, return directly.
70 @param[in, out] MpSpinLock A pointer to the spin lock.
75 IN OUT SPIN_LOCK
*MpSpinLock
79 Release a spin lock when Multi-processor supported.
81 @param[in, out] MpSpinLock A pointer to the spin lock.
86 IN OUT SPIN_LOCK
*MpSpinLock
90 Check if the specified processor is BSP or not.
92 @param[in] ProcessorIndex Processor index value.
94 @retval TRUE It is BSP.
95 @retval FALSE It isn't BSP.
100 IN UINT32 ProcessorIndex
104 Set processor stop flag bitmask in MP context.
106 @param[in] ProcessorIndex Processor index value.
107 @param[in] StopFlag TRUE means set stop flag.
108 FALSE means clean break flag.
112 SetCpuStopFlagByIndex (
113 IN UINT32 ProcessorIndex
,
118 Set processor break flag bitmask in MP context.
120 @param[in] ProcessorIndex Processor index value.
121 @param[in] BreakFlag TRUE means set break flag.
122 FALSE means clean break flag.
126 SetCpuBreakFlagByIndex (
127 IN UINT32 ProcessorIndex
,
132 Check if processor is stopped already.
134 @param[in] ProcessorIndex Processor index value.
136 @retval TRUE Processor is stopped already.
137 @retval FALSE Processor isn't stopped.
142 IN UINT32 ProcessorIndex
146 Set the run command flag.
148 @param[in] RunningFlag TRUE means run command flag is set.
149 FALSE means run command flag is cleared.
154 IN BOOLEAN RunningFlag
158 Set the current view point to be debugged.
160 @param[in] ProcessorIndex Processor index value.
165 IN UINT32 ProcessorIndex
169 Set the IPI send by BPS/AP flag.
171 @param[in] IpiSentByApFlag TRUE means this IPI is sent by AP.
172 FALSE means this IPI is sent by BSP.
177 IN BOOLEAN IpiSentByApFlag
181 Check the next pending breaking CPU.
183 @retval others There is at least one processor broken, the minimum
184 index number of Processor returned.
185 @retval -1 No any processor broken.
189 FindNextPendingBreakCpu (
194 Check if all processors are in running status.
196 @retval TRUE All processors run.
197 @retval FALSE At least one processor does not run.
206 Check if the current processor is the first breaking processor.
208 If yes, halt other processors.
210 @param[in] ProcessorIndex Processor index value.
212 @return TRUE This processor is the first breaking processor.
213 @return FALSE This processor is not the first breaking processor.
217 IsFirstBreakProcessor (
218 IN UINT32 ProcessorIndex