]>
git.proxmox.com Git - mirror_edk2.git/blob - UefiCpuPkg/PiSmmCpuDxeSmm/SyncTimer.c
2 SMM Timer feature support
4 Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #include "PiSmmCpuDxeSmm.h"
11 UINT64 mTimeoutTicker
= 0;
13 // Number of counts in a roll-over cycle of the performance counter.
17 // Flag to indicate the performance counter is count-up or count-down.
22 Initialize Timer for SMM AP Sync.
30 UINT64 TimerFrequency
;
34 TimerFrequency
= GetPerformanceCounterProperties (&Start
, &End
);
35 mTimeoutTicker
= DivU64x32 (
36 MultU64x64 (TimerFrequency
, PcdGet64 (PcdCpuSmmApSyncTimeout
)),
49 Start Timer for SMM AP Sync.
58 return GetPerformanceCounter ();
62 Check if the SMM AP Sync timer is timeout.
64 @param Timer The start timer from the begin.
76 CurrentTimer
= GetPerformanceCounter ();
78 // We need to consider the case that CurrentTimer is equal to Timer
79 // when some timer runs too slow and CPU runs fast. We think roll over
80 // condition does not happen on this case.
84 // The performance counter counts down. Check for roll over condition.
86 if (CurrentTimer
<= Timer
) {
87 Delta
= Timer
- CurrentTimer
;
90 // Handle one roll-over.
92 Delta
= mCycle
- (CurrentTimer
- Timer
) + 1;
96 // The performance counter counts up. Check for roll over condition.
98 if (CurrentTimer
>= Timer
) {
99 Delta
= CurrentTimer
- Timer
;
102 // Handle one roll-over.
104 Delta
= mCycle
- (Timer
- CurrentTimer
) + 1;
108 return (BOOLEAN
)(Delta
>= mTimeoutTicker
);