]>
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 ();
63 Check if the SMM AP Sync timer is timeout.
65 @param Timer The start timer from the begin.
77 CurrentTimer
= GetPerformanceCounter ();
79 // We need to consider the case that CurrentTimer is equal to Timer
80 // when some timer runs too slow and CPU runs fast. We think roll over
81 // condition does not happen on this case.
85 // The performance counter counts down. Check for roll over condition.
87 if (CurrentTimer
<= Timer
) {
88 Delta
= Timer
- CurrentTimer
;
91 // Handle one roll-over.
93 Delta
= mCycle
- (CurrentTimer
- Timer
) + 1;
97 // The performance counter counts up. Check for roll over condition.
99 if (CurrentTimer
>= Timer
) {
100 Delta
= CurrentTimer
- Timer
;
103 // Handle one roll-over.
105 Delta
= mCycle
- (Timer
- CurrentTimer
) + 1;
109 return (BOOLEAN
) (Delta
>= mTimeoutTicker
);