]>
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 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.
15 #include "PiSmmCpuDxeSmm.h"
17 UINT64 mTimeoutTicker
= 0;
19 // Number of counts in a roll-over cycle of the performance counter.
23 // Flag to indicate the performance counter is count-up or count-down.
28 Initialize Timer for SMM AP Sync.
36 UINT64 TimerFrequency
;
40 TimerFrequency
= GetPerformanceCounterProperties (&Start
, &End
);
41 mTimeoutTicker
= DivU64x32 (
42 MultU64x64(TimerFrequency
, PcdGet64 (PcdCpuSmmApSyncTimeout
)),
55 Start Timer for SMM AP Sync.
64 return GetPerformanceCounter ();
69 Check if the SMM AP Sync timer is timeout.
71 @param Timer The start timer from the begin.
83 CurrentTimer
= GetPerformanceCounter ();
85 // We need to consider the case that CurrentTimer is equal to Timer
86 // when some timer runs too slow and CPU runs fast. We think roll over
87 // condition does not happen on this case.
91 // The performance counter counts down. Check for roll over condition.
93 if (CurrentTimer
<= Timer
) {
94 Delta
= Timer
- CurrentTimer
;
97 // Handle one roll-over.
99 Delta
= mCycle
- (CurrentTimer
- Timer
) + 1;
103 // The performance counter counts up. Check for roll over condition.
105 if (CurrentTimer
>= Timer
) {
106 Delta
= CurrentTimer
- Timer
;
109 // Handle one roll-over.
111 Delta
= mCycle
- (Timer
- CurrentTimer
) + 1;
115 return (BOOLEAN
) (Delta
>= mTimeoutTicker
);